Hunting down bugs in m4 macros sucks. Using $# in macros sucks, too. Sorry for the cross-post.
First: LT_WITH_LTDL needs to be documented correctly. Its predecessor AC_WITH_LTDL needed documentation as well. I accept patches. :) Second: Autoconf bug: AU_ALIAS mumbles with the number of arguments: cat >configure.ac <<\EOF AC_INIT AC_DEFUN([FOO], [echo foo: $#]) AU_DEFUN([BAR],[FOO]) AU_ALIAS([BAZ],[FOO]) FOO FOO(1) FOO(1,2) BAR BAR(1) BAR(1,2) BAZ BAZ(1) BAZ(1,2) AC_OUTPUT EOF autoconf ./configure leads to: foo: 0 foo: 1 foo: 2 foo: 0 foo: 0 foo: 0 foo: 1 foo: 1 foo: 2 We knew about AU_DEFUN, but AU_ALIAS sucks here. (No, AU_ALIAS is not documented; but I have a promise from 2005-01-03 to use it in Libtool as if it were documented! Since there is no documentation, I assumed it would just work the way I thought it would :) Third: In light of this, calling (from within AC_WITH_LTDL, AU_ALIASed to LT_WITH_LTDL): LTDL_CONVENIENCE([$1]) and in LTDL_CONVENIENCE, testing $# is bound to lead to failure. Example: AC_INIT([foo], [0.1], [devnull]) AC_CONFIG_AUX_DIR([libltdl/config]) AC_CONFIG_MACRO_DIR([libltdl/m4]) AM_INIT_AUTOMAKE([foreign]) AC_PROG_CC AC_WITH_LTDL AC_LIBLTDL_CONVENIENCE AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL AC_CONFIG_FILES([Makefile]) AC_OUTPUT will break, because the configure script will contain something like | LIBLTDL='${top_builddir}/'/libltdlc.la instead of | LIBLTDL='${top_builddir}/''libltdl'/libltdlc.la from the expansion of LTDL_CONVENIENCE from withtin AC_WITH_LTDL, which is obviously wrong. The second expansion (directly from configure.ac) contains this same error, but I haven't found the reason (does AU_ALIAS mess with the number of macro arguments or something?). Anyway, I consider testing against $# error-prone, and bad for forward compatibility anyway (when the possible number of arguments could be greater than one), so I would like to apply this patch, which uses m4_default instead. OK for HEAD? Note that I also removed the extra single quotes around the default argument. (part of this situation is in branch-1-5 as well, but I don't want change there unless someone tells me it is necessary.) Cheers, Ralf * libltdl/m4/ltdl.m4 (LT_WITH_LTDL, LTDL_CONVENIENCE) (LTDL_INSTALLABLE): Use m4_default instead of m4_if, to cope with empty macro arguments. Use less quoting for expanded LIBLTDL, LTDLINCL Index: libltdl/m4/ltdl.m4 =================================================================== RCS file: /cvsroot/libtool/libtool/libltdl/m4/ltdl.m4,v retrieving revision 1.6 diff -u -r1.6 ltdl.m4 --- libltdl/m4/ltdl.m4 29 Aug 2005 10:47:41 -0000 1.6 +++ libltdl/m4/ltdl.m4 9 Sep 2005 11:39:27 -0000 @@ -33,7 +33,7 @@ if test "x$enable_ltdl_install" != xyes; then # If the user did not specify an installable libltdl, then default # to a convenience lib. - LTDL_CONVENIENCE([$1]) + LTDL_CONVENIENCE(m4_default([$1], [libltdl])) fi if test "x$with_included_ltdl" = xno; then @@ -48,7 +48,7 @@ AC_MSG_CHECKING([whether to use included libltdl]) AC_MSG_RESULT([$with_included_ltdl]) -AC_CONFIG_SUBDIRS(m4_if($#, 1, [$1], [libltdl])) +AC_CONFIG_SUBDIRS(m4_default([$1], [libltdl])) ])# LT_WITH_LTDL # Old name: @@ -74,8 +74,8 @@ "") enable_ltdl_convenience=yes ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; esac -LIBLTDL='${top_builddir}/'m4_if($#, 1, [$1], ['libltdl'])/libltdlc.la -LTDLINCL='-I${top_srcdir}/'m4_if($#, 1, [$1], ['libltdl']) +LIBLTDL='${top_builddir}/'m4_default([$1], [libltdl])/libltdlc.la +LTDLINCL='-I${top_srcdir}/'m4_default([$1], [libltdl]) AC_SUBST([LIBLTDL]) AC_SUBST([LTDLINCL]) @@ -114,8 +114,8 @@ ]) if test x"$enable_ltdl_install" = x"yes"; then ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL='${top_builddir}/'m4_if($#, 1, [$1], ['libltdl'])/libltdl.la - LTDLINCL='-I${top_srcdir}/'m4_if($#, 1, [$1], ['libltdl']) + LIBLTDL='${top_builddir}/'m4_default([$1], [libltdl])/libltdl.la + LTDLINCL='-I${top_srcdir}/'m4_default([$1], [libltdl]) else ac_configure_args="$ac_configure_args --enable-ltdl-install=no" LIBLTDL="-lltdl"