From 0635cc573b13255edb43862fe7bd638cae8de9f5 Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Tue, 30 Mar 2004 13:31:35 +0000
Subject: [PATCH] From Axel: let make automatically re-run ./configure in case
 one of the files used by ./configure has been changed.

git-svn-id: http://root.cern.ch/svn/root/trunk@8519 27541ba8-7e3a-0410-8455-c3a389f83636
---
 Makefile                  | 28 ++++++++++++++++++++--------
 build/unix/reconfigure.sh | 29 +++++++++++++++++++++++++++++
 configure                 | 19 +++++++++++++++++++
 3 files changed, 68 insertions(+), 8 deletions(-)
 create mode 100755 build/unix/reconfigure.sh

diff --git a/Makefile b/Makefile
index 4f296d452be..a9139526ded 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,6 @@ endif
 
 ##### Modules to build #####
 
-
 MODULES       = build cint metautils utils base cont meta net zip clib matrix \
                 newdelete hist tree freetype graf g3d gpad gui minuit \
                 histpainter treeplayer treeviewer proof physics postscript \
@@ -203,7 +202,7 @@ F77LDFLAGS   += -lfrtbegin
 endif
 endif
 
-##### utilities #####
+##### Utilities #####
 
 MAKEDEP       = build/unix/depend.sh
 MAKELIB       = build/unix/makelib.sh $(MKLIBOPTIONS)
@@ -218,6 +217,7 @@ MAKEHTML      = build/unix/makehtml.sh
 MAKELOGHTML   = build/unix/makeloghtml.sh
 MAKECINTDLLS  = build/unix/makecintdlls.sh
 MAKESTATIC    = build/unix/makestatic.sh
+RECONFIGURE   = build/unix/reconfigure.sh
 ifeq ($(PLATFORM),win32)
 MAKELIB       = build/win/makelib.sh
 MAKEDIST      = build/win/makedist.sh
@@ -225,7 +225,7 @@ MAKECOMPDATA  = build/win/compiledata.sh
 MAKEMAKEINFO  = build/win/makeinfo.sh
 endif
 
-##### compiler directives and run-control file #####
+##### Compiler directives and run-control file #####
 
 COMPILEDATA   = include/compiledata.h
 MAKEINFO      = cint/MAKEINFO
@@ -241,7 +241,7 @@ COREDO        = $(BASEDO) $(CONTDO) $(METADO) $(NETDO) $(SYSTEMDO) $(CLIBDO) \
 
 CORELIB      := $(LPATH)/libCore.$(SOEXT)
 
-##### if shared libs need to resolve all symbols (e.g.: aix, win32) #####
+##### In case shared libs need to resolve all symbols (e.g.: aix, win32) #####
 
 ifeq ($(EXPLICITLINK),yes)
 MAINLIBS      = $(CORELIB) $(CINTLIB)
@@ -327,9 +327,21 @@ config config/Makefile.:
 	   exit 1; \
 	fi)
 
-$(ROOTRC): config/rootrc.in
-	@(echo ""; echo "Please, run ./configure again to bring $@ up to date"; \
-	  echo ""; exit 1)
+# Target Makefile is synonym for "run (re-)configure"
+# Makefile is target as we need to re-parse dependencies after
+# configure is run (as config.h changed etc)
+config/Makefile.config include/config.h etc/system.rootauthrc \
+  etc/system.rootdaemonrc etc/root.mimes $(ROOTRC) bin/root-config: Makefile
+
+ifeq ($(findstring $(MAKECMDGOALS),distclean maintainer-clean),)
+Makefile: configure config/rootrc.in config/config.in config/Makefile.in \
+  config/root-config.in config/rootauthrc.in config/rootdaemonrc.in \
+  config/mimes.unix.in config/mimes.win32.in
+	@(if [ ! -x $(RECONFIGURE) ] || ! $(RECONFIGURE) "$?"; then \
+	   echo ""; echo "Please, run ./configure again as config option files ($?) have changed."; \
+	   echo ""; exit 1; \
+	 fi)
+endif
 
 $(COMPILEDATA): config/Makefile.$(ARCH) $(MAKECOMPDATA)
 	@$(MAKECOMPDATA) $(COMPILEDATA) "$(CXX)" "$(OPTFLAGS)" "$(DEBUGFLAGS)" \
