8188768: Fix interaction between make and autoconf after consolidation
authorihse
Thu, 05 Oct 2017 11:02:18 +0200
changeset 47313 eb28be8f935d
parent 47312 d4f959806fe9
child 47314 743814386712
8188768: Fix interaction between make and autoconf after consolidation Reviewed-by: erikj, tbell
make/Init.gmk
make/InitSupport.gmk
make/autoconf/autogen.sh
make/autoconf/configure
--- a/make/Init.gmk	Wed Oct 04 10:54:18 2017 -0700
+++ b/make/Init.gmk	Thu Oct 05 11:02:18 2017 +0200
@@ -137,15 +137,16 @@
 
     # The spec files depend on the autoconf source code. This check makes sure
     # the configuration is up to date after changes to configure.
-    CUSTOM_CONFIG_DIR ?= $(topdir)/closed/autoconf
-
-    $(SPECS): $(wildcard $(topdir)/common/autoconf/*) $(wildcard $(CUSTOM_CONFIG_DIR)/*)
+    $(SPECS): $(wildcard $(topdir)/make/autoconf/*) \
+            $(if $(CUSTOM_CONFIG_DIR), $(wildcard $(CUSTOM_CONFIG_DIR)/*))
         ifeq ($(CONF_CHECK), fail)
-	  @echo "Error: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'."
+	  @echo Error: The configuration is not up to date for \
+	      "'$(lastword $(subst /, , $(dir $@)))'."
 	  $(call PrintConfCheckFailed)
 	  @exit 2
         else ifeq ($(CONF_CHECK), auto)
-	  @echo "Note: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'."
+	  @echo Note: The configuration is not up to date for \
+	      "'$(lastword $(subst /, , $(dir $@)))'."
 	  @( cd $(topdir) && \
 	      $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -f $(topdir)/make/Init.gmk \
 	      SPEC=$@ HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
@@ -266,6 +267,7 @@
 	  $(ECHO) "Re-running configure using default settings"
         endif
 	( cd $(OUTPUTDIR) && PATH="$(ORIGINAL_PATH)" \
+	    CUSTOM_CONFIG_DIR="$(CUSTOM_CONFIG_DIR)" \
 	    $(BASH) $(CONFIGURE_CMD) $(CONFIGURE_COMMAND_LINE) )
 
   ##############################################################################
--- a/make/InitSupport.gmk	Wed Oct 04 10:54:18 2017 -0700
+++ b/make/InitSupport.gmk	Thu Oct 05 11:02:18 2017 +0200
@@ -35,8 +35,9 @@
 ifeq ($(HAS_SPEC),)
 
   # Include the corresponding closed file, if present.
-  # Normal hook mechanism cannot be used since we have no SPEC.
-  -include $(topdir)/../closed/make/InitSupport.gmk
+  ifneq ($(CUSTOM_MAKE_DIR), )
+    -include $(CUSTOM_MAKE_DIR)/InitSupport.gmk
+  endif
 
   ##############################################################################
   # Helper functions for the initial part of Init.gmk, before the spec file is
--- a/make/autoconf/autogen.sh	Wed Oct 04 10:54:18 2017 -0700
+++ b/make/autoconf/autogen.sh	Thu Oct 05 11:02:18 2017 +0200
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -52,15 +52,6 @@
   TIMESTAMP=`date +%s`
 fi
 
-if test "x$CUSTOM_CONFIG_DIR" = "x"; then
-  topdir=`cd $script_dir/../..  >/dev/null && pwd`
-  custom_script_dir="$topdir/closed/autoconf"
-else
-  custom_script_dir=$CUSTOM_CONFIG_DIR
-fi
-
-custom_hook=$custom_script_dir/custom-hook.m4
-
 AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"
 
 if test "x${AUTOCONF}" = x; then
@@ -75,11 +66,16 @@
 echo "Generating generated-configure.sh"
 generate_configure_script "$script_dir/generated-configure.sh" 'cat'
 
-if test -e $custom_hook; then
+if test "x$CUSTOM_CONFIG_DIR" != "x"; then
+  custom_hook=$CUSTOM_CONFIG_DIR/custom-hook.m4
+  if test ! -e $custom_hook; then
+    echo "CUSTOM_CONFIG_DIR set but $CUSTOM_CONFIG_DIR/custom-hook.m4 not present"
+    echo "Error: Cannot continue" 1>&2
+    exit 1
+  fi
+
   # We have custom sources available; also generate configure script
   # with custom hooks compiled in.
   echo "Generating custom generated-configure.sh"
-  generate_configure_script "$custom_script_dir/generated-configure.sh" 'sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
-else
-  echo "(No custom hook found at $custom_hook)"
+  generate_configure_script "$CUSTOM_CONFIG_DIR/generated-configure.sh" 'sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
 fi
--- a/make/autoconf/configure	Wed Oct 04 10:54:18 2017 -0700
+++ b/make/autoconf/configure	Thu Oct 05 11:02:18 2017 +0200
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -46,10 +46,12 @@
 
 conf_script_dir="$TOPDIR/make/autoconf"
 
-if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
-  conf_custom_script_dir="$TOPDIR/closed/autoconf"
-else
-  conf_custom_script_dir="$CUSTOM_CONFIG_DIR"
+if test "x$CUSTOM_CONFIG_DIR" != x; then
+  if test ! -e $CUSTOM_CONFIG_DIR/generated-configure.sh; then
+    echo "CUSTOM_CONFIG_DIR not pointing to a proper custom config dir."
+    echo "Error: Cannot continue" 1>&2
+    exit 1
+  fi
 fi
 
 ###
@@ -76,10 +78,10 @@
     fi
   done
 
-  if test -e $conf_custom_script_dir/generated-configure.sh; then
+  if test "x$CUSTOM_CONFIG_DIR" != x; then
     # If custom source configure is available, make sure it is up-to-date as well.
-    for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $conf_custom_script_dir/*.m4; do
-      if test $file -nt $conf_custom_script_dir/generated-configure.sh; then
+    for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $CUSTOM_CONFIG_DIR/*.m4; do
+      if test $file -nt $CUSTOM_CONFIG_DIR/generated-configure.sh; then
         echo "Warning: The configure source files is newer than the custom generated files."
         run_autogen_or_fail
       fi
@@ -93,11 +95,9 @@
     if test "x$conf_updated_autoconf_files" != x; then
       echo "Configure source code has been updated, checking time stamps"
       check_autoconf_timestamps
-    fi
-
-    if test -e $conf_custom_script_dir; then
+    elif test "x$CUSTOM_CONFIG_DIR" != x; then
       # If custom source configure is available, make sure it is up-to-date as well.
-      conf_custom_updated_autoconf_files=`cd $conf_custom_script_dir && hg status -mard 2> /dev/null | grep autoconf`
+      conf_custom_updated_autoconf_files=`cd $CUSTOM_CONFIG_DIR && hg status -mard 2> /dev/null | grep autoconf`
       if test "x$conf_custom_updated_autoconf_files" != x; then
         echo "Configure custom source code has been updated, checking time stamps"
         check_autoconf_timestamps
@@ -109,11 +109,11 @@
 # Check for local changes
 check_hg_updates
 
-if test -e $conf_custom_script_dir/generated-configure.sh; then
+if test "x$CUSTOM_CONFIG_DIR" != x; then
   # Test if open configure is newer than custom configure, if so, custom needs to
   # be regenerated. This test is required to ensure consistency with custom source.
   conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh  | cut -d"=" -f 2`
-  conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_custom_script_dir/generated-configure.sh  | cut -d"=" -f 2`
+  conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $CUSTOM_CONFIG_DIR/generated-configure.sh  | cut -d"=" -f 2`
   if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
     echo "Warning: The generated configure file contains changes not present in the custom generated file."
     run_autogen_or_fail
@@ -241,10 +241,10 @@
 ###
 ### Call the configure script
 ###
-if test -e $conf_custom_script_dir/generated-configure.sh; then
+if test "x$CUSTOM_CONFIG_DIR" != x; then
   # Custom source configure available; run that instead
   echo "Running custom generated-configure.sh"
-  conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
+  conf_script_to_run=$CUSTOM_CONFIG_DIR/generated-configure.sh
 else
   echo "Running generated-configure.sh"
   conf_script_to_run=$conf_script_dir/generated-configure.sh