aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile.build
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2017-06-09 17:52:48 -0400
committerGravatar Jason Gross <jgross@mit.edu>2017-07-08 20:09:54 -0400
commit31098bfe8fa98a072330b851afb3a4f0916527ab (patch)
tree2b3839fe8f8b213d51300f58b7b14e5903bdf9b8 /Makefile.build
parentba7129f547d1f06c7eb67412404445681d22b920 (diff)
Fix TIMED=1 on Mac OSX
Diffstat (limited to 'Makefile.build')
-rw-r--r--Makefile.build16
1 files changed, 15 insertions, 1 deletions
diff --git a/Makefile.build b/Makefile.build
index 05d751f54..3f870ed17 100644
--- a/Makefile.build
+++ b/Makefile.build
@@ -101,7 +101,21 @@ DEPENDENCIES := \
###########################################################################
# Default timing command
-STDTIME=/usr/bin/time -f "$* (real: %e, user: %U, sys: %S, mem: %M ko)"
+# Use /usr/bin/time on linux, gtime on Mac OS
+TIMEFMT?="$* (real: %e, user: %U, sys: %S, mem: %M ko)"
+ifneq (,$(TIMED))
+ifeq (0,$(shell /usr/bin/time -f $(TIMEFMT) true >/dev/null 2>/dev/null; echo $$?))
+STDTIME?=/usr/bin/time -f $(TIMEFMT)
+else
+ifeq (0,$(shell gtime -f $(TIMEFMT) true >/dev/null 2>/dev/null; echo $$?))
+STDTIME?=gtime -f $(TIMEFMT)
+else
+STDTIME?=time
+endif
+endif
+else
+STDTIME?=/usr/bin/time -f $(TIMEFMT)
+endif
TIMER=$(if $(TIMED), $(STDTIME), $(TIMECMD))