OSDN Git Service

Split the LDFLAGS make variable into two parts: LDFLAGS is now used for
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 5 Jul 2010 18:54:38 +0000 (18:54 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 5 Jul 2010 18:54:38 +0000 (18:54 +0000)
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.

49 files changed:
configure
configure.in
doc/src/sgml/installation.sgml
doc/src/sgml/ref/pg_config-ref.sgml
src/Makefile.global.in
src/Makefile.shlib
src/backend/Makefile
src/backend/port/Makefile
src/bin/initdb/Makefile
src/bin/pg_config/Makefile
src/bin/pg_config/pg_config.c
src/bin/pg_controldata/Makefile
src/bin/pg_ctl/Makefile
src/bin/pg_dump/Makefile
src/bin/pg_resetxlog/Makefile
src/bin/psql/Makefile
src/bin/scripts/Makefile
src/interfaces/ecpg/preproc/Makefile
src/interfaces/ecpg/test/Makefile
src/interfaces/ecpg/test/Makefile.regress
src/makefiles/Makefile.aix
src/makefiles/Makefile.bsdi
src/makefiles/Makefile.cygwin
src/makefiles/Makefile.darwin
src/makefiles/Makefile.dgux
src/makefiles/Makefile.freebsd
src/makefiles/Makefile.hpux
src/makefiles/Makefile.irix
src/makefiles/Makefile.linux
src/makefiles/Makefile.netbsd
src/makefiles/Makefile.openbsd
src/makefiles/Makefile.osf
src/makefiles/Makefile.sco
src/makefiles/Makefile.solaris
src/makefiles/Makefile.sunos4
src/makefiles/Makefile.svr4
src/makefiles/Makefile.ultrix4
src/makefiles/Makefile.univel
src/makefiles/Makefile.unixware
src/makefiles/Makefile.win32
src/makefiles/pgxs.mk
src/template/cygwin
src/template/win32
src/test/regress/GNUmakefile
src/test/thread/Makefile
src/timezone/Makefile
src/tools/findoidjoins/Makefile
src/tools/fsync/Makefile
src/tools/ifaddrs/Makefile

index f6b891e..91261a4 100755 (executable)
--- a/configure
+++ b/configure
@@ -704,6 +704,7 @@ ld_R_works
 with_gnu_ld
 LD
 LDFLAGS_SL
+LDFLAGS_EX
 ELF_SYS
 EGREP
 GREP
@@ -856,6 +857,7 @@ LDFLAGS
 LIBS
 CPPFLAGS
 CPP
+LDFLAGS_EX
 LDFLAGS_SL
 DOCBOOKSTYLE'
 
@@ -1551,7 +1553,8 @@ Some influential environment variables:
   CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
-  LDFLAGS_SL  linker flags for shared library linking
+  LDFLAGS_EX  extra linker flags for linking executables only
+  LDFLAGS_SL  extra linker flags for linking shared libraries only
   DOCBOOKSTYLE
               location of DocBook stylesheets
 
@@ -5788,6 +5791,7 @@ LDFLAGS="$LDFLAGS $LIBDIRS"
 
 
 
+
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then
   withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
@@ -28826,7 +28830,6 @@ fi
 # If compiler will take -Wl,--as-needed (or various platform-specific
 # spellings thereof) then add that to LDFLAGS.  This is much easier than
 # trying to filter LIBS to the minimum for each executable.
-# (Note that shared library links won't use this switch, though.)
 # On (at least) some Red-Hat-derived systems, this switch breaks linking to
 # libreadline; therefore we postpone testing it until we know what library
 # dependencies readline has.  The test code will try to link with $LIBS.
index a84e37b..c9c4f21 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.630 2010/06/04 07:28:30 scrappy Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.631 2010/07/05 18:54:37 tgl Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -785,7 +785,8 @@ AC_SUBST(ELF_SYS)
 CPPFLAGS="$CPPFLAGS $INCLUDES"
 LDFLAGS="$LDFLAGS $LIBDIRS"
 
-AC_ARG_VAR(LDFLAGS_SL, [linker flags for shared library linking])
+AC_ARG_VAR(LDFLAGS_EX, [extra linker flags for linking executables only])
+AC_ARG_VAR(LDFLAGS_SL, [extra linker flags for linking shared libraries only])
 
 PGAC_PROG_LD
 AC_SUBST(LD)
@@ -1770,7 +1771,6 @@ fi
 # If compiler will take -Wl,--as-needed (or various platform-specific
 # spellings thereof) then add that to LDFLAGS.  This is much easier than
 # trying to filter LIBS to the minimum for each executable.
-# (Note that shared library links won't use this switch, though.)
 # On (at least) some Red-Hat-derived systems, this switch breaks linking to
 # libreadline; therefore we postpone testing it until we know what library
 # dependencies readline has.  The test code will try to link with $LIBS.
index 2f3ec3b..01f57a7 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.347 2010/06/29 22:29:13 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.348 2010/07/05 18:54:37 tgl Exp $ -->
 
 <chapter id="installation">
  <title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -1468,7 +1468,16 @@ su - postgres
        <term><envar>LDFLAGS</envar></term>
        <listitem>
         <para>
-         options to pass to the link editor
+         options to use when linking either executables or shared libraries
+        </para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><envar>LDFLAGS_EX</envar></term>
+       <listitem>
+        <para>
+         additional options for linking executables only
         </para>
        </listitem>
       </varlistentry>
@@ -1477,7 +1486,7 @@ su - postgres
        <term><envar>LDFLAGS_SL</envar></term>
        <listitem>
         <para>
-         linker options for shared library linking
+         additional options for linking shared libraries only
         </para>
        </listitem>
       </varlistentry>
index 5c63942..66cf79b 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_config-ref.sgml,v 1.29 2010/04/03 07:23:01 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_config-ref.sgml,v 1.30 2010/07/05 18:54:37 tgl Exp $ -->
 
 <refentry id="app-pgconfig">
  <refmeta>
     </varlistentry>
 
     <varlistentry>
+     <term><option>--ldflags_ex</option></>
+     <listitem>
+      <para>
+       Print the value of the <varname>LDFLAGS_EX</varname> variable that was used for building
+       <productname>PostgreSQL</>.  This shows linker switches
+       used for building executables only.
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
      <term><option>--ldflags_sl</option></>
      <listitem>
       <para>
        Print the value of the <varname>LDFLAGS_SL</varname> variable that was used for building
        <productname>PostgreSQL</>.  This shows linker switches
-       used for building shared libraries.
+       used for building shared libraries only.
       </para>
      </listitem>
     </varlistentry>
   <title>Notes</title>
 
   <para>
-   The option <option>--includedir-server</option> was new in
+   The option <option>--includedir-server</option> was added in
    <productname>PostgreSQL</> 7.2.  In prior releases, the server include files were
    installed in the same location as the client headers, which could
    be queried with the option <option>--includedir</option>.  To make your
    <option>--cc</option>, <option>--cppflags</option>,
    <option>--cflags</option>, <option>--cflags_sl</option>,
    <option>--ldflags</option>, <option>--ldflags_sl</option>,
-   and <option>--libs</option> are new in <productname>PostgreSQL</> 8.1.
-   The option <option>--htmldir</option> is new in <productname>PostgreSQL</> 8.4.
+   and <option>--libs</option> were added in <productname>PostgreSQL</> 8.1.
+   The option <option>--htmldir</option> was added in <productname>PostgreSQL</> 8.4.
+   The option <option>--ldflags_ex</option> was added in <productname>PostgreSQL</> 9.0.
   </para>
 
   <para>
index bfbcf88..47b2f5e 100644 (file)
@@ -1,5 +1,5 @@
 # -*-makefile-*-
-# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.262 2010/05/13 11:49:47 petere Exp $
+# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.263 2010/07/05 18:54:37 tgl Exp $
 
 #------------------------------------------------------------------------------
 # All PostgreSQL makefiles include this file and use the variables it sets,
@@ -236,6 +236,7 @@ LD = @LD@
 with_gnu_ld = @with_gnu_ld@
 ld_R_works = @ld_R_works@
 LDFLAGS = @LDFLAGS@
+LDFLAGS_EX = @LDFLAGS_EX@
 LDFLAGS_SL = @LDFLAGS_SL@
 LDREL = -r
 LDOUT = -o
@@ -455,9 +456,9 @@ LIBOBJS = @LIBOBJS@
 LIBS := -lpgport $(LIBS)
 # add location of libpgport.a to LDFLAGS
 ifdef PGXS
-override LDFLAGS := -L$(libdir) $(LDFLAGS)
+  LDFLAGS += -L$(libdir)
 else
-override LDFLAGS := -L$(top_builddir)/src/port $(LDFLAGS)
+  LDFLAGS += -L$(top_builddir)/src/port
 endif
 
 # to make ws2_32.lib the last library, and always link with shfolder,
index add201d..6198493 100644 (file)
@@ -6,7 +6,7 @@
 # Copyright (c) 1998, Regents of the University of California
 #
 # IDENTIFICATION
-#    $PostgreSQL: pgsql/src/Makefile.shlib,v 1.123 2009/08/28 20:26:18 petere Exp $
+#    $PostgreSQL: pgsql/src/Makefile.shlib,v 1.124 2010/07/05 18:54:37 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -78,11 +78,8 @@ LINK.static = $(AR) $(AROPT)
 
 
 
-# Insert -L from LDFLAGS after any -L already present in SHLIB_LINK
-SHLIB_LINK := $(filter -L%, $(SHLIB_LINK)) $(filter -L%, $(LDFLAGS)) $(filter-out -L%, $(SHLIB_LINK))
-
-# Need a -L-free version of LDFLAGS to use in combination with SHLIB_LINK
-LDFLAGS_NO_L = $(filter-out -L%, $(LDFLAGS))
+# Automatically append LDFLAGS and LDFLAGS_SL to SHLIB_LINK
+SHLIB_LINK += $(LDFLAGS) $(LDFLAGS_SL)
 
 ifdef SO_MAJOR_VERSION
 # Default library naming convention used by the majority of platforms
@@ -104,7 +101,7 @@ stlib               = lib$(NAME).a
 
 ifndef soname
 # additional flags for backend modules
-SHLIB_LINK := $(BE_DLLLIBS) $(SHLIB_LINK)
+SHLIB_LINK += $(BE_DLLLIBS)
 endif
 
 # For each platform we support shared libraries on, set shlib to the
@@ -208,17 +205,17 @@ ifeq ($(PORTNAME), hpux)
     shlib                      = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
   endif
   ifeq ($(with_gnu_ld), yes)
-    LINK.shared                = $(CC) $(LDFLAGS_NO_L) -shared
+    LINK.shared                = $(CC) -shared
     ifdef soname
       LINK.shared      += -Wl,-h -Wl,$(soname)
     endif
   else
-    # can't use the CC-syntax rpath pattern here
-    rpath =
     LINK.shared                = $(LD) -b
     ifdef soname
       LINK.shared      += +h $(soname)
     endif
+    # can't use the CC-syntax rpath pattern here, so instead:
+    rpath =
     ifeq ($(enable_rpath), yes)
       LINK.shared      += +b '$(rpathdir)'
     endif
@@ -227,10 +224,10 @@ ifeq ($(PORTNAME), hpux)
     # ld can find the same libraries gcc does.  Make sure it goes after any
     # -L switches provided explicitly.
     ifeq ($(GCC), yes)
-      SHLIB_LINK := $(filter -L%, $(SHLIB_LINK)) -L/usr/local/lib $(filter-out -L%, $(SHLIB_LINK))
+      SHLIB_LINK       += -L/usr/local/lib
     endif
   endif
-  # do this last so above filtering doesn't pull out -L switches in LDFLAGS
+  # And we need to link with libgcc, too
   ifeq ($(GCC), yes)
     SHLIB_LINK         += `$(CC) $(LDFLAGS) -print-libgcc-file-name`
   endif
@@ -327,10 +324,6 @@ ifeq ($(PORTNAME), win32)
   haslibarule   = yes
 endif
 
-ifeq ($(enable_rpath), yes)
-SHLIB_LINK += $(rpath)
-endif
-
 
 
 ##
@@ -362,7 +355,7 @@ ifneq ($(PORTNAME), aix)
 
 # Normal case
 $(shlib): $(OBJS)
-       $(LINK.shared) $(LDFLAGS_SL) $(OBJS) $(SHLIB_LINK) -o $@
+       $(LINK.shared) -o $@ $(OBJS) $(SHLIB_LINK)
 ifdef shlib_major
 # If we're using major and minor versions, then make a symlink to major-version-only.
 ifneq ($(shlib), $(shlib_major))
@@ -396,7 +389,7 @@ $(shlib) $(stlib): $(OBJS)
        $(LINK.static) $(stlib) $^
        $(RANLIB) $(stlib)
        $(MKLDEXPORT) $(stlib) >$(exports_file)
-       $(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $(shlib) $(stlib) -Wl,-bE:$(exports_file) $(SHLIB_LINK)
+       $(COMPILER) -o $(shlib) $(stlib) -Wl,-bE:$(exports_file) $(SHLIB_LINK)
        rm -f $(stlib)
        $(AR) $(AROPT) $(stlib) $(shlib)
 
@@ -419,7 +412,7 @@ DLL_DEFFILE = lib$(NAME)dll.def
 endif
 
 $(shlib): $(OBJS) $(DLL_DEFFILE)
-       $(DLLWRAP) $(LDFLAGS_SL) -o $@ --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
+       $(DLLWRAP) -o $@ --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
 
 $(stlib): $(shlib) $(DLL_DEFFILE)
        $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib $@
index 8c9c7f2..a11b2b5 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/backend/Makefile,v 1.144 2010/05/12 23:48:36 momjian Exp $
+# $PostgreSQL: pgsql/src/backend/Makefile,v 1.145 2010/07/05 18:54:37 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -52,7 +52,7 @@ ifneq ($(PORTNAME), win32)
 ifneq ($(PORTNAME), aix)
 
 postgres: $(OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o $@
 
 endif
 endif
@@ -62,9 +62,9 @@ ifeq ($(PORTNAME), cygwin)
 
 postgres: $(OBJS) postgres.def libpostgres.a
        $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(LIBS)
        $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack,$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack,$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(LIBS)
        rm -f $@.exp $@.base
 
 postgres.def: $(OBJS)
@@ -80,9 +80,9 @@ LIBS += -lsecur32
 
 postgres: $(OBJS) postgres.def libpostgres.a $(WIN32RES)
        $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
        $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack=$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
        rm -f $@.exp $@.base
 
 postgres.def: $(OBJS)
@@ -96,7 +96,7 @@ endif # win32
 ifeq ($(PORTNAME), aix)
 
 postgres: $(POSTGRES_IMP)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
 
 $(POSTGRES_IMP): $(OBJS)
        $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(call expand_subsys,$^)
@@ -128,7 +128,7 @@ catalog/schemapg.h: submake-schemapg
 # 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) $(LDFLAGS) $(call expand_subsys,$^) $(LIBS) -o $@
+       $(CC) $(LDREL) $(LDFLAGS) $(LDFLAGS_EX) $(call expand_subsys,$^) $(LIBS) -o $@
 
 
 # The following targets are specified in make commands that appear in
@@ -306,4 +306,4 @@ maintainer-clean: distclean
 # are up to date.  It saves the time of doing all the submakes.
 .PHONY: quick
 quick: $(OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o postgres
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o postgres
index 4798042..2009919 100644 (file)
@@ -13,7 +13,7 @@
 # be converted to Method 2.  
 #
 # IDENTIFICATION
-#    $PostgreSQL: pgsql/src/backend/port/Makefile,v 1.27 2008/10/29 16:06:46 petere Exp $
+#    $PostgreSQL: pgsql/src/backend/port/Makefile,v 1.28 2010/07/05 18:54:37 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -44,7 +44,7 @@ endif
 
 # IPC test program
 ipc_test: ipc_test.o pg_sema.o pg_shmem.o
-       $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $^ $(LIBS) -o $@
 
 distclean clean:
        rm -f ipc_test ipc_test.o tas_cpp.s
index 4f87715..2ffcb54 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.60 2010/05/12 11:33:09 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.61 2010/07/05 18:54:37 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -23,7 +23,7 @@ OBJS= initdb.o encnames.o pqsignal.o $(WIN32RES)
 all: submake-libpgport initdb
 
 initdb: $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 # We used to pull in all of libpq to get encnames and pqsignal, but that
 # exposes us to risks of version skew if we link to a shared library.
index 4355874..b9ca579 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2010, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.24 2010/05/12 11:33:09 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.25 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -27,13 +27,14 @@ override CPPFLAGS += -DVAL_CPPFLAGS="\"$(STD_CPPFLAGS)\""
 override CPPFLAGS += -DVAL_CFLAGS="\"$(CFLAGS)\""
 override CPPFLAGS += -DVAL_CFLAGS_SL="\"$(CFLAGS_SL)\""
 override CPPFLAGS += -DVAL_LDFLAGS="\"$(STD_LDFLAGS)\""
+override CPPFLAGS += -DVAL_LDFLAGS_EX="\"$(LDFLAGS_EX)\""
 override CPPFLAGS += -DVAL_LDFLAGS_SL="\"$(LDFLAGS_SL)\""
 override CPPFLAGS += -DVAL_LIBS="\"$(LIBS)\""
 
 all: submake-libpgport pg_config
 
 pg_config: $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 install: all installdirs
        $(INSTALL_SCRIPT) pg_config$(X) '$(DESTDIR)$(bindir)/pg_config$(X)'
index 6e764b1..e8ddbed 100644 (file)
@@ -17,7 +17,7 @@
  *
  * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.32 2010/01/02 16:57:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.33 2010/07/05 18:54:38 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -327,6 +327,22 @@ show_ldflags(bool all)
 }
 
 static void
+show_ldflags_ex(bool all)
+{
+#ifdef VAL_LDFLAGS_EX
+       if (all)
+               printf("LDFLAGS_EX = ");
+       printf("%s\n", VAL_LDFLAGS_EX);
+#else
+       if (!all)
+       {
+               fprintf(stderr, _("not recorded\n"));
+               exit(1);
+       }
+#endif
+}
+
+static void
 show_ldflags_sl(bool all)
 {
 #ifdef VAL_LDFLAGS_SL
@@ -398,6 +414,7 @@ static const InfoItem info_items[] = {
        {"--cflags", show_cflags},
        {"--cflags_sl", show_cflags_sl},
        {"--ldflags", show_ldflags},
+       {"--ldflags_ex", show_ldflags_ex},
        {"--ldflags_sl", show_ldflags_sl},
        {"--libs", show_libs},
        {"--version", show_version},
@@ -433,6 +450,7 @@ help(void)
        printf(_("  --cflags              show CFLAGS value used when PostgreSQL was built\n"));
        printf(_("  --cflags_sl           show CFLAGS_SL value used when PostgreSQL was built\n"));
        printf(_("  --ldflags             show LDFLAGS value used when PostgreSQL was built\n"));
+       printf(_("  --ldflags_ex          show LDFLAGS_EX value used when PostgreSQL was built\n"));
        printf(_("  --ldflags_sl          show LDFLAGS_SL value used when PostgreSQL was built\n"));
        printf(_("  --libs                show LIBS value used when PostgreSQL was built\n"));
        printf(_("  --version             show the PostgreSQL version\n"));
index c12bf33..ab551fe 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2010, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.21 2010/05/12 11:33:09 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.22 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -20,7 +20,7 @@ OBJS= pg_controldata.o pg_crc.o $(WIN32RES)
 all: submake-libpgport pg_controldata
 
 pg_controldata: $(OBJS)
-       $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
        rm -f $@ && $(LN_S) $< .
index 32a4fc9..6bd6399 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/pg_ctl/Makefile,v 1.29 2010/05/12 11:33:09 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_ctl/Makefile,v 1.30 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -23,7 +23,7 @@ OBJS= pg_ctl.o $(WIN32RES)
 all: submake-libpq submake-libpgport pg_ctl
 
 pg_ctl: $(OBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 install: all installdirs
        $(INSTALL_PROGRAM) pg_ctl$(X) '$(DESTDIR)$(bindir)/pg_ctl$(X)'
index 2eeb099..0a26c70 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.70 2010/05/12 11:33:09 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.71 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -30,13 +30,13 @@ kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
 all: submake-libpq submake-libpgport pg_dump pg_restore pg_dumpall
 
 pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(KEYWRDOBJS) $(libpq_builddir)/libpq.a 
-       $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 pg_restore: pg_restore.o $(OBJS) $(KEYWRDOBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) pg_restore.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) pg_restore.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 pg_dumpall: pg_dumpall.o dumputils.o $(KEYWRDOBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(KEYWRDOBJS) $(WIN32RES) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(KEYWRDOBJS) $(WIN32RES) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 install: all installdirs
        $(INSTALL_PROGRAM) pg_dump$(X) '$(DESTDIR)$(bindir)'/pg_dump$(X)
index 57efc8d..868c62f 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2010, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.23 2010/05/12 11:33:10 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.24 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -20,7 +20,7 @@ OBJS= pg_resetxlog.o pg_crc.o $(WIN32RES)
 all: submake-libpgport pg_resetxlog
 
 pg_resetxlog: $(OBJS)
-       $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
        rm -f $@ && $(LN_S) $< .
index 80e2dab..8227b43 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.69 2010/05/12 11:33:10 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.70 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -32,7 +32,7 @@ FLEXFLAGS = -Cfe
 all: submake-libpq submake-libpgport psql
 
 psql: $(OBJS) $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 help.o: sql_help.h
 
index 5cd61ad..cc40f0f 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/scripts/Makefile,v 1.45 2010/05/12 11:33:10 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/scripts/Makefile,v 1.46 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -23,7 +23,7 @@ override CPPFLAGS := -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psq
 all: submake-libpq $(PROGRAMS)
 
 %: %.o $(WIN32RES)
-       $(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 createdb: createdb.o common.o dumputils.o kwlookup.o keywords.o
 createlang: createlang.o common.o print.o mbprint.o
index 3c0a4c7..0690c7c 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2010, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.149 2010/05/12 11:33:10 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.150 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -33,7 +33,7 @@ OBJS= preproc.o type.o ecpg.o output.o parser.o \
 all: submake-libpgport ecpg
 
 ecpg: $(OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
 
 # pgc is compiled as part of preproc
 preproc.o: pgc.c
index 05e7be7..404b604 100644 (file)
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.78 2009/12/19 02:38:51 alvherre Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.79 2010/07/05 18:54:38 tgl Exp $
 
 subdir = src/interfaces/ecpg/test
 top_builddir = ../../../..
@@ -54,7 +54,7 @@ clean distclean maintainer-clean:
 all: pg_regress$(X)
 
 pg_regress$(X): pg_regress_ecpg.o $(top_builddir)/src/test/regress/pg_regress.o
-       $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $^ $(LIBS) -o $@
 
 $(top_builddir)/src/test/regress/pg_regress.o:
        $(MAKE) -C $(dir $@) $(notdir $@)
index 847cded..e01168b 100644 (file)
@@ -8,7 +8,7 @@ override LIBS := -lecpg -lpgtypes $(filter -l%, $(libpq)) $(LIBS) $(PTHREAD_LIBS
 ECPG = ../../preproc/ecpg --regression -I$(srcdir)/../../include
 
 %: %.c
-       $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@
+       $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
 
 %.c: %.pgc ../regression.h
        $(ECPG) -o $@ -I$(srcdir) $<
index 696e5f4..6f5715d 100644 (file)
@@ -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)
index a5a10db..e2c9be3 100644 (file)
@@ -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 $@ $<
index 5d4f33b..2c0f87c 100644 (file)
@@ -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
index debad62..2f6743a 100644 (file)
@@ -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)
index f951963..0c34d4a 100644 (file)
@@ -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
index 57afc18..839864c 100644 (file)
@@ -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 $@
index f91dfae..1917d61 100644 (file)
@@ -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
index 1456538..8141a96 100644 (file)
@@ -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
index e266e8f..cc5cbff 100644 (file)
@@ -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 $@ $<
index 366f20c..31a5260 100644 (file)
@@ -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 $@
index 4abc80c..7bf5493 100644 (file)
@@ -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 $@
index 957f27a..31822fd 100644 (file)
@@ -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 $@ $<
 
index 499dd53..9938615 100644 (file)
@@ -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 $@ $<
index bb56830..7681441 100644 (file)
@@ -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
index 129edbe..d19e165 100644 (file)
@@ -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 $@ $<
index 7a01c5c..44a6f1c 100644 (file)
@@ -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 $@ $<
 
index 1c03737..6685b8c 100644 (file)
@@ -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 $@ $<
index 41e6461..eb0d324 100644 (file)
@@ -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 $@ $<
 
index 3fa10f9..a52717b 100644 (file)
@@ -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)
index 07438d9..09aa523 100644 (file)
@@ -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
index 4f760bc..0e629c0 100644 (file)
@@ -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
index 276fa80..b2fe364 100644 (file)
@@ -1,9 +1,8 @@
-# $PostgreSQL: pgsql/src/template/cygwin,v 1.7 2006/03/11 04:38:40 momjian Exp $
+# $PostgreSQL: pgsql/src/template/cygwin,v 1.8 2010/07/05 18:54:38 tgl Exp $
 
 SRCH_LIB="/usr/local/lib"
 
-# This is required to link pg_dump because it finds pg_toupper() in
-# libpq and pgport
-LDFLAGS="-Wl,--allow-multiple-definition -Wl,--enable-auto-import"
+# --allow-multiple-definition is required to link pg_dump because it finds
+# pg_toupper() in both libpq and pgport
 # --enable-auto-import gets rid of a diagnostics linker message
-LDFLAGS_SL="-Wl,--enable-auto-import"
+LDFLAGS="-Wl,--allow-multiple-definition -Wl,--enable-auto-import"
index e9ab1fe..71f5fa1 100644 (file)
@@ -1,4 +1,3 @@
-# This is required to link pg_dump because it finds pg_toupper() in
-# libpq and pgport
+# --allow-multiple-definition is required to link pg_dump because it finds
+# pg_toupper() in both libpq and pgport
 LDFLAGS="-Wl,--allow-multiple-definition"
-
index 91e24b5..5f8f04f 100644 (file)
@@ -6,7 +6,7 @@
 # Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.82 2010/01/02 16:58:13 momjian Exp $
+# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.83 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -53,7 +53,7 @@ EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \
 all: submake-libpgport pg_regress$(X)
 
 pg_regress$(X): pg_regress.o pg_regress_main.o
-       $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@
+       $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
 
 # dependencies ensure that path changes propagate
 pg_regress.o: pg_regress.c $(top_builddir)/src/port/pg_config_paths.h
index fda66bd..b932d10 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2003-2010, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/test/thread/Makefile,v 1.6 2010/01/02 16:58:16 momjian Exp $
+# $PostgreSQL: pgsql/src/test/thread/Makefile,v 1.7 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -18,7 +18,7 @@ all: thread_test
 
 thread_test: thread_test.o
 # no need for $LIBS, might not be compiled yet
-       $(CC) $(CFLAGS) $(LDFLAGS) $^ $(PTHREAD_LIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $^ $(PTHREAD_LIBS) -o $@
 
 clean distclean maintainer-clean:
        rm -f thread_test$(X) thread_test.o
index fda2fa7..ddf07ad 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for the timezone library
 
 # IDENTIFICATION
-#    $PostgreSQL: pgsql/src/timezone/Makefile,v 1.32 2009/08/26 22:24:43 petere Exp $
+#    $PostgreSQL: pgsql/src/timezone/Makefile,v 1.33 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -47,7 +47,7 @@ ZIC= ./zic
 endif
 
 zic: $(ZICOBJS)
-       $(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 install: all installdirs
 ifeq (,$(with_system_tzdata))
index a11bff0..5f7bd0c 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2003-2010, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/tools/findoidjoins/Makefile,v 1.7 2010/01/02 16:58:16 momjian Exp $
+# $PostgreSQL: pgsql/src/tools/findoidjoins/Makefile,v 1.8 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -19,7 +19,7 @@ OBJS= findoidjoins.o
 all: submake-libpq submake-libpgport findoidjoins
 
 findoidjoins: findoidjoins.o $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) findoidjoins.o $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) findoidjoins.o $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 clean distclean maintainer-clean:
        rm -f findoidjoins$(X) $(OBJS)
index 299bc3f..2ddbbe9 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2003-2010, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/tools/fsync/Makefile,v 1.8 2010/01/02 16:58:16 momjian Exp $
+# $PostgreSQL: pgsql/src/tools/fsync/Makefile,v 1.9 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -19,7 +19,7 @@ OBJS= test_fsync.o
 all: submake-libpq submake-libpgport test_fsync
 
 test_fsync: test_fsync.o $(libpq_builddir)/libpq.a
-       $(CC) $(CFLAGS) test_fsync.o $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) test_fsync.o $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 clean distclean maintainer-clean:
        rm -f test_fsync$(X) $(OBJS)
index de8cf45..72a6aa7 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2003-2010, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/tools/ifaddrs/Makefile,v 1.2 2010/01/02 16:58:16 momjian Exp $
+# $PostgreSQL: pgsql/src/tools/ifaddrs/Makefile,v 1.3 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -21,7 +21,7 @@ OBJS = test_ifaddrs.o
 all: test_ifaddrs
 
 test_ifaddrs: test_ifaddrs.o $(libpq_backend_dir)/ip.o
-       $(CC) $(CFLAGS) test_ifaddrs.o $(libpq_backend_dir)/ip.o $(LDFLAGS) $(LIBS) -o $@$(X)
+       $(CC) $(CFLAGS) test_ifaddrs.o $(libpq_backend_dir)/ip.o $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
 clean distclean maintainer-clean:
        rm -f test_ifaddrs$(X) $(OBJS)