Have libpgport link before libpq so that PG client applications are more
authorBruce Momjian <bruce@momjian.us>
Fri, 25 Mar 2005 18:17:14 +0000 (18:17 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 25 Mar 2005 18:17:14 +0000 (18:17 +0000)
immunte to changes in libpq's usage of pgport between major versions.

14 files changed:
contrib/dbase/Makefile
contrib/findoidjoins/Makefile
contrib/oid2name/Makefile
contrib/pg_autovacuum/Makefile
contrib/pg_dumplo/Makefile
contrib/pgbench/Makefile
contrib/vacuumlo/Makefile
src/Makefile.global.in
src/bin/initdb/Makefile
src/bin/pg_ctl/Makefile
src/bin/pg_dump/Makefile
src/bin/psql/Makefile
src/bin/scripts/Makefile
src/test/examples/Makefile

index 17096d37cb079f724f4f1b47fd94b2875e541e66..3b1c9ac02294b13f67d16687b71333dc657ad79c 100644 (file)
@@ -3,7 +3,7 @@
 PROGRAM = dbf2pg
 OBJS   = dbf.o dbf2pg.o endian.o
 PG_CPPFLAGS = -I$(libpq_srcdir)
-PG_LIBS = $(libpq)
+PG_LIBS = $(libpq_pgport)
 
 # Uncomment this to provide charset translation
 #PG_CPPFLAGS += -DHAVE_ICONV_H
index cb0f4b5622a4aca8bf415be73e79a7dec4653ffd..f0fac2da25bcaebe40849838f57a277cecf5549c 100644 (file)
@@ -4,7 +4,7 @@ PROGRAM = findoidjoins
 OBJS   = findoidjoins.o
 
 PG_CPPFLAGS = -I$(libpq_srcdir)
-PG_LIBS = $(libpq)
+PG_LIBS = $(libpq_pgport)
 
 SCRIPTS = make_oidjoins_check
 DOCS = README.findoidjoins
index 02d51dec86a5a41904edd4d7d8bc988d744128fb..152cf1ccd321f1f1bbaaa0bda34f98ec2b32ad26 100644 (file)
@@ -4,7 +4,7 @@ PROGRAM = oid2name
 OBJS   = oid2name.o
 
 PG_CPPFLAGS = -I$(libpq_srcdir)
-PG_LIBS = $(libpq)
+PG_LIBS = $(libpq_pgport)
 
 DOCS = README.oid2name
 
index 00b1b3fe957fa2a3d2bb346a09ad2e390c9e8193..c512d18b7efe98ee0fa3fac7af62f0c98cec26ad 100644 (file)
@@ -2,7 +2,7 @@ PROGRAM = pg_autovacuum
 OBJS   = pg_autovacuum.o dllist.o
 
 PG_CPPFLAGS = -I$(libpq_srcdir) -DFRONTEND
-PG_LIBS = $(libpq)
+PG_LIBS = $(libpq_pgport)
 
 DOCS = README.pg_autovacuum
 
index 8373a0b05c623418fecdc17b2ff6b3295f9982ee..682d9dcf1ac261a35c1d05e0b7d9f0659cb66e04 100644 (file)
@@ -4,7 +4,7 @@ PROGRAM = pg_dumplo
 OBJS   = main.o lo_export.o lo_import.o utils.o
 
 PG_CPPFLAGS = -I$(libpq_srcdir)
-PG_LIBS = $(libpq)
+PG_LIBS = $(libpq_pgport)
 
 DOCS = README.pg_dumplo
 
index 827fd1b037d32200228a10d6015259e0588ef402..1e0f6393490eb99f45ab01080c5f1fbd1d7bad41 100644 (file)
@@ -4,7 +4,7 @@ PROGRAM = pgbench
 OBJS   = pgbench.o
 
 PG_CPPFLAGS = -I$(libpq_srcdir)
-PG_LIBS = $(libpq)
+PG_LIBS = $(libpq_pgport)
 
 DOCS = README.pgbench README.pgbench_jis
 
index fc44bc857583c776f9f92027f8d58ba89331b8da..1b5229d40755bef3e3c5d371d1d0f560c8d23560 100644 (file)
@@ -4,7 +4,7 @@ PROGRAM = vacuumlo
 OBJS   = vacuumlo.o
 
 PG_CPPFLAGS = -I$(libpq_srcdir)
-PG_LIBS = $(libpq)
+PG_LIBS = $(libpq_pgport)
 
 DOCS = README.vacuumlo
 
index 9a8b4935d8c8f944947c510672c69d4ddb0f4034..02d75f8e8bef53dfb0ecddcc3ba21329fc15e82c 100644 (file)
@@ -306,8 +306,10 @@ libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
 libpq_builddir = $(top_builddir)/src/interfaces/libpq
 endif
 
+# This is for use for libraries linking to libpq.  Because libpqport
+# isn't created with the same link flags as libpq, it can't be used.
 libpq = -L$(libpq_builddir) -lpq
-
+  
 # If doing static linking, shared library dependency can't be
 # used so we specify pthread libs for every usage of libpq
 ifeq ($(enable_shared), no)
@@ -320,6 +322,19 @@ libpq += $(PTHREAD_LIBS)
 endif
 endif
 
+# Force clients to pull symbols from the non-shared library libpgport 
+# rather than pulling some libpgport symbols from libpq just because 
+# libpq uses those functions too.  This makes applications less 
+# dependent on changes in libpq's usage of pgport.  To do this we link to
+# pgport before libpq.  This does cause duplicate -lpgport's to appear
+# on client link lines.
+ifdef PGXS
+libpq_pgport = -L$(libdir) -lpgport $(libpq)
+else
+libpq_pgport = -L$(top_builddir)/src/port -lpgport $(libpq)
+endif
+
+
 submake-libpq:
        $(MAKE) -C $(libpq_builddir) all
 
index 7e27cebd5cc6342f6d6f05f642e70035b777f52c..4ea426f2f6dfda5e190d556eaee7aa6cfb5d9883 100644 (file)
@@ -21,7 +21,7 @@ OBJS= initdb.o $(WIN32RES)
 all: submake-libpq submake-libpgport initdb
 
 initdb: $(OBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
 
 install: all installdirs
        $(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
index a20a8a6a886e08bf542bc7897a41da4be658dae1..975a22658b86fa32372248ad3557c628ccee47b0 100644 (file)
@@ -21,7 +21,7 @@ OBJS= pg_ctl.o $(WIN32RES)
 all: submake-libpq submake-libpgport pg_ctl
 
 pg_ctl: $(OBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
 
 install: all installdirs
        $(INSTALL_PROGRAM) pg_ctl$(X) $(DESTDIR)$(bindir)/pg_ctl$(X)
index e774f6507f79a0b6729c621d5591cdbac2991509..d71966cdf3dbc15c2aff4b9f974c99eecc45e27d 100644 (file)
@@ -25,13 +25,13 @@ EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
 all: submake-libpq submake-libpgport submake-backend pg_dump pg_restore pg_dumpall
 
 pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(libpq_builddir)/libpq.a 
-       $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(EXTRA_OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
 
 pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
 
 pg_dumpall: pg_dumpall.o dumputils.o $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(EXTRA_OBJS) $(WIN32RES) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(EXTRA_OBJS) $(WIN32RES) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
 
 .PHONY: submake-backend
 submake-backend:
index 9934d95512c8175210e8f771201421a2b57cdcda..1b214bda7906b53499d846ee779d1dd0af47bf70 100644 (file)
@@ -29,7 +29,7 @@ FLEXFLAGS = -Cfe
 all: submake-libpq submake-libpgport psql
 
 psql: $(OBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
 
 help.o: $(srcdir)/sql_help.h
 
index 83a319b37cf4aa772913e139a7db2e33e174255d..15b4e0c4fd8770ef98335c777fe69d01452b728b 100644 (file)
@@ -21,7 +21,7 @@ override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/
 all: submake-libpq submake-backend $(PROGRAMS)
 
 %: %.o $(WIN32RES)
-       $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
 
 createdb: createdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
 createlang: createlang.o common.o print.o mbprint.o
index 0326d429112f5268e0e531a6c4efb5ae0dcdd9e5..b55405d7372bf56767cb1d38512c85ca5f06a262 100644 (file)
@@ -7,7 +7,7 @@ top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
 override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
-override LDLIBS := $(libpq) -lpgport $(LDLIBS)
+override LDLIBS := $(libpq_pgport) $(LDLIBS)
 
 
 PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo