Permalink
Browse files

build: fix automake serial-tests check again

This effectively undoes the following commits:

    a97685e build: add automake serial-tests version check
    e4c1483 build: serial-tests was added in automake v1.12

After much trial and error I've come to the conclusion that you cannot
reliably test for the automake version inside configure.ac itself.

Feature checks (testing for the presence of macros with m4_ifdef) is
not reliable when the macro is "lazy-loaded" by aclocal: m4 won't see
its definition unless it's actually used in configure.ac, hence checking
for obsolete macros like AM_ENABLE_MULTILIB and AM_WITH_REGEX is not a
reliable proxy for the automake version - both are are lazy-loaded.

That's why this commit moves the version check to autogen.sh, creates
a m4 file with automake options on the fly and includes that in
configure.ac.

Thank you, automake maintainers, for making hard what should be easy.
That's an hour of my life I won't be getting back!
  • Loading branch information...
1 parent 5ff6f85 commit acf1310bb070ee75593b581a22079d9c691028b0 @bnoordhuis bnoordhuis committed Aug 17, 2013
Showing with 27 additions and 9 deletions.
  1. +25 −4 autogen.sh
  2. +2 −5 configure.ac
View
@@ -14,12 +14,33 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+cd `dirname "$0"`
+
if [ "$LIBTOOLIZE" = "" ] && [ "`uname`" = "Darwin" ]; then
LIBTOOLIZE=glibtoolize
fi
+ACLOCAL=${ACLOCAL:-aclocal}
+AUTOCONF=${AUTOCONF:-autoconf}
+AUTOMAKE=${AUTOMAKE:-automake}
+LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
+
+automake_version=`"$AUTOMAKE" --version | head -n 1 | sed 's/[^.0-9]//g'`
+automake_version_major=`echo "$automake_version" | cut -d. -f1`
+automake_version_minor=`echo "$automake_version" | cut -d. -f2`
+
+UV_EXTRA_AUTOMAKE_FLAGS=
+if test "$automake_version_major" -gt 1 || \
+ test "$automake_version_major" -eq 1 && \
+ test "$automake_version_minor" -gt 11; then
+ # serial-tests is available in v0.12 and newer.
+ UV_EXTRA_AUTOMAKE_FLAGS="$UV_EXTRA_AUTOMAKE_FLAGS serial-tests"
+fi
+echo "m4_define([UV_EXTRA_AUTOMAKE_FLAGS], [$UV_EXTRA_AUTOMAKE_FLAGS])" \
+ > m4/libuv-extra-automake-flags.m4
+
set -ex
-${LIBTOOLIZE:-libtoolize}
-${ACLOCAL:-aclocal -I m4}
-${AUTOCONF:-autoconf}
-${AUTOMAKE:-automake} --add-missing
+"$LIBTOOLIZE"
+"$ACLOCAL" -I m4
+"$AUTOCONF"
+"$AUTOMAKE" --add-missing --copy
View
@@ -14,12 +14,9 @@
AC_PREREQ(2.57)
AC_INIT([libuv], [0.11.5], [https://github.com/joyent/libuv/issues])
-# Use AM_PROG_AR as an ad-hoc version check to find out if it's safe
-# to use the serial-tests directive. Both were added in automake v0.12.
-AM_INIT_AUTOMAKE(m4_ifdef([AM_PROG_AR],
- [-Wall -Werror foreign subdir-objects serial-tests],
- [-Wall -Werror foreign subdir-objects]))
AC_CONFIG_MACRO_DIR([m4])
+m4_include([m4/libuv-extra-automake-flags.m4])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects] UV_EXTRA_AUTOMAKE_FLAGS)
AC_CANONICAL_HOST
AC_ENABLE_SHARED
AC_ENABLE_STATIC

0 comments on commit acf1310

Please sign in to comment.