summaryrefslogtreecommitdiffstats
path: root/Configurations
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-02-21 16:09:36 +0100
committerRichard Levitte <levitte@openssl.org>2016-02-21 16:26:06 +0100
commitf8d9d6e48b7ce50aee32d151e5dc7253594e01ed (patch)
tree9a5a1ef1c873fe545190f36f7e5df2a7be281d38 /Configurations
parent380f047707de4f8c22eeaec63f481d4734efe7a5 (diff)
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>
Diffstat (limited to 'Configurations')
-rw-r--r--Configurations/unix-Makefile.tmpl38
1 files changed, 30 insertions, 8 deletions
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index 47608f7d84..b591c4da20 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -249,17 +249,39 @@ clean: libclean
rm -f $(TARFILE)
# 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:
- @( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
- echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
- echo; \
+ @catdepends=false; \
+ if [ Makefile -nt Makefile ] 2>/dev/null || [ $$? = 1 ]; then \
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; \
+ if [ $$d -nt Makefile ]; then \
+ catdepends=true; \
+ break; \
+ fi; \
+ done; \
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
# Install helper targets #############################################