]> granicus.if.org Git - postgresql/blobdiff - src/Makefile.shlib
Fix HAVE_OPTRESET to be HAVE_INT_OPTRESET. Typos spotted by Lorne Sunley.
[postgresql] / src / Makefile.shlib
index 5e1f0aa258443e8c63f06506976b7572000994e4..002071e06cc1afe9b3a6bc8f14adadd20cd17ef1 100644 (file)
@@ -6,7 +6,7 @@
 # Copyright (c) 1998, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.66 2003/01/11 17:22:19 tgl Exp $
+#    $PostgreSQL: pgsql/src/Makefile.shlib,v 1.90 2004/11/20 21:13:04 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
 #                       additional stuff to put in its link command
 # (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
+# platforms).
+# 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.
 # (Makefile.global sets PORTNAME and other needed symbols.)
@@ -65,8 +73,14 @@ LINK.static = $(AR) $(AROPT)
 
 ifeq ($(enable_shared), yes)
 
+# Default shlib naming convention used by the majority of platforms
+shlib          = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+shlib_major    = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+shlib_bare     = lib$(NAME)$(DLSUFFIX)
+
 # For each platform we support shared libraries on, set shlib to the
-# name of the library, LINK.shared to the command to link the library,
+# name of the library (if default above is not right), set
+# LINK.shared to the command to link the library,
 # and adjust SHLIB_LINK if necessary.
 
 # Try to keep the sections in some kind of order, folks...
@@ -76,17 +90,28 @@ override CFLAGS += $(CFLAGS_SL)
 soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
 
 ifeq ($(PORTNAME), aix)
-  shlib                        := lib$(NAME)$(DLSUFFIX)
+  shlib                        = lib$(NAME)$(DLSUFFIX)
 #   SHLIB_LINK         += -lc
 endif
 
 ifeq ($(PORTNAME), darwin)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LINK.shared          = $(COMPILER) $(DARWIN_NAMESPACE_SPEC) -bundle -undefined suppress
+  ifneq ($(SO_MAJOR_VERSION), 0)
+    version_link       := -compatibility_version $(SO_MAJOR_VERSION) -current_version $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+  endif
+  ifeq ($(DLTYPE), library)
+    # linkable library
+    DLSUFFIX           := .dylib
+    LINK.shared                = $(COMPILER) -dynamiclib -install_name $(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) $(version_link) -multiply_defined suppress
+  else
+    # loadable module (default case)
+    DLSUFFIX           := .so
+    LINK.shared                = $(COMPILER) -bundle
+  endif
+  shlib                        = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
+  shlib_major          = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
 endif
 
 ifeq ($(PORTNAME), openbsd)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   ifdef ELF_SYSTEM
     LINK.shared                = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
     SHLIB_LINK         += -lc
@@ -96,7 +121,6 @@ ifeq ($(PORTNAME), openbsd)
 endif
 
 ifeq ($(PORTNAME), bsdi)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   ifeq ($(DLSUFFIX), .so)
     LINK.shared                = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
     SHLIB_LINK         += -lc
@@ -108,16 +132,15 @@ endif
 
 ifeq ($(PORTNAME), freebsd)
   ifdef ELF_SYSTEM
-    shlib              := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+    shlib              = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
     LINK.shared                = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
   else
-    shlib              := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+    shlib              = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
     LINK.shared                = $(LD) -x -Bshareable -Bforcearchive
   endif
 endif
 
 ifeq ($(PORTNAME), netbsd)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   ifdef ELF_SYSTEM
     LINK.shared                = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
   else
@@ -126,22 +149,33 @@ ifeq ($(PORTNAME), netbsd)
 endif
 
 ifeq ($(PORTNAME), hpux)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
