diff options
| author | Tom Lane | 2010-07-05 18:54:38 +0000 |
|---|---|---|
| committer | Tom Lane | 2010-07-05 18:54:38 +0000 |
| commit | 291a9577454a63f99b5537e48a3dceae6d35ea8d (patch) | |
| tree | a842e9bd4b21b681b89516a33fe65b207a21c42d /src/makefiles | |
| parent | eb81b6509f4c9109ecf8839d8c482cc597270687 (diff) | |
Split the LDFLAGS make variable into two parts: LDFLAGS is now used for
linking both executables and shared libraries, and we add on LDFLAGS_EX when
linking executables or LDFLAGS_SL when linking shared libraries. This
provides a significantly cleaner way of dealing with link-time switches than
the former behavior. Also, make sure that the various platform-specific
%.so: %.o rules incorporate LDFLAGS and LDFLAGS_SL; most of them missed that
before. (I did not add these variables for the platforms that invoke $(LD)
directly, however. It's not clear if we can do that safely, since for the
most part we assume these variables use CC command-line syntax.)
Per gripe from Aaron Swenson and subsequent investigation.
Diffstat (limited to 'src/makefiles')
| -rw-r--r-- | src/makefiles/Makefile.aix | 1 | ||||
| -rw-r--r-- | src/makefiles/Makefile.bsdi | 3 | ||||
| -rw-r--r-- | src/makefiles/Makefile.cygwin | 13 | ||||
| -rw-r--r-- | src/makefiles/Makefile.darwin | 11 | ||||
| -rw-r--r-- | src/makefiles/Makefile.dgux | 3 | ||||
| -rw-r--r-- | src/makefiles/Makefile.freebsd | 3 | ||||
| -rw-r--r-- | src/makefiles/Makefile.hpux | 9 | ||||
| -rw-r--r-- | src/makefiles/Makefile.irix | 9 | ||||
| -rw-r--r-- | src/makefiles/Makefile.linux | 3 | ||||
| -rw-r--r-- | src/makefiles/Makefile.netbsd | 3 | ||||
| -rw-r--r-- | src/makefiles/Makefile.openbsd | 3 | ||||
| -rw-r--r-- | src/makefiles/Makefile.osf | 1 | ||||
| -rw-r--r-- | src/makefiles/Makefile.sco | 1 | ||||
| -rw-r--r-- | src/makefiles/Makefile.solaris | 7 | ||||
| -rw-r--r-- | src/makefiles/Makefile.sunos4 | 1 | ||||
| -rw-r--r-- | src/makefiles/Makefile.svr4 | 1 | ||||
| -rw-r--r-- | src/makefiles/Makefile.ultrix4 | 3 | ||||
| -rw-r--r-- | src/makefiles/Makefile.univel | 1 | ||||
| -rw-r--r-- | src/makefiles/Makefile.unixware | 9 | ||||
| -rw-r--r-- | src/makefiles/Makefile.win32 | 13 | ||||
| -rw-r--r-- | src/makefiles/pgxs.mk | 5 |
21 files changed, 58 insertions, 45 deletions
diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix index 696e5f42687..6f5715db151 100644 --- a/src/makefiles/Makefile.aix +++ b/src/makefiles/Makefile.aix @@ -37,5 +37,6 @@ MKLDEXPORT=$(top_srcdir)/src/backend/port/aix/mkldexport.sh %.exp: %.o $(MKLDEXPORT) $^ >$@ +# Rule for building a shared library from a single .o file %$(DLSUFFIX): %.o %.exp $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -o $@ $*.o -Wl,-bE:$*.exp $(SHLIB_LINK) diff --git a/src/makefiles/Makefile.bsdi b/src/makefiles/Makefile.bsdi index a5a10dbb8dd..e2c9be3dcd0 100644 --- a/src/makefiles/Makefile.bsdi +++ b/src/makefiles/Makefile.bsdi @@ -20,5 +20,6 @@ else CFLAGS_SL = endif +# Rule for building a shared library from a single .o file %.so: %.o - $(CC) $(CFLAGS) -shared -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< diff --git a/src/makefiles/Makefile.cygwin b/src/makefiles/Makefile.cygwin index 5d4f33b90ca..2c0f87cd53d 100644 --- a/src/makefiles/Makefile.cygwin +++ b/src/makefiles/Makefile.cygwin @@ -1,4 +1,4 @@ -# $PostgreSQL: pgsql/src/makefiles/Makefile.cygwin,v 1.13 2010/01/20 09:30:07 heikki Exp $ +# $PostgreSQL: pgsql/src/makefiles/Makefile.cygwin,v 1.14 2010/07/05 18:54:38 tgl Exp $ DLLTOOL= dlltool DLLWRAP= dllwrap ifdef PGXS @@ -15,11 +15,6 @@ AROPT = crs DLSUFFIX = .dll CFLAGS_SL = -%.dll: %.o - $(DLLTOOL) --export-all --output-def $*.def $< - $(DLLWRAP) -o $@ --def $*.def $< $(SHLIB_LINK) - rm -f $*.def - ifneq (,$(findstring backend,$(subdir))) ifeq (,$(findstring conversion_procs,$(subdir))) ifeq (,$(findstring snowball,$(subdir))) @@ -42,3 +37,9 @@ endif ifneq (,$(findstring src/pl/plpython,$(subdir))) override CPPFLAGS+= -DUSE_DL_IMPORT endif + +# Rule for building a shared library from a single .o file +%.dll: %.o + $(DLLTOOL) --export-all --output-def $*.def $< + $(DLLWRAP) -o $@ --def $*.def $< $(SHLIB_LINK) + rm -f $*.def diff --git a/src/makefiles/Makefile.darwin b/src/makefiles/Makefile.darwin index debad62e8a3..2f6743ab14e 100644 --- a/src/makefiles/Makefile.darwin +++ b/src/makefiles/Makefile.darwin @@ -1,16 +1,13 @@ AROPT = crs -AWK= awk DLSUFFIX = .so -CFLAGS_SL = ifdef PGXS -BE_DLLLIBS= -bundle_loader $(bindir)/postgres + BE_DLLLIBS = -bundle_loader $(bindir)/postgres else -BE_DLLLIBS= -bundle_loader $(top_builddir)/src/backend/postgres + BE_DLLLIBS = -bundle_loader $(top_builddir)/src/backend/postgres endif -# Rule for building shared libs (currently used only for regression test -# shlib ... should go away, since this is not really enough knowledge) +# Rule for building a shared library from a single .o file %.so: %.o - $(CC) $(CFLAGS) -bundle -o $@ $< $(BE_DLLLIBS) + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -bundle -o $@ $< $(BE_DLLLIBS) diff --git a/src/makefiles/Makefile.dgux b/src/makefiles/Makefile.dgux index f9519632a20..0c34d4a3901 100644 --- a/src/makefiles/Makefile.dgux +++ b/src/makefiles/Makefile.dgux @@ -2,7 +2,8 @@ AROPT = crs DLSUFFIX = .so CFLAGS_SL = -fpic +# Rule for building a shared library from a single .o file %.so: %.o - $(CC) -shared -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< sqlmansect = 5 diff --git a/src/makefiles/Makefile.freebsd b/src/makefiles/Makefile.freebsd index 57afc185249..839864c7f8e 100644 --- a/src/makefiles/Makefile.freebsd +++ b/src/makefiles/Makefile.freebsd @@ -14,9 +14,10 @@ allow_nonpic_in_shlib = yes endif +# Rule for building a shared library from a single .o file %.so: %.o ifdef ELF_SYSTEM - $(CC) $(CFLAGS) -shared -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< else $(LD) $(LDREL) $(LDOUT) $<.obj -x $< @echo building shared object $@ diff --git a/src/makefiles/Makefile.hpux b/src/makefiles/Makefile.hpux index f91dfae391c..1917d61b436 100644 --- a/src/makefiles/Makefile.hpux +++ b/src/makefiles/Makefile.hpux @@ -22,7 +22,7 @@ endif ifeq ($(with_gnu_ld), yes) # XXX what to put here? else - LDFLAGS += -Wl,-z + LDFLAGS_EX += -Wl,-z endif # set up appropriate options for shared library builds @@ -43,18 +43,17 @@ else CFLAGS_SL = +Z endif -# Rule for building shared libs (currently used only for regression test -# shlib ... should go away, since this is not really enough knowledge) +# Rule for building a shared library from a single .o file %$(DLSUFFIX): %.o ifeq ($(GCC), yes) ifeq ($(with_gnu_ld), yes) - $(CC) $(LDFLAGS) -shared -o $@ $< `$(CC) $(LDFLAGS) -print-libgcc-file-name` + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< `$(CC) $(LDFLAGS) -print-libgcc-file-name` else $(LD) -b -o $@ $< `$(CC) $(LDFLAGS) -print-libgcc-file-name` endif else ifeq ($(with_gnu_ld), yes) - $(CC) $(LDFLAGS) -shared -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< else $(LD) -b -o $@ $< endif diff --git a/src/makefiles/Makefile.irix b/src/makefiles/Makefile.irix index 145653860e1..8141a96b1a8 100644 --- a/src/makefiles/Makefile.irix +++ b/src/makefiles/Makefile.irix @@ -5,14 +5,15 @@ DLSUFFIX = .so # PIC is default CFLAGS_SL = -%.so: %.o - $(CC) $(CFLAGS) -shared -o $@ $< - override CPPFLAGS += -U_NO_XOPEN4 ifneq ($(GCC), yes) -CFLAGS += -woff 1164,1171,1185,1195,1552 + CFLAGS += -woff 1164,1171,1185,1195,1552 endif LDFLAGS += -Wl,-woff,15 -Wl,-woff,84 +# Rule for building a shared library from a single .o file +%.so: %.o + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< + sqlmansect = 5sql diff --git a/src/makefiles/Makefile.linux b/src/makefiles/Makefile.linux index e266e8fdd5f..cc5cbff2b36 100644 --- a/src/makefiles/Makefile.linux +++ b/src/makefiles/Makefile.linux @@ -12,5 +12,6 @@ else CFLAGS_SL = -fpic endif +# Rule for building a shared library from a single .o file %.so: %.o - $(CC) $(CFLAGS) -shared -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< diff --git a/src/makefiles/Makefile.netbsd b/src/makefiles/Makefile.netbsd index 366f20cdddc..31a52601aff 100644 --- a/src/makefiles/Makefile.netbsd +++ b/src/makefiles/Makefile.netbsd @@ -16,9 +16,10 @@ CFLAGS_SL = -fpic -DPIC endif +# Rule for building a shared library from a single .o file %.so: %.o ifdef ELF_SYSTEM - $(CC) $(CFLAGS) -shared -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< else $(LD) $(LDREL) $(LDOUT) $<.obj -x $< @echo building shared object $@ diff --git a/src/makefiles/Makefile.openbsd b/src/makefiles/Makefile.openbsd index 4abc80ccf18..7bf54933090 100644 --- a/src/makefiles/Makefile.openbsd +++ b/src/makefiles/Makefile.openbsd @@ -14,9 +14,10 @@ CFLAGS_SL = -fpic -DPIC endif +# Rule for building a shared library from a single .o file %.so: %.o ifdef ELF_SYSTEM - $(CC) $(CFLAGS) -shared -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< else $(LD) $(LDREL) $(LDOUT) $<.obj -x $< @echo building shared object $@ diff --git a/src/makefiles/Makefile.osf b/src/makefiles/Makefile.osf index 957f27a54e8..31822fd79d3 100644 --- a/src/makefiles/Makefile.osf +++ b/src/makefiles/Makefile.osf @@ -3,6 +3,7 @@ DLSUFFIX = .so CFLAGS_SL = rpath = -rpath '$(rpathdir)' +# Rule for building a shared library from a single .o file %.so: %.o $(LD) -shared -expect_unresolved '*' -o $@ $< diff --git a/src/makefiles/Makefile.sco b/src/makefiles/Makefile.sco index 499dd53a7e6..993861570ac 100644 --- a/src/makefiles/Makefile.sco +++ b/src/makefiles/Makefile.sco @@ -8,5 +8,6 @@ else CFLAGS_SL = -K PIC endif +# Rule for building a shared library from a single .o file %.so: %.o $(LD) -G -Bdynamic -o $@ $< diff --git a/src/makefiles/Makefile.solaris b/src/makefiles/Makefile.solaris index bb56830fe5a..7681441f803 100644 --- a/src/makefiles/Makefile.solaris +++ b/src/makefiles/Makefile.solaris @@ -1,4 +1,4 @@ -# $PostgreSQL: pgsql/src/makefiles/Makefile.solaris,v 1.14 2008/09/01 08:50:10 petere Exp $ +# $PostgreSQL: pgsql/src/makefiles/Makefile.solaris,v 1.15 2010/07/05 18:54:38 tgl Exp $ AROPT = crs @@ -16,11 +16,12 @@ else CFLAGS_SL = -KPIC endif +# Rule for building a shared library from a single .o file %.so: %.o ifeq ($(GCC), yes) - $(CC) $(CFLAGS) -shared -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $< else - $(CC) $(CFLAGS) -G -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -G -o $@ $< endif sqlmansect = 5sql diff --git a/src/makefiles/Makefile.sunos4 b/src/makefiles/Makefile.sunos4 index 129edbe08ab..d19e165ea53 100644 --- a/src/makefiles/Makefile.sunos4 +++ b/src/makefiles/Makefile.sunos4 @@ -7,5 +7,6 @@ else CFLAGS_SL = -PIC endif +# Rule for building a shared library from a single .o file %.so: %.o $(LD) -assert pure-text -Bdynamic -o $@ $< diff --git a/src/makefiles/Makefile.svr4 b/src/makefiles/Makefile.svr4 index 7a01c5c944e..44a6f1c34ad 100644 --- a/src/makefiles/Makefile.svr4 +++ b/src/makefiles/Makefile.svr4 @@ -8,6 +8,7 @@ LDFLAGS += -LD-Blargedynsym DLSUFFIX = .so CFLAGS_SL = +# Rule for building a shared library from a single .o file %.so: %.o $(LD) -G -Bdynamic -o $@ $< diff --git a/src/makefiles/Makefile.ultrix4 b/src/makefiles/Makefile.ultrix4 index 1c03737756f..6685b8c0af6 100644 --- a/src/makefiles/Makefile.ultrix4 +++ b/src/makefiles/Makefile.ultrix4 @@ -6,5 +6,6 @@ DLSUFFIX = .so # "-G 0" works for both DEC cc and GNU cc. CFLAGS_SL = -G 0 +# Rule for building a shared library from a single .c file %.so: %.c - $(CC) -c -G 0 $(CPPFLAGS) $(CFLAGS) -o $@ $< + $(CC) -c -G 0 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -o $@ $< diff --git a/src/makefiles/Makefile.univel b/src/makefiles/Makefile.univel index 41e64616ef2..eb0d324ae64 100644 --- a/src/makefiles/Makefile.univel +++ b/src/makefiles/Makefile.univel @@ -3,6 +3,7 @@ export_dynamic = -Wl,-Bexport DLSUFFIX = .so CFLAGS_SL = -K PIC +# Rule for building a shared library from a single .o file %.so: %.o $(LD) -G -Bdynamic -o $@ $< diff --git a/src/makefiles/Makefile.unixware b/src/makefiles/Makefile.unixware index 3fa10f97d93..a52717b2688 100644 --- a/src/makefiles/Makefile.unixware +++ b/src/makefiles/Makefile.unixware @@ -13,6 +13,9 @@ else endif endif +# Unixware needs threads for everything that uses libpq +CFLAGS += $(PTHREAD_CFLAGS) + DLSUFFIX = .so ifeq ($(GCC), yes) CFLAGS_SL = -fpic @@ -25,10 +28,8 @@ else SO_FLAGS = -G endif +# Rule for building a shared library from a single .o file %.so: %.o - $(CC) $(SO_FLAGS) -o $@ $< + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) $(SO_FLAGS) -o $@ $< sqlmansect = 5sql - -# Unixware needs threads for everything that uses libpq -CFLAGS += $(PTHREAD_CFLAGS) diff --git a/src/makefiles/Makefile.win32 b/src/makefiles/Makefile.win32 index 07438d94aa7..09aa523ba6a 100644 --- a/src/makefiles/Makefile.win32 +++ b/src/makefiles/Makefile.win32 @@ -1,4 +1,4 @@ -# $PostgreSQL: pgsql/src/makefiles/Makefile.win32,v 1.15 2010/01/20 09:30:07 heikki Exp $ +# $PostgreSQL: pgsql/src/makefiles/Makefile.win32,v 1.16 2010/07/05 18:54:38 tgl Exp $ # Use replacement include files for those missing on Win32 override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32" @@ -13,11 +13,6 @@ AROPT = crs DLSUFFIX = .dll CFLAGS_SL = -%.dll: %.o - $(DLLTOOL) --export-all --output-def $*.def $< - $(DLLWRAP) -o $@ --def $*.def $< $(SHLIB_LINK) - rm -f $*.def - ifneq (,$(findstring backend,$(subdir))) ifeq (,$(findstring conversion_procs,$(subdir))) ifeq (,$(findstring snowball,$(subdir))) @@ -70,3 +65,9 @@ win32ver.rc: $(top_srcdir)/src/port/win32ver.rc win32ver.o: win32ver.rc $(WINDRES) -i $< -o $@ --include-dir=$(top_builddir)/src/include --include-dir=$(srcdir) + +# Rule for building a shared library from a single .o file +%.dll: %.o + $(DLLTOOL) --export-all --output-def $*.def $< + $(DLLWRAP) -o $@ --def $*.def $< $(SHLIB_LINK) + rm -f $*.def diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index 4f760bc8662..0e629c0a5d9 100644 --- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -1,6 +1,6 @@ # PGXS: PostgreSQL extensions makefile -# $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.19 2010/01/05 03:56:52 tgl Exp $ +# $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.20 2010/07/05 18:54:38 tgl Exp $ # This file contains generic rules to build many kinds of simple # extension modules. You only need to set a few variables and include @@ -68,7 +68,6 @@ override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) ifdef MODULES override CFLAGS += $(CFLAGS_SL) -SHLIB_LINK += $(BE_DLLLIBS) endif ifdef MODULEDIR @@ -287,5 +286,5 @@ endif ifdef PROGRAM $(PROGRAM): $(OBJS) - $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LIBS) -o $@ + $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LIBS) $(LDFLAGS) $(LDFLAGS_EX) -o $@ endif |