@@ -341,7 +353,7 @@ $(COMPILEDATA): config/Makefile.$(ARCH) $(MAKECOMPDATA)
 $(MAKEINFO): config/Makefile.$(ARCH) $(MAKEMAKEINFO)
 	@$(MAKEMAKEINFO) $(MAKEINFO) "$(CXX)" "$(CC)" "$(CPPPREP)"
 
-build/dummy.d: config $(ROOTRC) $(RMKDEP) $(BINDEXP) $(ALLHDRS)
+build/dummy.d: config Makefile $(RMKDEP) $(BINDEXP) $(ALLHDRS)
 	@(if [ ! -f $@ ] ; then \
 	   touch $@; \
 	fi)
diff --git a/build/unix/reconfigure.sh b/build/unix/reconfigure.sh
new file mode 100755
index 00000000000..eb1c6242f9d
--- /dev/null
+++ b/build/unix/reconfigure.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+#
+# A simple reconfigure script.
+#
+# Author: Axel Naumann
+#
+######################################################################
+
+if [ ! -f config.status ]; then
+  echo ""
+  echo "Can't get config line from config.status."
+  exit 1;
+fi
+
+confline=`cat config.status`
+
+if [ "x$1" != "x" ]; then
+  what=" because $1 has changed"
+fi
+
+echo ""
+echo "Trying to reconfigure${what}."
+echo "Using config statement:"
+echo "./configure $confline"
+echo ""
+./configure $confline --nohowto || exit 1
+echo "Reconfigure successful."
+echo "If the build fails, please run ./configure again."
+echo ""
diff --git a/configure b/configure
index d329b174fa5..a7aeb5dc74a 100755
--- a/configure
+++ b/configure
@@ -19,6 +19,7 @@ found_dir=no
 found_hdr=no
 show_pkglist=no
 noact="no"
+nohowto="no"
 
 options="                 \
    enable_afs             \
@@ -104,6 +105,8 @@ for c in $envvars ; do
 done
 
 configargs="$*"
+# don't write --nohowto to config.h
+configargs=`echo $configargs|sed 's, *--nohowto,,g'`
 
 configoptions=
 if test ! "x$configenvvars" = "x" ; then
@@ -689,6 +692,7 @@ if test $# -gt 0 ; then
       # With options to specifiy third part software
       #
       --no-create)             noact="yes"           ;;
+      --nohowto)               nohowto="yes"         ;;
       --with-afs=*)            afsdir=$optarg        ; enable_afs="yes"     ;;
       --with-alien-incdir=*)   alienincdir=$optarg   ; enable_alien="yes"   ;;
       --with-alien-libdir=*)   alienlibdir=$optarg   ; enable_alien="yes"   ;;
@@ -2555,6 +2559,17 @@ sed -e "s|@bindir@|$bindir|"           \
     < config/root-help.el.in > build/misc/root-help.el
 echo "done"
 
+#---------------------------------------------------------------------
+# config.status
+#
+message "Writing config.status"
+echo $configargs > config.status
+echo done
+
+#---------------------------------------------------------------------
+# for reconfigure
+#
+touch Makefile
 
 ######################################################################
 #
@@ -2593,6 +2608,10 @@ fi
 #
 # List the possible Makefiles
 #
+if [ "x$nohowto" == "xyes" ]; then
+    exit 0
+fi
+
 echo "To build ROOT type:"
 echo ""
 if test "x$platform" = "xwin32" || test "x$platform" = "xwin32gcc" ; then
-- 
GitLab