]> granicus.if.org Git - postgresql/blobdiff - src/Makefile.shlib
Turn the rangetable used by the executor into a flat list, and avoid storing
[postgresql] / src / Makefile.shlib
index 1a050aaa4812fbb35d610f66ea33ecfc9821cdeb..4f897f4eff41a6f22ee3e73ee425d2818af9cc19 100644 (file)
@@ -6,7 +6,7 @@
 # Copyright (c) 1998, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.25 2000/10/10 21:22:21 petere Exp $
+#    $PostgreSQL: pgsql/src/Makefile.shlib,v 1.109 2007/02/20 22:45:57 momjian 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.)
 # plus any additional things you want to install. Et cetera.
 #
 # Got that?  Look at src/interfaces/libpq/Makefile for an example.
+#
+# While the linker allows creation of most shared libraries,
+# -Bsymbolic requires resolution of all symbols, making the
+# compiler a better choice for shared library creation on ELF platforms.
+# With the linker, -Bsymbolic requires the crt1.o startup object file.
+# bjm 2001-02-10
+
+
+COMPILER = $(CC) $(CFLAGS)
+LINK.static = $(AR) $(AROPT)
+
+
+
+ifeq ($(enable_shared), yes)
 
+# Insert -L from LDFLAGS after any -L already present in SHLIB_LINK
+SHLIB_LINK := $(filter -L%, $(SHLIB_LINK)) $(filter -L%, $(LDFLAGS)) $(filter-out -L%, $(SHLIB_LINK))
 
-# shlib is empty by default. If we know how to build a shared library
-# it will contain the name of the file, otherwise it will remain
-# empty. Thus `ifdef shlib' could be used in the containing make file
-# to test whether shared libraries are available.
-shlib := 
+# Need a -L-free version of LDFLAGS to use in combination with SHLIB_LINK
+LDFLAGS_NO_L = $(filter-out -L%, $(LDFLAGS))
 
-# For each platform we support shared libraries on, set shlib and
-# update flags as needed to build a shared lib. Note we depend on
-# Makefile.global (or really Makefile.port) to supply DLSUFFIX and
-# other symbols.
+# 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 (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...
 
+override CFLAGS += $(CFLAGS_SL)
+
+soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+
 ifeq ($(PORTNAME), aix)
-  shlib                        := lib$(NAME)$(DLSUFFIX)
-  SHLIB_LINK           += -lc
+  shlib                        = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+  haslibarule   = yes
+endif
+
+ifeq ($(PORTNAME), darwin)
+  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) $(exported_symbols_list) -multiply_defined suppress
+  else
+    # loadable module (default case)
+    DLSUFFIX           = .so
+    LINK.shared                = $(COMPILER) -bundle -multiply_defined suppress
+  endif
+  shlib                        = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
+  shlib_major          = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
 endif
 
 ifeq ($(PORTNAME), openbsd)
-  ifdef BSD_SHLIB
-    shlib              := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-    ifdef ELF_SYSTEM
-      LDFLAGS_SL       := -x -Bshareable -soname $(shlib)
-    else
-      LDFLAGS_SL       := -x -Bshareable -Bforcearchive
-    endif
-    CFLAGS             += $(CFLAGS_SL)
+  ifdef ELF_SYSTEM
+    LINK.shared                = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
+    SHLIB_LINK         += -lc
+  else
+    LINK.shared                = $(LD) -x -Bshareable -Bforcearchive
   endif
 endif
 
 ifeq ($(PORTNAME), bsdi)
-  ifdef BSD_SHLIB
-    ifeq ($(DLSUFFIX), .so)
-      shlib                    := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LDFLAGS_SL                += -shared -soname $(shlib)
-      CFLAGS                   += $(CFLAGS_SL)
-    endif
-    ifeq ($(DLSUFFIX), .o)
-      shlib                    := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LD                       := shlicc
-      LDFLAGS_SL               += -O $(LDREL)
-      CFLAGS                   += $(CFLAGS_SL)
-    endif
+  ifeq ($(DLSUFFIX), .so)
+    LINK.shared                = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
+    SHLIB_LINK         += -lc
+  endif
+  ifeq ($(DLSUFFIX), .o)
+    LINK.shared                = shlicc -O $(LDREL)
   endif
 endif
 
 ifeq ($(PORTNAME), freebsd)
