postgresql/src/fe_utils/Makefile
Michael Paquier cd0be131ba Introduce frontend API able to retrieve the contents of PG_VERSION
get_pg_version() is able to return a version number, that can be used
for comparisons based on PG_VERSION_NUM.  A macro is added to convert
the result to a major version number, to work with PG_MAJORVERSION_NUM.

It is possible to pass to the routine an optional argument, where the
contents retrieved from PG_VERSION are saved.  This requirement matters
for some of the frontend code (one example: pg_upgrade wants that for
tablespace paths with a version number strictly older than v10).

This will be used by a set of follow-up patches, to be consumed in
various frontend tools that duplicate a logic similar to do what this
new routine does, like:
- pg_resetwal
- pg_combinebackup
- pg_createsubscriber
- pg_upgrade

This routine supports both the post-v10 version number and the older
flavor (aka 9.6), as required at least by pg_upgrade.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/aOiirvWJzwdVCXph@paquier.xyz
2025-10-14 16:20:42 +09:00

68 lines
1.5 KiB
Makefile

#-------------------------------------------------------------------------
#
# Makefile for src/fe_utils
#
# This makefile generates a static library, libpgfeutils.a,
# for use by client applications
#
# Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# IDENTIFICATION
# src/fe_utils/Makefile
#
#-------------------------------------------------------------------------
subdir = src/fe_utils
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
OBJS = \
archive.o \
astreamer_file.o \
astreamer_gzip.o \
astreamer_lz4.o \
astreamer_tar.o \
astreamer_zstd.o \
cancel.o \
conditional.o \
connect_utils.o \
mbprint.o \
option_utils.o \
parallel_slot.o \
print.o \
psqlscan.o \
query_utils.o \
recovery_gen.o \
simple_list.o \
string_utils.o \
version.o
ifeq ($(PORTNAME), win32)
override CPPFLAGS += -DFD_SETSIZE=1024
endif
all: libpgfeutils.a
libpgfeutils.a: $(OBJS)
rm -f $@
$(AR) $(AROPT) $@ $^
psqlscan.c: FLEXFLAGS = -Cfe -p -p
psqlscan.c: FLEX_NO_BACKUP=yes
# libpgfeutils could be useful to contrib, so install it
install: all installdirs
$(INSTALL_STLIB) libpgfeutils.a '$(DESTDIR)$(libdir)/libpgfeutils.a'
installdirs:
$(MKDIR_P) '$(DESTDIR)$(libdir)'
uninstall:
rm -f '$(DESTDIR)$(libdir)/libpgfeutils.a'
clean distclean:
rm -f libpgfeutils.a $(OBJS) lex.backup
rm -f psqlscan.c