Blame confdb/aclocal_cache.m4

Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl AC_CACHE_LOAD - Replacement for autoconf cache load 
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl Caching in autoconf is broken (at least through version 2.13).  
Packit 0848f5
dnl The problem is that the cache is read
Packit 0848f5
dnl without any check for whether it makes any sense to read it.
Packit 0848f5
dnl A common problem is a build on a shared file system; connecting to 
Packit 0848f5
dnl a different computer and then building within the same directory will
Packit 0848f5
dnl lead to at best error messages from configure and at worse a build that
Packit 0848f5
dnl is wrong but fails only at run time (e.g., wrong datatype sizes used).
Packit 0848f5
dnl Later versions of autoconf do include some checks for changes in the
Packit 0848f5
dnl environment that impact the choices, but still misses problems with
Packit 0848f5
dnl multiple different systems.
Packit 0848f5
dnl 
Packit 0848f5
dnl This fixes that by requiring the user to explicitly enable caching 
Packit 0848f5
dnl before the cache file will be loaded.
Packit 0848f5
dnl
Packit 0848f5
dnl To use this version of 'AC_CACHE_LOAD', you need to include
Packit 0848f5
dnl 'aclocal_cache.m4' in your 'aclocal.m4' file.  The sowing 'aclocal.m4'
Packit 0848f5
dnl file includes this file.
Packit 0848f5
dnl
Packit 0848f5
dnl If no --enable-cache or --disable-cache option is selected, the
Packit 0848f5
dnl command causes configure to keep track of the system being configured
Packit 0848f5
dnl in a config.system file; if the current system matches the value stored
Packit 0848f5
dnl in that file (or there is neither a config.cache nor config.system file),
Packit 0848f5
dnl configure will enable caching.  In order to ensure that the configure
Packit 0848f5
dnl tests make sense, the values of CC, F77, F90, and CXX are also included 
Packit 0848f5
dnl in the config.system file.  In addition, the value of PATH is included
Packit 0848f5
dnl to ensure that changes in the PATH that might select a different version
Packit 0848f5
dnl of a program with the same name (such as a native make versus gnumake)
Packit 0848f5
dnl are detected.
Packit 0848f5
dnl
Packit 0848f5
dnl Bugs:
Packit 0848f5
dnl This does not work with the Cygnus configure because the enable arguments
Packit 0848f5
dnl are processed *after* AC_CACHE_LOAD (!).  To address this, we avoid 
Packit 0848f5
dnl changing the value of enable_cache, and use real_enable_cache, duplicating
Packit 0848f5
dnl the "notgiven" value.
Packit 0848f5
dnl
Packit 0848f5
dnl The environment variable CONFIGURE_DEBUG_CACHE, if set to yes,
Packit 0848f5
dnl will cause additional data to be written out during the configure process.
Packit 0848f5
dnl This can be helpful in debugging the cache file process.
Packit 0848f5
dnl
Packit 0848f5
dnl See Also:
Packit 0848f5
dnl PAC_ARG_CACHING
Packit 0848f5
dnl D*/
Packit 0848f5
define([AC_CACHE_LOAD],
Packit 0848f5
[if test "$CONFIGURE_DEBUG_CACHE" = yes ; then 
Packit 0848f5
    oldopts="$-"
Packit 0848f5
    clearMinusX=no
Packit 0848f5
    set -x 
Packit 0848f5
    if test "$oldopts" != "$-" ; then 
Packit 0848f5
        clearMinusX=yes
Packit 0848f5
    fi
Packit 0848f5
fi 
Packit 0848f5
if test "X$cache_system" = "X" ; then
Packit 0848f5
    # A default file name, just in case
Packit 0848f5
    cache_system="config.system"
Packit 0848f5
    if test "$cache_file" != "/dev/null" ; then
Packit 0848f5
        # Get the directory for the cache file, if any
Packit 0848f5
	changequote(,)
Packit 0848f5
        dnl Be careful to ensure that there is no doubled slash
Packit 0848f5
        cache_system=`echo $cache_file | sed -e 's%^\(.*/\)[^/]*%\1config.system%'`
Packit 0848f5
	changequote([,])
Packit 0848f5
        test "x$cache_system" = "x$cache_file" && cache_system="config.system"
Packit 0848f5
#    else
Packit 0848f5
#        We must *not* set enable_cache to no because we need to know if
Packit 0848f5
#        enable_cache was not set.  
Packit 0848f5
#        enable_cache=no
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
dnl
Packit 0848f5
dnl The "action-if-not-given" part of AC_ARG_ENABLE is not executed until
Packit 0848f5
dnl after the AC_CACHE_LOAD is executed (!).  Thus, the value of 
Packit 0848f5
dnl enable_cache if neither --enable-cache or --disable-cache is selected
Packit 0848f5
dnl is null.  Just in case autoconf ever fixes this, we test both cases.
Packit 0848f5
dnl
Packit 0848f5
dnl Include PATH in the cache.system file since changing the path can
Packit 0848f5
dnl change which versions of programs are found (such as vendor make
Packit 0848f5
dnl or GNU make).
Packit 0848f5
dnl
Packit 0848f5
#
Packit 0848f5
# Get a test value and flag whether we should remove/replace the 
Packit 0848f5
# cache_system file (do so unless cache_system_ok is yes)
Packit 0848f5
# FC and F77 should be synonyms.  Save both in case
Packit 0848f5
# We include the xxxFLAGS in case the user is using the flags to change
Packit 0848f5
# the language (either input or output) of the compiler.  E.g., 
Packit 0848f5
# using -xarch=v9 on Solaris to select 64 bit output or using -D_BSD_SOURCE 
Packit 0848f5
# with gcc to get different header files on input.
Packit 0848f5
cleanargs=`echo "$CC $F77 $FC $CXX $F90 $CFLAGS $FFLAGS $CXXFLAGS $F90FLAGS $PATH" | tr '"' ' '`
Packit 0848f5
if uname -srm >/dev/null 2>&1 ; then
Packit 0848f5
    cache_system_text="`uname -srm` $cleanargs"
Packit 0848f5
else
Packit 0848f5
    cache_system_text="-no-uname- $cleanargs"
Packit 0848f5
fi
Packit 0848f5
cache_system_ok=no
Packit 0848f5
#
Packit 0848f5
if test -z "$real_enable_cache" ; then
Packit 0848f5
    real_enable_cache=$enable_cache
Packit 0848f5
    if test -z "$real_enable_cache" ; then real_enable_cache="notgiven" ; fi
Packit 0848f5
fi
Packit 0848f5
if test "X$real_enable_cache" = "Xnotgiven" ; then
Packit 0848f5
    # check for valid cache file
Packit 0848f5
    if test -z "$cache_system" ; then cache_system="config.system" ; fi
Packit 0848f5
    if uname -srm >/dev/null 2>&1 ; then
Packit 0848f5
        if test -f "$cache_system" -a -n "$cache_system_text" ; then
Packit 0848f5
	    if test "$cache_system_text" = "`cat $cache_system`" ; then
Packit 0848f5
	        real_enable_cache="yes"
Packit 0848f5
                cache_system_ok=yes
Packit 0848f5
	    fi
Packit 0848f5
        elif test ! -f "$cache_system" -a -n "$cache_system_text" ; then
Packit 0848f5
	    # remove the cache file because it may not correspond to our
Packit 0848f5
	    # system
Packit 0848f5
	    if test "$cache_file" != "/dev/null" ; then 
Packit 0848f5
	        rm -f $cache_file
Packit 0848f5
	    fi
Packit 0848f5
	    real_enable_cache="yes"
Packit 0848f5
        fi
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
if test "X$real_enable_cache" = "Xyes" -a "$cache_file" = "/dev/null" ; then
Packit 0848f5
    real_enable_cache=no
Packit 0848f5
fi
Packit 0848f5
if test "X$real_enable_cache" = "Xyes" ; then
Packit 0848f5
  if test -r "$cache_file" ; then
Packit 0848f5
    echo "loading cache $cache_file"
Packit 0848f5
    if test -w "$cache_file" ; then
Packit 0848f5
        # Clean the cache file (ergh)
Packit 0848f5
	PAC_CACHE_CLEAN
Packit 0848f5
    fi
Packit 0848f5
    . $cache_file
Packit 0848f5
  else
Packit 0848f5
    echo "Configure in `pwd` creating cache $cache_file"
Packit 0848f5
    > $cache_file
Packit 0848f5
    rm -f $cache_system
Packit 0848f5
  fi
Packit 0848f5
else
Packit 0848f5
  cache_file="/dev/null"
Packit 0848f5
fi
Packit 0848f5
# Remember our location and the name of the cachefile
Packit 0848f5
pac_cv_my_conf_dir=`pwd`
Packit 0848f5
dnl do not include the cachefile name, since this may contain the process
Packit 0848f5
dnl number and cause comparisons looking for changes to the cache file
Packit 0848f5
dnl to detect a change that isn't real.
Packit 0848f5
dnl pac_cv_my_cachefile=$cachefile
Packit 0848f5
#
Packit 0848f5
# Update the cache_system file if necessary
Packit 0848f5
if test "$cache_system_ok" != yes ; then
Packit 0848f5
    if test -n "$cache_system" ; then
Packit 0848f5
        rm -f $cache_system
Packit 0848f5
        echo $cache_system_text > $cache_system
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
if test "$clearMinusX" = yes ; then
Packit 0848f5
    set +x
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D 
Packit 0848f5
dnl PAC_ARG_CACHING - Enable caching of results from a configure execution
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_ARG_CACHING
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effects:
Packit 0848f5
dnl Adds '--enable-cache' and '--disable-cache' to the command line arguments
Packit 0848f5
dnl accepted by 'configure'.  
Packit 0848f5
dnl
Packit 0848f5
dnl See Also:
Packit 0848f5
dnl AC_CACHE_LOAD
Packit 0848f5
dnl D*/
Packit 0848f5
dnl Add this call to the other ARG_ENABLE calls.  Note that the values
Packit 0848f5
dnl set here are redundant; the LOAD_CACHE call relies on the way autoconf
Packit 0848f5
dnl initially processes ARG_ENABLE commands.
Packit 0848f5
AC_DEFUN([PAC_ARG_CACHING],[
Packit 0848f5
AC_ARG_ENABLE(cache,
Packit 0848f5
	AC_HELP_STRING([--enable-cache], [Turn on configure caching]),,
Packit 0848f5
	[enable_cache="notgiven"])
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Clean the cache of extraneous quotes that AC_CACHE_SAVE may add
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_CACHE_CLEAN],[
Packit 0848f5
    rm -f confcache
Packit 0848f5
    sed -e "s/'\\\\''//g" -e "s/'\\\\/'/" -e "s/\\\\'/'/" \
Packit 0848f5
		-e "s/'\\\\''//g" $cache_file > confcache
Packit 0848f5
    if cmp -s $cache_file confcache ; then
Packit 0848f5
        :
Packit 0848f5
    else
Packit 0848f5
        if test -w $cache_file ; then
Packit 0848f5
	    echo "updating cache $cache_file"
Packit 0848f5
            cat confcache > $cache_file
Packit 0848f5
        else
Packit 0848f5
            echo "not updating unwritable cache $cache_file"
Packit 0848f5
        fi
Packit 0848f5
    fi	
Packit 0848f5
    rm -f confcache
Packit 0848f5
    if test "$DEBUG_AUTOCONF_CACHE" = "yes" ; then
Packit 0848f5
        echo "Results of cleaned cache file:"
Packit 0848f5
	echo "--------------------------------------------------------"
Packit 0848f5
	cat $cache_file
Packit 0848f5
	echo "--------------------------------------------------------"
Packit 0848f5
    fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_SUBDIR_CACHE - Create a cache file before ac_output for subdirectory
Packit 0848f5
dnl configures.
Packit 0848f5
dnl 
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_SUBDIR_CACHE(when)
Packit 0848f5
dnl
Packit 0848f5
dnl Input Parameter:
Packit 0848f5
dnl . when - Indicates when the cache should be created (optional)
Packit 0848f5
dnl          If 'always', create a new cache file.  This option
Packit 0848f5
dnl          should be used if any of the cache parameters (such as 
Packit 0848f5
dnl          CFLAGS or LDFLAGS) may have changed.
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effects:
Packit 0848f5
dnl 	
Packit 0848f5
dnl Create a cache file before ac_output so that subdir configures don't
Packit 0848f5
dnl make mistakes. 
Packit 0848f5
dnl We can't use OUTPUT_COMMANDS to remove the cache file, because those
Packit 0848f5
dnl commands are executed *before* the subdir configures.
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_SUBDIR_CACHE],[])
Packit 0848f5
AC_DEFUN([PAC_SUBDIR_CACHE_OLD],[
Packit 0848f5
if test "x$1" = "xalways" -o \( "$cache_file" = "/dev/null" -a "X$real_enable_cache" = "Xnotgiven" \) ; then
Packit 0848f5
    # Use an absolute directory to help keep the subdir configures from getting
Packit 0848f5
    # lost
Packit 0848f5
    cache_file=`pwd`/$$conf.cache
Packit 0848f5
    touch $cache_file
Packit 0848f5
    dnl 
Packit 0848f5
    dnl For Autoconf 2.52+, we should ensure that the environment is set
Packit 0848f5
    dnl for the cache.  Make sure that we get the values and set the 
Packit 0848f5
    dnl xxx_set variables properly
Packit 0848f5
    ac_cv_env_CC_set=set
Packit 0848f5
    ac_cv_env_CC_value=$CC
Packit 0848f5
    ac_cv_env_CFLAGS_set=${CFLAGS+set}
Packit 0848f5
    ac_cv_env_CFLAGS_value=$CFLAGS
Packit 0848f5
    ac_cv_env_CPP_set=set
Packit 0848f5
    ac_cv_env_CPP_value=$CPP
Packit 0848f5
    ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
Packit 0848f5
    ac_cv_env_CPPFLAGS_value=$CPPFLAGS
Packit 0848f5
    ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
Packit 0848f5
    ac_cv_env_LDFLAGS_value=$LDFLAGS
Packit 0848f5
    ac_cv_env_LIBS_set=${LIBS+set}
Packit 0848f5
    ac_cv_env_LIBS_value=$LIBS
Packit 0848f5
    ac_cv_env_FC_set=${FC+set}
Packit 0848f5
    ac_cv_env_FC_value=$FC
Packit 0848f5
    ac_cv_env_F77_set=${F77+set}
Packit 0848f5
    ac_cv_env_F77_value=$F77
Packit 0848f5
    ac_cv_env_F90_set=${F90+set}
Packit 0848f5
    ac_cv_env_F90_value=$F90
Packit 0848f5
    ac_cv_env_FFLAGS_set=${FFLAGS+set}
Packit 0848f5
    ac_cv_env_FFLAGS_value=$FFLAGS
Packit 0848f5
    ac_cv_env_CXX_set=${CXX+set}
Packit 0848f5
    ac_cv_env_CXX_value=$CXX
Packit 0848f5
Packit 0848f5
    ac_env_CC_set=set
Packit 0848f5
    ac_env_CC_value=$CC
Packit 0848f5
    ac_env_CFLAGS_set=${CFLAGS+set}
Packit 0848f5
    ac_env_CFLAGS_value=$CFLAGS
Packit 0848f5
    ac_env_CPP_set=set
Packit 0848f5
    ac_env_CPP_value=$CPP
Packit 0848f5
    ac_env_CPPFLAGS_set=${CPPFLAGS+set}
Packit 0848f5
    ac_env_CPPFLAGS_value=$CPPFLAGS
Packit 0848f5
    ac_env_LDFLAGS_set=${LDFLAGS+set}
Packit 0848f5
    ac_env_LDFLAGS_value=$LDFLAGS
Packit 0848f5
    ac_env_LIBS_set=${LIBS+set}
Packit 0848f5
    ac_env_LIBS_value=$LIBS
Packit 0848f5
    ac_env_FC_set=${FC+set}
Packit 0848f5
    ac_env_FC_value=$FC
Packit 0848f5
    ac_env_F77_set=${F77+set}
Packit 0848f5
    ac_env_F77_value=$F77
Packit 0848f5
    ac_env_F90_set=${F90+set}
Packit 0848f5
    ac_env_F90_value=$F90
Packit 0848f5
    ac_env_FFLAGS_set=${FFLAGS+set}
Packit 0848f5
    ac_env_FFLAGS_value=$FFLAGS
Packit 0848f5
    ac_env_CXX_set=${CXX+set}
Packit 0848f5
    ac_env_CXX_value=$CXX
Packit 0848f5
Packit 0848f5
    dnl other parameters are
Packit 0848f5
    dnl build_alias, host_alias, target_alias
Packit 0848f5
Packit 0848f5
    # It turns out that A C CACHE_SAVE can't be invoked more than once
Packit 0848f5
    # with data that contains blanks.  What happens is that the quotes
Packit 0848f5
    # that it adds get quoted and then added again.  To avoid this,
Packit 0848f5
    # we strip off the outer quotes for all cached variables
Packit 0848f5
    dnl We add pac_cv_my_conf_dir to give the source of this cachefile,
Packit 0848f5
    dnl and pac_cv_my_cachefile to indicate how it chose the cachefile.
Packit 0848f5
    pac_cv_my_conf_dir=`pwd`
Packit 0848f5
    pac_cv_my_cachefile=$cachefile
Packit 0848f5
    AC_CACHE_SAVE
Packit 0848f5
    PAC_CACHE_CLEAN
Packit 0848f5
    ac_configure_args="$ac_configure_args -enable-cache"
Packit 0848f5
fi
Packit 0848f5
dnl Unconditionally export these values.  Subdir configures break otherwise
Packit 0848f5
export CC
Packit 0848f5
export CFLAGS
Packit 0848f5
export LDFLAGS
Packit 0848f5
export LIBS
Packit 0848f5
export CPPFLAGS
Packit 0848f5
export CPP
Packit 0848f5
export FC
Packit 0848f5
export F77
Packit 0848f5
export F90
Packit 0848f5
export CXX
Packit 0848f5
export FFLAGS
Packit 0848f5
export CCFLAGS
Packit 0848f5
])
Packit 0848f5
AC_DEFUN([PAC_SUBDIR_CACHE_CLEANUP],[])
Packit 0848f5
AC_DEFUN([PAC_SUBDIR_CACHE_CLEANUP_OLD],[
Packit 0848f5
if test "$cache_file" != "/dev/null" -a "X$real_enable_cache" = "Xnotgiven" ; then
Packit 0848f5
   rm -f $cache_file
Packit 0848f5
   cache_file=/dev/null
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl The following three macros support the sharing of configure results
Packit 0848f5
dnl by configure scripts, including ones that are not run with 
Packit 0848f5
dnl AC_CONFIG_SUBDIRS (the cachefiles managed by --enable-cache can
Packit 0848f5
dnl only be used with AC_CONFIG_SUBDIRS; creating a autoconf-style
Packit 0848f5
dnl cachefile before the the end of the autoconf process will often
Packit 0848f5
dnl cause problems.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_CREATE_BASE_CACHE],[
Packit 0848f5
AC_ARG_ENABLE(base-cache,
Packit 0848f5
	AC_HELP_STRING([--enable-base-cache],
Packit 0848f5
		[Enable the use of a simple cache for the subsidiary
Packit 0848f5
                 configure scripts]),,enable_base_cache=default)
Packit 0848f5
# The default case is controlled by the environment variable CONF_USE_CACHEFILE
Packit 0848f5
if test "$enable_base_cache" = "default" ; then
Packit 0848f5
    if test "$CONF_USE_CACHEFILE" = yes ; then
Packit 0848f5
        enable_base_cache=yes
Packit 0848f5
    else 
Packit 0848f5
        enable_base_cache=no
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
if test "$enable_base_cache" != no ; then
Packit 0848f5
    if test "$enable_base_cache" = yes ; then
Packit 0848f5
        basecachefile=`pwd`/cache.base
Packit 0848f5
    else
Packit 0848f5
        basecachefile=`pwd`/$enable_base_cache
Packit 0848f5
    fi
Packit 0848f5
    set | grep ac_cv > $basecachefile
Packit 0848f5
    # Tell other configures to load this file
Packit 0848f5
    echo "Creating and exporting the base cache file $basecachefile"
Packit 0848f5
    CONF_BASE_CACHEFILE=$basecachefile
Packit 0848f5
    export CONF_BASE_CACHEFILE
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
AC_DEFUN([PAC_LOAD_BASE_CACHE],[
Packit 0848f5
if test -n "$CONF_BASE_CACHEFILE" -a -s "$CONF_BASE_CACHEFILE" ; then
Packit 0848f5
    echo "Loading base cachefile $CONF_BASE_CACHEFILE"
Packit 0848f5
    . $CONF_BASE_CACHEFILE
Packit 0848f5
    export CONF_BASE_CACHEFILE
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
AC_DEFUN([PAC_UPDATE_BASE_CACHE],[
Packit 0848f5
if test -n "$CONF_BASE_CACHEFILE" -a -s "$CONF_BASE_CACHEFILE" ; then
Packit 0848f5
    set | grep ac_cv > $CONF_BASE_CACHEFILE.new
Packit 0848f5
    if cmp -s $CONF_BASE_CACHEFILE.new $CONF_BASE_CACHEFILE ; then
Packit 0848f5
	:
Packit 0848f5
    else
Packit 0848f5
	echo "Replacing $CONF_BASE_CACHEFILE"
Packit 0848f5
	mv $CONF_BASE_CACHEFILE.new $CONF_BASE_CACHEFILE
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
])