libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/7] libtoolize: refactor aux_dir discovery.


From: Gary V. Vaughan
Subject: [PATCH 4/7] libtoolize: refactor aux_dir discovery.
Date: Sat, 5 Nov 2011 23:43:37 +0700

* libtoolize.m4sh (require_ac_aux_dir, require_aux_dir): New
functions factored out of func_scan_files for scanning and
setting aux_dir and friends.
(func_scan_files): Remove the factored out code to scan
configure.ac with sed, and then set macro_dir appropriately.
(func_install_pkgconfig_subproject, func_install_pkgconfig_parent)
(func_install_pkgmacro_files, func_check_macros): Adjust.

Signed-off-by: Gary V. Vaughan <address@hidden>
---
 libtoolize.m4sh |  106 ++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 66 insertions(+), 40 deletions(-)

diff --git a/libtoolize.m4sh b/libtoolize.m4sh
index 591e726..cc3b4e2 100644
--- a/libtoolize.m4sh
+++ b/libtoolize.m4sh
@@ -413,10 +413,6 @@ func_scan_files ()
         s,^.*AC_REQUIRE(.*$,,; s,^.*m4@&address@hidden(.*$,,;
        s,^.*m4@&address@hidden(.*$,,
        s,^.*A[CU]_DEFUN(.*$,,; s,^.*m4@&address@hidden(.*$,,
-       /AC_CONFIG_AUX_DIR(/ {
-           s,^.*AC_CONFIG_AUX_DIR([[    ]*\([^])]*\).*$,ac_aux_dir=\1,
-           p
-        }
        /_LT_CONFIG_LTDL_DIR(/d
        /LT_CONFIG_LTDL_DIR(/ {
            s,^.*LT_CONFIG_LTDL_DIR([[   ]*\([^])]*\).*$,ac_ltdldir=\1,
@@ -519,38 +515,6 @@ func_scan_files ()
            func_fatal_error "--$ltdl_mode does not match 
LTDL_INIT($ac_ltdl_mode)"
        ;;
     esac
-
-    # ----------------- #
-    # Validate aux_dir. #
-    # ----------------- #
-
-    if test -n "$ac_aux_dir"; then
-      # If $configure_ac contains AC_CONFIG_AUX_DIR, check that it was
-      # not given in terms of a shell variable!
-      case "$ac_aux_dir" in
-      *\$*)
-        func_fatal_error "can not handle variables in AC_CONFIG_AUX_DIR"
-        ;;
-      *)
-       aux_dir=$ac_aux_dir
-       ;;
-      esac
-    else
-      # Try to discover aux_dir the same way it is discovered by configure.
-      # Note that we default to the current directory.
-      for dir in . .. ../..; do
-        if test -f "$dir/install-sh"; then
-          aux_dir=$dir
-          break
-        elif test -f "$dir/install.sh"; then
-          aux_dir="$dir"
-          break
-        fi
-      done
-    fi
-
-    # Just use the current directory if all else fails.
-    test -n "$aux_dir" || aux_dir=.
 }
 
 # func_included_files searchfile
@@ -1212,6 +1176,8 @@ func_install_pkgconfig_subproject ()
 {
     $debug_cmd
 
+    $require_aux_dir
+
     # Remove any lingering files that my have been installed by some
     # previous libtoolize release:
     $opt_force && for file in $all_pkgconfig_files; do
@@ -1223,7 +1189,7 @@ func_install_pkgconfig_subproject ()
     # user specified an aux_dir.
     $opt_quiet || if test "x$ac_aux_dir" = "x$subproject_aux_dir"; then
       pkgconfig_header="putting auxiliary files in AC_CONFIG_AUX_DIR, 
\`$subproject_aux_dir'."
-    elif test -n "$aux_dir"; then
+    else
       pkgconfig_header="putting auxiliary files in \`$aux_dir'."
     fi
 
@@ -1240,6 +1206,9 @@ func_install_pkgconfig_parent ()
 {
     $debug_cmd
 
+    $require_ac_aux_dir
+    $require_aux_dir
+
     # Remove any lingering files that my have been installed by some
     # previous libtoolize release:
     $opt_force && for file in $all_pkgconfig_files; do
@@ -1249,7 +1218,7 @@ func_install_pkgconfig_parent ()
 
     if test -n "$ac_aux_dir"; then
       pkgconfig_header="putting auxiliary files in AC_CONFIG_AUX_DIR, 
\`$ac_aux_dir'."
-    elif test -n "$aux_dir" || test "x$ltdldir" = "x."; then
+    else
       pkgconfig_header="putting auxiliary files in \`$aux_dir'."
     fi
 
@@ -1274,13 +1243,14 @@ func_install_pkgconfig_files ()
 {
     $debug_cmd
 
+    $require_aux_dir
     $require_configure_ac
 
     func_massage_pkgconfig_files
 
   # 1. Parent shares aux_dir with subproject ltdl:
     if $opt_ltdl && test "x$ltdl_mode" = "xsubproject" &&
-       test "x$ac_aux_dir" = "x$subproject_aux_dir"
+       test "x$aux_dir" = "x$subproject_aux_dir"
     then
       func_install_pkgconfig_subproject
 
@@ -1332,6 +1302,7 @@ func_check_macros ()
 
     $require_ac_macro_dir
     $require_am_macro_dir
+    $require_aux_dir
     $require_configure_ac
     $require_macro_dir
 
@@ -1488,6 +1459,32 @@ func_autoconf_configure ()
 # most, once.
 
 
+# require_ac_aux_dir
+# ------------------
+# Extract ac_aux_dir from AC_CONFIG_AUX_DIR.
+require_ac_aux_dir=func_require_ac_aux_dir
+func_require_ac_aux_dir ()
+{
+    $debug_cmd
+
+    $require_configure_ac
+
+    if test -n "$configure_ac"; then
+      func_extract_trace AC_CONFIG_AUX_DIR
+      ac_aux_dir=$func_extract_trace_result
+
+      case $ac_aux_dir in
+        *\$*)
+          func_fatal_error "\
+can not expand unknown variable in AC_CONFIG_AUX_DIR argument."
+          ;;
+      esac
+    fi
+
+    require_ac_aux_dir=:
+}
+
+
 # require_ac_macro_dir
 # --------------------
 # Extract ac_macro_dir from AC_CONFIG_MACRO_DIR.
@@ -1558,6 +1555,36 @@ func_require_am_macro_dir ()
 }
 
 
+# require_aux_dir
+# ---------------
+# Set aux_dir according to AC_CONFIG_AUX_DIR or else use the same
+# heuristics as Autoconf to intuit an appropriate setting.
+require_aux_dir=func_require_aux_dir
+func_require_aux_dir ()
+{
+    $debug_cmd
+
+    $require_ac_aux_dir
+
+    test -n "$aux_dir" || aux_dir=$ac_aux_dir
+    test -n "$aux_dir" || {
+      # Try to intuit aux_dir using the same heuristic as Autoconf.
+      for _G_dir in . .. ../..; do
+        if test -f "$_G_dir/install-sh" || test -f "$_G_dir/install.sh"
+        then
+          aux_dir=$_G_dir
+          break
+        fi
+      done
+    }
+
+    # Use the current directory if all else fails.
+    test -n "$aux_dir" || aux_dir=.
+
+    require_aux_dir=:
+}
+
+
 # require_configure_ac
 # --------------------
 # Ensure that there is a `configure.ac' or `configure.in' file in the
@@ -1645,7 +1672,6 @@ func_require_makefile_am ()
   address@hidden@
   address@hidden@
   address@hidden@
-  aux_dir=
 
   seen_libtool=false
   seen_ltdl=false
-- 
1.7.7.2

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]