root/mpich2/branches/dev/kumudb/confdb/aclocal_cache.m4
@
4870
| Revision 4870, 12.7 KB (checked in by kumudb, 5 months ago) |
|---|
| Line | |
|---|---|
| 1 | dnl |
| 2 | dnl/*D |
| 3 | dnl AC_CACHE_LOAD - Replacement for autoconf cache load |
| 4 | dnl |
| 5 | dnl Notes: |
| 6 | dnl Caching in autoconf is broken (through version 2.13). The problem is |
| 7 | dnl that the cache is read |
| 8 | dnl without any check for whether it makes any sense to read it. |
| 9 | dnl A common problem is a build on a shared file system; connecting to |
| 10 | dnl a different computer and then building within the same directory will |
| 11 | dnl lead to at best error messages from configure and at worse a build that |
| 12 | dnl is wrong but fails only at run time (e.g., wrong datatype sizes used). |
| 13 | dnl Later versions of autoconf do include some checks for changes in the |
| 14 | dnl environment that impact the choices, but still misses problems with |
| 15 | dnl multiple different systems. |
| 16 | dnl |
| 17 | dnl This fixes that by requiring the user to explicitly enable caching |
| 18 | dnl before the cache file will be loaded. |
| 19 | dnl |
| 20 | dnl To use this version of 'AC_CACHE_LOAD', you need to include |
| 21 | dnl 'aclocal_cache.m4' in your 'aclocal.m4' file. The sowing 'aclocal.m4' |
| 22 | dnl file includes this file. |
| 23 | dnl |
| 24 | dnl If no --enable-cache or --disable-cache option is selected, the |
| 25 | dnl command causes configure to keep track of the system being configured |
| 26 | dnl in a config.system file; if the current system matches the value stored |
| 27 | dnl in that file (or there is neither a config.cache nor config.system file), |
| 28 | dnl configure will enable caching. In order to ensure that the configure |
| 29 | dnl tests make sense, the values of CC, F77, F90, and CXX are also included |
| 30 | dnl in the config.system file. In addition, the value of PATH is included |
| 31 | dnl to ensure that changes in the PATH that might select a different version |
| 32 | dnl of a program with the same name (such as a native make versus gnumake) |
| 33 | dnl are detected. |
| 34 | dnl |
| 35 | dnl Bugs: |
| 36 | dnl This does not work with the Cygnus configure because the enable arguments |
| 37 | dnl are processed *after* AC_CACHE_LOAD (!). To address this, we avoid |
| 38 | dnl changing the value of enable_cache, and use real_enable_cache, duplicating |
| 39 | dnl the "notgiven" value. |
| 40 | dnl |
| 41 | dnl The environment variable CONFIGURE_DEBUG_CACHE, if set to yes, |
| 42 | dnl will cause additional data to be written out during the configure process. |
| 43 | dnl This can be helpful in debugging the cache file process. |
| 44 | dnl |
| 45 | dnl See Also: |
| 46 | dnl PAC_ARG_CACHING |
| 47 | dnl D*/ |
| 48 | define([AC_CACHE_LOAD], |
| 49 | [if test "$CONFIGURE_DEBUG_CACHE" = yes ; then |
| 50 | oldopts="$-" |
| 51 | clearMinusX=no |
| 52 | set -x |
| 53 | if test "$oldopts" != "$-" ; then |
| 54 | clearMinusX=yes |
| 55 | fi |
| 56 | fi |
| 57 | if test "X$cache_system" = "X" ; then |
| 58 | # A default file name, just in case |
| 59 | cache_system="config.system" |
| 60 | if test "$cache_file" != "/dev/null" ; then |
| 61 | # Get the directory for the cache file, if any |
| 62 | changequote(,) |
| 63 | dnl Be careful to ensure that there is no doubled slash |
| 64 | cache_system=`echo $cache_file | sed -e 's%^\(.*/\)[^/]*%\1config.system%'` |
| 65 | changequote([,]) |
| 66 | test "x$cache_system" = "x$cache_file" && cache_system="config.system" |
| 67 | # else |
| 68 | # We must *not* set enable_cache to no because we need to know if |
| 69 | # enable_cache was not set. |
| 70 | # enable_cache=no |
| 71 | fi |
| 72 | fi |
| 73 | dnl |
| 74 | dnl The "action-if-not-given" part of AC_ARG_ENABLE is not executed until |
| 75 | dnl after the AC_CACHE_LOAD is executed (!). Thus, the value of |
| 76 | dnl enable_cache if neither --enable-cache or --disable-cache is selected |
| 77 | dnl is null. Just in case autoconf ever fixes this, we test both cases. |
| 78 | dnl |
| 79 | dnl Include PATH in the cache.system file since changing the path can |
| 80 | dnl change which versions of programs are found (such as vendor make |
| 81 | dnl or GNU make). |
| 82 | dnl |
| 83 | # |
| 84 | # Get a test value and flag whether we should remove/replace the |
| 85 | # cache_system file (do so unless cache_system_ok is yes) |
| 86 | # FC and F77 should be synonyms. Save both in case |
| 87 | # We include the xxxFLAGS in case the user is using the flags to change |
| 88 | # the language (either input or output) of the compiler. E.g., |
| 89 | # using -xarch=v9 on Solaris to select 64 bit output or using -D_BSD_SOURCE |
| 90 | # with gcc to get different header files on input. |
| 91 | cleanargs=`echo "$CC $F77 $FC $CXX $F90 $CFLAGS $FFLAGS $CXXFLAGS $F90FLAGS $PATH" | tr '"' ' '` |
| 92 | if uname -srm >/dev/null 2>&1 ; then |
| 93 | cache_system_text="`uname -srm` $cleanargs" |
| 94 | else |
| 95 | cache_system_text="-no-uname- $cleanargs" |
| 96 | fi |
| 97 | cache_system_ok=no |
| 98 | # |
| 99 | if test -z "$real_enable_cache" ; then |
| 100 | real_enable_cache=$enable_cache |
| 101 | if test -z "$real_enable_cache" ; then real_enable_cache="notgiven" ; fi |
| 102 | fi |
| 103 | if test "X$real_enable_cache" = "Xnotgiven" ; then |
| 104 | # check for valid cache file |
| 105 | if test -z "$cache_system" ; then cache_system="config.system" ; fi |
| 106 | if uname -srm >/dev/null 2>&1 ; then |
| 107 | if test -f "$cache_system" -a -n "$cache_system_text" ; then |
| 108 | if test "$cache_system_text" = "`cat $cache_system`" ; then |
| 109 | real_enable_cache="yes" |
| 110 | cache_system_ok=yes |
| 111 | fi |
| 112 | elif test ! -f "$cache_system" -a -n "$cache_system_text" ; then |
| 113 | # remove the cache file because it may not correspond to our |
| 114 | # system |
| 115 | if test "$cache_file" != "/dev/null" ; then |
| 116 | rm -f $cache_file |
| 117 | fi |
| 118 | real_enable_cache="yes" |
| 119 | fi |
| 120 | fi |
| 121 | fi |
| 122 | if test "X$real_enable_cache" = "Xyes" -a "$cache_file" = "/dev/null" ; then |
| 123 | real_enable_cache=no |
| 124 | fi |
| 125 | if test "X$real_enable_cache" = "Xyes" ; then |
| 126 | if test -r "$cache_file" ; then |
| 127 | echo "loading cache $cache_file" |
| 128 | if test -w "$cache_file" ; then |
| 129 | # Clean the cache file (ergh) |
| 130 | PAC_CACHE_CLEAN |
| 131 | fi |
| 132 | . $cache_file |
| 133 | else |
| 134 | echo "Configure in `pwd` creating cache $cache_file" |
| 135 | > $cache_file |
| 136 | rm -f $cache_system |
| 137 | fi |
| 138 | else |
| 139 | cache_file="/dev/null" |
| 140 | fi |
| 141 | # Remember our location and the name of the cachefile |
| 142 | pac_cv_my_conf_dir=`pwd` |
| 143 | dnl do not include the cachefile name, since this may contain the process |
| 144 | dnl number and cause comparisons looking for changes to the cache file |
| 145 | dnl to detect a change that isn't real. |
| 146 | dnl pac_cv_my_cachefile=$cachefile |
| 147 | # |
| 148 | # Update the cache_system file if necessary |
| 149 | if test "$cache_system_ok" != yes ; then |
| 150 | if test -n "$cache_system" ; then |
| 151 | rm -f $cache_system |
| 152 | echo $cache_system_text > $cache_system |
| 153 | fi |
| 154 | fi |
| 155 | if test "$clearMinusX" = yes ; then |
| 156 | set +x |
| 157 | fi |
| 158 | ]) |
| 159 | dnl |
| 160 | dnl/*D |
| 161 | dnl PAC_ARG_CACHING - Enable caching of results from a configure execution |
| 162 | dnl |
| 163 | dnl Synopsis: |
| 164 | dnl PAC_ARG_CACHING |
| 165 | dnl |
| 166 | dnl Output Effects: |
| 167 | dnl Adds '--enable-cache' and '--disable-cache' to the command line arguments |
| 168 | dnl accepted by 'configure'. |
| 169 | dnl |
| 170 | dnl See Also: |
| 171 | dnl AC_CACHE_LOAD |
| 172 | dnl D*/ |
| 173 | dnl Add this call to the other ARG_ENABLE calls. Note that the values |
| 174 | dnl set here are redundant; the LOAD_CACHE call relies on the way autoconf |
| 175 | dnl initially processes ARG_ENABLE commands. |
| 176 | AC_DEFUN([PAC_ARG_CACHING],[ |
| 177 | AC_ARG_ENABLE(cache, |
| 178 | [--enable-cache - Turn on configure caching], |
| 179 | enable_cache="$enableval",enable_cache="notgiven") |
| 180 | ]) |
| 181 | dnl |
| 182 | |
| 183 | dnl Clean the cache of extraneous quotes that AC_CACHE_SAVE may add |
| 184 | dnl |
| 185 | AC_DEFUN([PAC_CACHE_CLEAN],[ |
| 186 | rm -f confcache |
| 187 | sed -e "s/'\\\\''//g" -e "s/'\\\\/'/" -e "s/\\\\'/'/" \ |
| 188 | -e "s/'\\\\''//g" $cache_file > confcache |
| 189 | if cmp -s $cache_file confcache ; then |
| 190 | : |
| 191 | else |
| 192 | if test -w $cache_file ; then |
| 193 | echo "updating cache $cache_file" |
| 194 | cat confcache > $cache_file |
| 195 | else |
| 196 | echo "not updating unwritable cache $cache_file" |
| 197 | fi |
| 198 | fi |
| 199 | rm -f confcache |
| 200 | if test "$DEBUG_AUTOCONF_CACHE" = "yes" ; then |
| 201 | echo "Results of cleaned cache file:" |
| 202 | echo "--------------------------------------------------------" |
| 203 | cat $cache_file |
| 204 | echo "--------------------------------------------------------" |
| 205 | fi |
| 206 | ]) |
| 207 | |
| 208 | dnl/*D |
| 209 | dnl PAC_SUBDIR_CACHE - Create a cache file before ac_output for subdirectory |
| 210 | dnl configures. |
| 211 | dnl |
| 212 | dnl Synopsis: |
| 213 | dnl PAC_SUBDIR_CACHE(when) |
| 214 | dnl |
| 215 | dnl Input Parameter: |
| 216 | dnl . when - Indicates when the cache should be created (optional) |
| 217 | dnl If 'always', create a new cache file. This option |
| 218 | dnl should be used if any of the cache parameters (such as |
| 219 | dnl CFLAGS or LDFLAGS) may have changed. |
| 220 | dnl |
| 221 | dnl Output Effects: |
| 222 | dnl |
| 223 | dnl Create a cache file before ac_output so that subdir configures don't |
| 224 | dnl make mistakes. |
| 225 | dnl We can't use OUTPUT_COMMANDS to remove the cache file, because those |
| 226 | dnl commands are executed *before* the subdir configures. |
| 227 | dnl |
| 228 | dnl D*/ |
| 229 | AC_DEFUN([PAC_SUBDIR_CACHE],[]) |
| 230 | AC_DEFUN([PAC_SUBDIR_CACHE_OLD],[ |
| 231 | if test "x$1" = "xalways" -o \( "$cache_file" = "/dev/null" -a "X$real_enable_cache" = "Xnotgiven" \) ; then |
| 232 | # Use an absolute directory to help keep the subdir configures from getting |
| 233 | # lost |
| 234 | cache_file=`pwd`/$$conf.cache |
| 235 | touch $cache_file |
| 236 | dnl |
| 237 | dnl For Autoconf 2.52+, we should ensure that the environment is set |
| 238 | dnl for the cache. Make sure that we get the values and set the |
| 239 | dnl xxx_set variables properly |
| 240 | ac_cv_env_CC_set=set |
| 241 | ac_cv_env_CC_value=$CC |
| 242 | ac_cv_env_CFLAGS_set=${CFLAGS+set} |
| 243 | ac_cv_env_CFLAGS_value=$CFLAGS |
| 244 | ac_cv_env_CPP_set=set |
| 245 | ac_cv_env_CPP_value=$CPP |
| 246 | ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} |
| 247 | ac_cv_env_CPPFLAGS_value=$CPPFLAGS |
| 248 | ac_cv_env_LDFLAGS_set=${LDFLAGS+set} |
| 249 | ac_cv_env_LDFLAGS_value=$LDFLAGS |
| 250 | ac_cv_env_LIBS_set=${LIBS+set} |
| 251 | ac_cv_env_LIBS_value=$LIBS |
| 252 | ac_cv_env_FC_set=${FS+set} |
| 253 | ac_cv_env_FC_value=$FC |
| 254 | ac_cv_env_F77_set=${F77+set} |
| 255 | ac_cv_env_F77_value=$F77 |
| 256 | ac_cv_env_F90_set=${F90+set} |
| 257 | ac_cv_env_F90_value=$F90 |
| 258 | ac_cv_env_FFLAGS_set=${FFLAGS+set} |
| 259 | ac_cv_env_FFLAGS_value=$FFLAGS |
| 260 | ac_cv_env_CXX_set=${CXX+set} |
| 261 | ac_cv_env_CXX_value=$CXX |
| 262 | |
| 263 | ac_env_CC_set=set |
| 264 | ac_env_CC_value=$CC |
| 265 | ac_env_CFLAGS_set=${CFLAGS+set} |
| 266 | ac_env_CFLAGS_value=$CFLAGS |
| 267 | ac_env_CPP_set=set |
| 268 | ac_env_CPP_value=$CPP |
| 269 | ac_env_CPPFLAGS_set=${CPPFLAGS+set} |
| 270 | ac_env_CPPFLAGS_value=$CPPFLAGS |
| 271 | ac_env_LDFLAGS_set=${LDFLAGS+set} |
| 272 | ac_env_LDFLAGS_value=$LDFLAGS |
| 273 | ac_env_LIBS_set=${LIBS+set} |
| 274 | ac_env_LIBS_value=$LIBS |
| 275 | ac_env_FC_set=${FS+set} |
| 276 | ac_env_FC_value=$FC |
| 277 | ac_env_F77_set=${F77+set} |
| 278 | ac_env_F77_value=$F77 |
| 279 | ac_env_F90_set=${F90+set} |
| 280 | ac_env_F90_value=$F90 |
| 281 | ac_env_FFLAGS_set=${FFLAGS+set} |
| 282 | ac_env_FFLAGS_value=$FFLAGS |
| 283 | ac_env_CXX_set=${CXX+set} |
| 284 | ac_env_CXX_value=$CXX |
| 285 | |
| 286 | dnl other parameters are |
| 287 | dnl build_alias, host_alias, target_alias |
| 288 | |
| 289 | # It turns out that A C CACHE_SAVE can't be invoked more than once |
| 290 | # with data that contains blanks. What happens is that the quotes |
| 291 | # that it adds get quoted and then added again. To avoid this, |
| 292 | # we strip off the outer quotes for all cached variables |
| 293 | dnl We add pac_cv_my_conf_dir to give the source of this cachefile, |
| 294 | dnl and pac_cv_my_cachefile to indicate how it chose the cachefile. |
| 295 | pac_cv_my_conf_dir=`pwd` |
| 296 | pac_cv_my_cachefile=$cachefile |
| 297 | AC_CACHE_SAVE |
| 298 | PAC_CACHE_CLEAN |
| 299 | ac_configure_args="$ac_configure_args -enable-cache" |
| 300 | fi |
| 301 | dnl Unconditionally export these values. Subdir configures break otherwise |
| 302 | export CC |
| 303 | export CFLAGS |
| 304 | export LDFLAGS |
| 305 | export LIBS |
| 306 | export CPPFLAGS |
| 307 | export CPP |
| 308 | export FC |
| 309 | export F77 |
| 310 | export F90 |
| 311 | export CXX |
| 312 | export FFLAGS |
| 313 | export CCFLAGS |
| 314 | ]) |
| 315 | AC_DEFUN([PAC_SUBDIR_CACHE_CLEANUP],[]) |
| 316 | AC_DEFUN([PAC_SUBDIR_CACHE_CLEANUP_OLD],[ |
| 317 | if test "$cache_file" != "/dev/null" -a "X$real_enable_cache" = "Xnotgiven" ; then |
| 318 | rm -f $cache_file |
| 319 | cache_file=/dev/null |
| 320 | fi |
| 321 | ]) |
| 322 | dnl |
| 323 | dnl The following three macros support the sharing of configure results |
| 324 | dnl by configure scripts, including ones that are not run with |
| 325 | dnl AC_CONFIG_SUBDIRS (the cachefiles managed by --enable-cache can |
| 326 | dnl only be used with AC_CONFIG_SUBDIRS; creating a autoconf-style |
| 327 | dnl cachefile before the the end of the autoconf process will often |
| 328 | dnl cause problems. |
| 329 | dnl |
| 330 | AC_DEFUN([PAC_CREATE_BASE_CACHE],[ |
| 331 | AC_ARG_ENABLE(base-cache, |
| 332 | [--enable-base-cache - Enable the use of a simple cache for the subsidieary |
| 333 | configure scripts.],,enable_base_cache=default) |
| 334 | # The default case is controlled by the environment variable CONF_USE_CACHEFILE |
| 335 | if test "$enable_base_cache" = "default" ; then |
| 336 | if test "$CONF_USE_CACHEFILE" = yes ; then |
| 337 | enable_base_cache=yes |
| 338 | else |
| 339 | enable_base_cache=no |
| 340 | fi |
| 341 | fi |
| 342 | if test "$enable_base_cache" != no ; then |
| 343 | if test "$enable_base_cache" = yes ; then |
| 344 | basecachefile=`pwd`/cache.base |
| 345 | else |
| 346 | basecachefile=`pwd`/$enable_base_cache |
| 347 | fi |
| 348 | set | grep ac_cv > $basecachefile |
| 349 | # Tell other configures to load this file |
| 350 | echo "Creating and exporting the base cache file $basecachefile" |
| 351 | CONF_BASE_CACHEFILE=$basecachefile |
| 352 | export CONF_BASE_CACHEFILE |
| 353 | fi |
| 354 | ]) |
| 355 | AC_DEFUN([PAC_LOAD_BASE_CACHE],[ |
| 356 | if test -n "$CONF_BASE_CACHEFILE" -a -s "$CONF_BASE_CACHEFILE" ; then |
| 357 | echo "Loading base cachefile $CONF_BASE_CACHEFILE" |
| 358 | . $CONF_BASE_CACHEFILE |
| 359 | export CONF_BASE_CACHEFILE |
| 360 | fi |
| 361 | ]) |
| 362 | AC_DEFUN([PAC_UPDATE_BASE_CACHE],[ |
| 363 | if test -n "$CONF_BASE_CACHEFILE" -a -s "$CONF_BASE_CACHEFILE" ; then |
| 364 | set | grep ac_cv > $CONF_BASE_CACHEFILE.new |
| 365 | if cmp -s $CONF_BASE_CACHEFILE.new $CONF_BASE_CACHEFILE ; then |
| 366 | : |
| 367 | else |
| 368 | echo "Replacing $CONF_BASE_CACHEFILE" |
| 369 | mv $CONF_BASE_CACHEFILE.new $CONF_BASE_CACHEFILE |
| 370 | fi |
| 371 | fi |
| 372 | ]) |
Note: See TracBrowser
for help on using the browser.
