Re: Multiple subdirectories with non-similar configure needs

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

 



Hi Jim, hi Ralf, hi all,

On 03/29/2011 08:35 AM, Ralf Wildenhues wrote:
> Hello Jim,
>
> * Jim Galarowicz wrote on Mon, Mar 28, 2011 at 09:08:02PM CEST:
>> I was wondering if anyone can point me to any information on how to
>> configure from a top-level directory multiple sub-directories with
>> different configure requirements.
>
> Well, you can just write code yourself that calls the sub configure
> scripts with the arguments you intend for it.  Basically your own
> version of AC_CONFIG_SUBDIRS, if you like.

I wrote a macro (AC_CONFIG_SUBDIR_CUSTOM, patch applied) to pass
different arguments to different sub-configures. Like AC_CONFIG_SUBDIRS
it preserves
 * --cache-file
 * --silent
and passes always
 * --srcdir
 * --prefix
 * --disable-option-checking

AC_CONFIG_SUBDIR_CUSTOM takes at least two arguments, the directory
where the sub-configure resides and the additional arguments to be
passed to this specific sub-configure. An optional third parameter
controls if the sub-configure is recognized by a configure --help=recursive.


> GCC does this in its own tree (except the code is partly in the
> makefile, not only the toplevel configure script).
>
> For simple things, it often suffices to adjust $ac_configure_args during
> configure (beware of the eval quoting though!).
>
> However, you haven't written what kind of adjustments you need at all,
> so it's not clear how to help more.
>
>> My subdirectories are: libcbtf, libcbtf-xml, libcbtf-mrnet.  Each
>> subdirectory has different package requirements and has been set up
>> to use autoconf, automake, libtool, m4, etc..

Jim, you would use it like this in your toplevel configure.ac:

AC_CONFIG_SUBDIR_CUSTOM([libcbtf], [$arguments_to_libcbtf])
AC_CONFIG_SUBDIR_CUSTOM([libcbtf-xml], [$arguments_to_libcbtf-xml])
AC_CONFIG_SUBDIR_CUSTOM([libcbtf-mrnet], [$arguments_to_libcbtf-mrnet])

Cheers,
Christian

------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDirig Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------

Besuchen Sie uns auf unserem neuen Webauftritt unter www.fz-juelich.de
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 46a0341..d028ede 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -191,7 +191,7 @@ m4_define([_AC_CONFIG_DEPENDENCY_DEFAULT],
 
 # _AC_CONFIG_UNIQUE(MODE, DEST)
 # -----------------------------
-# MODE is `FILES', `HEADERS', `LINKS', `COMMANDS', or `SUBDIRS'.
+# MODE is `FILES', `HEADERS', `LINKS', `COMMANDS', `SUBDIRS' or CONFIG_SUBDIR_CUSTOM.
 #
 # Verify that there is no double definition of an output file.
 #
@@ -1097,7 +1097,7 @@ m4_define([AC_OUTPUT_COMMANDS_POST])
 AC_DEFUN([AC_CONFIG_SUBDIRS],
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])]dnl
 [AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])]dnl