-  LINK.shared          = $(LD) +h $(soname) -b +b $(libdir)
+  shlib                        = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+  ifeq ($(GCC), yes)
+    SHLIB_LINK         += `$(CC) $(LDFLAGS) -print-libgcc-file-name`
+  endif
+  ifeq ($(with_gnu_ld), yes)
+    LINK.shared                = $(CC) $(LDFLAGS) -shared -Wl,-h -Wl,$(soname)
+  else
+    # 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), irix5)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+ifeq ($(PORTNAME), irix)
+  shlib                        = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
   LINK.shared          = $(COMPILER) -shared -Wl,-set_version,sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
 endif
 
 ifeq ($(PORTNAME), linux)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   LINK.shared          = $(COMPILER) -shared -Wl,-soname,$(soname)
 endif
 
 ifeq ($(PORTNAME), solaris)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   ifeq ($(GCC), yes)
     LINK.shared                = $(CC) -shared
   else
@@ -155,17 +189,14 @@ ifeq ($(PORTNAME), solaris)
 endif
 
 ifeq ($(PORTNAME), sunos4)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   LINK.shared          = $(LD) -assert pure-text -Bdynamic
 endif
  
 ifeq ($(PORTNAME), osf)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   LINK.shared          = $(LD) -shared -expect_unresolved '*'
 endif
 
 ifeq ($(PORTNAME), sco)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   ifeq ($(GCC), yes)
     LINK.shared                = $(CC) -shared
   else
@@ -175,31 +206,36 @@ ifeq ($(PORTNAME), sco)
 endif
 
 ifeq ($(PORTNAME), svr4)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   LINK.shared          = $(LD) -G
 endif
 
 ifeq ($(PORTNAME), univel)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   LINK.shared          = $(LD) -G -z text
 endif
 
 ifeq ($(PORTNAME), unixware)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
   ifeq ($(GCC), yes)
     LINK.shared                = $(CC) -shared
   else
     LINK.shared                = $(CC) -G
   endif
-  LINK.shared          += -Wl,-z,text -Wl,-h,$(soname)
+  LINK.shared          += -Wl,-z,text -Wl,-h,$(soname) 
 endif
 
-ifeq ($(PORTNAME), win)
-  shlib                        := $(NAME)$(DLSUFFIX)
+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)
-  shlib                        := lib$(NAME)$(DLSUFFIX)
+  shlib                        = lib$(NAME)$(DLSUFFIX)
   LINK.shared          = $(LD) -nostart
   SHLIB_LINK           += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
 endif
@@ -225,12 +261,11 @@ all-static-lib: lib$(NAME).a
 
 all-shared-lib: $(shlib)
 
-ifneq ($(PORTNAME), win)
-
 ifndef LORDER
 MK_NO_LORDER := true
 endif
 
+ifndef haslibarule
 lib$(NAME).a: $(OBJS)
 ifdef MK_NO_LORDER
        $(LINK.static) $@ $^
@@ -238,27 +273,27 @@ else
        $(LINK.static) $@ `$(LORDER) $^ | tsort`
 endif
        $(RANLIB) $@
-
-endif # not win
+endif #haslibarule
 
 ifeq ($(enable_shared), yes)
 
+ifneq ($(PORTNAME), win32)
+ifneq ($(PORTNAME), cygwin)
 ifneq ($(PORTNAME), beos)
-ifneq ($(PORTNAME), win)
 ifneq ($(PORTNAME), aix)
 
 # 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), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION))
-       rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
-       $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+ifneq ($(shlib), $(shlib_major))
+       rm -f $(shlib_major)
+       $(LN_S) $(shlib) $(shlib_major)
 endif
 # Make sure we have a link to a name without any version numbers
-ifneq ($(shlib), lib$(NAME)$(DLSUFFIX))
-       rm -f lib$(NAME)$(DLSUFFIX)
-       $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX)
+ifneq ($(shlib), $(shlib_bare))
+       rm -f $(shlib_bare)
+       $(LN_S) $(shlib) $(shlib_bare)
 endif
 
 else # PORTNAME == aix
