From: Dave Hart Date: Sun, 3 May 2009 14:43:41 +0000 (+0000) Subject: reliably detect invocation of child configure (NTP_CONFIGURE_PARENT) X-Git-Tag: NTP_4_2_5P171~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=443d521e985e5f765029d19ac4d627748f606445;p=thirdparty%2Fntp.git reliably detect invocation of child configure (NTP_CONFIGURE_PARENT) bk: 49fdad9d1pflbDGbNyUVlYalOSSp2w --- diff --git a/gsoc_sntp/configure.ac b/gsoc_sntp/configure.ac index dc8d5c3e8..b95523c4e 100644 --- a/gsoc_sntp/configure.ac +++ b/gsoc_sntp/configure.ac @@ -16,6 +16,16 @@ sntp_configure_cache_version=0 # When the version of config.cache and configure do not # match, NTP_CACHEVERSION will flush the cache. +# $NTP_CONFIGURE_PARENT is used to detect the top-level configure in +# NTP_CACHEVERSION. It is set to an empty string to indicate "known to +# have no parent" while unset indicates no knowledge. Just before +# AC_CONFIG_SUBDIRS in NTP's main configure.ac, NTP_CONFIGURE_PARENT +# is set to top. In all NTP configure.ac files, we set it to NULL +# if it is unset, so NTP_CACHE_VERSION does not rely on a heuristic. + +case "${NTP_CONFIGURE_PARENT=}" in +esac + NTP_CACHEVERSION([sntp], [$sntp_configure_cache_version]) AM_INIT_AUTOMAKE diff --git a/m4/ntp_cacheversion.m4 b/m4/ntp_cacheversion.m4 index 4e961f766..fa5d3d8a7 100644 --- a/m4/ntp_cacheversion.m4 +++ b/m4/ntp_cacheversion.m4 @@ -33,29 +33,56 @@ AC_DEFUN_ONCE([NTP_CACHEVERSION], [ '') # No cache, predates ntp_cv_$1_cache_version, or is empty. case "$cache_file" in - ../*) - # Parent configure will have cleared cache once already. - # This will misfire if a top-level configure is invoked - # with --config-cache= value beginning with '../', is - # there a better way to detect this configure was - # invoked by a parent directory configure? - ntp_cache_flush=0 - ;; /dev/null) ntp_cache_flush=0 ;; *) - # This appears to be the top-level configure file. - # Do not clear the cache immediately after it is created - # empty as it is noisy. Differentiate a newly-created - # config.cache from one predating the cache version - # mechanism by looking for the first cached variable set - # by Autoconf - case "$ac_cv_path_install" in + # Is this the top-level configure, or a child invoked + # by a parent via AC_CONFIG_SUBDIRS? There is no + # reliable general way to say, so we use a variable + # NTP_CONFIGURE_PARENT set to an empty string early + # in our top-level configure.ac and then set to the + # simple flag value 'top' before AC_CONFIG_SUBDIRS. + # Assuming only two levels of configure.ac files, + # only the parent has to manage AC_CONFIG_PARENT. + case "${NTP_CONFIGURE_PARENT-varnotset}" in '') - # presumably empty config.cache file - ntp_cache_flush=0 + ntp_top_configure=1 + ;; + varnotset) + # without a clear indication from NTP_CONFIGURE_PARENT + # heuristically assume we are a child configure if our + # cache file path begins with ../ + case "$cache_file" in + ../*) + ntp_top_configure=0 + ;; + *) + ntp_top_configure=1 + esac + ;; + *) + ntp_top_configure=0; + esac + case "$ntp_top_configure" in + 1) + # Do not clear the cache immediately after it is created + # empty as it is noisy. Differentiate a newly-created + # config.cache from one predating the cache version + # mechanism by looking for the first cached variable set + # by Autoconf + case "$ac_cv_path_install" in + '') + # empty config.cache file + ntp_cache_flush=0 + esac + ;; + 0) + # Parent configure just created cache from empty, + # flushing would be counterproductive. + ntp_cache_flush=0; esac + $as_unset ntp_top_configure esac ;; *) diff --git a/sntp/configure.ac b/sntp/configure.ac index 14d2edd26..2979cb03e 100644 --- a/sntp/configure.ac +++ b/sntp/configure.ac @@ -14,6 +14,16 @@ msntp_configure_cache_version=0 # When the version of config.cache and configure do not # match, NTP_CACHEVERSION will flush the cache. +# $NTP_CONFIGURE_PARENT is used to detect the top-level configure in +# NTP_CACHEVERSION. It is set to an empty string to indicate "known to +# have no parent" while unset indicates no knowledge. Just before +# AC_CONFIG_SUBDIRS in NTP's main configure.ac, NTP_CONFIGURE_PARENT +# is set to top. In all NTP configure.ac files, we set it to NULL +# if it is unset, so NTP_CACHE_VERSION does not rely on a heuristic. + +case "${NTP_CONFIGURE_PARENT=}" in +esac + NTP_CACHEVERSION([msntp], [$msntp_configure_cache_version]) AM_INIT_AUTOMAKE([msntp],[1.6])