OSDN Git Service

Refactor the code that creates the shared library export files to appear
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 26 Feb 2008 06:41:24 +0000 (06:41 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 26 Feb 2008 06:41:24 +0000 (06:41 +0000)
only once in Makefile.shlib and not in four copies.

src/Makefile.shlib
src/interfaces/ecpg/compatlib/Makefile
src/interfaces/ecpg/ecpglib/Makefile
src/interfaces/ecpg/pgtypeslib/Makefile
src/interfaces/libpq/Makefile

index 4f897f4..3cb5e55 100644 (file)
@@ -6,7 +6,7 @@
 # Copyright (c) 1998, Regents of the University of California
 #
 # IDENTIFICATION
-#    $PostgreSQL: pgsql/src/Makefile.shlib,v 1.109 2007/02/20 22:45:57 momjian Exp $
+#    $PostgreSQL: pgsql/src/Makefile.shlib,v 1.110 2008/02/26 06:41:23 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -24,6 +24,8 @@
 # OBJS                  List of object files to include in library
 # SHLIB_LINK            If shared library relies on other libraries,
 #                       additional stuff to put in its link command
+# SHLIB_EXPORTS         (optional) Name of file containing list of symbols to
+#                       export
 # (If you want a patchlevel, include it in SO_MINOR_VERSION, e.g., "6.2".)
 #
 # Optional flags when building DLL's (only applicable to win32 and cygwin
@@ -31,8 +33,6 @@
 # DLLTOOL_DEFFLAGS      Additional flags when creating the dll .def file
 # DLLTOOL_LIBFLAGS      Additional flags when creating the lib<module>.a file
 # DLLWRAP_FLAGS         Additional flags to dllwrap
-# DLL_DEFFILE           Use pre-existing .def file instead of auto-generating
-#                       one with all exports in it (win32 only).
 #
 # The module Makefile must also include
 # $(top_builddir)/src/Makefile.global before including this file.
@@ -44,6 +44,7 @@
 # install-lib           install the libraries into $(libdir)
 # uninstall-lib         remove the libraries from $(libdir)
 # clean-lib             delete the static and shared libraries from the build dir
+# maintainer-clean-lib  delete .def files built for win32
 #
 # Since `all-lib' is the first rule in this file you probably want to
 # have the `all' target before including this file. In the most simple
@@ -115,6 +116,10 @@ ifeq ($(PORTNAME), darwin)
   endif
   shlib                        = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
   shlib_major          = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
+  BUILD.exports                = $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
+  ifneq (,$(SHLIB_EXPORTS))
+    exported_symbols_list = -exported_symbols_list $(SHLIB_EXPORTS:%.txt=%.list)
+  endif
 endif
 
 ifeq ($(PORTNAME), openbsd)
@@ -186,7 +191,11 @@ ifeq ($(PORTNAME), irix)
 endif
 
 ifeq ($(PORTNAME), linux)
-  LINK.shared          = $(COMPILER) -shared -Wl,-soname,$(soname) $(exported_symbols_list)
+  LINK.shared          = $(COMPILER) -shared -Wl,-soname,$(soname)
+  BUILD.exports                = ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
+  ifneq (,$(SHLIB_EXPORTS))
+    LINK.shared                += -Wl,--version-script=$(SHLIB_EXPORTS:%.txt=%.list)
+  endif
 endif
 
 ifeq ($(PORTNAME), solaris)
@@ -293,6 +302,19 @@ ifneq ($(shlib), $(shlib_bare))
        $(LN_S) $(shlib) $(shlib_bare)
 endif
 
+# Where possible, restrict the symbols exported by the library to just the
+# official list, so as to avoid unintentional ABI changes.  On recent Darwin
+# this also quiets multiply-defined-symbol warnings in programs that use
+# libpgport along with libpq.
+ifneq (,$(SHLIB_EXPORTS))
+ifdef BUILD.exports
+$(shlib): $(SHLIB_EXPORTS:%.txt=%.list)
+
+$(SHLIB_EXPORTS:%.txt=%.list): %.list: %.txt
+       $(BUILD.exports)
+endif
+endif
+
 else # PORTNAME == aix
 
 # AIX case
@@ -303,7 +325,7 @@ $(shlib) lib$(NAME).a: $(OBJS)
        $(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $(shlib) lib$(NAME).a -Wl,-bE:lib$(NAME)$(EXPSUFF) $(SHLIB_LINK)
        rm -f lib$(NAME).a
        $(AR) $(AROPT) lib$(NAME).a $(shlib)
-       
+
 endif # PORTNAME == aix
 
 else # PORTNAME == cygwin
@@ -323,6 +345,10 @@ endif # PORTNAME == cygwin
 
 else # PORTNAME == win32
 
+ifneq (,$(SHLIB_EXPORTS))
+DLL_DEFFILE = lib$(NAME)dll.def
+endif
+
 # win32 case
 $(shlib) lib$(NAME).a: $(OBJS)
 ifndef DLL_DEFFILE
@@ -339,6 +365,46 @@ endif # PORTNAME == win32
 endif # enable_shared
 
 
+# We need several not-quite-identical variants of .DEF files to build
+# DLLs for Windows.  These are made from the single source file
+# exports.txt.  Since we can't assume that Windows boxes will have
+# sed, the .DEF files are always built and included in distribution
+# tarballs.
+
+ifneq (,$(SHLIB_EXPORTS))
+all: def-files
+
+distprep: def-files
+
+.PHONY: def-files
+
+def-files: $(srcdir)/lib$(NAME)dll.def $(srcdir)/lib$(NAME)ddll.def $(srcdir)/blib$(NAME)dll.def
+
+UC_NAME = $(shell echo $(NAME) | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
+
+$(srcdir)/lib$(NAME)dll.def: $(SHLIB_EXPORTS)
+       echo '; DEF file for MS VC++' >$@
+       echo 'LIBRARY LIB$(UC_NAME)' >>$@
+       echo 'EXPORTS' >>$@
+       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' $< >>$@
+
+$(srcdir)/lib$(NAME)ddll.def: $(SHLIB_EXPORTS)
+       echo '; DEF file for MS VC++' >$@
+       echo 'LIBRARY LIB$(UC_NAME)D' >>$@
+       echo 'EXPORTS' >>$@
+       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' $< >>$@
+
+$(srcdir)/blib$(NAME)dll.def: $(SHLIB_EXPORTS)
+       echo '; DEF file for Borland C++ Builder' >$@
+       echo 'LIBRARY BLIB$(UC_NAME)' >>$@
+       echo 'EXPORTS' >>$@
+       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    _\1@ \2/' $< >>$@
+       echo >>$@
+       echo '; Aliases for MS compatible names' >> $@
+       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1= _\1/' $< | sed 's/ *$$//' >>$@
+endif # SHLIB_EXPORTS
+
+
 ##
 ## INSTALL
 ##
@@ -398,7 +464,7 @@ endif # enable_shared
 clean-lib:
        rm -f lib$(NAME).a
 ifeq ($(enable_shared), yes)
-       rm -f $(shlib_bare) $(shlib_major) $(shlib)
+       rm -f $(shlib_bare) $(shlib_major) $(shlib) $(SHLIB_EXPORTS:%.txt=%.list)
 ifdef EXPSUFF
        rm -f lib$(NAME)$(EXPSUFF)
 endif
@@ -410,3 +476,8 @@ endif
 ifeq ($(PORTNAME), win32)
        rm -f $(NAME).dll $(NAME).def
 endif
+
+ifneq (,$(SHLIB_EXPORTS))
+maintainer-clean-lib:
+       rm -f $(srcdir)/lib$(NAME)dll.def $(srcdir)/lib$(NAME)ddll.def $(srcdir)/blib$(NAME)dll.def
+endif
index b6aa299..b8c17f0 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.38 2008/02/13 18:14:46 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.39 2008/02/26 06:41:23 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -25,16 +25,14 @@ override CFLAGS += $(PTHREAD_CFLAGS)
 SHLIB_LINK = -L../ecpglib -lecpg -L../pgtypeslib -lpgtypes $(libpq) -lm \
        $(PTHREAD_LIBS)
 
+SHLIB_EXPORTS = exports.txt
+
 # Need to recompile any libpgport object files
 LIBS := $(filter-out -lpgport, $(LIBS))
 
 OBJS= informix.o $(filter snprintf.o, $(LIBOBJS))
 
-ifeq ($(PORTNAME), win32)
-DLL_DEFFILE=libecpg_compatdll.def
-endif
-
-all: def-files all-lib
+all: all-lib
 
 # Shared library stuff
 include $(top_srcdir)/src/Makefile.shlib
@@ -42,55 +40,6 @@ include $(top_srcdir)/src/Makefile.shlib
 snprintf.c: % : $(top_srcdir)/src/port/%
        rm -f $@ && $(LN_S) $< .
 
-# We need several not-quite-identical variants of .DEF files to build libecpg
-# DLLs for Windows.  These are made from the single source file exports.txt.
-# Since we can't assume that Windows boxes will have sed, the .DEF files are
-# always built and included in distribution tarballs.
-
-distprep: def-files
-
-.PHONY: def-files
-
-def-files: $(srcdir)/libecpg_compatdll.def $(srcdir)/blibecpg_compatdll.def
-
-$(srcdir)/libecpg_compatdll.def: exports.txt
-       echo '; DEF file for MS VC++' > $@
-       echo 'LIBRARY LIBECPG_COMPAT' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
-
-$(srcdir)/blibecpg_compatdll.def: exports.txt
-       echo '; DEF file for Borland C++ Builder' > $@
-       echo 'LIBRARY BLIBECPG_COMPAT' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    _\1@ \2/' < $< >> $@
-       echo '' >> $@
-       echo '; Aliases for MS compatible names' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1= _\1/' < $< | sed 's/ *$$//' >> $@
-
-# Where possible, restrict the symbols exported by the library to just the
-# official list, so as to avoid unintentional ABI changes.
-
-ifeq ($(PORTNAME), darwin)
-$(shlib): exports.list
-
-exports.list: exports.txt
-       $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
-
-exported_symbols_list = -exported_symbols_list exports.list
-endif
-
-ifeq ($(PORTNAME), linux)
-$(shlib): exports.list
-
-exports.list: exports.txt
-       echo '{ global:' >$@
-       $(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
-       echo ' local: *; };' >>$@
-
-exported_symbols_list = -Wl,--version-script=exports.list
-endif
-
 install: all installdirs install-lib
 
 installdirs:
@@ -99,7 +48,6 @@ installdirs:
 uninstall: uninstall-lib
 
 clean distclean: clean-lib
-       rm -f $(OBJS) snprintf.c exports.list
+       rm -f $(OBJS) snprintf.c
 
-maintainer-clean: distclean
-       rm -f $(srcdir)/libecpg_compatdll.def $(srcdir)/blibecpg_compatdll.def
+maintainer-clean: distclean maintainer-clean-lib
index 32d06b8..d7f0a86 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.55 2008/02/13 18:14:46 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.56 2008/02/26 06:41:24 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -36,13 +36,14 @@ endif
 
 SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) -lm $(PTHREAD_LIBS)
 
+SHLIB_EXPORTS = exports.txt
+
 ifeq ($(PORTNAME), win32)
 # Link to shfolder.dll instead of shell32.dll
 SHLIB_LINK += -lshfolder
-DLL_DEFFILE=libecpgdll.def
 endif
 
-all: def-files all-lib
+all: all-lib
 
 # Shared library stuff
 include $(top_srcdir)/src/Makefile.shlib
@@ -60,55 +61,6 @@ path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
 $(top_builddir)/src/port/pg_config_paths.h:
        $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
 
-# We need several not-quite-identical variants of .DEF files to build libecpg
-# DLLs for Windows.  These are made from the single source file exports.txt.
-# Since we can't assume that Windows boxes will have sed, the .DEF files are
-# always built and included in distribution tarballs.
-
-distprep: def-files
-
-.PHONY: def-files
-
-def-files: $(srcdir)/libecpgdll.def $(srcdir)/blibecpgdll.def
-
-$(srcdir)/libecpgdll.def: exports.txt
-       echo '; DEF file for MS VC++' > $@
-       echo 'LIBRARY LIBECPG' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
-
-$(srcdir)/blibecpgdll.def: exports.txt
-       echo '; DEF file for Borland C++ Builder' > $@
-       echo 'LIBRARY BLIBECPG' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    _\1@ \2/' < $< >> $@
-       echo '' >> $@
-       echo '; Aliases for MS compatible names' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1= _\1/' < $< | sed 's/ *$$//' >> $@
-
-# Where possible, restrict the symbols exported by the library to just the
-# official list, so as to avoid unintentional ABI changes.
-
-ifeq ($(PORTNAME), darwin)
-$(shlib): exports.list
-
-exports.list: exports.txt
-       $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
-
-exported_symbols_list = -exported_symbols_list exports.list
-endif
-
-ifeq ($(PORTNAME), linux)
-$(shlib): exports.list
-
-exports.list: exports.txt
-       echo '{ global:' >$@
-       $(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
-       echo ' local: *; };' >>$@
-
-exported_symbols_list = -Wl,--version-script=exports.list
-endif
-
 install: all installdirs install-lib
 
 installdirs:
@@ -118,7 +70,6 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
        rm -f $(OBJS)
-       rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c exports.list
+       rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c
 
-maintainer-clean: distclean
-       rm -f $(srcdir)/libecpgdll.def $(srcdir)/blibecpgdll.def
+maintainer-clean: distclean maintainer-clean-lib
index 6b468c8..1397167 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.40 2008/02/13 18:14:46 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.41 2008/02/26 06:41:24 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -27,68 +27,17 @@ LIBS := $(filter-out -lpgport, $(LIBS))
 
 SHLIB_LINK += -lm
 
+SHLIB_EXPORTS = exports.txt
+
 OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
        pgstrcasecmp.o \
        $(filter rint.o snprintf.o, $(LIBOBJS))
 
-ifeq ($(PORTNAME), win32)
-DLL_DEFFILE=libpgtypesdll.def
-endif
-
-all: def-files all-lib
+all: all-lib
 
 # Shared library stuff
 include $(top_srcdir)/src/Makefile.shlib
 
-# We need several not-quite-identical variants of .DEF files to build libecpg
-# DLLs for Windows.  These are made from the single source file exports.txt.
-# Since we can't assume that Windows boxes will have sed, the .DEF files are
-# always built and included in distribution tarballs.
-
-distprep: def-files
-
-.PHONY: def-files
-
-def-files: $(srcdir)/libpgtypesdll.def $(srcdir)/blibpgtypesdll.def
-
-$(srcdir)/libpgtypesdll.def: exports.txt
-       echo '; DEF file for MS VC++' > $@
-       echo 'LIBRARY LIBPGTYPES' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
-
-$(srcdir)/blibpgtypesdll.def: exports.txt
-       echo '; DEF file for Borland C++ Builder' > $@
-       echo 'LIBRARY BLIBPGTYPES' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    _\1@ \2/' < $< >> $@
-       echo '' >> $@
-       echo '; Aliases for MS compatible names' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1= _\1/' < $< | sed 's/ *$$//' >> $@
-
-# Where possible, restrict the symbols exported by the library to just the
-# official list, so as to avoid unintentional ABI changes.
-
-ifeq ($(PORTNAME), darwin)
-$(shlib): exports.list
-
-exports.list: exports.txt
-       $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
-
-exported_symbols_list = -exported_symbols_list exports.list
-endif
-
-ifeq ($(PORTNAME), linux)
-$(shlib): exports.list
-
-exports.list: exports.txt
-       echo '{ global:' >$@
-       $(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
-       echo ' local: *; };' >>$@
-
-exported_symbols_list = -Wl,--version-script=exports.list
-endif
-
 # We use some port modules verbatim, but since we need to
 # compile with appropriate options to build a shared lib, we can't
 # necessarily use the same object files as the backend uses. Instead,
@@ -105,7 +54,6 @@ installdirs:
 uninstall: uninstall-lib
 
 clean distclean: clean-lib
-       rm -f $(OBJS) pgstrcasecmp.c rint.c snprintf.c exports.list
+       rm -f $(OBJS) pgstrcasecmp.c rint.c snprintf.c
 
-maintainer-clean: distclean
-       rm -f $(srcdir)/libpgtypesdll.def $(srcdir)/blibpgtypesdll.def
+maintainer-clean: distclean maintainer-clean-lib
index ff2a50b..c44c425 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.160 2008/02/13 18:14:46 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.161 2008/02/26 06:41:24 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -42,7 +42,6 @@ endif
 
 ifeq ($(PORTNAME), win32)
 OBJS += win32.o pgsleep.o libpqrc.o
-DLL_DEFFILE=libpqdll.def
 
 libpqrc.o: libpq.rc
        windres -i libpq.rc -o libpqrc.o
@@ -65,8 +64,9 @@ ifeq ($(PORTNAME), win32)
 SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
 endif
 
+SHLIB_EXPORTS = exports.txt
 
-all: def-files $(srcdir)/libpq.rc all-lib
+all: $(srcdir)/libpq.rc all-lib
 
 # Shared library stuff
 include $(top_srcdir)/src/Makefile.shlib
@@ -90,62 +90,7 @@ encnames.c wchar.c : % : $(backend_src)/utils/mb/%
        rm -f $@ && $(LN_S) $< .
 
 
-# We need several not-quite-identical variants of .DEF files to build libpq
-# DLLs for Windows.  These are made from the single source file exports.txt.
-# Since we can't assume that Windows boxes will have sed, the .DEF files are
-# always built and included in distribution tarballs.
-
-distprep: def-files $(srcdir)/libpq.rc
-
-.PHONY: def-files
-
-def-files: $(srcdir)/libpqdll.def $(srcdir)/libpqddll.def $(srcdir)/blibpqdll.def
-
-$(srcdir)/libpqdll.def: exports.txt
-       echo '; DEF file for MS VC++' > $@
-       echo 'LIBRARY LIBPQ' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
-
-$(srcdir)/libpqddll.def: exports.txt
-       echo '; DEF file for MS VC++' > $@
-       echo 'LIBRARY LIBPQD' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
-
-$(srcdir)/blibpqdll.def: exports.txt
-       echo '; DEF file for Borland C++ Builder' > $@
-       echo 'LIBRARY BLIBPQ' >> $@
-       echo 'EXPORTS' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    _\1@ \2/' < $< >> $@
-       echo '' >> $@
-       echo '; Aliases for MS compatible names' >> $@
-       sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1= _\1/' < $< | sed 's/ *$$//' >> $@
-
-# Where possible, restrict the symbols exported by the library to just the
-# official list, so as to avoid unintentional ABI changes.  On recent Darwin
-# this also quiets multiply-defined-symbol warnings in programs that use
-# libpgport along with libpq.
-
-ifeq ($(PORTNAME), darwin)
-$(shlib): exports.list
-
-exports.list: exports.txt
-       $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
-
-exported_symbols_list = -exported_symbols_list exports.list
-endif
-
-ifeq ($(PORTNAME), linux)
-$(shlib): exports.list
-
-exports.list: exports.txt
-       echo '{ global:' >$@
-       $(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
-       echo ' local: *; };' >>$@
-
-exported_symbols_list = -Wl,--version-script=exports.list
-endif
+distprep: $(srcdir)/libpq.rc
 
 # depend on Makefile.global to force rebuild on re-run of configure
 $(srcdir)/libpq.rc: libpq.rc.in $(top_builddir)/src/Makefile.global
@@ -169,9 +114,9 @@ uninstall: uninstall-lib
        rm -f '$(DESTDIR)$(includedir)/libpq-fe.h' '$(DESTDIR)$(includedir_internal)/libpq-int.h' '$(DESTDIR)$(includedir_internal)/pqexpbuffer.h' '$(DESTDIR)$(datadir)/pg_service.conf.sample'
 
 clean distclean: clean-lib
-       rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c md5.c ip.c encnames.c wchar.c win32error.c pgsleep.c pthread.h exports.list
+       rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c md5.c ip.c encnames.c wchar.c win32error.c pgsleep.c pthread.h
 # Might be left over from a Win32 client-only build
        rm -f pg_config_paths.h
 
-maintainer-clean: distclean
-       rm -f $(srcdir)/libpqdll.def $(srcdir)/libpqddll.def $(srcdir)/blibpqdll.def $(srcdir)/libpq.rc
+maintainer-clean: distclean maintainer-clean-lib
+       rm -f $(srcdir)/libpq.rc