Blame confdb/aclocal_subcfg.m4

Packit 0848f5
dnl PAC_RESET_ALL_FLAGS - Reset precious flags to those set by the user
Packit 0848f5
AC_DEFUN([PAC_RESET_ALL_FLAGS],[
Packit 0848f5
	if test "$FROM_MPICH" = "yes" ; then
Packit 0848f5
	   CFLAGS="$USER_CFLAGS"
Packit 0848f5
	   CPPFLAGS="$USER_CPPFLAGS"
Packit 0848f5
	   CXXFLAGS="$USER_CXXFLAGS"
Packit 0848f5
	   FFLAGS="$USER_FFLAGS"
Packit 0848f5
	   FCFLAGS="$USER_FCFLAGS"
Packit 0848f5
	   LDFLAGS="$USER_LDFLAGS"
Packit 0848f5
	   LIBS="$USER_LIBS"
Packit 0848f5
	fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl PAC_RESET_LINK_FLAGS - Reset precious link flags to those set by the user
Packit 0848f5
AC_DEFUN([PAC_RESET_LINK_FLAGS],[
Packit 0848f5
	if test "$FROM_MPICH" = "yes" ; then
Packit 0848f5
	   LDFLAGS="$USER_LDFLAGS"
Packit 0848f5
	   LIBS="$USER_LIBS"
Packit 0848f5
	fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Sandbox configure with additional arguments
Packit 0848f5
dnl Usage: PAC_CONFIG_SUBDIR_ARGS(subdir,configure-args,action-if-success,action-if-failure)
Packit 0848f5
dnl
Packit 0848f5
dnl The subconfigure argument list is created based on "ac_precious_vars"
Packit 0848f5
dnl instead of explicitly use of well-known Makefile variables, like
Packit 0848f5
dnl CC/CFLAGS/CPPFLAGS..., this generalization is effective as long as
Packit 0848f5
dnl calling configure.ac declares the needed variables to be passed down
Packit 0848f5
dnl to subconfigure as "precious" appropriately.  The precious variable
Packit 0848f5
dnl can be created in the following ways:
Packit 0848f5
dnl 1) implicit declaration through use of autoconf macros, like
Packit 0848f5
dnl    AC_PROG_CC (declares CC/CFLAGS/CPPFLAGS/LIBS/LDFLAGS), or
Packit 0848f5
dnl    AC_PROG_F77 (declares F77/FFLAGS/FLIBS) ... 
Packit 0848f5
dnl    which are in turns invoked by other subconfigure.
Packit 0848f5
dnl    When in doubt, check "ac_precious_var" in the calling configure.
Packit 0848f5
dnl 2) explicit "precious" declaration through AC_ARG_VAR.
Packit 0848f5
dnl Without correct "precious" declaration in the calling configure.ac,
Packit 0848f5
dnl there would be variables not being included in the subconfigure
Packit 0848f5
dnl argument list.
Packit 0848f5
dnl
Packit 0848f5
dnl Note: I suspect this DEFUN body is underquoted in places, but it does not
Packit 0848f5
dnl seem to cause problems in practice yet. [goodell@ 2010-05-18]
Packit 0848f5
AC_DEFUN([PAC_CONFIG_SUBDIR_ARGS],[
Packit 0848f5
        pac_dir="$1"
Packit 0848f5
        AC_MSG_NOTICE([===== configuring $1 =====])
Packit 0848f5
Packit 0848f5
	pac_abs_srcdir=`(cd $srcdir && pwd)`
Packit 0848f5
Packit 0848f5
	if test -f $pac_abs_srcdir/$1/setup ; then
Packit 0848f5
           AC_MSG_NOTICE([sourcing $pac_abs_srcdir/$1/setup])
Packit 0848f5
	   . $pac_abs_srcdir/$1/setup
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
        # Adapted for MPICH from the autoconf-2.67 implementation of
Packit 0848f5
        # AC_CONFIG_SUBDIRS.  Search for "MPICH note:" for relevant commentary and
Packit 0848f5
        # local modifications.
Packit 0848f5
      
Packit 0848f5
        # Remove --cache-file, --srcdir, and --disable-option-checking arguments
Packit 0848f5
        # so they do not pile up.  Otherwise relative paths (like --srcdir=.. from
Packit 0848f5
        # make distcheck) will be incorrect.
Packit 0848f5
        pac_sub_configure_args="$2"
Packit 0848f5
        pac_prev=
Packit 0848f5
        eval "set x $ac_configure_args"
Packit 0848f5
        shift
Packit 0848f5
        for pac_arg
Packit 0848f5
        do
Packit 0848f5
          if test -n "$pac_prev"; then
Packit 0848f5
            pac_prev=
Packit 0848f5
            continue
Packit 0848f5
          fi
Packit 0848f5
          case $pac_arg in
Packit 0848f5
          -cache-file | --cache-file | --cache-fil | --cache-fi \
Packit 0848f5
          | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
Packit 0848f5
            pac_prev=cache_file ;;
Packit 0848f5
          -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
Packit 0848f5
          | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
Packit 0848f5
          | --c=*)
Packit 0848f5
            ;;
Packit 0848f5
          --config-cache | -C)
Packit 0848f5
            ;;
Packit 0848f5
          -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
Packit 0848f5
            pac_prev=srcdir ;;
Packit 0848f5
          -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
Packit 0848f5
            ;;
Packit 0848f5
          -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
Packit 0848f5
            pac_prev=prefix ;;
Packit 0848f5
          -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
Packit 0848f5
            ;;
Packit 0848f5
          --disable-option-checking)
Packit 0848f5
            ;;
Packit 0848f5
          *)
