no library dependency in Makefile?
Hi,
Recently, I found 'psql' is not rebuilt automatically after
editing 'fe_utils/psqlscan.l'.
The detail is:
'psqlscan.l' is part of 'libpgfeutils.a' which will be built
into 'psql' statically. But there is no dependency rule between
them.
It's OK for 'libpq' since 'libpq' is a dynamic library.
For a static library such as 'libpgfeutils.a', should we
add dependency rule in Makefile?
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
Is this a problem or not?
A simple fix:
1. add a STLIBS variable in Makefiles as normal prerequisite
<https://www.gnu.org/software/make/manual/make.html#Prerequisite-Types>
2. using GNU make's function to generate '-Lxxx -lxxx' for items in STLIBS
For example: libpgfeutils.a in psql's Makefile:
'''
# function to generate '-Lxxx -lxxx', may put in another file
expand_stlibs = $(patsubst %,-L%,$(dir $(1))) $(patsubst
lib%.a,-l%,$(notdir $(1)))
# static lib
STLIBS := $(top_builddir)/src/fe_utils/libpgfeutils.a
# add STLIBS as normal prerequisite
psql: $(OBJS) $(STLIBS) | submake-libpq submake-libpgport
submake-libpgfeutils
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
'''
2017-11-15 16:10 GMT+08:00 高增琦 <pgf00a@gmail.com>:
Hi,
Recently, I found 'psql' is not rebuilt automatically after
editing 'fe_utils/psqlscan.l'.The detail is:
'psqlscan.l' is part of 'libpgfeutils.a' which will be built
into 'psql' statically. But there is no dependency rule between
them.It's OK for 'libpq' since 'libpq' is a dynamic library.
For a static library such as 'libpgfeutils.a', should we
add dependency rule in Makefile?--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
LDFLAGS in the example changed to:
'''
override LDFLAGS := $(call expand_stlibs,$(STLIBS)) $(libpq_pgport)
$(LDFLAGS)
'''
2017-11-16 20:50 GMT+08:00 高增琦 <pgf00a@gmail.com>:
Is this a problem or not?
A simple fix:
1. add a STLIBS variable in Makefiles as normal prerequisite
<https://www.gnu.org/software/make/manual/make.html#Prerequisite-Types>
2. using GNU make's function to generate '-Lxxx -lxxx' for items in STLIBSFor example: libpgfeutils.a in psql's Makefile:
'''
# function to generate '-Lxxx -lxxx', may put in another file
expand_stlibs = $(patsubst %,-L%,$(dir $(1))) $(patsubst
lib%.a,-l%,$(notdir $(1)))# static lib
STLIBS := $(top_builddir)/src/fe_utils/libpgfeutils.a# add STLIBS as normal prerequisite
psql: $(OBJS) $(STLIBS) | submake-libpq submake-libpgport
submake-libpgfeutils
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
'''2017-11-15 16:10 GMT+08:00 高增琦 <pgf00a@gmail.com>:
Hi,
Recently, I found 'psql' is not rebuilt automatically after
editing 'fe_utils/psqlscan.l'.The detail is:
'psqlscan.l' is part of 'libpgfeutils.a' which will be built
into 'psql' statically. But there is no dependency rule between
them.It's OK for 'libpq' since 'libpq' is a dynamic library.
For a static library such as 'libpgfeutils.a', should we
add dependency rule in Makefile?--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
I very much look forward to hearing everyone's views on this issue.
If the solution mentioned before is ok, I will start to complete it.
thanks
高增琦 <pgf00a@gmail.com>于2017年11月16日 周四20:51写道:
LDFLAGS in the example changed to:
'''
override LDFLAGS := $(call expand_stlibs,$(STLIBS)) $(libpq_pgport)
$(LDFLAGS)
'''2017-11-16 20:50 GMT+08:00 高增琦 <pgf00a@gmail.com>:
Is this a problem or not?
A simple fix:
1. add a STLIBS variable in Makefiles as normal prerequisite
<https://www.gnu.org/software/make/manual/make.html#Prerequisite-Types>
2. using GNU make's function to generate '-Lxxx -lxxx' for items in STLIBSFor example: libpgfeutils.a in psql's Makefile:
'''
# function to generate '-Lxxx -lxxx', may put in another file
expand_stlibs = $(patsubst %,-L%,$(dir $(1))) $(patsubst
lib%.a,-l%,$(notdir $(1)))# static lib
STLIBS := $(top_builddir)/src/fe_utils/libpgfeutils.a# add STLIBS as normal prerequisite
psql: $(OBJS) $(STLIBS) | submake-libpq submake-libpgport
submake-libpgfeutils
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
'''2017-11-15 16:10 GMT+08:00 高增琦 <pgf00a@gmail.com>:
Hi,
Recently, I found 'psql' is not rebuilt automatically after
editing 'fe_utils/psqlscan.l'.The detail is:
'psqlscan.l' is part of 'libpgfeutils.a' which will be built
into 'psql' statically. But there is no dependency rule between
them.It's OK for 'libpq' since 'libpq' is a dynamic library.
For a static library such as 'libpgfeutils.a', should we
add dependency rule in Makefile?--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
=?UTF-8?B?6auY5aKe55Cm?= <pgf00a@gmail.com> writes:
I very much look forward to hearing everyone's views on this issue.
If the solution mentioned before is ok, I will start to complete it.
Please don't top-post, it makes the flow of the conversation very hard
to follow.
Recently, I found 'psql' is not rebuilt automatically after
editing 'fe_utils/psqlscan.l'.
...
It's OK for 'libpq' since 'libpq' is a dynamic library.
For a static library such as 'libpgfeutils.a', should we
add dependency rule in Makefile?
Hm. I think what you're saying is that when we copied the makefile
patterns used for libpq.so to use for libpgport and libpgfeutils,
we did the wrong thing because those are static not dynamic libraries.
We don't have to relink psql if libpq.so gets some non-API-relevant
changes, but we do need to relink it if libpgport.a does, so I suppose
you are right. However, this doesn't seem like the right way to
fix it:
# add STLIBS as normal prerequisite
psql: $(OBJS) $(STLIBS) | submake-libpq submake-libpgport submake-libpgfeutils
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
Your point is that the static libraries should be treated as normal
dependencies not order-only ones, so building that behavior like
this seems pretty bizarre.
I think what we want is something more like
../../src/port/libpgport.a: submake-libpgport
../../src/fe_utils/libpgfeutils.a: submake-libpgfeutils
psql: $(OBJS) ../../src/port/libpgport.a ../../src/fe_utils/libpgfeutils.a | submake-libpq
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
where of course the library file names need to be wrapped up in macros,
but this is what it'd look like after macro expansion. (I'm not sure
this is right in detail, but my point is that we don't want order-only
dependencies for these libraries.)
regards, tom lane
2017-11-20 2:25 GMT+08:00 Tom Lane <tgl@sss.pgh.pa.us>:
=?UTF-8?B?6auY5aKe55Cm?= <pgf00a@gmail.com> writes:
I very much look forward to hearing everyone's views on this issue.
If the solution mentioned before is ok, I will start to complete it.Please don't top-post, it makes the flow of the conversation very hard
to follow.
Sorry, my fault, I am so anxious.
Recently, I found 'psql' is not rebuilt automatically after
editing 'fe_utils/psqlscan.l'.
...
It's OK for 'libpq' since 'libpq' is a dynamic library.
For a static library such as 'libpgfeutils.a', should we
add dependency rule in Makefile?Hm. I think what you're saying is that when we copied the makefile
patterns used for libpq.so to use for libpgport and libpgfeutils,
we did the wrong thing because those are static not dynamic libraries.
We don't have to relink psql if libpq.so gets some non-API-relevant
changes, but we do need to relink it if libpgport.a does, so I suppose
you are right. However, this doesn't seem like the right way to
fix it:# add STLIBS as normal prerequisite
psql: $(OBJS) $(STLIBS) | submake-libpq submake-libpgportsubmake-libpgfeutils
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
Your point is that the static libraries should be treated as normal
dependencies not order-only ones, so building that behavior like
this seems pretty bizarre.I think what we want is something more like
../../src/port/libpgport.a: submake-libpgport
../../src/fe_utils/libpgfeutils.a: submake-libpgfeutils
psql: $(OBJS) ../../src/port/libpgport.a ../../src/fe_utils/libpgfeutils.a
| submake-libpq
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS)
-o $@$(X)where of course the library file names need to be wrapped up in macros,
but this is what it'd look like after macro expansion. (I'm not sure
this is right in detail, but my point is that we don't want order-only
dependencies for these libraries.)regards, tom lane
Thank you, I will try it this way.
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
The attached patch use normal dependency instead of order-only dependency
for static libraries.
2017-11-20 12:58 GMT+08:00 高增琦 <pgf00a@gmail.com>:
2017-11-20 2:25 GMT+08:00 Tom Lane <tgl@sss.pgh.pa.us>:
=?UTF-8?B?6auY5aKe55Cm?= <pgf00a@gmail.com> writes:
I very much look forward to hearing everyone's views on this issue.
If the solution mentioned before is ok, I will start to complete it.Please don't top-post, it makes the flow of the conversation very hard
to follow.Sorry, my fault, I am so anxious.
Recently, I found 'psql' is not rebuilt automatically after
editing 'fe_utils/psqlscan.l'.
...
It's OK for 'libpq' since 'libpq' is a dynamic library.
For a static library such as 'libpgfeutils.a', should we
add dependency rule in Makefile?Hm. I think what you're saying is that when we copied the makefile
patterns used for libpq.so to use for libpgport and libpgfeutils,
we did the wrong thing because those are static not dynamic libraries.
We don't have to relink psql if libpq.so gets some non-API-relevant
changes, but we do need to relink it if libpgport.a does, so I suppose
you are right. However, this doesn't seem like the right way to
fix it:# add STLIBS as normal prerequisite
psql: $(OBJS) $(STLIBS) | submake-libpq submake-libpgportsubmake-libpgfeutils
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
Your point is that the static libraries should be treated as normal
dependencies not order-only ones, so building that behavior like
this seems pretty bizarre.I think what we want is something more like
../../src/port/libpgport.a: submake-libpgport
../../src/fe_utils/libpgfeutils.a: submake-libpgfeutils
psql: $(OBJS) ../../src/port/libpgport.a
../../src/fe_utils/libpgfeutils.a | submake-libpq
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS)
-o $@$(X)where of course the library file names need to be wrapped up in macros,
but this is what it'd look like after macro expansion. (I'm not sure
this is right in detail, but my point is that we don't want order-only
dependencies for these libraries.)regards, tom lane
Thank you, I will try it this way.
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
Attachments:
0001-add-dependency-between-client-executables-and-static.patchapplication/octet-stream; name=0001-add-dependency-between-client-executables-and-static.patchDownload
From d8484f6695179fe491939aab17a447561e02e3dc Mon Sep 17 00:00:00 2001
From: Gao Zengqi <pgf00a@gmail.com>
Date: Mon, 20 Nov 2017 08:42:57 +0000
Subject: [PATCH] add dependency between client executables and static
libraries
---
src/Makefile.global.in | 15 +++++++++++++++
src/backend/storage/lmgr/Makefile | 2 +-
src/bin/initdb/Makefile | 4 ++--
src/bin/pg_archivecleanup/Makefile | 2 +-
src/bin/pg_basebackup/Makefile | 8 ++++----
src/bin/pg_config/Makefile | 2 +-
src/bin/pg_controldata/Makefile | 2 +-
src/bin/pg_ctl/Makefile | 2 +-
src/bin/pg_dump/Makefile | 8 ++++----
src/bin/pg_resetwal/Makefile | 2 +-
src/bin/pg_rewind/Makefile | 2 +-
src/bin/pg_test_fsync/Makefile | 2 +-
src/bin/pg_test_timing/Makefile | 2 +-
src/bin/pg_upgrade/Makefile | 4 ++--
src/bin/pg_waldump/Makefile | 2 +-
src/bin/pgbench/Makefile | 4 ++--
src/bin/psql/Makefile | 4 ++--
src/bin/scripts/Makefile | 18 +++++++++---------
src/interfaces/ecpg/preproc/Makefile | 2 +-
src/test/isolation/Makefile | 2 +-
src/test/regress/GNUmakefile | 4 ++--
src/timezone/Makefile | 2 +-
src/tools/findoidjoins/Makefile | 2 +-
23 files changed, 56 insertions(+), 41 deletions(-)
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 27ec54a..b7caacf 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -502,6 +502,9 @@ ifeq ($(PORTNAME),cygwin)
libpq_pgport += $(LDAP_LIBS_FE)
endif
+# This macro is for use by client executables linking to libpgfeutils.
+libpgfeutils = -L$(top_builddir)/src/fe_utils -lpgfeutils
+
##########################################################################
#
@@ -527,6 +530,18 @@ submake-generated-headers:
##########################################################################
#
+# Static libraries for client executables
+
+stlib_pgport = $(top_builddir)/src/port/libpgport.a $(top_builddir)/src/common/libpgcommon.a
+stlib_pgfeutils = $(top_builddir)/src/fe_utils/libpgfeutils.a
+
+# start submake for these static libraries
+$(stlib_pgport): | submake-libpgport
+$(stlib_pgfeutils): | submake-libpgfeutils
+
+
+##########################################################################
+#
# Testing support
PL_TESTDB = pl_regression
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index e1b787e..2ca0595 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -21,7 +21,7 @@ ifdef TAS
TASPATH = $(top_builddir)/src/backend/port/tas.o
endif
-s_lock_test: s_lock.c $(top_builddir)/src/port/libpgport.a
+s_lock_test: s_lock.c $(stlib_pgport)
$(CC) $(CPPFLAGS) $(CFLAGS) -DS_LOCK_TEST=1 $(srcdir)/s_lock.c \
$(TASPATH) -L $(top_builddir)/src/port -lpgport -o s_lock_test
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index ec26652..f5000ca 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -19,7 +19,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone $(CPPFLAGS)
# note: we need libpq only because fe_utils does
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
# use system timezone data?
ifneq (,$(with_system_tzdata))
@@ -30,7 +30,7 @@ OBJS= initdb.o findtimezone.o localtime.o encnames.o $(WIN32RES)
all: initdb
-initdb: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+initdb: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
# We used to pull in all of libpq to get encnames.c, but that
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
index c5bf99d..49aab01 100644
--- a/src/bin/pg_archivecleanup/Makefile
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -11,7 +11,7 @@ OBJS = pg_archivecleanup.o $(WIN32RES)
all: pg_archivecleanup
-pg_archivecleanup: $(OBJS) | submake-libpgport
+pg_archivecleanup: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile
index b707af9..4f731d1 100644
--- a/src/bin/pg_basebackup/Makefile
+++ b/src/bin/pg_basebackup/Makefile
@@ -19,19 +19,19 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
OBJS=receivelog.o streamutil.o walmethods.o $(WIN32RES)
all: pg_basebackup pg_receivewal pg_recvlogical
-pg_basebackup: pg_basebackup.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_basebackup: pg_basebackup.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_basebackup.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_receivewal: pg_receivewal.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_receivewal: pg_receivewal.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_receivewal.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_recvlogical: pg_recvlogical.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_recvlogical: pg_recvlogical.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_recvlogical.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_config/Makefile b/src/bin/pg_config/Makefile
index c410087..b085575 100644
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -19,7 +19,7 @@ OBJS= pg_config.o $(WIN32RES)
all: pg_config
-pg_config: $(OBJS) | submake-libpgport
+pg_config: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index fd87daa..9bb580b 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -19,7 +19,7 @@ OBJS= pg_controldata.o $(WIN32RES)
all: pg_controldata
-pg_controldata: $(OBJS) | submake-libpgport
+pg_controldata: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile
index e734c95..1c82171 100644
--- a/src/bin/pg_ctl/Makefile
+++ b/src/bin/pg_ctl/Makefile
@@ -28,7 +28,7 @@ OBJS= pg_ctl.o $(WIN32RES)
all: pg_ctl
-pg_ctl: $(OBJS) | submake-libpgport $(SUBMAKE_LIBPQ)
+pg_ctl: $(OBJS) $(stlib_pgport) | $(SUBMAKE_LIBPQ)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 3700884..aba501c 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -17,7 +17,7 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
pg_backup_null.o pg_backup_tar.o pg_backup_directory.o \
@@ -25,13 +25,13 @@ OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
all: pg_dump pg_restore pg_dumpall
-pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_restore: pg_restore.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_restore: pg_restore.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_dumpall: pg_dumpall.o dumputils.o | submake-libpq submake-libpgport submake-libpgfeutils
+pg_dumpall: pg_dumpall.o dumputils.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(WIN32RES) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile
index 0f6e5da..82da592 100644
--- a/src/bin/pg_resetwal/Makefile
+++ b/src/bin/pg_resetwal/Makefile
@@ -19,7 +19,7 @@ OBJS= pg_resetwal.o $(WIN32RES)
all: pg_resetwal
-pg_resetwal: $(OBJS) | submake-libpgport
+pg_resetwal: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile
index e64ad76..8a23041 100644
--- a/src/bin/pg_rewind/Makefile
+++ b/src/bin/pg_rewind/Makefile
@@ -26,7 +26,7 @@ EXTRA_CLEAN = xlogreader.c
all: pg_rewind
-pg_rewind: $(OBJS) | submake-libpq submake-libpgport
+pg_rewind: $(OBJS) $(stlib_pgport) | submake-libpq
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
index 90496df..ade9072 100644
--- a/src/bin/pg_test_fsync/Makefile
+++ b/src/bin/pg_test_fsync/Makefile
@@ -11,7 +11,7 @@ OBJS = pg_test_fsync.o $(WIN32RES)
all: pg_test_fsync
-pg_test_fsync: $(OBJS) | submake-libpgport
+pg_test_fsync: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
index d1f3595..ae144fb 100644
--- a/src/bin/pg_test_timing/Makefile
+++ b/src/bin/pg_test_timing/Makefile
@@ -11,7 +11,7 @@ OBJS = pg_test_timing.o $(WIN32RES)
all: pg_test_timing
-pg_test_timing: $(OBJS) | submake-libpgport
+pg_test_timing: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 1d6ee70..78024bb 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -12,12 +12,12 @@ OBJS = check.o controldata.o dump.o exec.o file.o function.o info.o \
tablespace.o util.o version.o $(WIN32RES)
override CPPFLAGS := -DDLSUFFIX=\"$(DLSUFFIX)\" -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
all: pg_upgrade
-pg_upgrade: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_upgrade: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_waldump/Makefile b/src/bin/pg_waldump/Makefile
index f5957bd..98ce844 100644
--- a/src/bin/pg_waldump/Makefile
+++ b/src/bin/pg_waldump/Makefile
@@ -18,7 +18,7 @@ RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES))
all: pg_waldump
-pg_waldump: $(OBJS) | submake-libpgport
+pg_waldump: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index 8a8e516..6bd5940 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -10,7 +10,7 @@ include $(top_builddir)/src/Makefile.global
OBJS = pgbench.o exprparse.o $(WIN32RES)
override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
ifneq ($(PORTNAME), win32)
override CFLAGS += $(PTHREAD_CFLAGS)
@@ -20,7 +20,7 @@ LIBS += $(PTHREAD_LIBS)
all: pgbench
-pgbench: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pgbench: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
# exprscan is compiled as part of exprparse
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index cabfe15..b4d1e55 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -19,7 +19,7 @@ include $(top_builddir)/src/Makefile.global
REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref
override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
OBJS= command.o common.o conditional.o copy.o crosstabview.o \
describe.o help.o input.o large_obj.o mainloop.o \
@@ -30,7 +30,7 @@ OBJS= command.o common.o conditional.o copy.o crosstabview.o \
all: psql
-psql: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+psql: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
help.o: sql_help.h
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index a9c24a9..d0d7ab6 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -19,21 +19,21 @@ include $(top_builddir)/src/Makefile.global
PROGRAMS = createdb createuser dropdb dropuser clusterdb vacuumdb reindexdb pg_isready
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
all: $(PROGRAMS)
%: %.o $(WIN32RES)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-createdb: createdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-createuser: createuser.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-dropdb: dropdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-dropuser: dropuser.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-clusterdb: clusterdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-vacuumdb: vacuumdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-reindexdb: reindexdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-pg_isready: pg_isready.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
+createdb: createdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+createuser: createuser.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+dropdb: dropdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+dropuser: dropuser.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+clusterdb: clusterdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+vacuumdb: vacuumdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+reindexdb: reindexdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+pg_isready: pg_isready.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
install: all installdirs
$(INSTALL_PROGRAM) createdb$(X) '$(DESTDIR)$(bindir)'/createdb$(X)
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 02a6e65..2e55b75 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -33,7 +33,7 @@ endif
all: ecpg
-ecpg: $(OBJS) | submake-libpgport
+ecpg: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
../ecpglib/typename.o: ../ecpglib/typename.c
diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile
index 8eb4969..27264b4 100644
--- a/src/test/isolation/Makefile
+++ b/src/test/isolation/Makefile
@@ -24,7 +24,7 @@ pg_regress.o: | submake-regress
pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
-isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport
+isolationtester$(X): $(OBJS) $(stlib_pgport) | submake-libpq
$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
distprep: specparse.c specscanner.c
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 8b2d20c..a9f8738 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -36,7 +36,7 @@ EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \
all: pg_regress$(X)
-pg_regress$(X): pg_regress.o pg_regress_main.o $(WIN32RES) | submake-libpgport
+pg_regress$(X): pg_regress.o pg_regress_main.o $(WIN32RES) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
# dependencies ensure that path changes propagate
@@ -107,7 +107,7 @@ $(top_builddir)/contrib/spi/refint$(DLSUFFIX): | submake-contrib-spi ;
$(top_builddir)/contrib/spi/autoinc$(DLSUFFIX): | submake-contrib-spi ;
-submake-contrib-spi: | submake-libpgport submake-generated-headers
+submake-contrib-spi: $(stlib_pgport) | submake-generated-headers
$(MAKE) -C $(top_builddir)/contrib/spi
.PHONY: submake-contrib-spi
diff --git a/src/timezone/Makefile b/src/timezone/Makefile
index bed5727..4eee23a 100644
--- a/src/timezone/Makefile
+++ b/src/timezone/Makefile
@@ -49,7 +49,7 @@ ifeq (,$(ZIC))
ZIC= ./zic
endif
-zic: $(ZICOBJS) | submake-libpgport
+zic: $(ZICOBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/tools/findoidjoins/Makefile b/src/tools/findoidjoins/Makefile
index 5410d85..3bcea54 100644
--- a/src/tools/findoidjoins/Makefile
+++ b/src/tools/findoidjoins/Makefile
@@ -19,7 +19,7 @@ OBJS= findoidjoins.o
all: findoidjoins
-findoidjoins: findoidjoins.o | submake-libpq submake-libpgport
+findoidjoins: findoidjoins.o $(stlib_pgport) | submake-libpq
$(CC) $(CFLAGS) findoidjoins.o $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
clean distclean maintainer-clean:
--
2.7.4
Hi, all
Update version:
1. Re-base with head of master
2. Add some basic support for PGXS
After replacing submake-libpgport/submake-libpgfeutils with
$(stlib_pgport)/$(stlib_pgfeutils) in
Makefiles of client programs, I think, may be we should add static lib
dependency for PGXS.
I can think two ways to do that: first, add a new PG_STLIBS variable, user
need to
add static libs to it; second, we generate static lib dependency
automatically
from PG_LIBS variable. Which one is better?
Thanks
2017-11-20 17:00 GMT+08:00 高增琦 <pgf00a@gmail.com>:
The attached patch use normal dependency instead of order-only dependency
for static libraries.2017-11-20 12:58 GMT+08:00 高增琦 <pgf00a@gmail.com>:
2017-11-20 2:25 GMT+08:00 Tom Lane <tgl@sss.pgh.pa.us>:
=?UTF-8?B?6auY5aKe55Cm?= <pgf00a@gmail.com> writes:
I very much look forward to hearing everyone's views on this issue.
If the solution mentioned before is ok, I will start to complete it.Please don't top-post, it makes the flow of the conversation very hard
to follow.Sorry, my fault, I am so anxious.
Recently, I found 'psql' is not rebuilt automatically after
editing 'fe_utils/psqlscan.l'.
...
It's OK for 'libpq' since 'libpq' is a dynamic library.
For a static library such as 'libpgfeutils.a', should we
add dependency rule in Makefile?Hm. I think what you're saying is that when we copied the makefile
patterns used for libpq.so to use for libpgport and libpgfeutils,
we did the wrong thing because those are static not dynamic libraries.
We don't have to relink psql if libpq.so gets some non-API-relevant
changes, but we do need to relink it if libpgport.a does, so I suppose
you are right. However, this doesn't seem like the right way to
fix it:# add STLIBS as normal prerequisite
psql: $(OBJS) $(STLIBS) | submake-libpq submake-libpgportsubmake-libpgfeutils
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o
$@$(X)
Your point is that the static libraries should be treated as normal
dependencies not order-only ones, so building that behavior like
this seems pretty bizarre.I think what we want is something more like
../../src/port/libpgport.a: submake-libpgport
../../src/fe_utils/libpgfeutils.a: submake-libpgfeutils
psql: $(OBJS) ../../src/port/libpgport.a
../../src/fe_utils/libpgfeutils.a | submake-libpq
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS)
-o $@$(X)where of course the library file names need to be wrapped up in macros,
but this is what it'd look like after macro expansion. (I'm not sure
this is right in detail, but my point is that we don't want order-only
dependencies for these libraries.)regards, tom lane
Thank you, I will try it this way.
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
--
GaoZengqi
pgf00a@gmail.com
zengqigao@gmail.com
Attachments:
0001-Add-build-dependency-between-client-and-static-lib.patchapplication/octet-stream; name=0001-Add-build-dependency-between-client-and-static-lib.patchDownload
From 69282fb8c1474439ee6b9fba18b184089b523ee3 Mon Sep 17 00:00:00 2001
From: Gao Zengqi <pgf00a@gmail.com>
Date: Sun, 26 Nov 2017 10:52:50 +0800
Subject: [PATCH] Add build dependency between client and static lib
---
src/Makefile.global.in | 24 ++++++++++++++++++++++++
src/backend/storage/lmgr/Makefile | 2 +-
src/bin/initdb/Makefile | 4 ++--
src/bin/pg_archivecleanup/Makefile | 2 +-
src/bin/pg_basebackup/Makefile | 8 ++++----
src/bin/pg_config/Makefile | 2 +-
src/bin/pg_controldata/Makefile | 2 +-
src/bin/pg_ctl/Makefile | 2 +-
src/bin/pg_dump/Makefile | 8 ++++----
src/bin/pg_resetwal/Makefile | 2 +-
src/bin/pg_rewind/Makefile | 2 +-
src/bin/pg_test_fsync/Makefile | 2 +-
src/bin/pg_test_timing/Makefile | 2 +-
src/bin/pg_upgrade/Makefile | 4 ++--
src/bin/pg_waldump/Makefile | 2 +-
src/bin/pgbench/Makefile | 4 ++--
src/bin/psql/Makefile | 4 ++--
src/bin/scripts/Makefile | 18 +++++++++---------
src/interfaces/ecpg/preproc/Makefile | 2 +-
src/test/isolation/Makefile | 2 +-
src/test/regress/GNUmakefile | 4 ++--
src/timezone/Makefile | 2 +-
src/tools/findoidjoins/Makefile | 2 +-
23 files changed, 65 insertions(+), 41 deletions(-)
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index d980f81046..4166bf1877 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -500,6 +500,13 @@ ifeq ($(PORTNAME),cygwin)
libpq_pgport += $(LDAP_LIBS_FE)
endif
+# This macro is for use by client executables linking to libpgfeutils.
+ifdef PGXS
+libpgfeutils = -L$(libdir) -lpgfeutils
+else
+libpgfeutils = -L$(top_builddir)/src/fe_utils -lpgfeutils
+endif
+
##########################################################################
#
@@ -523,6 +530,23 @@ submake-generated-headers:
.PHONY: submake-libpq submake-libpgport submake-libpgfeutils submake-generated-headers
+##########################################################################
+#
+# Static libraries for client executables
+
+ifdef PGXS
+stlib_pgport = $(libdir)/libpgport.a $(libdir)/libpgcommon.a
+stlib_pgfeutils = $(libdir)/libpgfeutils.a
+else
+stlib_pgport = $(top_builddir)/src/port/libpgport.a $(top_builddir)/src/common/libpgcommon.a
+stlib_pgfeutils = $(top_builddir)/src/fe_utils/libpgfeutils.a
+
+# start submake for these static libraries
+$(stlib_pgport): | submake-libpgport
+$(stlib_pgfeutils): | submake-libpgfeutils
+endif
+
+
##########################################################################
#
# Testing support
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index e1b787e838..2ca0595cce 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -21,7 +21,7 @@ ifdef TAS
TASPATH = $(top_builddir)/src/backend/port/tas.o
endif
-s_lock_test: s_lock.c $(top_builddir)/src/port/libpgport.a
+s_lock_test: s_lock.c $(stlib_pgport)
$(CC) $(CPPFLAGS) $(CFLAGS) -DS_LOCK_TEST=1 $(srcdir)/s_lock.c \
$(TASPATH) -L $(top_builddir)/src/port -lpgport -o s_lock_test
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index ec26652e82..f5000cae23 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -19,7 +19,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone $(CPPFLAGS)
# note: we need libpq only because fe_utils does
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
# use system timezone data?
ifneq (,$(with_system_tzdata))
@@ -30,7 +30,7 @@ OBJS= initdb.o findtimezone.o localtime.o encnames.o $(WIN32RES)
all: initdb
-initdb: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+initdb: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
# We used to pull in all of libpq to get encnames.c, but that
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
index c5bf99db0f..49aab01271 100644
--- a/src/bin/pg_archivecleanup/Makefile
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -11,7 +11,7 @@ OBJS = pg_archivecleanup.o $(WIN32RES)
all: pg_archivecleanup
-pg_archivecleanup: $(OBJS) | submake-libpgport
+pg_archivecleanup: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile
index b707af9d26..4f731d151f 100644
--- a/src/bin/pg_basebackup/Makefile
+++ b/src/bin/pg_basebackup/Makefile
@@ -19,19 +19,19 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
OBJS=receivelog.o streamutil.o walmethods.o $(WIN32RES)
all: pg_basebackup pg_receivewal pg_recvlogical
-pg_basebackup: pg_basebackup.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_basebackup: pg_basebackup.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_basebackup.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_receivewal: pg_receivewal.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_receivewal: pg_receivewal.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_receivewal.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_recvlogical: pg_recvlogical.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_recvlogical: pg_recvlogical.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_recvlogical.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_config/Makefile b/src/bin/pg_config/Makefile
index c41008763e..b08557580a 100644
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -19,7 +19,7 @@ OBJS= pg_config.o $(WIN32RES)
all: pg_config
-pg_config: $(OBJS) | submake-libpgport
+pg_config: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index fd87daa11a..9bb580b58c 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -19,7 +19,7 @@ OBJS= pg_controldata.o $(WIN32RES)
all: pg_controldata
-pg_controldata: $(OBJS) | submake-libpgport
+pg_controldata: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile
index e734c952a2..1c821717ce 100644
--- a/src/bin/pg_ctl/Makefile
+++ b/src/bin/pg_ctl/Makefile
@@ -28,7 +28,7 @@ OBJS= pg_ctl.o $(WIN32RES)
all: pg_ctl
-pg_ctl: $(OBJS) | submake-libpgport $(SUBMAKE_LIBPQ)
+pg_ctl: $(OBJS) $(stlib_pgport) | $(SUBMAKE_LIBPQ)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 3700884720..aba501c187 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -17,7 +17,7 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
pg_backup_null.o pg_backup_tar.o pg_backup_directory.o \
@@ -25,13 +25,13 @@ OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
all: pg_dump pg_restore pg_dumpall
-pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_restore: pg_restore.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_restore: pg_restore.o $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_dumpall: pg_dumpall.o dumputils.o | submake-libpq submake-libpgport submake-libpgfeutils
+pg_dumpall: pg_dumpall.o dumputils.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(WIN32RES) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile
index 0f6e5da255..82da5929eb 100644
--- a/src/bin/pg_resetwal/Makefile
+++ b/src/bin/pg_resetwal/Makefile
@@ -19,7 +19,7 @@ OBJS= pg_resetwal.o $(WIN32RES)
all: pg_resetwal
-pg_resetwal: $(OBJS) | submake-libpgport
+pg_resetwal: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile
index e64ad76509..8a230419a9 100644
--- a/src/bin/pg_rewind/Makefile
+++ b/src/bin/pg_rewind/Makefile
@@ -26,7 +26,7 @@ EXTRA_CLEAN = xlogreader.c
all: pg_rewind
-pg_rewind: $(OBJS) | submake-libpq submake-libpgport
+pg_rewind: $(OBJS) $(stlib_pgport) | submake-libpq
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
index 90496df566..ade9072767 100644
--- a/src/bin/pg_test_fsync/Makefile
+++ b/src/bin/pg_test_fsync/Makefile
@@ -11,7 +11,7 @@ OBJS = pg_test_fsync.o $(WIN32RES)
all: pg_test_fsync
-pg_test_fsync: $(OBJS) | submake-libpgport
+pg_test_fsync: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
index d1f35954f0..ae144fb451 100644
--- a/src/bin/pg_test_timing/Makefile
+++ b/src/bin/pg_test_timing/Makefile
@@ -11,7 +11,7 @@ OBJS = pg_test_timing.o $(WIN32RES)
all: pg_test_timing
-pg_test_timing: $(OBJS) | submake-libpgport
+pg_test_timing: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 1d6ee702c6..78024bb06d 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -12,12 +12,12 @@ OBJS = check.o controldata.o dump.o exec.o file.o function.o info.o \
tablespace.o util.o version.o $(WIN32RES)
override CPPFLAGS := -DDLSUFFIX=\"$(DLSUFFIX)\" -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
all: pg_upgrade
-pg_upgrade: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pg_upgrade: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/bin/pg_waldump/Makefile b/src/bin/pg_waldump/Makefile
index f5957bd75a..98ce844b84 100644
--- a/src/bin/pg_waldump/Makefile
+++ b/src/bin/pg_waldump/Makefile
@@ -18,7 +18,7 @@ RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES))
all: pg_waldump
-pg_waldump: $(OBJS) | submake-libpgport
+pg_waldump: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index 8a8e516896..6bd59400f7 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -10,7 +10,7 @@ include $(top_builddir)/src/Makefile.global
OBJS = pgbench.o exprparse.o $(WIN32RES)
override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
ifneq ($(PORTNAME), win32)
override CFLAGS += $(PTHREAD_CFLAGS)
@@ -20,7 +20,7 @@ LIBS += $(PTHREAD_LIBS)
all: pgbench
-pgbench: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+pgbench: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
# exprscan is compiled as part of exprparse
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index cabfe15f97..b4d1e553a8 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -19,7 +19,7 @@ include $(top_builddir)/src/Makefile.global
REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref
override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
OBJS= command.o common.o conditional.o copy.o crosstabview.o \
describe.o help.o input.o large_obj.o mainloop.o \
@@ -30,7 +30,7 @@ OBJS= command.o common.o conditional.o copy.o crosstabview.o \
all: psql
-psql: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
+psql: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
help.o: sql_help.h
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index a9c24a9f83..d0d7ab68d3 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -19,21 +19,21 @@ include $(top_builddir)/src/Makefile.global
PROGRAMS = createdb createuser dropdb dropuser clusterdb vacuumdb reindexdb pg_isready
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
-override LDFLAGS := -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(LDFLAGS)
+override LDFLAGS := $(libpgfeutils) $(libpq_pgport) $(LDFLAGS)
all: $(PROGRAMS)
%: %.o $(WIN32RES)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-createdb: createdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-createuser: createuser.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-dropdb: dropdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-dropuser: dropuser.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-clusterdb: clusterdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-vacuumdb: vacuumdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-reindexdb: reindexdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
-pg_isready: pg_isready.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
+createdb: createdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+createuser: createuser.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+dropdb: dropdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+dropuser: dropuser.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+clusterdb: clusterdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+vacuumdb: vacuumdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+reindexdb: reindexdb.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
+pg_isready: pg_isready.o common.o $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
install: all installdirs
$(INSTALL_PROGRAM) createdb$(X) '$(DESTDIR)$(bindir)'/createdb$(X)
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 02a6e65daf..2e55b75cd1 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -33,7 +33,7 @@ endif
all: ecpg
-ecpg: $(OBJS) | submake-libpgport
+ecpg: $(OBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
../ecpglib/typename.o: ../ecpglib/typename.c
diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile
index efbdc40e1d..0e05621c9b 100644
--- a/src/test/isolation/Makefile
+++ b/src/test/isolation/Makefile
@@ -31,7 +31,7 @@ pg_regress.o: | submake-regress
pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
-isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport
+isolationtester$(X): $(OBJS) $(stlib_pgport) | submake-libpq
$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
distprep: specparse.c specscanner.c
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 8b2d20c5b5..a9f8738b5d 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -36,7 +36,7 @@ EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \
all: pg_regress$(X)
-pg_regress$(X): pg_regress.o pg_regress_main.o $(WIN32RES) | submake-libpgport
+pg_regress$(X): pg_regress.o pg_regress_main.o $(WIN32RES) $(stlib_pgport)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
# dependencies ensure that path changes propagate
@@ -107,7 +107,7 @@ $(top_builddir)/contrib/spi/refint$(DLSUFFIX): | submake-contrib-spi ;
$(top_builddir)/contrib/spi/autoinc$(DLSUFFIX): | submake-contrib-spi ;
-submake-contrib-spi: | submake-libpgport submake-generated-headers
+submake-contrib-spi: $(stlib_pgport) | submake-generated-headers
$(MAKE) -C $(top_builddir)/contrib/spi
.PHONY: submake-contrib-spi
diff --git a/src/timezone/Makefile b/src/timezone/Makefile
index 87493da8b3..8cc0a79a90 100644
--- a/src/timezone/Makefile
+++ b/src/timezone/Makefile
@@ -47,7 +47,7 @@ ifeq (,$(ZIC))
ZIC= ./zic
endif
-zic: $(ZICOBJS) | submake-libpgport
+zic: $(ZICOBJS) $(stlib_pgport)
$(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
diff --git a/src/tools/findoidjoins/Makefile b/src/tools/findoidjoins/Makefile
index 5410d85ec2..3bcea54117 100644
--- a/src/tools/findoidjoins/Makefile
+++ b/src/tools/findoidjoins/Makefile
@@ -19,7 +19,7 @@ OBJS= findoidjoins.o
all: findoidjoins
-findoidjoins: findoidjoins.o | submake-libpq submake-libpgport
+findoidjoins: findoidjoins.o $(stlib_pgport) | submake-libpq
$(CC) $(CFLAGS) findoidjoins.o $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
clean distclean maintainer-clean:
--
2.14.0
This burned me recently.
On Sun, Nov 26, 2017 at 02:18:16PM +0800, 高增琦 wrote:
Update version:
1. Re-base with head of master
2. Add some basic support for PGXSAfter replacing submake-libpgport/submake-libpgfeutils with
$(stlib_pgport)/$(stlib_pgfeutils) in
Makefiles of client programs, I think, may be we should add static lib
dependency for PGXS.
Maybe. Naming an installed file as a Make prerequisite can break if installed
to a directory containing a space. If that works now, we shouldn't break it
for this. Otherwise, naming the installed prerequisites sounds fine.
I can think two ways to do that: first, add a new PG_STLIBS variable, user
need to
add static libs to it; second, we generate static lib dependency
automatically
from PG_LIBS variable. Which one is better?
I prefer the second one. With the first one, it's easy to miss omissions. I
think that concept is useful beyond PG_LIBS and beyond PGXS. For example:
-initdb: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils +initdb: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
This could look like
initdb: $(OBJS) $(call lib_prereq,$(LDFLAGS) $(LDFLAGS_EX) $(LIBS))
where lib_prereq is a GNU make function that translates -lpgcommon to
SOMEDIR/libpgcommon.a, translates unrecognized arguments to nothing, etc.
This avoids the need to edit the "initdb" rule every time you edit LIBS. It's
easy to miss doing that, due to distance between the places that edit LIBS and
the places that read it. For example, Makefile.global is one of the editors
of LIBS. How do you see it?
Thanks,
nm