[PATCH VTPM v9 8/8] Add conditional build of subsystems to configure.ac

Matthew Fioravante
Thu, 10 Jan 2013 23:01:07 -0000

The toplevel Makefile still works without running configure
and will default build everything

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 Makefile              |   10 +-
 config/Toplevel.mk.in |    1 +
 configure             |  576 ++++++++++++++++++++++++++++++++++++++++++++++++-
 configure.ac          |   11 +-
 m4/subsystem.m4       |   32 +++
 5 files changed, 625 insertions(+), 5 deletions(-)
 create mode 100644 config/Toplevel.mk.in
 create mode 100644 m4/subsystem.m4

diff --git a/Makefile b/Makefile
index a6ed8be..aa3c7bd 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,11 @@
 .PHONY: all
 all: dist

+-include config/Toplevel.mk
+SUBSYSTEMS?=xen kernels tools stubdom docs
+TARGS_DIST=$(patsubst %, dist-%, $(SUBSYSTEMS))
+TARGS_INSTALL=$(patsubst %, install-%, $(SUBSYSTEMS))
+
 export XEN_ROOT=$(CURDIR)
 include Config.mk

@@ -15,7 +20,7 @@ include buildconfigs/Rules.mk

 # build and install everything into the standard system directories
 .PHONY: install
-install: install-xen install-kernels install-tools install-stubdom install-docs
+install: $(TARGS_INSTALL)

 .PHONY: build
 build: kernels
@@ -37,7 +42,7 @@ test:
 # build and install everything into local dist directory
 .PHONY: dist
 dist: DESTDIR=$(DISTDIR)/install
-dist: dist-xen dist-kernels dist-tools dist-stubdom dist-docs dist-misc
+dist: $(TARGS_DIST) dist-misc

 dist-misc:
 	$(INSTALL_DIR) $(DISTDIR)/
@@ -151,6 +156,7 @@ endif
 # clean, but blow away kernel build tree plus tarballs
 .PHONY: distclean
 distclean:
+	-rm config/Toplevel.mk
 	$(MAKE) -C xen distclean
 	$(MAKE) -C tools distclean
 	$(MAKE) -C stubdom distclean
diff --git a/config/Toplevel.mk.in b/config/Toplevel.mk.in
new file mode 100644
index 0000000..4db7eaf
--- /dev/null
+++ b/config/Toplevel.mk.in
@@ -0,0 +1 @@
+SUBSYSTEMS               := @SUBSYSTEMS@
diff --git a/configure b/configure
index 3cbeea0..2c1f5bc 100755
--- a/configure
+++ b/configure
@@ -561,6 +561,12 @@ ac_default_prefix=/usr
 enable_option_checking=no
 ac_subst_vars=''LTLIBOBJS
 LIBOBJS
+SUBSYSTEMS
+docs
+stubdom
+tools
+kernels
+xen
 subdirs
 target_alias
 host_alias
@@ -603,11 +609,20 @@ SHELL''
 ac_subst_files=''''
 ac_user_opts=''
 enable_option_checking
+enable_xen
+enable_kernels
+enable_tools
+enable_stubdom
+enable_docs
 ''
       ac_precious_vars=''build_alias
 host_alias
 target_alias''
-ac_subdirs_all=''tools stubdom''
+ac_subdirs_all=''xen
+kernels
+tools
+stubdom
+docs''

 # Initialize some variables set by options.
 ac_init_help@@ -1214,6 +1229,16 @@ if test -n "$ac_init_help"; then
    esac
   cat <<\_ACEOF

+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-xen           Disable build and install of xen
+  --disable-kernels       Disable build and install of kernels
+  --disable-tools         Disable build and install of tools
+  --disable-stubdom       Disable build and install of stubdom
+  --disable-docs          Disable build and install of docs
+
 Report bugs to <xen-devel@lists.xen.org>.
 Xen Hypervisor home page: <http://www.xen.org/>.
 _ACEOF
@@ -1645,6 +1670,22 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu



+ac_config_files="$ac_config_files ./config/Toplevel.mk"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

 ac_aux_dir for ac_dir in "$srcdir" "$srcdir/.."
"$srcdir/../.."; do
@@ -1677,7 +1718,113 @@ ac_configure="$SHELL $ac_aux_dir/configure"  #
Please don''t use this var.



-subdirs="$subdirs tools stubdom"
+
+# Check whether --enable-xen was given.
+if test "${enable_xen+set}" = set; then :
+  enableval=$enable_xen;
+xen=n
+
+else
+
+xen=y
+SUBSYSTEMS="$SUBSYSTEMS xen"
+if test -e "xen/configure"; then :
+
+subdirs="$subdirs xen"
+
+
+fi
+
+fi
+
+
+
+
+# Check whether --enable-kernels was given.
+if test "${enable_kernels+set}" = set; then :
+  enableval=$enable_kernels;
+kernels=n
+
+else
+
+kernels=y
+SUBSYSTEMS="$SUBSYSTEMS kernels"
+if test -e "kernels/configure"; then :
+
+subdirs="$subdirs kernels"
+
+
+fi
+
+fi
+
+
+
+
+# Check whether --enable-tools was given.
+if test "${enable_tools+set}" = set; then :
+  enableval=$enable_tools;
+tools=n
+
+else
+
+tools=y
+SUBSYSTEMS="$SUBSYSTEMS tools"
+if test -e "tools/configure"; then :
+
+subdirs="$subdirs tools"
+
+
+fi
+
+fi
+
+
+
+
+# Check whether --enable-stubdom was given.
+if test "${enable_stubdom+set}" = set; then :
+  enableval=$enable_stubdom;
+stubdom=n
+
+else
+
+stubdom=y
+SUBSYSTEMS="$SUBSYSTEMS stubdom"
+if test -e "stubdom/configure"; then :
+
+subdirs="$subdirs stubdom"
+
+
+fi
+
+fi
+
+
+
+
+# Check whether --enable-docs was given.
+if test "${enable_docs+set}" = set; then :
+  enableval=$enable_docs;
+docs=n
+
+else
+
+docs=y
+SUBSYSTEMS="$SUBSYSTEMS docs"
+if test -e "docs/configure"; then :
+
+subdirs="$subdirs docs"
+
+
+fi
+
+fi
+
+
+
+
+


 cat >confcache <<\_ACEOF
@@ -2236,11 +2383,15 @@ on `(hostname || uname -n) 2>/dev/null | sed 1q`

 _ACEOF

+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac



 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # Files that config.status was made for.
+config_files="$ac_config_files"

 _ACEOF

@@ -2259,6 +2410,11 @@ Usage: $0 [OPTION]... [TAG]...
                    do not print progress messages
   -d, --debug      don''t remove temporary files
       --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+
+Configuration files:
+$config_files

 Report bugs to <xen-devel@lists.xen.org>.
 Xen Hypervisor home page: <http://www.xen.org/>."
@@ -2313,6 +2469,14 @@ do
     $as_echo "$ac_cs_config"; exit ;;
   --debug | --debu | --deb | --de | --d | -d )
     debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\''*) ac_optarg=`$as_echo "$ac_optarg" | sed
"s/''/''\\\\\\\\''''/g"` ;;
+    '''') as_fn_error $? "missing file argument" ;;
+    esac
+    as_fn_append CONFIG_FILES " ''$ac_optarg''"
+    ac_need_defaults=false;;
   --he | --h |  --help | --hel | -h )
     $as_echo "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
@@ -2369,12 +2533,420 @@ cat >>$CONFIG_STATUS <<\_ACEOF ||
ac_write_fail=1
 for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
+    "./config/Toplevel.mk") CONFIG_FILES="$CONFIG_FILES
./config/Toplevel.mk" ;;

   *) as_fn_error $? "invalid argument: \`$ac_config_target''"
"$LINENO" 5 ;;
   esac
 done


+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp''.
+$debug ||
+{
+  tmp+  trap ''exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr
"$tmp"; } && exit $exit_status
+'' 0
+  trap ''as_fn_exit 1'' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX")
2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ."
"$LINENO" 5
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h''.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X ''\015''`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\''\\r\''
+fi
+ac_cs_awk_cr=`$AWK ''BEGIN { print "a\rb" }''
</dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr=''\\r''
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo ''BEGIN {'' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed
''s/.*/&!$&$ac_delim/'' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO"
5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c ''^''`
+ac_delim=''%!_!# ''
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error $? "could not make $CONFIG_STATUS"
"$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c
X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_STATUS"
"$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n ''
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/''"$ac_delim"''$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+'' <conf$$subs.awk | sed ''
+/^[^""]/{
+  N
+  s/\n//
+}
+'' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = ""
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line,
len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery"
"$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip
leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub=''/^[	 ]*VPATH[	 ]*=[	 ]*/{
+h
+s///
+s/^/:/
+s/[	 ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[	 ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[	 ]*$//
+}''
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+
+eval set X "  :F $CONFIG_FILES      "
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag''"
"$LINENO" 5 ;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:''.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" &&
ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   as_fn_error 1 "cannot find input file: \`$ac_f''"
"$LINENO" 5 ;;
+      esac
+      case $ac_f in *\''*) ac_f=`$as_echo "$ac_f" | sed
"s/''/''\\\\\\\\''''/g"`;; esac
+      as_fn_append ac_file_inputs " ''$ac_f''"
+    done
+
+    # Let''s still pretend it is `configure'' which
instantiates (i.e., don''t
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input=''Generated from ''`
+	  $as_echo "$*" | sed ''s|^[^:]*/||;s|:[^:]*/|, |g''
+	`'' by configure.''
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file"
>&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed ''s/[\\\\&|]/\\\\&/g''`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file"
"$LINENO" 5  ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : ''X\(.*[^/]\)//*[^/][^/]*/*$''
\| \
+	 X"$ac_file" : ''X\(//\)[^/]'' \| \
+	 X"$ac_file" : ''X\(//\)$'' \| \
+	 X"$ac_file" : ''X\(/\)'' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed ''/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q''`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed
''s|^\.[\\/]||''`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed
''s|/[^\\/]*|/..|g;s|/||''`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen+ac_sed_dataroot=''
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p''
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"`
in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems
to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the
--datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack=''
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g'' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir'' = `.''.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f
"$tmp/subs.awk" >$tmp/out \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n ''/\${datarootdir}/p''
"$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n ''/^[	 ]*datarootdir[	 ]*:*=/p''
"$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a
reference to the variable \`datarootdir''
+which seems to be undefined.  Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable
\`datarootdir''
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out"
"$ac_file";;
+  esac \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+
+
+
+  esac
+
+done # for ac_tag
+
+
 as_fn_exit 0
 _ACEOF
 ac_clean_files=$ac_clean_files_save
diff --git a/configure.ac b/configure.ac
index 5dacb46..fcbc4ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,16 @@ AC_INIT([Xen Hypervisor], m4_esyscmd([./version.sh
./xen/Makefile]),
     [xen-devel@lists.xen.org], [xen], [http://www.xen.org/])
 AC_CONFIG_SRCDIR([./xen/common/kernel.c])
 AC_PREFIX_DEFAULT([/usr])
+AC_CONFIG_FILES([./config/Toplevel.mk])

-AC_CONFIG_SUBDIRS([tools stubdom])
+m4_include([m4/features.m4])
+m4_include([m4/subsystem.m4])
+
+AX_SUBSYSTEM_DEFAULT_ENABLE([xen])
+AX_SUBSYSTEM_DEFAULT_ENABLE([kernels])
+AX_SUBSYSTEM_DEFAULT_ENABLE([tools])
+AX_SUBSYSTEM_DEFAULT_ENABLE([stubdom])
+AX_SUBSYSTEM_DEFAULT_ENABLE([docs])
+AX_SUBSYSTEM_FINISH

 AC_OUTPUT()
diff --git a/m4/subsystem.m4 b/m4/subsystem.m4
new file mode 100644
index 0000000..d3eb8c9
--- /dev/null
+++ b/m4/subsystem.m4
@@ -0,0 +1,32 @@
+AC_DEFUN([AX_SUBSYSTEM_DEFAULT_ENABLE], [
+AC_ARG_ENABLE([$1],
+AS_HELP_STRING([--disable-$1], [Disable build and install of $1]),[
+$1=n
+],[
+$1=y
+SUBSYSTEMS="$SUBSYSTEMS $1"
+AS_IF([test -e "$1/configure"], [
+AC_CONFIG_SUBDIRS([$1])
+])
+])
+AC_SUBST($1)
+])
+
+AC_DEFUN([AX_SUBSYSTEM_DEFAULT_DISABLE], [
+AC_ARG_ENABLE([$1],
+AS_HELP_STRING([--enable-$1], [Enable build and install of $1]),[
+$1=y
+SUBSYSTEMS="$SUBSYSTEMS $1"
+AS_IF([test -e "$1/configure"], [
+AC_CONFIG_SUBDIRS([$1])
+])
+],[
+$1=n
+])
+AC_SUBST($1)
+])
+
+
+AC_DEFUN([AX_SUBSYSTEM_FINISH], [
+AC_SUBST(SUBSYSTEMS)
+])
--
1.7.10.4