Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> I think you should leave the $(libpq) macro alone and add a $(libpgport)
> >> macro ... and yes, you will have to go around and modify the client
> >> program Makefiles individually.
>
> > How is this? It creates a new $(libpq_only) for library usage.
> > ecpglib/Makefile is the only place I saw that can use it.
>
> I think you are creating long-term confusion in order to save yourself a
> little bit of editing work. I don't object to having a combined macro
> but it shouldn't be called $(libpq). Maybe $(libpq_plus_support)
> or something like that ... or even libpq_plus_libpgport ...
>
> Also think about whether the hack in Makefile.global to add PTHREAD_LIBS
> to $(libpq) ought to add them to $(libpq_plus_support) instead. I'm
> not sure about that one ... it might be that you cannot link libpq
> successfully without PTHREAD_LIBS in the cases where the hack fires.
OK, here is a new patch. I called it 'libpq_pgport'.
I restructured the code so the threading is added first, and uses just
$libpq so it includes any thread additions.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: contrib/dbase/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/dbase/Makefile,v
retrieving revision 1.6
diff -c -c -r1.6 Makefile
*** contrib/dbase/Makefile 20 Aug 2004 20:13:02 -0000 1.6
--- contrib/dbase/Makefile 25 Mar 2005 17:59:39 -0000
***************
*** 3,9 ****
PROGRAM = dbf2pg
OBJS = dbf.o dbf2pg.o endian.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq)
# Uncomment this to provide charset translation
#PG_CPPFLAGS += -DHAVE_ICONV_H
--- 3,9 ----
PROGRAM = dbf2pg
OBJS = dbf.o dbf2pg.o endian.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq_pgport)
# Uncomment this to provide charset translation
#PG_CPPFLAGS += -DHAVE_ICONV_H
Index: contrib/findoidjoins/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/findoidjoins/Makefile,v
retrieving revision 1.16
diff -c -c -r1.16 Makefile
*** contrib/findoidjoins/Makefile 20 Aug 2004 20:13:03 -0000 1.16
--- contrib/findoidjoins/Makefile 25 Mar 2005 17:59:39 -0000
***************
*** 4,10 ****
OBJS = findoidjoins.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq)
SCRIPTS = make_oidjoins_check
DOCS = README.findoidjoins
--- 4,10 ----
OBJS = findoidjoins.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq_pgport)
SCRIPTS = make_oidjoins_check
DOCS = README.findoidjoins
Index: contrib/oid2name/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/oid2name/Makefile,v
retrieving revision 1.6
diff -c -c -r1.6 Makefile
*** contrib/oid2name/Makefile 20 Aug 2004 20:13:05 -0000 1.6
--- contrib/oid2name/Makefile 25 Mar 2005 17:59:39 -0000
***************
*** 4,10 ****
OBJS = oid2name.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq)
DOCS = README.oid2name
--- 4,10 ----
OBJS = oid2name.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq_pgport)
DOCS = README.oid2name
Index: contrib/pg_autovacuum/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_autovacuum/Makefile,v
retrieving revision 1.3
diff -c -c -r1.3 Makefile
*** contrib/pg_autovacuum/Makefile 16 Oct 2004 21:50:02 -0000 1.3
--- contrib/pg_autovacuum/Makefile 25 Mar 2005 17:59:39 -0000
***************
*** 2,8 ****
OBJS = pg_autovacuum.o dllist.o
PG_CPPFLAGS = -I$(libpq_srcdir) -DFRONTEND
! PG_LIBS = $(libpq)
DOCS = README.pg_autovacuum
--- 2,8 ----
OBJS = pg_autovacuum.o dllist.o
PG_CPPFLAGS = -I$(libpq_srcdir) -DFRONTEND
! PG_LIBS = $(libpq_pgport)
DOCS = README.pg_autovacuum
Index: contrib/pg_dumplo/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_dumplo/Makefile,v
retrieving revision 1.13
diff -c -c -r1.13 Makefile
*** contrib/pg_dumplo/Makefile 20 Aug 2004 20:13:05 -0000 1.13
--- contrib/pg_dumplo/Makefile 25 Mar 2005 17:59:39 -0000
***************
*** 4,10 ****
OBJS = main.o lo_export.o lo_import.o utils.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq)
DOCS = README.pg_dumplo
--- 4,10 ----
OBJS = main.o lo_export.o lo_import.o utils.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq_pgport)
DOCS = README.pg_dumplo
Index: contrib/pgbench/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/pgbench/Makefile,v
retrieving revision 1.12
diff -c -c -r1.12 Makefile
*** contrib/pgbench/Makefile 20 Aug 2004 20:13:06 -0000 1.12
--- contrib/pgbench/Makefile 25 Mar 2005 17:59:39 -0000
***************
*** 4,10 ****
OBJS = pgbench.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq)
DOCS = README.pgbench README.pgbench_jis
--- 4,10 ----
OBJS = pgbench.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq_pgport)
DOCS = README.pgbench README.pgbench_jis
Index: contrib/vacuumlo/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/vacuumlo/Makefile,v
retrieving revision 1.13
diff -c -c -r1.13 Makefile
*** contrib/vacuumlo/Makefile 20 Aug 2004 20:13:10 -0000 1.13
--- contrib/vacuumlo/Makefile 25 Mar 2005 17:59:39 -0000
***************
*** 4,10 ****
OBJS = vacuumlo.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq)
DOCS = README.vacuumlo
--- 4,10 ----
OBJS = vacuumlo.o
PG_CPPFLAGS = -I$(libpq_srcdir)
! PG_LIBS = $(libpq_pgport)
DOCS = README.vacuumlo
Index: src/Makefile.global.in
===================================================================
RCS file: /cvsroot/pgsql/src/Makefile.global.in,v
retrieving revision 1.211
diff -c -c -r1.211 Makefile.global.in
*** src/Makefile.global.in 24 Mar 2005 23:53:48 -0000 1.211
--- src/Makefile.global.in 25 Mar 2005 17:59:40 -0000
***************
*** 306,313 ****
libpq_builddir = $(top_builddir)/src/interfaces/libpq
endif
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)
--- 306,315 ----
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,325 ****
--- 322,340 ----
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: src/bin/initdb/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/bin/initdb/Makefile,v
retrieving revision 1.48
diff -c -c -r1.48 Makefile
*** src/bin/initdb/Makefile 31 Dec 2004 22:02:59 -0000 1.48
--- src/bin/initdb/Makefile 25 Mar 2005 17:59:41 -0000
***************
*** 21,27 ****
all: submake-libpq submake-libpgport initdb
initdb: $(OBJS) $(libpq_builddir)/libpq.a
! $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
install: all installdirs
$(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
--- 21,27 ----
all: submake-libpq submake-libpgport initdb
initdb: $(OBJS) $(libpq_builddir)/libpq.a
! $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
install: all installdirs
$(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
Index: src/bin/pg_ctl/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/bin/pg_ctl/Makefile,v
retrieving revision 1.19
diff -c -c -r1.19 Makefile
*** src/bin/pg_ctl/Makefile 31 Dec 2004 22:03:05 -0000 1.19
--- src/bin/pg_ctl/Makefile 25 Mar 2005 17:59:41 -0000
***************
*** 21,27 ****
all: submake-libpq submake-libpgport pg_ctl
pg_ctl: $(OBJS) $(libpq_builddir)/libpq.a
! $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
install: all installdirs
$(INSTALL_PROGRAM) pg_ctl$(X) $(DESTDIR)$(bindir)/pg_ctl$(X)
--- 21,27 ----
all: submake-libpq submake-libpgport pg_ctl
pg_ctl: $(OBJS) $(libpq_builddir)/libpq.a
! $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
install: all installdirs
$(INSTALL_PROGRAM) pg_ctl$(X) $(DESTDIR)$(bindir)/pg_ctl$(X)
Index: src/bin/pg_dump/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v
retrieving revision 1.59
diff -c -c -r1.59 Makefile
*** src/bin/pg_dump/Makefile 1 Jan 2005 20:44:23 -0000 1.59
--- src/bin/pg_dump/Makefile 25 Mar 2005 17:59:41 -0000
***************
*** 25,37 ****
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)
pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
! $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(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)
.PHONY: submake-backend
submake-backend:
--- 25,37 ----
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_pgport) $(LDFLAGS) $(LIBS) -o
$@$(X)
pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
! $(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_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
.PHONY: submake-backend
submake-backend:
Index: src/bin/psql/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/Makefile,v
retrieving revision 1.52
diff -c -c -r1.52 Makefile
*** src/bin/psql/Makefile 1 Jan 2005 20:44:25 -0000 1.52
--- src/bin/psql/Makefile 25 Mar 2005 17:59:41 -0000
***************
*** 29,35 ****
all: submake-libpq submake-libpgport psql
psql: $(OBJS) $(libpq_builddir)/libpq.a
! $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
help.o: $(srcdir)/sql_help.h
--- 29,35 ----
all: submake-libpq submake-libpgport psql
psql: $(OBJS) $(libpq_builddir)/libpq.a
! $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
help.o: $(srcdir)/sql_help.h
Index: src/bin/scripts/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/bin/scripts/Makefile,v
retrieving revision 1.32
diff -c -c -r1.32 Makefile
*** src/bin/scripts/Makefile 1 Jan 2005 20:44:26 -0000 1.32
--- src/bin/scripts/Makefile 25 Mar 2005 17:59:41 -0000
***************
*** 21,27 ****
all: submake-libpq submake-backend $(PROGRAMS)
%: %.o $(WIN32RES)
! $(CC) $(CFLAGS) $^ $(libpq) $(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
--- 21,27 ----
all: submake-libpq submake-backend $(PROGRAMS)
%: %.o $(WIN32RES)
! $(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: src/test/examples/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/test/examples/Makefile,v
retrieving revision 1.13
diff -c -c -r1.13 Makefile
*** src/test/examples/Makefile 20 Sep 2003 21:14:57 -0000 1.13
--- src/test/examples/Makefile 25 Mar 2005 17:59:42 -0000
***************
*** 7,13 ****
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
! override LDLIBS := $(libpq) -lpgport $(LDLIBS)
PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo
--- 7,13 ----
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
! override LDLIBS := $(libpq_pgport) $(LDLIBS)
PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo