# Copyright (c) 1998, Regents of the University of California
#
# IDENTIFICATION
-# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.78 2004/09/02 23:06:43 tgl Exp $
+# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.90 2004/11/20 21:13:04 tgl Exp $
#
#-------------------------------------------------------------------------
# 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.
ifeq ($(PORTNAME), hpux)
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
ifeq ($(GCC), yes)
- SHLIB_LINK += `$(CC) -print-libgcc-file-name`
+ SHLIB_LINK += `$(CC) $(LDFLAGS) -print-libgcc-file-name`
endif
ifeq ($(with_gnu_ld), yes)
LINK.shared = $(CC) $(LDFLAGS) -shared -Wl,-h -Wl,$(soname)
else
- LINK.shared = $(LD) +h $(soname) -b +b $(libdir)
+ # can't use the CC-syntax rpath pattern here
+ rpath =
+ ifeq ($(enable_rpath), yes)
+ LINK.shared = $(LD) +h $(soname) -b +b $(rpathdir)
+ else
+ LINK.shared = $(LD) +h $(soname) -b
+ endif
endif
endif
ifeq ($(PORTNAME), cygwin)
shlib = $(NAME)$(DLSUFFIX)
+ # needed for /contrib modules, not sure why
+ SHLIB_LINK += $(LIBS)
+ haslibarule = yes
endif
ifeq ($(PORTNAME), win32)
shlib = lib$(NAME)$(DLSUFFIX)
+ haslibarule = yes
endif
ifeq ($(PORTNAME), beos)
all-shared-lib: $(shlib)
-ifneq ($(PORTNAME), cygwin)
-ifneq ($(PORTNAME), win32)
-
ifndef LORDER
MK_NO_LORDER := true
endif
+ifndef haslibarule
lib$(NAME).a: $(OBJS)
ifdef MK_NO_LORDER
$(LINK.static) $@ $^
$(LINK.static) $@ `$(LORDER) $^ | tsort`
endif
$(RANLIB) $@
-
-endif # not win32
-endif # not cygwin
+endif #haslibarule
ifeq ($(enable_shared), yes)
# Normal case
$(shlib): $(OBJS)
- $(LINK.shared) $(OBJS) $(SHLIB_LINK) -o $@
+ $(LINK.shared) $(LDFLAGS_SL) $(OBJS) $(SHLIB_LINK) -o $@
# If we're using major and minor versions, then make a symlink to major-version-only.
ifneq ($(shlib), $(shlib_major))
rm -f $(shlib_major)
else # PORTNAME == cygwin
# Cygwin case
-$(shlib) lib$(NAME).a: $(OBJS) $(DLLINIT)
+$(shlib) lib$(NAME).a: $(OBJS)
+ifndef DLL_DEFFILE
$(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
- $(DLLWRAP) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(DLLINIT) $(SHLIB_LINK)
+ $(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
-
-$(DLLINIT): $(DLLINIT:%.o=%.c)
- $(MAKE) -C $(@D) $(@F)
+else
+ $(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
+ $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib lib$(NAME).a
+endif
endif # PORTNAME == cygwin
# win32 case
$(shlib) lib$(NAME).a: $(OBJS)
+ifndef DLL_DEFFILE
$(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
- $(DLLWRAP) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
+ $(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
+else
+ $(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
+ $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib lib$(NAME).a
+endif
endif # PORTNAME == win32