From: Tony Finch Date: Fri, 7 Dec 2012 17:44:42 +0000 (+0000) Subject: Avoid spurious rebuilds of the dynamic lookups Makefile. X-Git-Tag: exim-4_81_RC1~3^2~16 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=58ee1eb660af5f69de403aaf36019f5dcaf9760e;p=exim.git Avoid spurious rebuilds of the dynamic lookups Makefile. This was noticable when re-building as a non-privileged user after installing as root; lookups/Makefile had been rebuilt by root and when it was rebuilt again by the unprivileged user `mv` demanded confirmation before overwriting the file. --- diff --git a/src/Makefile b/src/Makefile index 4c8300ca7..a18c3d728 100644 --- a/src/Makefile +++ b/src/Makefile @@ -52,16 +52,14 @@ build-directory: configure: build-directory @cd build-$(buildname); \ - build=$(build) $(SHELL) ../scripts/Configure-Makefile; \ - $(SHELL) ../scripts/lookups-Makefile + build=$(build) $(SHELL) ../scripts/Configure-Makefile # The "makefile" target forces a rebuild of the makefile (as opposed to # "configure", which doesn't force it). makefile: build-directory @cd build-$(buildname); $(RM_COMMAND) -f Makefile; \ - build=$(build) $(SHELL) ../scripts/Configure-Makefile; \ - $(SHELL) ../scripts/lookups-Makefile + build=$(build) $(SHELL) ../scripts/Configure-Makefile # The installation commands are kept in a separate script, which expects # to be run from inside the build directory. diff --git a/src/scripts/Configure-Makefile b/src/scripts/Configure-Makefile index 3e901e6a6..58b2b5770 100755 --- a/src/scripts/Configure-Makefile +++ b/src/scripts/Configure-Makefile @@ -77,8 +77,9 @@ mf=Makefile mft=$mf-t mftt=$mf-tt -look_mf=lookups/Makefile.predynamic -look_mft=${look_mf}-t +look_mf=lookups/Makefile +look_mf_pre=${look_mf}.predynamic +look_mf_post=${look_mf}.postdynamic # Ensure the temporary does not exist and start the new one by setting # the OSTYPE and ARCHTYPE variables. @@ -195,10 +196,10 @@ fi rm -f $mftt # make the lookups Makefile with the definitions +# the auxiliary script generates $look_mf_post from $look_mf_pre -## prepend stuff here; eg: grep LOOKUP_ $mft > $look_mft -## cat ../src/lookups/Makefile >> $look_mft -cp ../src/lookups/Makefile $look_mft +cp ../src/lookups/Makefile $look_mf_pre +../scripts/lookups-Makefile # See if there is a definition of EXIM_PERL in what we have built so far. # If so, run Perl to find the default values for PERL_CC, PERL_CCOPTS, @@ -249,14 +250,14 @@ cat ../OS/Makefile-Base >> $mft || exit 1 # If the new makefile is the same as the existing one, say so, and just # update the timestamp. Otherwise remove the old and install the new. -if [ -s $mf ] && cmp -s $mft $mf && [ -s $look_mf ] && cmp -s $look_mft $look_mf +if [ -s $mf ] && cmp -s $mft $mf && [ -s $look_mf ] && cmp -s $look_mf_post $look_mf then echo ">>> rebuilt $mf unchanged" echo " " touch $mf || exit - rm -f $mft -elif rm -f $mf $look_mf + rm -f $mft $look_mf_pre $look_mf_post +elif rm -f $mf $look_mf $look_mf_pre mv $mft $mf - mv $look_mft $look_mf + mv $look_mf_post $look_mf then echo ">>> New $mf & $look_mf installed" echo '>>> Use "make makefile" if you need to force rebuilding of the makefile' echo " " diff --git a/src/scripts/lookups-Makefile b/src/scripts/lookups-Makefile index 14c15259e..e7aeaa08a 100755 --- a/src/scripts/lookups-Makefile +++ b/src/scripts/lookups-Makefile @@ -28,8 +28,8 @@ then fi input=lookups/Makefile.predynamic -target=lookups/Makefile -defs_source=Makefile +target=lookups/Makefile.postdynamic +defs_source=Makefile-t tag_marker='MAGIC-TAG-MODS-OBJ-RULES-GO-HERE' tab=' ' @@ -44,20 +44,19 @@ export LC_ALL # nb: do not permit leading whitespace for this, as CFLAGS_DYNAMIC is exported # to the lookups subdir via a line with leading whitespace which otherwise # matches -if grep -q "^CFLAGS_DYNAMIC[ $tab]*=" "$defs_source" +if grep -q "^CFLAGS_DYNAMIC[ $tab?:]*=" "$defs_source" then # we have a definition, we're good to go + echo >&2 ">>> Creating lookups/Makefile for building dynamic modules" enable_dynamic=yes else - echo >&2 "Missing CFLAGS_DYNAMIC inhibits building dynamic module lookup" + echo >&2 ">>> Creating lookups/Makefile without dynamic module support" enable_dynamic='' # We always do something now, since there should always be a lookup, # and now we need to run in order to put the OBJ=$(OBJ)+ rules in. So we # continue on. fi -tmp="$target.t" - # For the want_ checks, we need to let the user override values from the make # command-line, not just check the Makefile. @@ -96,7 +95,7 @@ emit_module_rule() { if want_dynamic "$lookup_name" then if [ -z "$enable_dynamic" ]; then - echo >&2 "Inhibited dynamic modules prevents building dynamic $lookup_name" + echo >&2 "Missing CFLAGS_DYNAMIC prevents building dynamic $lookup_name" exit 1 fi MODS="${MODS} ${mod_name}.so" @@ -116,8 +115,9 @@ emit_module_rule() { fi } +rm -f "$target" exec 5>&1 -exec > "$tmp" +exec > "$target" sed -n "1,/$tag_marker/p" < "$input" @@ -145,7 +145,7 @@ echo "OBJ = $OBJ" sed -n "/$tag_marker/,\$p" < "$input" exec >&5 -mv "$tmp" "$target" +# Configure-Makefile will move $target into place # vim: set ft=sh sw=2 :