From e5ba2fc5b59ee5a7993b3ab65a32860661da81b8 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter_e@gmx.net> Date: Thu, 30 Nov 2000 20:36:13 +0000 Subject: [PATCH] Make all commands that link a program look like $(CC) $(CFLAGS) $(LDFLAGS) <object files> <extra-libraries> $(LIBS) -o $@ This form seemed to be the most portable, readable, and logical, but in any case it's better than having a dozen different ones in the tree. --- contrib/pg_dumplo/Makefile | 4 ++-- src/Makefile.global.in | 4 ++-- src/Makefile.shlib | 6 +++--- src/backend/Makefile | 8 ++++---- src/backend/regex/Makefile | 4 ++-- src/backend/utils/mb/Makefile | 8 ++++---- src/bin/pg_dump/Makefile | 6 +++--- src/bin/pg_encoding/Makefile | 8 ++++---- src/bin/pg_id/Makefile | 8 ++++---- src/bin/pg_passwd/Makefile | 5 ++++- src/bin/pgtclsh/Makefile | 6 +++--- src/bin/psql/Makefile | 8 ++++---- src/interfaces/ecpg/preproc/Makefile | 5 +++-- src/makefiles/Makefile.aix | 4 ++-- src/makefiles/Makefile.qnx4 | 3 +-- src/makefiles/Makefile.svr4 | 3 ++- 16 files changed, 47 insertions(+), 43 deletions(-) diff --git a/contrib/pg_dumplo/Makefile b/contrib/pg_dumplo/Makefile index f8900b17c79..2342ea20be5 100644 --- a/contrib/pg_dumplo/Makefile +++ b/contrib/pg_dumplo/Makefile @@ -1,5 +1,5 @@ # -# $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/Makefile,v 1.7 2000/10/20 21:03:25 petere Exp $ +# $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/Makefile,v 1.8 2000/11/30 20:36:09 petere Exp $ # subdir = contrib/pg_dumplo @@ -12,7 +12,7 @@ override CPPFLAGS += -I$(libpq_srcdir) all: pg_dumplo pg_dumplo: $(OBJS) $(libpq_builddir)/libpq.a - $(CC) -o $@ $(OBJS) $(libpq) $(CFLAGS) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(libpq) $(LIBS) -o $@ install: all installdirs $(INSTALL_PROGRAM) pg_dumplo$(X) $(bindir) diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 72d489d38d5..a09651f348a 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-makefile-*- -# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.113 2000/11/20 16:52:54 petere Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.114 2000/11/30 20:36:10 petere Exp $ #------------------------------------------------------------------------------ # All PostgreSQL makefiles include this file and use the variables it sets, @@ -166,7 +166,7 @@ LIBS = @LIBS@ LD = @LD@ with_gnu_ld = @with_gnu_ld@ ld_R_works = @ld_R_works@ -LDFLAGS = @LDFLAGS@ $(LIBS) +LDFLAGS = @LDFLAGS@ LDREL = -r LDOUT = -o RANLIB = @RANLIB@ diff --git a/src/Makefile.shlib b/src/Makefile.shlib index 6c543f61fea..a5decfaa496 100644 --- a/src/Makefile.shlib +++ b/src/Makefile.shlib @@ -6,7 +6,7 @@ # Copyright (c) 1998, Regents of the University of California # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.35 2000/11/14 21:11:59 petere Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.36 2000/11/30 20:36:10 petere Exp $ # #------------------------------------------------------------------------- @@ -221,7 +221,7 @@ ifeq ($(PORTNAME), beos) endif # Pull in any extra -L options that the user might have specified. -SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK) +SHLIB_LINK := $(filter -L%, $(LIBS)) $(SHLIB_LINK) ifeq ($(enable_rpath), yes) SHLIB_LINK += $(rpath) @@ -262,7 +262,7 @@ ifneq ($(PORTNAME), aix) # Normal case $(shlib): $(OBJS) - $(LINK.shared) -o $@ $(OBJS) $(SHLIB_LINK) + $(LINK.shared) $(OBJS) $(SHLIB_LINK) -o $@ # If we're using major and minor versions, then make a symlink to major-version-only. ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)) rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) diff --git a/src/backend/Makefile b/src/backend/Makefile index 07c18427bf9..701db4265a5 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.67 2000/10/20 21:03:39 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.68 2000/11/30 20:36:10 petere Exp $ # #------------------------------------------------------------------------- @@ -37,7 +37,7 @@ all: postgres $(POSTGRES_IMP) ifneq ($(PORTNAME), win) postgres: $(OBJS) - $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(export_dynamic) + $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@ else # win @@ -80,7 +80,7 @@ $(top_builddir)/src/utils/dllinit.o: $(top_srcdir)/src/utils/dllinit.c # The postgres.o target is needed by the rule in Makefile.global that # creates the exports file when MAKE_EXPORTS = true. postgres.o: $(OBJS) - $(CC) $(LDREL) $(LDOUT) $@ $^ $(LDFLAGS) + $(CC) $(LDREL) $(LDFLAGS) $^ $(LIBS) -o $@ # The following targets are specified in make commands that appear in @@ -193,7 +193,7 @@ maintainer-clean: distclean # are up to date. It saves the time of doing all the submakes. .PHONY: quick quick: $(OBJS) - $(CC) -o postgres $(OBJS) $(LDFLAGS) $(export_dynamic) + $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o postgres depend dep: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h for i in $(DIRS); do $(MAKE) -C $$i $@; done diff --git a/src/backend/regex/Makefile b/src/backend/regex/Makefile index 9d2d929b689..d6d62d2f81c 100644 --- a/src/backend/regex/Makefile +++ b/src/backend/regex/Makefile @@ -4,7 +4,7 @@ # Makefile for regex # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/regex/Makefile,v 1.15 2000/10/20 21:03:46 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/regex/Makefile,v 1.16 2000/11/30 20:36:10 petere Exp $ # #------------------------------------------------------------------------- @@ -28,7 +28,7 @@ SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) retest: retest.o SUBSYS.o $(DEBUGOBJ) - $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ depend dep: $(CC) -MM $(CFLAGS) *.c >depend diff --git a/src/backend/utils/mb/Makefile b/src/backend/utils/mb/Makefile index 229a5fc2425..952ba8789d8 100644 --- a/src/backend/utils/mb/Makefile +++ b/src/backend/utils/mb/Makefile @@ -4,7 +4,7 @@ # Makefile for utils/mb # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.14 2000/10/30 10:40:28 ishii Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.15 2000/11/30 20:36:11 petere Exp $ # #------------------------------------------------------------------------- @@ -22,13 +22,13 @@ SUBSYS.o: $(OBJS) utftest.o: utftest.c conv.c wchar.c mbutils.c sjistest: sjistest.o palloc.o common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o big5.o - $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ liketest: liketest.o palloc.o $(OBJS) - $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ utftest: utftest.o palloc.o common.o wstrcmp.o wstrncmp.o big5.o - $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ depend dep: $(CC) -MM $(CFLAGS) *.c >depend diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile index ba9a08900b2..38a2cf29469 100644 --- a/src/bin/pg_dump/Makefile +++ b/src/bin/pg_dump/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.26 2000/10/20 21:03:56 petere Exp $ +# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.27 2000/11/30 20:36:11 petere Exp $ # #------------------------------------------------------------------------- @@ -20,10 +20,10 @@ override CPPFLAGS+= -I$(libpq_srcdir) all: submake pg_dump pg_restore pg_dumpall pg_dump: pg_dump.o common.o $(OBJS) $(libpq_builddir)/libpq.a - $(CC) $(CFLAGS) -o $@ pg_dump.o common.o $(OBJS) $(libpq) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) pg_dump.o common.o $(OBJS) $(libpq) $(LIBS) -o $@ pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a - $(CC) $(CFLAGS) -o $@ pg_restore.o $(OBJS) $(libpq) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) pg_restore.o $(OBJS) $(libpq) $(LIBS) -o $@ ../../utils/strdup.o: $(MAKE) -C ../../utils strdup.o diff --git a/src/bin/pg_encoding/Makefile b/src/bin/pg_encoding/Makefile index e4c4e4c65ca..784d78d4bc8 100644 --- a/src/bin/pg_encoding/Makefile +++ b/src/bin/pg_encoding/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1998, PostgreSQL Global Development Group # -# $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.11 2000/09/17 13:02:37 petere Exp $ +# $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.12 2000/11/30 20:36:11 petere Exp $ # #------------------------------------------------------------------------- @@ -14,10 +14,10 @@ include $(top_builddir)/src/Makefile.global OBJS= pg_encoding.o -all: submake pg_encoding$(X) +all: submake pg_encoding -pg_encoding$(X): $(OBJS) - $(CC) -o $@ $(OBJS) $(libpq) $(LDFLAGS) $(CFLAGS) +pg_encoding: $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(libpq) $(LIBS) -o $@ .PHONY: submake diff --git a/src/bin/pg_id/Makefile b/src/bin/pg_id/Makefile index ed9ec2ce069..e9577b4f671 100644 --- a/src/bin/pg_id/Makefile +++ b/src/bin/pg_id/Makefile @@ -4,7 +4,7 @@ # # Copyright (C) 2000 by PostgreSQL Global Development Team # -# $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/Makefile,v 1.19 2000/09/17 13:02:39 petere Exp $ +# $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/Makefile,v 1.20 2000/11/30 20:36:11 petere Exp $ # #------------------------------------------------------------------------- @@ -12,10 +12,10 @@ subdir = src/bin/pg_id top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -all: pg_id$(X) +all: pg_id -pg_id$(X): pg_id.o - $(CC) -o $@ $^ $(LDFLAGS) +pg_id: pg_id.o + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ install: all installdirs $(INSTALL_PROGRAM) pg_id$(X) $(DESTDIR)$(bindir)/pg_id$(X) diff --git a/src/bin/pg_passwd/Makefile b/src/bin/pg_passwd/Makefile index d96b102dfa2..e14690c0601 100644 --- a/src/bin/pg_passwd/Makefile +++ b/src/bin/pg_passwd/Makefile @@ -1,4 +1,4 @@ -# $Header: /cvsroot/pgsql/src/bin/pg_passwd/Attic/Makefile,v 1.12 2000/11/18 19:00:23 petere Exp $ +# $Header: /cvsroot/pgsql/src/bin/pg_passwd/Attic/Makefile,v 1.13 2000/11/30 20:36:12 petere Exp $ subdir = src/bin/pg_passwd top_builddir = ../../.. @@ -6,6 +6,9 @@ include $(top_builddir)/src/Makefile.global all: pg_passwd +pg_passwd: pg_passwd.o + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ + install: all installdirs $(INSTALL_PROGRAM) pg_passwd$(X) $(DESTDIR)$(bindir)/pg_passwd$(X) diff --git a/src/bin/pgtclsh/Makefile b/src/bin/pgtclsh/Makefile index 02b19c8b269..7891eab4f23 100644 --- a/src/bin/pgtclsh/Makefile +++ b/src/bin/pgtclsh/Makefile @@ -5,7 +5,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/bin/pgtclsh/Attic/Makefile,v 1.34 2000/10/20 21:04:00 petere Exp $ +# $Header: /cvsroot/pgsql/src/bin/pgtclsh/Attic/Makefile,v 1.35 2000/11/30 20:36:12 petere Exp $ # #------------------------------------------------------------------------- @@ -39,10 +39,10 @@ endif all: submake $(PROGRAMS) pgtclsh: pgtclAppInit.o - $(CC) $(CFLAGS) -o $@ $< $(libpgtcl) $(libpq) $(TCL_LIB_SPEC) $(TCL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(libpgtcl) $(libpq) $(TCL_LIB_SPEC) $(TCL_LIBS) $(LIBS) -o $@ pgtksh: pgtkAppInit.o - $(CC) $(CFLAGS) -o $@ $< $(libpgtcl) $(libpq) $(TK_LIB_SPEC) $(TK_LIBS) $(TCL_LIB_SPEC) $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(libpgtcl) $(libpq) $(TK_LIB_SPEC) $(TK_LIBS) $(TCL_LIB_SPEC) $(LIBS) -o $@ .PHONY: submake submake: diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile index bd38be47b4e..3b54c44da8e 100644 --- a/src/bin/psql/Makefile +++ b/src/bin/psql/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.26 2000/10/20 21:04:01 petere Exp $ +# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.27 2000/11/30 20:36:12 petere Exp $ # #------------------------------------------------------------------------- @@ -20,7 +20,7 @@ OBJS=command.o common.o help.o input.o stringutils.o mainloop.o \ copy.o startup.o prompt.o variables.o large_obj.o print.o describe.o \ tab-complete.o -all: submake psql$(X) +all: submake psql ifdef STRDUP OBJS+=$(top_builddir)/src/utils/strdup.o @@ -47,8 +47,8 @@ endif # End of hacks for picking up backend 'port' modules -psql$(X): $(OBJS) $(libpq_builddir)/libpq.a - $(CC) $(CFLAGS) -o $@ $(OBJS) $(libpq) $(LDFLAGS) +psql: $(OBJS) $(libpq_builddir)/libpq.a + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(libpq) $(LIBS) -o $@ help.o: $(srcdir)/sql_help.h diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile index 1948eb9208f..5db47e4366c 100644 --- a/src/interfaces/ecpg/preproc/Makefile +++ b/src/interfaces/ecpg/preproc/Makefile @@ -1,3 +1,5 @@ +# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.72 2000/11/30 20:36:13 petere Exp $ + subdir = src/interfaces/ecpg/preproc top_builddir = ../../../.. include $(top_builddir)/src/Makefile.global @@ -9,7 +11,6 @@ PATCHLEVEL=0 override CPPFLAGS+=-I$(srcdir)/../include -DMAJOR_VERSION=$(MAJOR_VERSION) \ -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \ -DINCLUDE_PATH=\"$(includedir)\" -# -DYYDEBUG -g OBJS=preproc.o pgc.o type.o ecpg.o ecpg_keywords.o output.o\ keywords.o c_keywords.o ../lib/typename.o descriptor.o variable.o @@ -25,7 +26,7 @@ endif ecpg: $(OBJS) - $(CC) -o $@ $^ $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ $(srcdir)/preproc.c $(srcdir)/preproc.h: preproc.y $(YACC) -d $(YFLAGS) $< diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix index d3ee2fab357..c33c7a546c0 100644 --- a/src/makefiles/Makefile.aix +++ b/src/makefiles/Makefile.aix @@ -35,11 +35,11 @@ else $(MKLDEXPORT) postgres . > $@ endif endif - $(CC) -Wl,-bE:$(top_builddir)/src/backend/$@ -o postgres $(OBJS) $(LDFLAGS) + $(CC) -Wl,-bE:$(top_builddir)/src/backend/$@ -o postgres $(OBJS) $(LDFLAGS) $(LIBS) %$(EXPSUFF): %.o $(MKLDEXPORT) $*.o > $*$(EXPSUFF) %$(DLSUFFIX): %.o %$(EXPSUFF) @echo Making shared library $@ from $*.o, $*$(EXPSUFF) and postgres.imp - $(CC) -Wl,-H512 -Wl,-bM:SRE -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) -Wl,-bE:$*$(EXPSUFF) -o $@ $*.o $(LDFLAGS) $(LDFLAGS_SL) + $(CC) -Wl,-H512 -Wl,-bM:SRE -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) -Wl,-bE:$*$(EXPSUFF) -o $@ $*.o $(LDFLAGS) $(LIBS) $(LDFLAGS_SL) diff --git a/src/makefiles/Makefile.qnx4 b/src/makefiles/Makefile.qnx4 index 2cf15be5f5f..5a74d84c7cc 100644 --- a/src/makefiles/Makefile.qnx4 +++ b/src/makefiles/Makefile.qnx4 @@ -1,12 +1,11 @@ MK_NO_LORDER= true -CXXFLAGS+= -I/usr/local/lib/gcc-lib/i386-pc-qnx4/egcs-2.91.60/include/g++ AR= ar AROPT = cr LD= $(AR) LDREL= $(AROPT) LDOUT= LIBS= -lunix -LDFLAGS= $(LIBS) +LDFLAGS= enable_shared = no DLSUFFIX = .so diff --git a/src/makefiles/Makefile.svr4 b/src/makefiles/Makefile.svr4 index dd1fdec4fa9..9704f1a1d64 100644 --- a/src/makefiles/Makefile.svr4 +++ b/src/makefiles/Makefile.svr4 @@ -2,7 +2,8 @@ # symbol names to tell them what to export/import. #MAKE_EXPORTS= true -LDFLAGS+= -lc /usr/ucblib/libucb.a -LD-Blargedynsym +LIBS += -lc /usr/ucblib/libucb.a +LDFLAGS += -LD-Blargedynsym DLSUFFIX = .so CFLAGS_SL = -- GitLab