From: Gary V. Vaughan Date: Thu, 3 Nov 2011 14:45:15 +0000 (+0700) Subject: libtoolize: refactor configure_ac discovery. X-Git-Tag: v2.4.2.418~293 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6df0b275b596ef6670179bca06d4e9e96cc894c4;p=thirdparty%2Flibtool.git libtoolize: refactor configure_ac discovery. Make a start on decomposing some of the giant functions at the heart of libtoolize into the much more flexible and manageable (albeit somewhat more verbose) model of self-organising $require_ function pointers. * libtoolize.m4sh (require_configure_ac): New function factored out of func_scan_files for setting $configure_ac appropriately, implementation taken from extract-trace script. (func_autoconf_configure): And similarly for ensuring that a filename which matches something Autoconf would read also has content that appears to be destined for Autoconf processing. (func_scan_files): Simplified the factored out code to a single require_configure_ac call. (func_install_pkgconfig_files, func_check_macros): Ditto. (seen_autoconf): Removed. Signed-off-by: Gary V. Vaughan --- diff --git a/libtoolize.m4sh b/libtoolize.m4sh index 1857ad9a2..d924e7f28 100644 --- a/libtoolize.m4sh +++ b/libtoolize.m4sh @@ -376,25 +376,9 @@ func_scan_files () { $debug_cmd - # Prefer configure.ac to configure.in - test -f configure.ac && configure_ac=configure.ac - test -f "$configure_ac" || configure_ac= - - # Set local variables to reflect contents of configure.ac - my_sed_scan_configure_ac='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,; - /AC_INIT/ { - s,^.*$,seen_autoconf=:, - p - } - d' - test -z "$configure_ac" \ - || eval `$SED "$my_sed_scan_configure_ac" "$configure_ac"` - - $seen_autoconf || { - my_configure_ac= - test -n "$configure_ac" && my_configure_ac="$configure_ac: " - func_verbose "${my_configure_ac}not using Autoconf" + $require_configure_ac + test -n "$configure_ac" || { # Make sure ltdldir and ltdl_mode have sensible defaults # since we return early here: test -n "$ltdldir" || ltdldir=libltdl @@ -1305,6 +1289,8 @@ func_install_pkgconfig_files () { $debug_cmd + $require_configure_ac + func_massage_pkgconfig_files # 1. Parent shares aux_dir with subproject ltdl: @@ -1317,7 +1303,7 @@ func_install_pkgconfig_files () elif $opt_ltdl && test "x$ltdl_mode" = "xsubproject" # && test "x$aux_dir" != "x$subproject_aux_dir" is implied then - if $seen_autoconf; then + if test -n "$configure_ac"; then func_install_pkgconfig_parent fi func_install_pkgconfig_subproject @@ -1359,8 +1345,10 @@ func_check_macros () { $debug_cmd + $require_configure_ac + $opt_quiet && return - $seen_autoconf || return + test -n "$configure_ac" || return ac_config_macro_dir_advised=false @@ -1462,6 +1450,77 @@ func_check_macros () } + +## ------------------## +## Helper functions. ## +## ------------------## + +# This section contains the helper functions used by the rest of +# this script. + + +# func_autoconf_configure MAYBE-CONFIGURE-FILE +# ------------------------------------------ +# Ensure that MAYBE-CONFIGURE-FILE is the name of a file in the current +# directory which contains an uncommented call to AC_INIT. +func_autoconf_configure () +{ + $debug_cmd + + _G_sed_no_comment='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;' + _G_ac_init= + + # If we were passed a genuine file, make sure it calls AC_INIT. + test -f "$1" \ + && _G_ac_init=`$SED "$_G_sed_no_comment" "$1" |grep AC_INIT` + + # Otherwise it is not a genuine Autoconf input file. + test -n "$_G_ac_init" + _G_status=$? + + test "$_G_status" -ne 0 \ + && func_verbose "\`$1' not using Autoconf" + + (exit $_G_status) +} + + + +## -------------------- ## +## Resource management. ## +## -------------------- ## + +# This section contains definitions for functions that each ensure a +# particular resource (a file, or a non-empty configuration variable for +# example) is available, and if appropriate to extract default values +# from pertinent package files. Where a variable already has a non- +# empty value (as set by the package's `bootstrap.conf'), that value is +# used in preference to deriving the default. Call them using their +# associated `require_*' variable to ensure that they are executed, at +# most, once. + + +# require_configure_ac +# -------------------- +# Ensure that there is a `configure.ac' or `configure.in' file in the +# current directory, and that `$configure_ac' contains its name. +require_configure_ac=func_require_configure_ac +func_require_configure_ac () +{ + $debug_cmd + + test -z "$configure_ac" \ + && func_autoconf_configure configure.ac && configure_ac=configure.ac + test -z "$configure_ac" \ + && func_autoconf_configure configure.in && configure_ac=configure.in + test -z "$configure_ac" \ + || func_verbose "found \`$configure_ac'" + + require_configure_ac=: +} + + + ## ----------- ## ## Main. ## ## ----------- ## @@ -1484,9 +1543,7 @@ func_check_macros () aclocaldir=@aclocaldir@ aux_dir= macro_dir= - configure_ac=configure.in - seen_autoconf=false seen_libtool=false seen_ltdl=false