# -*-makefile-*-
-# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.263 2010/07/05 18:54:37 tgl Exp $
+# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.264 2010/07/06 22:03:05 tgl Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
LD = @LD@
with_gnu_ld = @with_gnu_ld@
ld_R_works = @ld_R_works@
-LDFLAGS = @LDFLAGS@
+
+# We want -L for libpgport.a to be first in LDFLAGS. We also need LDFLAGS
+# to be a "recursively expanded" variable, else adjustments to rpathdir
+# don't work right. So we must NOT do LDFLAGS := something, meaning this has
+# to be done first and elsewhere we must only do LDFLAGS += something.
+ifdef PGXS
+ LDFLAGS = -L$(libdir)
+else
+ LDFLAGS = -L$(top_builddir)/src/port
+endif
+LDFLAGS += @LDFLAGS@
+
LDFLAGS_EX = @LDFLAGS_EX@
-LDFLAGS_SL = @LDFLAGS_SL@
+# LDFLAGS_SL might have already been assigned by calling makefile
+LDFLAGS_SL += @LDFLAGS_SL@
LDREL = -r
LDOUT = -o
RANLIB = @RANLIB@
##########################################################################
#
# substitute implementations of C library routines (see src/port/)
+# note we already included -L.../src/port in LDFLAGS above
LIBOBJS = @LIBOBJS@
LIBS := -lpgport $(LIBS)
-# add location of libpgport.a to LDFLAGS
-ifdef PGXS
- LDFLAGS += -L$(libdir)
-else
- LDFLAGS += -L$(top_builddir)/src/port
-endif
# to make ws2_32.lib the last library, and always link with shfolder,
# so SHGetFolderName isn't picked up from shell32.dll