diff options
Diffstat (limited to 'src/port')
| -rw-r--r-- | src/port/.gitignore | 1 | ||||
| -rw-r--r-- | src/port/Makefile | 55 |
2 files changed, 44 insertions, 12 deletions
diff --git a/src/port/.gitignore b/src/port/.gitignore index 53a40324447..2037b7d2ab6 100644 --- a/src/port/.gitignore +++ b/src/port/.gitignore @@ -1,3 +1,4 @@ /libpgport.a +/libpgport_shlib.a /libpgport_srv.a /pg_config_paths.h diff --git a/src/port/Makefile b/src/port/Makefile index a2ee8e2d6d0..ec62a31d29f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -1,18 +1,23 @@ #------------------------------------------------------------------------- # # Makefile -# Makefile for the port-specific subsystem of the backend +# Makefile for src/port # -# These files are used in other directories for portability on systems -# with broken/missing library files, and for common code sharing. +# These files are used by the Postgres backend, and also by frontend +# programs. Primarily, they are meant to provide portability on systems +# with broken/missing library files. # -# This makefile generates two outputs: +# This makefile generates three outputs: # # libpgport.a - contains object files with FRONTEND defined, -# for use by client application and libraries +# for use by client applications +# +# libpgport_shlib.a - contains object files with FRONTEND defined, +# built suitably for use in shared libraries; for use +# by libpq and other frontend libraries # # libpgport_srv.a - contains object files without FRONTEND defined, -# for use only by the backend binaries +# for use only by the backend # # LIBOBJS is set by configure (via Makefile.global) to be the list of object # files that are conditionally needed as determined by configure's probing. @@ -40,12 +45,15 @@ ifeq ($(enable_strong_random), yes) OBJS += pg_strong_random.o endif -# foo_srv.o and foo.o are both built from foo.c, but only foo.o has -DFRONTEND +# libpgport.a, libpgport_shlib.a, and libpgport_srv.a contain the same files +# foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c +OBJS_SHLIB = $(OBJS:%.o=%_shlib.o) OBJS_SRV = $(OBJS:%.o=%_srv.o) -all: libpgport.a libpgport_srv.a +all: libpgport.a libpgport_shlib.a libpgport_srv.a # libpgport is needed by some contrib +# currently we don't install libpgport_shlib.a, maybe we should? install: all installdirs $(INSTALL_STLIB) libpgport.a '$(DESTDIR)$(libdir)/libpgport.a' @@ -59,18 +67,38 @@ libpgport.a: $(OBJS) rm -f $@ $(AR) $(AROPT) $@ $^ -# thread.o needs PTHREAD_CFLAGS (but thread_srv.o does not) +# thread.o and thread_shlib.o need PTHREAD_CFLAGS (but thread_srv.o does not) thread.o: CFLAGS+=$(PTHREAD_CFLAGS) +thread_shlib.o: CFLAGS+=$(PTHREAD_CFLAGS) -# pg_crc32c_sse42.o and its _srv.o version need CFLAGS_SSE42 +# all versions of pg_crc32c_sse42.o need CFLAGS_SSE42 pg_crc32c_sse42.o: CFLAGS+=$(CFLAGS_SSE42) +pg_crc32c_sse42_shlib.o: CFLAGS+=$(CFLAGS_SSE42) pg_crc32c_sse42_srv.o: CFLAGS+=$(CFLAGS_SSE42) -# pg_crc32c_armv8.o and its _srv.o version need CFLAGS_ARMV8_CRC32C +# all versions of pg_crc32c_armv8.o need CFLAGS_ARMV8_CRC32C pg_crc32c_armv8.o: CFLAGS+=$(CFLAGS_ARMV8_CRC32C) +pg_crc32c_armv8_shlib.o: CFLAGS+=$(CFLAGS_ARMV8_CRC32C) pg_crc32c_armv8_srv.o: CFLAGS+=$(CFLAGS_ARMV8_CRC32C) # +# Shared library versions of object files +# + +libpgport_shlib.a: $(OBJS_SHLIB) + rm -f $@ + $(AR) $(AROPT) $@ $^ + +# Because this uses its own compilation rule, it doesn't use the +# dependency tracking logic from Makefile.global. To make sure that +# dependency tracking works anyway for the *_shlib.o files, depend on +# their *.o siblings as well, which do have proper dependencies. It's +# a hack that might fail someday if there is a *_shlib.o without a +# corresponding *.o, but there seems little reason for that. +%_shlib.o: %.c %.o + $(CC) $(CFLAGS) $(CFLAGS_SL) $(CPPFLAGS) -c $< -o $@ + +# # Server versions of object files # @@ -92,6 +120,8 @@ libpgport_srv.a: $(OBJS_SRV) path.o: path.c pg_config_paths.h +path_shlib.o: path.c pg_config_paths.h + path_srv.o: path.c pg_config_paths.h # We create a separate file rather than put these in pg_config.h @@ -112,4 +142,5 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global echo "#define MANDIR \"$(mandir)\"" >>$@ clean distclean maintainer-clean: - rm -f libpgport.a libpgport_srv.a $(OBJS) $(OBJS_SRV) pg_config_paths.h + rm -f libpgport.a libpgport_shlib.a libpgport_srv.a + rm -f $(OBJS) $(OBJS_SHLIB) $(OBJS_SRV) pg_config_paths.h |