Packit 0848f5
            # MPICH note: this is a more robust version of the "precious
Packit 0848f5
            # variable" propagation code that was present in the previous
Packit 0848f5
            # incarnation of this macro
Packit 0848f5
            for pac_pvar in $ac_precious_vars ; do
Packit 0848f5
                # check if configure argument token contains the
Packit 0848f5
                # precious variable, i.e. "name_of_prec_var=".
Packit 0848f5
                if ( echo $pac_arg | grep "^$pac_pvar=" >/dev/null 2>&1 ) ; then
Packit 0848f5
                    # check if current precious variable is set in env
Packit 0848f5
                    eval pvar_set=\${$pac_pvar+set}
Packit 0848f5
                    if test "$pvar_set" = "set" ; then
Packit 0848f5
                        # Append 'name_of_prec_var=value_of_prec_var'
Packit 0848f5
                        # to the subconfigure arguments list, where
Packit 0848f5
                        # value_of_prec_var is fetched from the env.
Packit 0848f5
                        # this also overrides any value set on the command line
Packit 0848f5
                        eval pac_pval=\${$pac_pvar}
Packit 0848f5
                        pac_arg="$pac_pvar=$pac_pval"
Packit 0848f5
                        break
Packit 0848f5
                    fi
Packit 0848f5
                fi
Packit 0848f5
            done
Packit 0848f5
            case $pac_arg in
Packit 0848f5
            *\'*) pac_arg=`AS_ECHO(["$pac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
Packit 0848f5
            esac
Packit 0848f5
            AS_VAR_APPEND([pac_sub_configure_args], [" '$pac_arg'"]) ;;
Packit 0848f5
          esac
Packit 0848f5
        done
Packit 0848f5
      
Packit 0848f5
        # Always prepend --prefix to ensure using the same prefix
Packit 0848f5
        # in subdir configurations.
Packit 0848f5
        # MPICH note: see tt#983 for an example of why this is necessary
Packit 0848f5
        pac_arg="--prefix=$prefix"
Packit 0848f5
        case $pac_arg in
Packit 0848f5
        *\'*) pac_arg=`AS_ECHO(["$pac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
Packit 0848f5
        esac
Packit 0848f5
        pac_sub_configure_args="'$pac_arg' $pac_sub_configure_args"
Packit 0848f5
      
Packit 0848f5
        # Pass --silent
Packit 0848f5
        if test "$silent" = yes; then
Packit 0848f5
          pac_sub_configure_args="--silent $pac_sub_configure_args"
Packit 0848f5
        fi
Packit 0848f5
      
Packit 0848f5
        # Always prepend --disable-option-checking to silence warnings, since
Packit 0848f5
        # different subdirs can have different --enable and --with options.
Packit 0848f5
        pac_sub_configure_args="--disable-option-checking $pac_sub_configure_args"
Packit 0848f5
      
Packit 0848f5
        pac_popdir=`pwd`
Packit 0848f5
      
Packit 0848f5
        # Do not complain, so a configure script can configure whichever
Packit 0848f5
        # parts of a large source tree are present.
Packit 0848f5
        test -d "$srcdir/$pac_dir" || continue
Packit 0848f5
      
Packit 0848f5
        # MPICH note: modified to remove the internal "_AS_*" macro usage, also
Packit 0848f5
        # msg is already printed at top
Packit 0848f5
dnl        _AS_ECHO_LOG([$pac_msg])
Packit 0848f5
dnl        _AS_ECHO([$pac_msg])
Packit 0848f5
        AS_MKDIR_P(["$pac_dir"])
Packit 0848f5
        # MPICH note: we leave this internal macro reference for now.  We can clone
Packit 0848f5
        # the macro locally if this turns out to be non-portable across several autoconf
Packit 0848f5
        # versions.  It sets the following variables: ac_builddir,
Packit 0848f5
        # ac_top_builddir_sub, ac_top_build_prefix, ac_srcdir, ac_top_srcdir,
Packit 0848f5
        # ac_abs_top_builddir, ac_abs_builddir, ac_abs_top_srcdir, ac_abs_srcdir
Packit 0848f5
        _AC_SRCDIRS(["$pac_dir"])
Packit 0848f5
Packit 0848f5
        cd "$pac_dir"
Packit 0848f5
Packit 0848f5
        # Check for guested configure; otherwise get Cygnus style configure.
Packit 0848f5
        if test -f "$ac_srcdir/configure.gnu"; then
Packit 0848f5
          pac_sub_configure=$ac_srcdir/configure.gnu
Packit 0848f5
        elif test -f "$ac_srcdir/configure"; then
Packit 0848f5
          pac_sub_configure=$ac_srcdir/configure
Packit 0848f5
        elif test -f "$ac_srcdir/configure.ac"; then
Packit 0848f5
          # This should be Cygnus configure.
Packit 0848f5
          pac_sub_configure=$ac_aux_dir/configure
Packit 0848f5
        else
Packit 0848f5
          AC_MSG_WARN([no configuration information is in $pac_dir])
Packit 0848f5
          pac_sub_configure=
Packit 0848f5
        fi
Packit 0848f5
Packit 0848f5
        # The recursion is here.
Packit 0848f5
        if test -n "$pac_sub_configure"; then
Packit 0848f5
          # MPICH note: overriding the cache file on purpose to prevent strange
Packit 0848f5
          # issues resulting from inter-dir caching
Packit 0848f5
dnl          # Make the cache file name correct relative to the subdirectory.
Packit 0848f5
dnl          case $cache_file in
Packit 0848f5
dnl          [[\\/]]* | ?:[[\\/]]* ) pac_sub_cache_file=$cache_file ;;
Packit 0848f5
dnl          *) # Relative name.
Packit 0848f5
dnl            pac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
Packit 0848f5
dnl          esac
Packit 0848f5
          pac_sub_cache_file="/dev/null"
Packit 0848f5
Packit 0848f5
          AC_MSG_NOTICE([running $SHELL $pac_sub_configure $pac_sub_configure_args --cache-file=$pac_sub_cache_file --srcdir=$ac_srcdir])
Packit 0848f5
          # The eval makes quoting arguments work.
Packit 0848f5
          # MPICH note: we want to execute the provided actions, not be silent
Packit 0848f5
          # or error out if the subconfigure succeeded/failed
Packit 0848f5
dnl          eval "\$SHELL \"\$pac_sub_configure\" $pac_sub_configure_args \
Packit 0848f5
dnl               --cache-file=\"\$pac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
Packit 0848f5
dnl            AC_MSG_ERROR([$pac_sub_configure failed for $pac_dir])
Packit 0848f5
          if eval "\$SHELL \"\$pac_sub_configure\" $pac_sub_configure_args \
Packit 0848f5
               --cache-file=\"\$pac_sub_cache_file\" --srcdir=\"\$ac_srcdir\""
Packit 0848f5
          then
Packit 0848f5
            # restore the current dir for the provided actions
Packit 0848f5
            cd "$pac_popdir"
Packit 0848f5
            $3
Packit 0848f5
          else
Packit 0848f5
            # restore the current dir for the provided actions
Packit 0848f5
            cd "$pac_popdir"
Packit 0848f5
            $4
Packit 0848f5
          fi
Packit 0848f5
        fi
Packit 0848f5
Packit 0848f5
        cd "$pac_popdir"
Packit 0848f5
Packit 0848f5
        AC_MSG_NOTICE([===== done with $1 configure =====])
Packit 0848f5
Packit 0848f5
	# Check for any localdefs files.  These may be created, so we
Packit 0848f5
	# look in the local directory first.
Packit 0848f5
	if test -f $1/localdefs ; then
Packit 0848f5
           AC_MSG_NOTICE([sourcing $1/localdefs])
Packit 0848f5
	   . $1/localdefs
Packit 0848f5
	elif test -f $pac_abs_srcdir/$1/localdefs ; then
Packit 0848f5
           AC_MSG_NOTICE([sourcing $pac_abs_srcdir/$1/localdefs])
Packit 0848f5
	   . $pac_abs_srcdir/$1/localdefs
Packit 0848f5
	fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Sandbox configure
Packit 0848f5
dnl Usage: PAC_CONFIG_SUBDIR(subdir,action-if-success,action-if-failure)
Packit 0848f5
AC_DEFUN([PAC_CONFIG_SUBDIR],[PAC_CONFIG_SUBDIR_ARGS([$1],[],[$2],[$3])])
Packit 0848f5
Packit 0848f5
dnl PAC_SUBCFG_EXPAND_SUFFIX_MACRO(MACRO_PREFIX,MACRO_PATH_SUFFIX)
Packit 0848f5
dnl converts the path given by MACRO_PATH_SUFFIX (with '/' chars in it) to one
Packit 0848f5
dnl with '_' chars in it and then appends that to MACRO_PREFIX with '_' in
Packit 0848f5
dnl between.  The resulting macro name is then expanded, but with informative
Packit 0848f5
dnl "##" comments before and after the expansion.
Packit 0848f5
dnl
Packit 0848f5
dnl This is intended to be an internal helper macro for the PAC_SUBCFG
Packit 0848f5
dnl implementation.
Packit 0848f5
dnl
Packit 0848f5
dnl XXX DJG FIXME: need to be able to deal with PREREQ macros that potentially
Packit 0848f5
dnl aren't present while having safety for BODY macros when there are
Packit 0848f5
dnl misspellings
Packit 0848f5
AC_DEFUN([PAC_SUBCFG_EXPAND_PATH_SUFFIX_MACRO],[
Packit 0848f5
dnl convert path separators into '_', the m4_translit is intentionally unquoted
Packit 0848f5
m4_pushdef([subsys_uscore_name],[$1_]m4_translit([$2],[\/],[__]))dnl
Packit 0848f5
m4_ifdef(m4_defn([subsys_uscore_name]),[],[m4_fatal([macro ]m4_defn([subsys_uscore_name])[ is undefined])])dnl
Packit 0848f5
[##] begin expansion of m4_defn([subsys_uscore_name])
Packit 0848f5
dnl call the computed routine name with the remaining args
Packit 0848f5
m4_indir(m4_defn([subsys_uscore_name]),m4_shift($@))
Packit 0848f5
dnl there is intentionally no "dnl" on the previous line to reduce the chance of
Packit 0848f5
dnl a "fi## end expansion" bug when the BODY macro doesn't end in a newline
Packit 0848f5
[##] end expansion of m4_defn([subsys_uscore_name])
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl invokes the PAC_SUBCFG_BODY_foo macro for the "foo" subsys, when "foo" is
Packit 0848f5
dnl passed as the only argument to this macro.  The first arg may be the '/'
Packit 0848f5
dnl path version instead of having underscores.
Packit 0848f5
AC_DEFUN([PAC_SUBCFG_CONFIGURE_SUBSYS],[PAC_SUBCFG_EXPAND_PATH_SUFFIX_MACRO([PAC_SUBCFG_BODY],[$1])])
Packit 0848f5
Packit 0848f5
dnl invokes the PAC_SUBCFG_PREREQ_foo macro for the "foo" subsys, when "foo" is
Packit 0848f5
dnl passed as the only argument to this macro.  The first arg may be the '/'
Packit 0848f5
dnl path version instead of having underscores.
Packit 0848f5
AC_DEFUN([PAC_SUBCFG_DO_PREREQ],[PAC_SUBCFG_EXPAND_PATH_SUFFIX_MACRO([PAC_SUBCFG_PREREQ],[$1])])
Packit 0848f5
Packit 0848f5
dnl takes no arguments, expands to "foo_bar_baz" when invoked in a file named
Packit 0848f5
dnl "foo/bar/baz/subconfigure.m4"
Packit 0848f5
dnl
Packit 0848f5
dnl This is useful for reducing copy-paste errors when defining PREREQ and BODY
Packit 0848f5
dnl macros.  If you tinker with this macro, watch the quoting carefully.
Packit 0848f5
AC_DEFUN([PAC_SUBCFG_AUTO_SUFFIX],[m4_translit(m4_bpatsubst(m4_dquote(__file__),[/[^/]+.m4],[]),[/],[_])])
Packit 0848f5