@@ -270,19 +305,6 @@ $(shlib): lib$(NAME).a
        
 endif # PORTNAME == aix
 
-else # PORTNAME == win
-
-# WIN case
-$(shlib) lib$(NAME).a: $(OBJS) $(DLLINIT)
-       $(DLLTOOL) --export-all --output-def $(NAME).def $(OBJS)
-       $(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(DLLINIT) $(SHLIB_LINK)
-       $(DLLTOOL) --dllname $(shlib) --def $(NAME).def --output-lib lib$(NAME).a
-
-$(DLLINIT): $(DLLINIT:%.o=%.c)
-       $(MAKE) -C $(@D) $(@F)
-
-endif # PORTNAME == win
-
 else # PORTNAME == beos
 
 # BEOS case
@@ -292,6 +314,36 @@ $(shlib): $(OBJS)
 
 endif # PORTNAME == beos
 
+else # PORTNAME == cygwin
+
+# Cygwin case
+$(shlib) lib$(NAME).a: $(OBJS)
+ifndef DLL_DEFFILE
+       $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
+       $(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 == cygwin
+
+else # PORTNAME == win32
+
+# win32 case
+$(shlib) lib$(NAME).a: $(OBJS)
+ifndef DLL_DEFFILE
+       $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
+       $(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
+
 endif # enable_shared
 
 
@@ -304,23 +356,28 @@ install-lib: install-lib-static install-lib-shared
 
 install-lib-static: lib$(NAME).a
        $(INSTALL_STLIB) $< $(DESTDIR)$(libdir)/lib$(NAME).a
+ifeq ($(PORTNAME), darwin)
+       cd $(DESTDIR)$(libdir) && \
+       ranlib lib$(NAME).a
+endif
 
 ifeq ($(enable_shared), yes)
 install-lib-shared: $(shlib)
        $(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
-ifneq ($(PORTNAME), win)
-ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION))
+ifneq ($(PORTNAME), cygwin)
+ifneq ($(PORTNAME), win32)
+ifneq ($(shlib), $(shlib_major))
        cd $(DESTDIR)$(libdir) && \
-       rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) && \
-       $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+       rm -f $(shlib_major) && \
+       $(LN_S) $(shlib) $(shlib_major)
 endif
-ifneq ($(shlib), lib$(NAME)$(DLSUFFIX))
+ifneq ($(shlib), $(shlib_bare))
        cd $(DESTDIR)$(libdir) && \
-       rm -f lib$(NAME)$(DLSUFFIX) && \
-       $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX)
+       rm -f $(shlib_bare) && \
+       $(LN_S) $(shlib) $(shlib_bare)
 endif
-
-endif # not win
+endif # not win32
+endif # not cygwin
 endif # enable_shared
 
 
@@ -332,9 +389,9 @@ endif # enable_shared
 uninstall-lib:
        rm -f $(DESTDIR)$(libdir)/lib$(NAME).a
 ifeq ($(enable_shared), yes)
-       rm -f $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX) \
-         $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) \
-         $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+       rm -f $(DESTDIR)$(libdir)/$(shlib_bare) \
+         $(DESTDIR)$(libdir)/$(shlib_major) \
+         $(DESTDIR)$(libdir)/$(shlib)
 endif # enable_shared
 
 
@@ -346,11 +403,15 @@ endif # enable_shared
 clean-lib:
        rm -f lib$(NAME).a
 ifeq ($(enable_shared), yes)
-       rm -f lib$(NAME)$(DLSUFFIX) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+       rm -f $(shlib_bare) $(shlib_major) $(shlib)
 ifdef EXPSUFF
        rm -f lib$(NAME)$(EXPSUFF)
 endif
 endif
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
+       rm -f $(NAME).dll $(NAME).def
+endif
+
+ifeq ($(PORTNAME), win32)
        rm -f $(NAME).dll $(NAME).def
 endif