-  ifdef BSD_SHLIB
-    ifdef ELF_SYSTEM
-      shlib            := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
-      LDFLAGS_SL       := -x -shared -soname $(shlib)
-    else
-      shlib            := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-      LDFLAGS_SL       := -x -Bshareable -Bforcearchive
-    endif
-    CFLAGS             += $(CFLAGS_SL)
+  ifdef ELF_SYSTEM
+    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)
+    LINK.shared                = $(LD) -x -Bshareable -Bforcearchive
   endif
 endif
 
 ifeq ($(PORTNAME), netbsd)
-  ifdef BSD_SHLIB
-    soname             := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
-    shlib              := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-    ifdef ELF_SYSTEM
-      LD               := $(CC)
-      LDFLAGS_SL       := -shared -Wl,-soname -Wl,$(soname)
-      ifneq ($(SHLIB_LINK),)
-        LDFLAGS_SL     += -Wl,-R$(libdir)
-      endif
-    else
-      LDFLAGS_SL       := -x -Bshareable -Bforcearchive
-    endif
-    CFLAGS             += $(CFLAGS_SL)
+  ifdef ELF_SYSTEM
+    LINK.shared                = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
+  else
+    LINK.shared                = $(LD) -x -Bshareable -Bforcearchive
   endif
 endif
 
 ifeq ($(PORTNAME), hpux)
-# HPUX doesn't believe in version numbers for shlibs
-  shlib                        := lib$(NAME)$(DLSUFFIX)
-  LDFLAGS_SL           := -b
-  CFLAGS               += $(CFLAGS_SL)
+  shlib                        = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+  ifeq ($(with_gnu_ld), yes)
+    LINK.shared                = $(CC) $(LDFLAGS_NO_L) -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
+    # 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
+    # ld can find the same libraries gcc does.  Make sure it goes after any
+    # -L switches provided explicitly.
+    ifeq ($(GCC), yes)
+      SHLIB_LINK := $(filter -L%, $(SHLIB_LINK)) -L/usr/local/lib $(filter-out -L%, $(SHLIB_LINK))
+    endif
+  endif
+  # do this last so above filtering doesn't pull out -L switches in LDFLAGS
+  ifeq ($(GCC), yes)
+    SHLIB_LINK         += `$(CC) $(LDFLAGS) -print-libgcc-file-name`
+  endif
 endif
 
-ifeq ($(PORTNAME), irix5)
-  shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
-  LDFLAGS_SL := -shared -rpath $(libdir) -set_version sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  CFLAGS += $(CFLAGS_SL)
+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)
-  LD                   := $(CC)
-  LDFLAGS_SL           := -shared -Wl,-soname,$(shlib)
-  LDFLAGS_ODBC         := -lm
-  CFLAGS               += $(CFLAGS_SL)
+  LINK.shared          = $(COMPILER) -shared -Wl,-soname,$(soname) $(exported_symbols_list)
 endif
 
 ifeq ($(PORTNAME), solaris)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL           := -G
-  SHLIB_LINK           += -ldl -lsocket -lresolv -lnsl -lm -lc
-  CFLAGS               += $(CFLAGS_SL)
+  ifeq ($(GCC), yes)
+    LINK.shared                = $(COMPILER) -shared # $(COMPILER) needed for -m64
+  else
+# CFLAGS added for X86_64
+    LINK.shared                = $(CC) -G $(CFLAGS)
+  endif
+  ifeq ($(with_gnu_ld), yes)
+    LINK.shared                += -Wl,-soname,$(soname)
+  else
+    LINK.shared                += -h $(soname)
+  endif
 endif
 
+ifeq ($(PORTNAME), sunos4)
+  LINK.shared          = $(LD) -assert pure-text -Bdynamic
+endif
 ifeq ($(PORTNAME), osf)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL           += -shared -expect_unresolved '*'
+  LINK.shared          = $(LD) -shared -expect_unresolved '*'
+endif
+
+ifeq ($(PORTNAME), sco)
+  ifeq ($(GCC), yes)
+    LINK.shared                = $(CC) -shared
+  else
+    LINK.shared                = $(CC) -G
+    endif
+  LINK.shared          += -Wl,-z,text -Wl,-h,$(soname)
 endif
 
 ifeq ($(PORTNAME), svr4)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL           := -G
-  CFLAGS               += $(CFLAGS_SL)
+  LINK.shared          = $(LD) -G
 endif
 
 ifeq ($(PORTNAME), univel)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL           := -G -z text
-  CFLAGS               += $(CFLAGS_SL)
-  ifeq ($(CXX), CC)
-    CXXFLAGS += -Xw
-    COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
-  endif
+  LINK.shared          = $(LD) -G -z text
 endif
 
 ifeq ($(PORTNAME), unixware)
-  shlib                        := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
-  LDFLAGS_SL           := -G -z text
-  CFLAGS               += $(CFLAGS_SL)
-  ifeq ($(CXX), CC)
-    CXXFLAGS += -Xw
-    COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
+  ifeq ($(GCC), yes)
+    LINK.shared                = $(CC) -shared
+  else
+    LINK.shared                = $(CC) -G
   endif
+  LINK.shared          += -Wl,-z,text -Wl,-h,$(soname) 
 endif
 
-ifeq ($(PORTNAME), win)
-  shlib                        := $(NAME)$(DLSUFFIX)
+ifeq ($(PORTNAME), cygwin)
+  shlib                        = cyg$(NAME)$(DLSUFFIX)
+  haslibarule   = yes
 endif
 
-ifeq ($(PORTNAME), beos)
-  install-shlib-dep    := install-shlib
-  shlib                                := lib$(NAME)$(DLSUFFIX)
-  LDFLAGS_SL           := -nostart -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86 
+ifeq ($(PORTNAME), win32)
+  shlib                        = lib$(NAME)$(DLSUFFIX)
+  haslibarule   = yes
 endif
 
-# Note that in what follows, shlib is empty when not building a shared
-# library.
+ifeq ($(enable_rpath), yes)
+SHLIB_LINK += $(rpath)
+endif
+
+endif # enable_shared
+
 
 
 ##
 ## BUILD
 ##
 
-.PHONY: all-lib
-all-lib: lib$(NAME).a $(shlib)
+.PHONY: all-lib all-static-lib all-shared-lib
 
-# Rules to build regular and shared libraries
+all-lib: all-static-lib all-shared-lib
 
-ifneq ($(PORTNAME), win)
+all-static-lib: lib$(NAME).a
 
-ifndef LORDER
-MK_NO_LORDER := true
-endif
+all-shared-lib: $(shlib)
 
+ifndef haslibarule
 lib$(NAME).a: $(OBJS)
-ifdef MK_NO_LORDER
-       $(AR) $(AROPT) $@ $^
-else
-       $(AR) $(AROPT) $@ `$(LORDER) $^ | tsort`
-endif
+       $(LINK.static) $@ $^
        $(RANLIB) $@
+endif #haslibarule
 
-endif # not win
+ifeq ($(enable_shared), yes)
 
-ifdef shlib
-ifneq ($(PORTNAME), beos)
-ifneq ($(PORTNAME), win)
+ifneq ($(PORTNAME), win32)
+ifneq ($(PORTNAME), cygwin)
 ifneq ($(PORTNAME), aix)
 
 # Normal case
 $(shlib): $(OBJS)
