diff --git a/.gitignore b/.gitignore index 699e06681f8..bcce649fd9c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ lib*.a /ScummVMDockTilePlugin* /config.h /config.mk +/configure.stamp /.gdb_history /dumps /Credits.rtf diff --git a/Makefile b/Makefile index 2ab2f4fdbd0..338c74fa152 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ ifneq ($(SAVED_PKG_CONFIG_LIBDIR),unset) endif # check if configure has been run or has been changed since last run -config.h: $(srcdir)/configure $(ENGINE_SUBDIRS_CONFIGURE) +configure.stamp: $(srcdir)/configure $(ENGINE_SUBDIRS_CONFIGURE) ifeq "$(findstring config.mk,$(MAKEFILE_LIST))" "config.mk" @echo "Running $(srcdir)/configure with the last specified parameters" @sleep 2 @@ -111,12 +111,10 @@ else $(error You need to run $(srcdir)/configure before you can run make. Check $(srcdir)/configure --help for a list of parameters) endif -config.mk engines/plugins_table.h engines/engines.mk: config.h - @if test -f $@; then \ - touch $@; \ - else \ - rm -f config.h; \ - $(MAKE) config.h; \ +config.h config.mk engines/plugins_table.h engines/detection_table.h engines/engines.mk: configure.stamp + @if ! test -f $@; then \ + rm -f configure.stamp; \ + $(MAKE) configure.stamp; \ fi ifneq ($(origin port_mk), undefined) diff --git a/configure b/configure index b25d54059ff..d50395027b5 100755 --- a/configure +++ b/configure @@ -941,6 +941,15 @@ get_subengines_build_string() { echo "$subengine_string" } +# Copy first argument to second one if they are different. Otherwise, delete the first one. +copy_if_changed() { + if cmp -s $1 $2; then + rm -f $1 + else + mv -f $1 $2 + fi +} + # # Check any parameters we received # @@ -6273,7 +6282,7 @@ fi echo echo "Creating config.h" -cat > config.h << EOF +cat > config.h.new << EOF /* This file is automatically generated by configure */ /* DO NOT EDIT MANUALLY */ @@ -6306,9 +6315,11 @@ typedef $type_ptr uintptr; #endif /* CONFIG_H */ EOF +copy_if_changed config.h.new config.h + echo "Creating config.mk" -cat > config.mk << EOF +cat > config.mk.new << EOF # -------- Generated by configure ----------- SAVED_CONFIGFLAGS := $SAVED_CONFIGFLAGS @@ -6384,6 +6395,7 @@ $_mak_plugins port_mk = $_port_mk EOF +copy_if_changed config.mk.new config.mk # # Create a custom Makefile when building outside the source tree @@ -6392,7 +6404,7 @@ EOF if test ! -f Makefile.common ; then echo "Creating Makefile" -cat > Makefile << EOF +cat > Makefile.new << EOF # -------- Generated by configure ----------- srcdir = $_srcdir vpath %.h \$(srcdir) @@ -6407,6 +6419,7 @@ vpath %.rc \$(srcdir) vpath %.md \$(srcdir) include \$(srcdir)/Makefile EOF +copy_if_changed Makefile.new Makefile fi @@ -6415,7 +6428,7 @@ fi mkdir -p engines echo "Creating engines/engines.mk" -cat > engines/engines.mk << EOF +cat > engines/engines.mk.new << EOF # This file is automatically generated by configure # DO NOT EDIT MANUALLY # This file is being included by "Makefile.common" @@ -6425,7 +6438,7 @@ for engine in $_sorted_engines; do j=`echo $engine | tr '[:lower:]' '[:upper:]'` if test "`get_engine_sub $engine`" = "no" ; then # main engine - cat >> engines/engines.mk << EOF + cat >> engines/engines.mk.new << EOF ifdef ENABLE_$j DEFINES += -DENABLE_$j=\$(ENABLE_$j) @@ -6434,7 +6447,7 @@ EOF for subeng in `get_engine_subengines $engine` ; do k=`echo $subeng | tr '[:lower:]' '[:upper:]'` - cat >> engines/engines.mk << EOF + cat >> engines/engines.mk.new << EOF ifdef ENABLE_$k DEFINES += -DENABLE_$k @@ -6442,17 +6455,18 @@ endif EOF done - cat >> engines/engines.mk << EOF + cat >> engines/engines.mk.new << EOF endif EOF fi done +copy_if_changed engines/engines.mk.new engines/engines.mk # Name which is suffixed to each detection plugin detectId="_DETECTION" echo "Creating engines/detection_table.h" -cat > engines/detection_table.h << EOF +cat > engines/detection_table.h.new << EOF /* This file is automatically generated by configure */ /* DO NOT EDIT MANUALLY */ // This file is being included by "base/plugins.cpp" @@ -6462,17 +6476,18 @@ for engine in $_sorted_engines; do if test "`get_engine_sub $engine`" = "no" ; then j=`echo $engine | tr '[:lower:]' '[:upper:]'` detectEngine="${j}${detectId}" - cat >> engines/detection_table.h << EOF + cat >> engines/detection_table.h.new << EOF #if defined(ENABLE_$j) || defined(DETECTION_FULL) LINK_PLUGIN($detectEngine) #endif EOF fi done +copy_if_changed engines/detection_table.h.new engines/detection_table.h echo "Creating engines/plugins_table.h" -cat > engines/plugins_table.h << EOF +cat > engines/plugins_table.h.new << EOF /* This file is automatically generated by configure */ /* DO NOT EDIT MANUALLY */ // This file is being included by "base/plugins.cpp" @@ -6481,10 +6496,13 @@ EOF for engine in $_sorted_engines; do if test "`get_engine_sub $engine`" = "no" ; then j=`echo $engine | tr '[:lower:]' '[:upper:]'` - cat >> engines/plugins_table.h << EOF + cat >> engines/plugins_table.h.new << EOF #if PLUGIN_ENABLED_STATIC($j) LINK_PLUGIN($j) #endif EOF fi done +copy_if_changed engines/plugins_table.h.new engines/plugins_table.h + +touch configure.stamp