-[m4_map_args_w([$1], [_AC_CONFIG_UNIQUE([SUBDIRS],
+[m4_map_args_w([$1], [_AC_CONFIG_UNIQUE([SUBDIRS or CONFIG_SUBDIR_CUSTOM],
   _AC_CONFIG_COMPUTE_DEST(], [))])]dnl
 [m4_append([_AC_LIST_SUBDIRS], [$1], [
 ])]dnl
@@ -1106,6 +1106,41 @@ AC_DEFUN([AC_CONFIG_SUBDIRS],
 [AC_SUBST([subdirs], ["$subdirs m4_normalize([$1])"])])
 
 
+# AC_CONFIG_SUBDIR_CUSTOM(DIR, ARGUMENTS [, DISABLE_HELP_RECURSIVE])
+# ------------------------------------------------------------------
+# Build a list custom_subdirs of tuples (DIR, ARGUMENTS) where DIR is
+# unique in _AC_LIST_CUSTOM_SUBDIRS and _AC_LIST_SUBDIRS. This list is used in
+# _AC_OUTPUT_SUBDIRS to invoke nested configures in directory DIR with
+# arguments ARGUMENTS. The arguments are modified as in the AC_CONFIG_SUBDIRS
+# case, see _AC_SUB_CONFIGURE_ARGS. If the third argument
+# DISABLE_HELP_RECURSIVE is given, configure --help=recursive will omit DIR.
+AC_DEFUN([AC_CONFIG_SUBDIR_CUSTOM],
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])]dnl
+[AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])]dnl
+[m4_foreach_w([_AC_Sub], [$1],
+	      [_AC_CONFIG_UNIQUE([SUBDIRS or CONFIG_SUBDIR_CUSTOM],
+                                 m4_bpatsubst(m4_defn([_AC_Sub]), [:.*]))])]dnl
+
+# build a list of (directory,arguments) tuples that will be processed in _AC_OUTPUT_SUBDIRS
+[if test -z "$custom_subdirs"; then
+  custom_subdirs="custom_sub_configure_dir=\"m4_normalize([$1])\";custom_sub_configure_args=\"m4_normalize([$2])\""
+else
+  custom_subdirs="$custom_subdirs|custom_sub_configure_dir=\"m4_normalize([$1])\";custom_sub_configure_args=\"m4_normalize([$2])\""
+fi]
+
+# per default, enable --help=recursive in directory $1.
+[m4_ifval([$3], 
+          [], 
+          [m4_append([_AC_LIST_SUBDIRS], [$1], [
+])dnl
+])]dnl
+[AS_LITERAL_IF([$1], [],
+	       [AC_DIAGNOSE([syntax], [$0: you should use literals])])]dnl
+[AC_SUBST([subdirs_custom], ["$subdirs_custom m4_normalize([$1])"])]dnl
+)
+# AC_CONFIG_SUBDIR_CUSTOM
+
+
 # _AC_OUTPUT_SUBDIRS
 # ------------------
 # This is a subroutine of AC_OUTPUT, but it does not go into
@@ -1116,12 +1151,50 @@ m4_define([_AC_OUTPUT_SUBDIRS],
 # CONFIG_SUBDIRS section.
 #
 if test "$no_recursion" != yes; then
+  ac_popdir=`pwd`
+
+  # call configures in list $custom_subdirs with directory-specific arguments.
+  OIFS=$IFS
+  IFS='|'
+  list=$custom_subdirs
+  for dir_and_args in $list; do
+    IFS=$OIFS
+    eval $dir_and_args
+    if test "x$custom_sub_configure_dir" = x; then continue; fi
+    ac_custom_sub_configure_args=
+    _AC_SUB_CONFIGURE_ARGS([$custom_sub_configure_args], 
+                           [ac_custom_sub_configure_args])
+    _AC_SUB_CONFIGURE([$custom_sub_configure_dir], 
+                      [$ac_custom_sub_configure_args])
+    cd "$ac_popdir"
+    IFS='|'
+  done
+  IFS=$OIFS  
+
+  # call configures in $subdirs with fixed arguments.
+  ac_sub_configure_args=
+  _AC_SUB_CONFIGURE_ARGS([$ac_configure_args], 
+                         [ac_sub_configure_args])
+  for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
+     echo "ac_dir(inside): $ac_dir"
+    _AC_SUB_CONFIGURE([$ac_dir], 
+                      [$ac_sub_configure_args])
+    cd "$ac_popdir"
+  done
+fi
+])# _AC_OUTPUT_SUBDIRS
 
+
+# _AC_SUB_CONFIGURE_ARGS(ARGUMENTS_IN, ARGUMENTS_OUT)
+# ---------------------------------------------------
+# Create ARGUMENTS_OUT from ARGUMENTS_IN for use in nested configure calls.
+m4_define([_AC_SUB_CONFIGURE_ARGS],
+[
   # Remove --cache-file, --srcdir, and --disable-option-checking arguments
   # so they do not pile up.
   ac_sub_configure_args=
   ac_prev=
-  eval "set x $ac_configure_args"
+  eval "set x $1"
   shift
   for ac_arg
   do
@@ -1153,7 +1226,7 @@ if test "$no_recursion" != yes; then
       case $ac_arg in
       *\'*) ac_arg=`AS_ECHO(["$ac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
       esac
-      AS_VAR_APPEND([ac_sub_configure_args], [" '$ac_arg'"]) ;;
+      AS_VAR_APPEND([$2], [" '$ac_arg'"]) ;;
     esac
   done
 
@@ -1163,66 +1236,68 @@ if test "$no_recursion" != yes; then
   case $ac_arg in
   *\'*) ac_arg=`AS_ECHO(["$ac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
   esac
-  ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
+  $2="'$ac_arg' $$2"
 
   # Pass --silent
   if test "$silent" = yes; then
-    ac_sub_configure_args="--silent $ac_sub_configure_args"
+    $2="--silent $$2"
   fi
 
   # Always prepend --disable-option-checking to silence warnings, since
   # different subdirs can have different --enable and --with options.
-  ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"
+  $2="--disable-option-checking $$2"
+])# _AC_SUB_CONFIGURE_ARGS
 