-       $(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(SHLIB_LINK)
+       $(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
 
 # AIX case
-$(shlib): lib$(NAME).a
-       $(MKLDEXPORT) lib$(NAME).a $(libdir) > lib$(NAME)$(EXPSUFF)
-       $(LD) -H512 -bM:SRE -bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) -bE:lib$(NAME)$(EXPSUFF) -o $@ $< $(LDFLAGS) $(SHLIB_LINK)
-
+$(shlib) lib$(NAME).a: $(OBJS)
+       $(LINK.static) lib$(NAME).a $^
+       $(RANLIB) lib$(NAME).a
+       $(MKLDEXPORT) lib$(NAME).a > lib$(NAME)$(EXPSUFF)
+       $(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 == win
+else # PORTNAME == cygwin
 
-# WIN case
-$(shlib) lib$(NAME).a: $(OBJS) $(top_builddir)/src/utils/dllinit.o
-       $(DLLTOOL) --export-all --output-def $(NAME).def $(OBJS)
-       $(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(top_builddir)/src/utils/dllinit.o $(DLLINIT) $(SHLIB_LINK)
-       $(DLLTOOL) --dllname $(shlib) --def $(NAME).def --output-lib lib$(NAME).a
+# 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
 
-$(top_builddir)/src/utils/dllinit.o: $(top_srcdir)/src/utils/dllinit.c
-       $(MAKE) -C $(top_builddir)/src/utils dllinit.o
+endif # PORTNAME == cygwin
 
-endif # PORTNAME == win
+else # PORTNAME == win32
 
-else # PORTNAME == beos
+# 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
 
-# BEOS case
-$(shlib): $(OBJS)
-       ln -fs $(top_srcdir)/src/backend/postgres _APP_
-       $(CC) -Xlinker -soname=$@ $(LDFLAGS_SL) -o $@ _APP_ $(OBJS) $(SHLIB_LINK)
+endif # PORTNAME == win32
 
-endif # PORTNAME == beos
-endif # shlib
+endif # enable_shared
 
 
 ##
@@ -286,25 +347,33 @@ endif # shlib
 install-lib: install-lib-static install-lib-shared
 
 install-lib-static: lib$(NAME).a
-       $(INSTALL_DATA) $< $(DESTDIR)$(libdir)/lib$(NAME).a
+       $(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/lib$(NAME).a'
+ifeq ($(PORTNAME), darwin)
+       cd '$(DESTDIR)$(libdir)' && \
+       ranlib lib$(NAME).a
+endif
 
-ifdef shlib
+ifeq ($(enable_shared), yes)
 install-lib-shared: $(shlib)
-       $(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
-ifneq ($(PORTNAME), win)
-ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION))
-       cd $(DESTDIR)$(libdir) && \
-       rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) && \
-       $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+# we don't install $(shlib) on AIX
+ifneq ($(PORTNAME), aix)
+       $(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
+ifneq ($(PORTNAME), cygwin)
+ifneq ($(PORTNAME), win32)
+ifneq ($(shlib), $(shlib_major))
+       cd '$(DESTDIR)$(libdir)' && \
+       rm -f $(shlib_major) && \
+       $(LN_S) $(shlib) $(shlib_major)
 endif
-ifneq ($(shlib), lib$(NAME)$(DLSUFFIX))
-       cd $(DESTDIR)$(libdir) && \
-       rm -f lib$(NAME)$(DLSUFFIX) && \
-       $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX)
+ifneq ($(shlib), $(shlib_bare))
+       cd '$(DESTDIR)$(libdir)' && \
+       rm -f $(shlib_bare) && \
+       $(LN_S) $(shlib) $(shlib_bare)
 endif
-
-endif # not win
-endif # shlib
+endif # not win32
+endif # not cygwin
+endif # not aix
+endif # enable_shared
 
 
 ##
@@ -313,12 +382,12 @@ endif # shlib
 
 .PHONY: uninstall-lib
 uninstall-lib:
-       rm -f $(DESTDIR)$(libdir)/lib$(NAME).a
-ifdef shlib
-       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)
-endif # shlib
+       rm -f '$(DESTDIR)$(libdir)/lib$(NAME).a'
+ifeq ($(enable_shared), yes)
+       rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \
+         '$(DESTDIR)$(libdir)/$(shlib_major)' \
+         '$(DESTDIR)$(libdir)/$(shlib)'
+endif # enable_shared
 
 
 ##
@@ -328,7 +397,16 @@ endif # shlib
 .PHONY: clean-lib
 clean-lib:
        rm -f lib$(NAME).a
-       rm -f $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX)
-ifeq ($(PORTNAME), win)
-       rm -rf $(NAME).def
+ifeq ($(enable_shared), yes)
+       rm -f $(shlib_bare) $(shlib_major) $(shlib)
+ifdef EXPSUFF
+       rm -f lib$(NAME)$(EXPSUFF)
+endif
+endif
+ifeq ($(PORTNAME), cygwin)
+       rm -f $(NAME).dll $(NAME).def
+endif
+
+ifeq ($(PORTNAME), win32)
+       rm -f $(NAME).dll $(NAME).def
 endif