66# Copyright (c) 1998, Regents of the University of California
77#
88# IDENTIFICATION
9- # $PostgreSQL: pgsql/src/Makefile.shlib,v 1.111 2008/02/26 10:30:06 petere Exp $
9+ # $PostgreSQL: pgsql/src/Makefile.shlib,v 1.112 2008/02/26 10:45:24 petere Exp $
1010#
1111#-------------------------------------------------------------------------
1212
@@ -99,6 +99,7 @@ soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
9999ifeq ($(PORTNAME), aix)
100100 shlib= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
101101 haslibarule = yes
102+ exports_file= lib$(NAME).exp
102103endif
103104
104105ifeq ($(PORTNAME), darwin)
@@ -117,8 +118,9 @@ ifeq ($(PORTNAME), darwin)
117118 shlib= lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
118119 shlib_major= lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
119120 BUILD.exports= $(AWK) '/^[^\#]/ {printf "_%s\n",$$1}' $< >$@
120- ifneq (,$(SHLIB_EXPORTS))
121- exported_symbols_list = -exported_symbols_list $(SHLIB_EXPORTS:%.txt=%.list)
121+ exports_file= $(SHLIB_EXPORTS:%.txt=%.list)
122+ ifneq (,$(exports_file))
123+ exported_symbols_list = -exported_symbols_list $(exports_file)
122124 endif
123125endif
124126
@@ -193,8 +195,9 @@ endif
193195ifeq ($(PORTNAME), linux)
194196 LINK.shared= $(COMPILER) -shared -Wl,-soname,$(soname)
195197 BUILD.exports= ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
196- ifneq (,$(SHLIB_EXPORTS))
197- LINK.shared+= -Wl,--version-script=$(SHLIB_EXPORTS:%.txt=%.list)
198+ exports_file= $(SHLIB_EXPORTS:%.txt=%.list)
199+ ifneq (,$(exports_file))
200+ LINK.shared+= -Wl,--version-script=$(exports_file)
198201 endif
199202endif
200203
@@ -284,8 +287,7 @@ endif #haslibarule
284287
285288ifeq ($(enable_shared), yes)
286289
287- ifneq ($(PORTNAME), win32)
288- ifneq ($(PORTNAME), cygwin)
290+ ifeq (,$(filter cygwin win32,$(PORTNAME)))
289291ifneq ($(PORTNAME), aix)
290292
291293# Normal case
@@ -321,46 +323,35 @@ else # PORTNAME == aix
321323$(shlib) lib$(NAME).a: $(OBJS)
322324$(LINK.static) lib$(NAME).a $^
323325$(RANLIB) lib$(NAME).a
324- $(MKLDEXPORT) lib$(NAME).a > lib$(NAME)$(EXPSUFF )
325- $(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $(shlib) lib$(NAME).a -Wl,-bE:lib$(NAME)$(EXPSUFF ) $(SHLIB_LINK)
326+ $(MKLDEXPORT) lib$(NAME).a >$(exports_file )
327+ $(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $(shlib) lib$(NAME).a -Wl,-bE:$(exports_file ) $(SHLIB_LINK)
326328rm -f lib$(NAME).a
327329$(AR) $(AROPT) lib$(NAME).a $(shlib)
328330
329331endif # PORTNAME == aix
330332
331- else # PORTNAME == cygwin
333+ else # PORTNAME == cygwin || PORTNAME == win32
332334
333- # Cygwin case
334- $(shlib) lib$(NAME).a: $(OBJS)
335- ifndef DLL_DEFFILE
336- $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
337- $(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
338- $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
339- else
340- $(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
341- $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib lib$(NAME).a
342- endif
335+ # Cygwin or Win32 case
343336
344- endif # PORTNAME == cygwin
337+ DLL_DEFFILE = lib$(NAME)dll.def
345338
346- else # PORTNAME == win32
339+ # If SHLIB_EXPORTS is set, the rules below will build a .def file from
340+ # that. Else we build a temporary one here.
341+ ifeq (,$(SHLIB_EXPORTS))
342+ exports_file = $(DLL_DEFFILE)
347343
348- ifneq (,$(SHLIB_EXPORTS) )
349- DLL_DEFFILE = lib$(NAME)dll. def
344+ $(exports_file): $(OBJS )
345+ $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output- def $@ $^
350346endif
351347
352- # win32 case
353- $(shlib) lib$(NAME).a: $(OBJS)
354- ifndef DLL_DEFFILE
355- $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
356- $(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
357- $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
358- else
359- $(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
360- $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib lib$(NAME).a
361- endif
348+ $(shlib): $(OBJS) $(DLL_DEFFILE)
349+ $(DLLWRAP) $(LDFLAGS_SL) -o $@ --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
350+
351+ lib$(NAME).a: $(shlib) $(DLL_DEFFILE)
352+ $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib $@
362353
363- endif # PORTNAME == win32
354+ endif # PORTNAME ==cygwin || PORTNAME == win32
364355
365356endif # enable_shared
366357
@@ -464,17 +455,7 @@ endif # enable_shared
464455clean-lib:
465456rm -f lib$(NAME).a
466457ifeq ($(enable_shared), yes)
467- rm -f $(shlib_bare) $(shlib_major) $(shlib) $(SHLIB_EXPORTS:%.txt=%.list)
468- ifdef EXPSUFF
469- rm -f lib$(NAME)$(EXPSUFF)
470- endif
471- endif
472- ifeq ($(PORTNAME), cygwin)
473- rm -f $(NAME).dll $(NAME).def
474- endif
475-
476- ifeq ($(PORTNAME), win32)
477- rm -f $(NAME).dll $(NAME).def
458+ rm -f $(shlib_bare) $(shlib_major) $(shlib) $(exports_file)
478459endif
479460
480461ifneq (,$(SHLIB_EXPORTS))