From: Gary V. Vaughan Date: Thu, 3 Nov 2011 17:44:08 +0000 (+0700) Subject: libtoolize: refactor macro_dir discovery around extract-trace script. X-Git-Tag: v2.4.2.418~292 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a71b02b17b6d74532b38fc4fc9db0109fa83801;p=thirdparty%2Flibtool.git libtoolize: refactor macro_dir discovery around extract-trace script. * libtoolize.m4sh (func_extract_trace): Function to call $aux_dir/extract-trace. The name and footprint are the same as the core function in the extract-trace script file so that we can choose to source that file when the option processing becomes compatible with ours. (require_ac_macro_dir, require_aclocal_amflags) (require_am_macro_dir, require_macro_dir, require_makefile_am): New functions factored out of func_scan_files for scanning and setting macro_dir and friends. (func_scan_files): Remove the factored out code to scan configure.ac with sed, and then set macro_dir appropriately. (func_serial_update_check, func_install_pkgmacro_subproject) (func_install_pkgmacro_parent, func_install_pkgmacro_files) (func_check_macros): Adjust. * tests/libtoolize.at (Subproject ltdl without GNU M4): New test to ensure `libtoolize --subproject' continues to work without a GNU M4 dependency. * NEWS: Updated. Signed-off-by: Gary V. Vaughan --- diff --git a/NEWS b/NEWS index 7b583844a..3ab789bec 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,12 @@ NEWS - list of user-visible changes between releases of GNU Libtool mode is selected; `--standalone' never worked, and is no longer accepted. +** Important incompatible changes: + + - GNU M4 is required to run libtoolize in a directory with a + `configure.ac' (or `configure.in') that needs tracing to determine + what modes and directories have been specified. + New in 2.4.2 2011-10-17: git version 2.4.1a, Libtool team: * New features: diff --git a/libtoolize.m4sh b/libtoolize.m4sh index d924e7f28..25e6cf338 100644 --- a/libtoolize.m4sh +++ b/libtoolize.m4sh @@ -366,6 +366,24 @@ func_fixup_Makefile () fi } + +# func_extract_trace macro_name [filename ...] +# set `$func_extract_trace_result' to a colon delimited list of arguments +# to MACRO_NAME in FILENAME. If no FILENAME is given, then +# `configure.ac' is assumed. +func_extract_trace () +{ + $opt_debug + + if test 1 -eq $#; then + test -n "$configure_ac" || return + set dummy "$@" "$configure_ac"; shift + fi + + func_extract_trace_result=`$extract_trace ${1+"$@"}` +} + + # func_scan_files # Scan configure.(ac|in) and aclocal.m4 (if present) for use of libltdl # and libtool. Possibly running some of these tools if necessary. @@ -399,10 +417,6 @@ func_scan_files () s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,ac_aux_dir=\1, p } - /AC_CONFIG_MACRO_DIR(/ { - s,^.*AC_CONFIG_MACRO_DIR([[ ]*\([^])]*\).*$,ac_macro_dir=\1, - p - } /_LT_CONFIG_LTDL_DIR(/d /LT_CONFIG_LTDL_DIR(/ { s,^.*LT_CONFIG_LTDL_DIR([[ ]*\([^])]*\).*$,ac_ltdldir=\1, @@ -537,46 +551,6 @@ func_scan_files () # Just use the current directory if all else fails. test -n "$aux_dir" || aux_dir=. - - - # ------------------------------ # - # Find local m4 macro directory. # - # ------------------------------ # - - # Hunt for ACLOCAL_AMFLAGS in `Makefile.am' for a `-I' argument. - - my_sed_aclocal_flags=' - /^[ ]*ACLOCAL_[A-Z_]*FLAGS[ ]*=[ ]*/ { - s,,, - q - } - d' - if test -f Makefile.am; then - my_macro_dir_is_next=false - for arg in `$SED "$my_sed_aclocal_flags" Makefile.am`; do - if $my_macro_dir_is_next; then - am_macro_dir="$arg" - break - else - case $arg in - -I) my_macro_dir_is_next=: ;; - -I*) - am_macro_dir=`$ECHO "$arg" | sed 's,^-I,,'` - break - ;; - *) my_macro_dir_is_next=false ;; - esac - fi - done - fi - - macro_dir="$ac_macro_dir" - test -z "$macro_dir" && macro_dir="$am_macro_dir" - - if test -n "$am_macro_dir" && test -n "$ac_macro_dir"; then - test "$am_macro_dir" = "$ac_macro_dir" \ - || func_fatal_error "AC_CONFIG_MACRO_DIR([$ac_macro_dir]) conflicts with ACLOCAL_AMFLAGS=-I $am_macro_dir." - fi } # func_included_files searchfile @@ -701,6 +675,8 @@ func_serial_update_check () { $debug_cmd + $require_ac_macro_dir + my_srcfile="$1" my_src_serial="$2" my_destfile="$3" @@ -1000,6 +976,8 @@ func_install_pkgmacro_subproject () { $debug_cmd + $require_macro_dir + # Remove any lingering files that my have been installed by some # previous libtoolize release: $opt_force && for file in $all_pkgmacro_files; do @@ -1028,6 +1006,9 @@ func_install_pkgmacro_parent () { $debug_cmd + $require_ac_macro_dir + $require_macro_dir + # Remove any lingering files that my have been installed by some # previous libtoolize release: $opt_force && for file in $all_pkgmacro_files; do @@ -1039,7 +1020,7 @@ func_install_pkgmacro_parent () # user specified a macro_dir. $opt_quiet || if test -n "$ac_macro_dir"; then my_pkgmacro_header="putting macros in AC_CONFIG_MACRO_DIR, \`$ac_macro_dir'." - elif test -n "$macro_dir"; then + else my_pkgmacro_header="putting macros in \`$macro_dir'." fi @@ -1077,12 +1058,16 @@ func_install_pkgmacro_files () { $debug_cmd + $require_ac_macro_dir + $require_am_macro_dir + $require_macro_dir + # argz.m4, libtool.m4 and ltdl.m4 are handled specially: func_massage_aclocal_DATA 'argz.m4|libtool.m4|ltdl.m4' # 1. Parent has separate macro_dir to subproject ltdl: if $opt_ltdl && test "x$ltdl_mode" = "xsubproject" && - test -n "$macro_dir" && test "x$macro_dir" != "x$subproject_macro_dir" + test "x$macro_dir" != "x$subproject_macro_dir" then func_install_pkgmacro_parent func_install_pkgmacro_subproject @@ -1094,7 +1079,7 @@ func_install_pkgmacro_files () func_install_pkgmacro_subproject # 3. Not a subproject, but macro_dir was specified in parent: - elif test -n "$macro_dir"; then + elif test -n "$ac_macro_dir$am_macro_dir"; then func_install_pkgmacro_parent # 4. AC_CONFIG_MACRO_DIR was not specified: @@ -1345,14 +1330,17 @@ func_check_macros () { $debug_cmd + $require_ac_macro_dir + $require_am_macro_dir $require_configure_ac + $require_macro_dir $opt_quiet && return test -n "$configure_ac" || return ac_config_macro_dir_advised=false - if test -n "$ac_macro_dir$ltdldir" && test -z "$macro_dir"; then + if test -n "$ac_macro_dir$ltdldir" && test -z "$ac_macro_dir$am_macro_dir"; then my_ac_config_macro_srcdir="$aclocaldir" if $opt_ltdl && test "$macro_dir" != "$subproject_macro_dir"; then my_ac_config_macro_srcdir="$subproject_macro_dir" @@ -1430,7 +1418,7 @@ func_check_macros () ac_config_macro_dir_advised=: fi - if test -z "$am_macro_dir$macro_dir"; then + if test -z "$am_macro_dir$ac_macro_dir"; then func_echo "Consider adding \`-I m4' to ACLOCAL_AMFLAGS in Makefile.am." elif test -z "$am_macro_dir"; then @@ -1500,6 +1488,76 @@ func_autoconf_configure () # most, once. +# require_ac_macro_dir +# -------------------- +# Extract ac_macro_dir from AC_CONFIG_MACRO_DIR. +require_ac_macro_dir=func_require_ac_macro_dir +func_require_ac_macro_dir () +{ + $debug_cmd + + $require_configure_ac + + if test -n "$configure_ac"; then + func_extract_trace AC_CONFIG_MACRO_DIR + ac_macro_dir=$func_extract_trace_result + fi + + require_ac_macro_dir=: +} + + +# require_aclocal_amflags +# ----------------------- +# Extract `$aclocal_amflags' from `Makefile.am' if present. +require_aclocal_amflags=func_require_aclocal_amflags +func_require_aclocal_amflags () +{ + $debug_cmd + + $require_makefile_am + + test -n "$makefile_am" && { + _G_sed_extract_aclocal_amflags='s|#.*$|| + /^[ ]*ACLOCAL_AMFLAGS[ ]*=/ { + s|^.*=[ ]*\(.*\)|aclocal_amflags="\1"| + p + }' + + _G_aclocal_flags_cmd=`$SED -n "$_G_sed_extract_aclocal_amflags" \ + "$makefile_am"` + eval "$_G_aclocal_flags_cmd" + + func_verbose "ACLOCAL_AMFLAGS='$aclocal_amflags'" + } + + require_aclocal_amflags=: +} + + +# require_am_macro_dir +# -------------------- +# Set am_macro_dir to the first directory specified in ACLOCAL_AMFLAGS. +require_am_macro_dir=func_require_am_macro_dir +func_require_am_macro_dir () +{ + $debug_cmd + + $require_aclocal_amflags + + _G_minus_I_seen=false + for _G_arg in $aclocal_amflags; do + case $_G_minus_I_seen,$_G_arg in + :,*) am_macro_dir=$_G_arg; break ;; + *,-I) _G_minus_I_seen=: ;; + *,-I*) am_macro_dir=`expr x$_G_opt : 'x-I\(.*\)$'`; break ;; + esac + done + + require_am_macro_dir=: +} + + # require_configure_ac # -------------------- # Ensure that there is a `configure.ac' or `configure.in' file in the @@ -1520,6 +1578,52 @@ func_require_configure_ac () } +# require_macro_dir +# ----------------- +# If both are specified, ensure both ACLOCAL_AMFLAGS and +# AC_CONFIG_MACRO_DIR agree, and set macro_dir to the value of either. +require_macro_dir=func_require_macro_dir +func_require_macro_dir () +{ + $debug_cmd + + $require_ac_macro_dir + $require_am_macro_dir + + macro_dir=$ac_macro_dir + test -n "$macro_dir" || macro_dir=$am_macro_dir + test -n "$macro_dir" || macro_dir=m4 + + if test -n "$ac_macro_dir" && test -n "$am_macro_dir"; then + test "$ac_macro_dir" = "$am_macro_dir" || func_fatal_error "\ +AC_CONFIG_MACRO_DIR([$ac_macro_dir]) conflicts with ACLOCAL_AMFLAGS=-I $am_macro_dir." + fi + + require_macro_dir=: +} + + +# require_makefile_am +# ------------------- +# If not already set, set makefile_am to `Makefile.am' if that file is +# present in the current directory. +require_makefile_am=func_require_makefile_am +func_require_makefile_am () +{ + $debug_cmd + + test -n "$makefile_am" || makefile_am=Makefile.am + + if test -f Makefile.am; then + func_verbose "found \`$makefile_am'" + else + makefile_am= + fi + + require_makefile_am=: +} + + ## ----------- ## ## Main. ## @@ -1542,7 +1646,6 @@ func_require_configure_ac () pkgltdldir=@pkgdatadir@ aclocaldir=@aclocaldir@ aux_dir= - macro_dir= seen_libtool=false seen_ltdl=false @@ -1570,6 +1673,8 @@ func_require_configure_ac () func_nonemptydir_p pkgdatadir func_nonemptydir_p aclocaldir + extract_trace=$pkgdatadir/config/extract-trace + func_scan_files case $ltdldir in diff --git a/tests/libtoolize.at b/tests/libtoolize.at index 541753b1f..77525f43c 100644 --- a/tests/libtoolize.at +++ b/tests/libtoolize.at @@ -938,6 +938,78 @@ LT_AT_CHECK_LIBTOOLIZE([--copy --install], 0, expout) AT_CLEANUP +## ------------------------------------------- ## +## Create a working subproject without GNU M4. ## +## ------------------------------------------- ## + +AT_SETUP([Subproject ltdl without GNU M4]) + +AT_DATA(expout, +[[libtoolize: putting auxiliary files in `ltdl/config'. +libtoolize: linking file `ltdl/config/compile' +libtoolize: linking file `ltdl/config/config.guess' +libtoolize: linking file `ltdl/config/config.sub' +libtoolize: linking file `ltdl/config/depcomp' +libtoolize: linking file `ltdl/config/install-sh' +libtoolize: linking file `ltdl/config/missing' +libtoolize: linking file `ltdl/config/ltmain.sh' +libtoolize: putting macros in `ltdl/m4'. +libtoolize: linking file `ltdl/m4/argz.m4' +libtoolize: linking file `ltdl/m4/libtool.m4' +libtoolize: linking file `ltdl/m4/ltdl.m4' +libtoolize: linking file `ltdl/m4/ltoptions.m4' +libtoolize: linking file `ltdl/m4/ltsugar.m4' +libtoolize: linking file `ltdl/m4/ltversion.m4' +libtoolize: linking file `ltdl/m4/lt~obsolete.m4' +libtoolize: putting libltdl files in `ltdl'. +libtoolize: linking file `ltdl/COPYING.LIB' +libtoolize: linking file `ltdl/README' +libtoolize: linking file `ltdl/Makefile.am' +libtoolize: linking file `ltdl/configure.ac' +libtoolize: copying file `ltdl/aclocal.m4' +libtoolize: linking file `ltdl/Makefile.in' +libtoolize: linking file `ltdl/config-h.in' +libtoolize: linking file `ltdl/configure' +libtoolize: linking file `ltdl/argz_.h' +libtoolize: linking file `ltdl/argz.c' +libtoolize: linking file `ltdl/loaders/dld_link.c' +libtoolize: linking file `ltdl/loaders/dlopen.c' +libtoolize: linking file `ltdl/loaders/dyld.c' +libtoolize: linking file `ltdl/loaders/load_add_on.c' +libtoolize: linking file `ltdl/loaders/loadlibrary.c' +libtoolize: linking file `ltdl/loaders/shl_load.c' +libtoolize: linking file `ltdl/lt__dirent.c' +libtoolize: linking file `ltdl/lt__strl.c' +libtoolize: linking file `ltdl/libltdl/lt__alloc.h' +libtoolize: linking file `ltdl/libltdl/lt__dirent.h' +libtoolize: linking file `ltdl/libltdl/lt__glibc.h' +libtoolize: linking file `ltdl/libltdl/lt__private.h' +libtoolize: linking file `ltdl/libltdl/lt__strl.h' +libtoolize: linking file `ltdl/libltdl/lt_dlloader.h' +libtoolize: linking file `ltdl/libltdl/lt_error.h' +libtoolize: linking file `ltdl/libltdl/lt_system.h' +libtoolize: linking file `ltdl/libltdl/slist.h' +libtoolize: linking file `ltdl/loaders/preopen.c' +libtoolize: linking file `ltdl/lt__alloc.c' +libtoolize: linking file `ltdl/lt_dlloader.c' +libtoolize: linking file `ltdl/lt_error.c' +libtoolize: linking file `ltdl/ltdl.c' +libtoolize: linking file `ltdl/ltdl.h' +libtoolize: linking file `ltdl/slist.c' +]]) + +AT_DATA([no-m4], +[[#! /bin/sh +echo 'error: do not call m4' >&2 +exit 1 +]]) +chmod a+x ./no-m4 + +AT_CHECK([PATH=`pwd`:$PATH M4=`pwd`/no-m4 $LIBTOOLIZE --ltdl=ltdl], 0, expout) + +AT_CLEANUP + + ## --------------------------- ## ## Garbled LIBTOOLIZE_OPTIONS. ## ## --------------------------- ##