-  ac_popdir=`pwd`
-  for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
 
-    # Do not complain, so a configure script can configure whichever
-    # parts of a large source tree are present.
-    test -d "$srcdir/$ac_dir" || continue
-
-    ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
-    _AS_ECHO_LOG([$ac_msg])
-    _AS_ECHO([$ac_msg])
-    AS_MKDIR_P(["$ac_dir"])
-    _AC_SRCDIRS(["$ac_dir"])
-
-    cd "$ac_dir"
-
-    # Check for guested configure; otherwise get Cygnus style configure.
-    if test -f "$ac_srcdir/configure.gnu"; then
-      ac_sub_configure=$ac_srcdir/configure.gnu
-    elif test -f "$ac_srcdir/configure"; then
-      ac_sub_configure=$ac_srcdir/configure
-    elif test -f "$ac_srcdir/configure.in"; then
-      # This should be Cygnus configure.
-      ac_sub_configure=$ac_aux_dir/configure
-    else
-      AC_MSG_WARN([no configuration information is in $ac_dir])
-      ac_sub_configure=
-    fi
-
-    # The recursion is here.
-    if test -n "$ac_sub_configure"; then
-      # Make the cache file name correct relative to the subdirectory.
-      case $cache_file in
-      [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
-      *) # Relative name.
-	ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
-      esac
-
-      AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
-      # The eval makes quoting arguments work.
-      eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
-	   --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
-	AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
-    fi
+# _AC_SUB_CONFIGURE(DIR, ARGUMENTS)
+# ---------------------------------
+# Call nested configure in DIR with arguments ARGUMENTS.
+m4_define([_AC_SUB_CONFIGURE],
+[
+  sub_configure_dir=$1
+  sub_configure_args=$2
+
+  # Do not complain, so a configure script can configure whichever
+  # parts of a large source tree are present.
+  test -d "$srcdir/$sub_configure_dir" || continue
+
+  ac_msg="=== configuring in $sub_configure_dir (`pwd`/$sub_configure_dir)"
+  _AS_ECHO_LOG([$ac_msg])
+  _AS_ECHO([$ac_msg])
+  AS_MKDIR_P(["$sub_configure_dir"])
+  _AC_SRCDIRS(["$sub_configure_dir"])
+
+  cd "$sub_configure_dir"
+
+  # Check for guested configure; otherwise get Cygnus style configure.
+  if test -f "$ac_srcdir/configure.gnu"; then
+    ac_sub_configure=$ac_srcdir/configure.gnu
+  elif test -f "$ac_srcdir/configure"; then
+    ac_sub_configure=$ac_srcdir/configure
+  elif test -f "$ac_srcdir/configure.in"; then
+    # This should be Cygnus configure.
+    ac_sub_configure=$ac_aux_dir/configure
+  else
+    AC_MSG_WARN([no configuration information is in $sub_configure_dir])
+    ac_sub_configure=
+  fi
 
-    cd "$ac_popdir"
-  done
-fi
-])# _AC_OUTPUT_SUBDIRS
+  # The recursion is here.
+  if test -n "$ac_sub_configure"; then
+    # Make the cache file name correct relative to the subdirectory.
+    case $cache_file in
+    [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
+    *) # Relative name.
+      ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
+    esac
 
+    AC_MSG_NOTICE([running $SHELL $ac_sub_configure $sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
+    # The eval makes quoting arguments work.
+    eval "\$SHELL \"\$ac_sub_configure\" $sub_configure_args \
+	 --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
+      AC_MSG_ERROR([$ac_sub_configure failed for $sub_configure_dir])
+  fi
+])# _AC_SUB_CONFIGURE
 
 
 
@@ -1304,7 +1379,10 @@ if test "$no_create" != yes; then
   $ac_cs_success || AS_EXIT([1])
 fi
 dnl config.status should not do recursion.
-AC_PROVIDE_IFELSE([AC_CONFIG_SUBDIRS], [_AC_OUTPUT_SUBDIRS()])dnl
+AC_PROVIDE_IFELSE([AC_CONFIG_SUBDIRS], 
+                  [_AC_OUTPUT_SUBDIRS()],
+                  [AC_PROVIDE_IFELSE([AC_CONFIG_SUBDIR_CUSTOM],
+                                     [_AC_OUTPUT_SUBDIRS()])])dnl
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
   AC_MSG_WARN([unrecognized options: $ac_unrecognized_opts])
 fi
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux