]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
reliably detect invocation of child configure (NTP_CONFIGURE_PARENT)
authorDave Hart <hart@ntp.org>
Sun, 3 May 2009 14:43:41 +0000 (14:43 +0000)
committerDave Hart <hart@ntp.org>
Sun, 3 May 2009 14:43:41 +0000 (14:43 +0000)
bk: 49fdad9d1pflbDGbNyUVlYalOSSp2w

gsoc_sntp/configure.ac
m4/ntp_cacheversion.m4
sntp/configure.ac

index dc8d5c3e8653aac6530c39a728ee646abe458f5f..b95523c4ef5fc5f50f4f21d7c61dffe5c13f2854 100644 (file)
@@ -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
index 4e961f766b9b26034d1f4205bb7c4b787cb91a54..fa5d3d8a7d7a008d9733f3d538857a344be448d0 100644 (file)
@@ -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
        ;;
      *)
index 14d2edd2652939169d21d21119653c549f35c46f..2979cb03e6833cb9c75f9573729aa079bca0fb9d 100644 (file)
@@ -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])