1 # NTP_CACHEVERSION(component, version)
2 # ------------------------------------
3 # compare this configure script's cache version stamp with the stamp
4 # saved by the prior run in config.cache. If they differ, clear all
5 # cache variables to avoid using results cached with a script that
6 # is known to differ in a cache-invalidating manner.
8 # Note: use immediately following AC_INIT in configure.ac, as clearing
9 # all _cv_ variables only makes sense immediately after loading, before
10 # use or modification.
12 # It is assumed that parent configure.ac files which use
13 # AC_CONFIG_SUBDIR to invoke child configure.ac files have used
14 # NTP_CACHEVERSION if any children do. The top-level configure script
15 # will clear a previous cache lacking any saved cache version number,
16 # while children do not. The reason is the children can rely on the
17 # parent having cleared any cache variables predating this mechanism.
18 # Therefore the child can rely on the config.cache generated by the
19 # parent on the first run despite not finding its version stamp
20 # previously saved. In this case top-level means a configure script
21 # not invoked by another configure script in its parent directory.
23 AC_DEFUN_ONCE([NTP_CACHEVERSION], [
24 AC_BEFORE([$0], [AM_INIT_AUTOMAKE])dnl
25 AC_BEFORE([$0], [AM_CONFIG_HEADER])dnl
26 AC_BEFORE([$0], [AC_PROG_CC])dnl
27 AC_BEFORE([$0], [AC_CONFIG_SUBDIRS])dnl
31 case "$ntp_cv_[$1]_cache_version" in
37 # No cache, predates ntp_cv_$1_cache_version, or is empty.
43 case "$NTP_CACHEVERSION_PARENT" in
45 # Do not clear the cache immediately after it is created
46 # empty as it is noisy. Differentiate a newly-created
47 # config.cache from one predating the cache version
48 # mechanism by looking for the first cached variable set
50 case "$ac_cv_path_install" in
52 # empty config.cache file
57 # Parent configure just created cache from empty,
58 # flushing would be counterproductive.
64 # configure cache version mismatches config.cache version
67 case "$ntp_cache_flush" in
69 c_version="${ntp_cv_[$1]_cache_version:-(no version found)}"
71 # Do we flush all variables or exclude others' version stamps?
73 case "$NTP_CACHEVERSION_PARENT" in
75 # Clear all *_cv_* variables including our child subdirs'
76 # ntp_cv_*_cache_version variables. This prevents subdir
77 # configure scripts from noticing a version mismatch just
78 # after the top configure in the invocation cleared and
79 # recreated the cache.
82 sed -n -e 's/=.*$//' \
87 # This is not the top configure this particular invocation.
88 # Clear all *_cv_* variables sparing the version stamps
89 # of other configure scripts, so we don't trigger
90 # useless repeated clearings.
93 sed -n -e 's/=.*$//' \
94 -e '/ntp_cv_.*_cache_version/d' \
99 for c_varname in $c_varname_list
101 dnl use AS_UNSET([$c_varname]) eventually
102 eval ${c_varname}=; $as_unset $c_varname
105 dnl use AS_UNSET([c_varname_list c_varname]) eventually
106 c_varname_list=; $as_unset c_varname_list c_varname
108 AC_MSG_NOTICE([[$cache_file saved by another version, ignored.]])
109 AC_MSG_NOTICE([[configure script cache version: ]][$2])
110 AC_MSG_NOTICE([[$cache_file version: $c_version]])
114 # save configure version in config.cache for next time
115 ntp_cv_[$1]_cache_version="[$2]"
117 $as_unset ntp_cache_flush
119 # let any subdir configure.ac NTP_CACHEVERSION invocations
120 # know they are not the top level.
121 NTP_CACHEVERSION_PARENT='[$1]' ; export NTP_CACHEVERSION_PARENT