Only modify Makefile and config.mk if they change during configure.

This commit is contained in:
Graydon Hoare 2012-02-28 12:05:05 -08:00
parent 1ed12f3602
commit 418c6bcec3
1 changed files with 29 additions and 10 deletions

39
configure vendored
View File

@ -41,9 +41,26 @@ make_dir() {
fi fi
} }
copy() { copy_if_changed() {
msg "cp $1 $2" if cmp -s $1 $2
cp $1 $2 then
msg "leaving $2 unchanged"
else
msg "cp $1 $2"
cp $1 $2
chmod u-w $1 # make copied artifact read-only
fi
}
move_if_changed() {
if cmp -s $1 $2
then
msg "leaving $2 unchanged"
else
msg "mv $1 $2"
mv $1 $2
chmod u-w $1 # make moved artifact read-only
fi
} }
putvar() { putvar() {
@ -56,7 +73,7 @@ putvar() {
else else
printf "configure: %-20s := %s\n" $1 "$T" printf "configure: %-20s := %s\n" $1 "$T"
fi fi
printf "%-20s := %s\n" $1 "$T" >>config.mk printf "%-20s := %s\n" $1 "$T" >>config.tmp
} }
probe() { probe() {
@ -158,6 +175,7 @@ opt() {
msg "looking for configure programs" msg "looking for configure programs"
need_cmd cmp
need_cmd mkdir need_cmd mkdir
need_cmd printf need_cmd printf
need_cmd cut need_cmd cut
@ -250,8 +268,8 @@ then
echo "Options:" echo "Options:"
echo "" echo ""
else else
msg "recreating config.mk" msg "recreating config.tmp"
echo '' >config.mk echo '' >config.tmp
step_msg "processing $CFG_SELF args" step_msg "processing $CFG_SELF args"
fi fi
@ -665,11 +683,12 @@ done
# Munge any paths that appear in config.mk back to posix-y # Munge any paths that appear in config.mk back to posix-y
perl -i.bak -p -e 's@ ([a-zA-Z]):[/\\]@ /\1/@go;' \ perl -i.bak -p -e 's@ ([a-zA-Z]):[/\\]@ /\1/@go;' \
-e 's@\\@/@go;' config.mk -e 's@\\@/@go;' config.tmp
rm -f config.mk.bak rm -f config.tmp.bak
msg msg
copy ${CFG_SRC_DIR}Makefile.in ./Makefile copy_if_changed ${CFG_SRC_DIR}Makefile.in ./Makefile
chmod u-w Makefile # it is generated, make it read-only move_if_changed config.tmp config.mk
rm -f config.tmp
step_msg "complete" step_msg "complete"