# 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
-# case it would look like this:
+# Typically you would add `all-lib' to the `all' target so that `make all'
+# builds the libraries. In the most simple case it would look like this:
#
# all: all-lib
#
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
endif
haslibarule = yes
+ # $(exports_file) is also usable as an import file
exports_file = lib$(NAME).exp
endif
# can't use the CC-syntax rpath pattern here, so instead:
rpath =
ifeq ($(enable_rpath), yes)
- LINK.shared += +b '$(rpathdir)'
+ LINK.shared += +s +b '$(rpathdir)'
endif
# On HPUX platforms, gcc is usually configured to search for libraries
# in /usr/local/lib, but ld won't do so. Add an explicit -L switch so
endif
endif
-ifeq ($(PORTNAME), sco)
- ifeq ($(GCC), yes)
- LINK.shared = $(CC) -shared
- else
- LINK.shared = $(CC) -G
- endif
- LINK.shared += -Wl,-z,text
- ifdef soname
- LINK.shared += -Wl,-h,$(soname)
- endif
-endif
-
-ifeq ($(PORTNAME), unixware)
- ifeq ($(GCC), yes)
- LINK.shared = $(CC) -shared
- else
- LINK.shared = $(CC) -G
- endif
- LINK.shared += -Wl,-z,text
- ifdef soname
- LINK.shared += -Wl,-h,$(soname)
- endif
-endif
-
ifeq ($(PORTNAME), cygwin)
LINK.shared = $(CC) -shared
ifdef SO_MAJOR_VERSION
ifndef haslibarule
$(stlib): $(OBJS) | $(SHLIB_PREREQS)
+ rm -f $@
$(LINK.static) $@ $^
$(RANLIB) $@
endif #haslibarule
endif # shlib_major
# Where possible, restrict the symbols exported by the library to just the
-# official list, so as to avoid unintentional ABI changes. On recent Darwin
+# official list, so as to avoid unintentional ABI changes. On recent macOS
# this also quiets multiply-defined-symbol warnings in programs that use
# libpgport along with libpq.
ifneq (,$(SHLIB_EXPORTS))
else # PORTNAME == aix
# AIX case
-$(shlib) $(stlib): $(OBJS) | $(SHLIB_PREREQS)
+
+# There is no correct way to write a rule that generates two files.
+# Rules with two targets don't have that meaning, they are merely
+# shorthand for two otherwise separate rules. To be safe for parallel
+# make, we must chain the dependencies like this. The semicolon is
+# important, otherwise make will choose some built-in rule.
+
+$(stlib): $(shlib) ;
+
+$(shlib): $(OBJS) | $(SHLIB_PREREQS)
+ rm -f $(stlib)
$(LINK.static) $(stlib) $^
$(RANLIB) $(stlib)
- $(MKLDEXPORT) $(stlib) >$(exports_file)
+ $(MKLDEXPORT) $(stlib) $(shlib) >$(exports_file)
$(COMPILER) -o $(shlib) $(stlib) -Wl,-bE:$(exports_file) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK)
rm -f $(stlib)
$(AR) $(AROPT) $(stlib) $(shlib)
$(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) $(LDAP_LIBS_BE)
$(stlib): $(OBJS) | $(SHLIB_PREREQS)
+ rm -f $@
$(LINK.static) $@ $^
$(RANLIB) $@
$(stlib): $(shlib) ;
+# XXX A backend that loads a module linked with libgcc_s_dw2-1.dll will exit
+# uncleanly, hence -static-libgcc. (Last verified with MinGW-w64 compilers
+# from i686-4.9.1-release-win32-dwarf-rt_v3-rev1.) Shared libgcc has better
+# support for C++/Java exceptions; while core PostgreSQL does not use them, it
+# would be nice to support shared libgcc for the benefit of extensions.
+#
# If SHLIB_EXPORTS is set, the rules below will build a .def file from that.
# Else we just use --export-all-symbols.
ifeq (,$(SHLIB_EXPORTS))
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
- $(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
+ $(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
else
DLL_DEFFILE = lib$(NAME)dll.def
$(shlib): $(OBJS) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
- $(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
+ $(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
endif
endif # PORTNAME == cgywin
UC_NAME = $(shell echo $(NAME) | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
lib$(NAME)dll.def: $(SHLIB_EXPORTS)
- echo '; DEF file for MS VC++' >$@
- echo 'LIBRARY LIB$(UC_NAME)' >>$@
+ echo '; DEF file for win32.mak release build and for Makefile.shlib (MinGW)' >$@
+ echo 'LIBRARY LIB$(UC_NAME).dll' >>$@
echo 'EXPORTS' >>$@
sed -e '/^#/d' -e 's/^\(.*[ ]\)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
lib$(NAME)ddll.def: $(SHLIB_EXPORTS)
- echo '; DEF file for MS VC++' >$@
- echo 'LIBRARY LIB$(UC_NAME)D' >>$@
+ echo '; DEF file for win32.mak debug build' >$@
+ echo 'LIBRARY LIB$(UC_NAME)D.dll' >>$@
echo 'EXPORTS' >>$@
sed -e '/^#/d' -e 's/^\(.*[ ]\)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
blib$(NAME)dll.def: $(SHLIB_EXPORTS)
- echo '; DEF file for Borland C++ Builder' >$@
+ echo '; DEF file for bcc32.mak (Borland C++ Builder)' >$@
echo 'LIBRARY BLIB$(UC_NAME)' >>$@
echo 'EXPORTS' >>$@
sed -e '/^#/d' -e 's/^\(.*[ ]\)\([0-9][0-9]*\)/ _\1@ \2/' $< >>$@
endif # not win32
endif # not cygwin
endif # not aix
+ifneq (,$(findstring $(PORTNAME),win32 cygwin))
+ $(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
+endif
else # no soname
$(INSTALL_SHLIB) $< '$(DESTDIR)$(pkglibdir)/$(shlib)'
endif
installdirs-lib:
ifdef soname
- $(MKDIR_P) '$(DESTDIR)$(libdir)' '$(DESTDIR)$(pkgconfigdir)'
+ $(MKDIR_P) '$(DESTDIR)$(libdir)' '$(DESTDIR)$(pkgconfigdir)' $(if $(findstring $(PORTNAME),win32 cygwin),'$(DESTDIR)$(bindir)')
else
$(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
endif
rm -f '$(DESTDIR)$(libdir)/$(stlib)'
rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \
'$(DESTDIR)$(libdir)/$(shlib_major)' \
- '$(DESTDIR)$(libdir)/$(shlib)' \
+ '$(DESTDIR)$(libdir)/$(shlib)' $(if $(findstring $(PORTNAME),win32 cygwin),'$(DESTDIR)$(bindir)/$(shlib)') \
'$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
else # no soname
rm -f '$(DESTDIR)$(pkglibdir)/$(shlib)'