]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Moved cc-wrapper.sh handling to dovecot.m4
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 8 Aug 2016 10:12:15 +0000 (13:12 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 20 Oct 2016 20:04:41 +0000 (23:04 +0300)
When configuring Dovecot --without-shared-libs and pointing external plugins
to uninstalled sources --with-dovecot, any binaries complied for plugins
weren't using cc-wrapper.sh, which could have caused runtime failures when
they attempted to load plugins dynamically. Now it's possible to add
DC_CC_WRAPPER to plugins' configure.ac to build with the cc-wrapper.sh.

Makefile.am
cc-wrapper.sh.in [deleted file]
configure.ac
dovecot.m4

index e3145a8e7f2a81c29269e4322fc762394c864db1..f484aa21531ed50c5179e7452978d4806cbca39c 100644 (file)
@@ -13,7 +13,6 @@ EXTRA_DIST = \
        COPYING.LGPL \
        COPYING.MIT \
        ChangeLog \
-       cc-wrapper.sh.in \
        update-version.sh \
        run-test-valgrind.supp \
        $(conf_DATA)
diff --git a/cc-wrapper.sh.in b/cc-wrapper.sh.in
deleted file mode 100644 (file)
index 9a301c7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if echo "$*" | grep -- -ldl > /dev/null; then
-  # the binary uses plugins. make sure we include everything from .a libs
-  exec @CC@ -Wl,--whole-archive $* -Wl,--no-whole-archive
-else
-  exec @CC@ $*
-fi
index ff306d8a51d0d778abe05e0e78f7a0c2896072d4..75e34f3ef5defedc3626fe44228f32f57ba23ab4 100644 (file)
@@ -2860,14 +2860,7 @@ fi
 LDFLAGS="\$(NOPLUGIN_LDFLAGS) $LDFLAGS"
 AC_SUBST(NOPLUGIN_LDFLAGS)
 
-if test "$with_gnu_ld" = yes -a "$want_shared_libs" = "no"; then
-  # libtool can't handle using whole-archive flags, so we need to do this
-  # with a CC wrapper.. shouldn't be much of a problem, since most people
-  # are building with shared libs.
-  sed "s:@CC@:$CC:" < $srcdir/cc-wrapper.sh.in > cc-wrapper.sh
-  chmod +x cc-wrapper.sh
-  CC=`pwd`/cc-wrapper.sh
-fi
+DC_CC_WRAPPER
 
 if test "$docdir" = ""; then
   dnl docdir supported only by autoconf v2.59c and later
index 4fca0a0af67af722e40a1d87982efd4ce1091dcd..b77a915b09e37088d093bfc61b9ca46db44dd076 100644 (file)
@@ -6,7 +6,7 @@
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 23
+# serial 24
 
 AC_DEFUN([DC_DOVECOT_MODULEDIR],[
        AC_ARG_WITH(moduledir,
@@ -137,3 +137,28 @@ AC_DEFUN([DC_DOVECOT],[
        DC_PLUGIN_DEPS
        DC_DOVECOT_TEST_WRAPPER
 ])
+
+AC_DEFUN([DC_CC_WRAPPER],[
+  if test "$want_shared_libs" != "yes"; then
+    # want_shared_libs=no is for internal use. the liblib.la check is for plugins
+    if test "$want_shared_libs" = "no" || echo "$LIBDOVECOT" | grep "/liblib.la" > /dev/null; then
+      if test "$with_gnu_ld" = yes; then
+       # libtool can't handle using whole-archive flags, so we need to do this
+       # with a CC wrapper.. shouldn't be much of a problem, since most people
+       # are building with shared libs.
+       cat > cc-wrapper.sh <<EOF
+#!/bin/sh
+
+if echo "\$[*]" | grep -- -ldl > /dev/null; then
+  # the binary uses plugins. make sure we include everything from .a libs
+  exec $CC -Wl,--whole-archive \$[*] -Wl,--no-whole-archive
+else
+  exec $CC \$[*]
+fi
+EOF
+       chmod +x cc-wrapper.sh
+       CC=`pwd`/cc-wrapper.sh
+      fi
+    fi
+  fi
+])