Overload --disable-shared to also build static executables.
authorJ. Ali Harlow <ali@juiblex.co.uk>
Mon, 20 Feb 2012 19:28:38 +0000 (19:28 +0000)
committerJ. Ali Harlow <ali@juiblex.co.uk>
Mon, 20 Feb 2012 19:28:38 +0000 (19:28 +0000)
configure.ac

index 98ebf5f..b3aed81 100644 (file)
@@ -26,8 +26,34 @@ AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS([sys/mman.h])
 gl_INIT
 AC_CHECK_FUNCS([symlink chroot])
-AC_LIBTOOL_WIN32_DLL
-AM_PROG_LIBTOOL
+LT_INIT([win32-dll])
+# Libtool supports a --disable-shared option to tell it to avoid
+# building shared versions of libraries. In addition to this,we want
+# to support building static versions of our executables. Libtool
+# can do this (under the right circumstances) so we overload this
+# switch for this purpose.
+#
+# The libtool option that we use (-static-libtool-libs) means to use
+# static linking with libraries that supply a .la file and which
+# include a non-empty value for "old_library". If the library doesn't
+# include a .la file (they are deleted by some distributions), then
+# this option will have no effect and likewise if old_library is set
+# to '' (eg., if the library was build with --disable-static) then
+# again -static-libtool-libs will have no effect.
+#
+# If old_library is set to a non-empty value, then specifying
+# -static-libtool-libs will cause the link to fail if the old library
+# cannot be found (libtool will not fallback to a shared library
+# in these circumstances). This can happen with Fedora, for example,
+# if a main mingw32 library package is installed but not the
+# coresponding static sub-package. The solution is to either
+# install the relevant static sub-packages or don't use --disable-shared.
+AS_IF([test "$enable_shared" = no],[
+  LDFLAGS="$LDFLAGS -static-libtool-libs"
+])
+LT_OUTPUT
+ac_compile="./libtool --mode=compile --tag=CC $ac_compile"
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 AC_PROG_MAKE_SET
 AC_PROG_LN_S
 AC_SYS_LARGEFILE