Check that any dependency file is newer than Makefile before concatenating

On slower file systems, this makes a huge difference

Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Richard Levitte 2016-02-21 16:09:36 +01:00
parent 380f047707
commit f8d9d6e48b

View file

@ -249,17 +249,39 @@ clean: libclean
rm -f $(TARFILE) rm -f $(TARFILE)
# This exists solely for those who still type 'make depend' # This exists solely for those who still type 'make depend'
#
# We check if any depfile is newer than Makefile and decide to
# concatenate only if that is true, or if 'test' (a.k.a [ )
# doesn't have the option to figure it out (-nt).
#
# To check if test has the file age comparison operator, we
# simply try, and rely test to exit with 0 if the comparison
# was true, 1 if false, and most importantly, 2 if it doesn't
# recognise the operator.
depend: depend:
@( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \ @catdepends=false; \
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \ if [ Makefile -nt Makefile ] 2>/dev/null || [ $$? = 1 ]; then \
echo; \
for d in $(DEPS); do \ for d in $(DEPS); do \
if [ -f $$d ]; then cat $$d; fi; \ if [ $$d -nt Makefile ]; then \
done ) > Makefile.new catdepends=true; \
@if ! cmp Makefile.new Makefile >/dev/null 2>&1; then \ break; \
mv -f Makefile.new Makefile; \ fi; \
done; \
else \ else \
rm -f Makefile.new; \ catdepends=true; \
fi; \
if [ $$catdepends = true ]; then \
( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
echo; \
for d in $(DEPS); do \
if [ -f $$d ]; then cat $$d; fi; \
done ) > Makefile.new; \
if ! cmp Makefile.new Makefile >/dev/null 2>&1; then \
mv -f Makefile.new Makefile; \
else \
rm -f Makefile.new; \
fi; \
fi fi
# Install helper targets ############################################# # Install helper targets #############################################