Skip to content

Commit 418c6bc

Browse files
committed
Only modify Makefile and config.mk if they change during configure.
1 parent 1ed12f3 commit 418c6bc

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

configure

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,26 @@ make_dir() {
4141
fi
4242
}
4343

44-
copy() {
45-
msg "cp $1 $2"
46-
cp $1 $2
44+
copy_if_changed() {
45+
if cmp -s $1 $2
46+
then
47+
msg "leaving $2 unchanged"
48+
else
49+
msg "cp $1 $2"
50+
cp $1 $2
51+
chmod u-w $1 # make copied artifact read-only
52+
fi
53+
}
54+
55+
move_if_changed() {
56+
if cmp -s $1 $2
57+
then
58+
msg "leaving $2 unchanged"
59+
else
60+
msg "mv $1 $2"
61+
mv $1 $2
62+
chmod u-w $1 # make moved artifact read-only
63+
fi
4764
}
4865

4966
putvar() {
@@ -56,7 +73,7 @@ putvar() {
5673
else
5774
printf "configure: %-20s := %s\n" $1 "$T"
5875
fi
59-
printf "%-20s := %s\n" $1 "$T" >>config.mk
76+
printf "%-20s := %s\n" $1 "$T" >>config.tmp
6077
}
6178

6279
probe() {
@@ -158,6 +175,7 @@ opt() {
158175

159176

160177
msg "looking for configure programs"
178+
need_cmd cmp
161179
need_cmd mkdir
162180
need_cmd printf
163181
need_cmd cut
@@ -250,8 +268,8 @@ then
250268
echo "Options:"
251269
echo ""
252270
else
253-
msg "recreating config.mk"
254-
echo '' >config.mk
271+
msg "recreating config.tmp"
272+
echo '' >config.tmp
255273

256274
step_msg "processing $CFG_SELF args"
257275
fi
@@ -665,11 +683,12 @@ done
665683

666684
# Munge any paths that appear in config.mk back to posix-y
667685
perl -i.bak -p -e 's@ ([a-zA-Z]):[/\\]@ /\1/@go;' \
668-
-e 's@\\@/@go;' config.mk
669-
rm -f config.mk.bak
686+
-e 's@\\@/@go;' config.tmp
687+
rm -f config.tmp.bak
670688

671689
msg
672-
copy ${CFG_SRC_DIR}Makefile.in ./Makefile
673-
chmod u-w Makefile # it is generated, make it read-only
690+
copy_if_changed ${CFG_SRC_DIR}Makefile.in ./Makefile
691+
move_if_changed config.tmp config.mk
692+
rm -f config.tmp
674693

675694
step_msg "complete"

0 commit comments

Comments
 (0)