aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gross2017-06-09 17:52:48 -0400
committerJason Gross2017-07-08 20:09:54 -0400
commit31098bfe8fa98a072330b851afb3a4f0916527ab (patch)
tree2b3839fe8f8b213d51300f58b7b14e5903bdf9b8
parentba7129f547d1f06c7eb67412404445681d22b920 (diff)
Fix TIMED=1 on Mac OSX
This closes [bug #5596](https://coq.inria.fr/bugs/show_bug.cgi?id=5596).
-rw-r--r--Makefile.build16
-rw-r--r--tools/CoqMakefile.in16
2 files changed, 30 insertions, 2 deletions
diff --git a/Makefile.build b/Makefile.build
index 05d751f541..3f870ed172 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))
diff --git a/tools/CoqMakefile.in b/tools/CoqMakefile.in
index 86be54d462..e4f527d445 100644
--- a/tools/CoqMakefile.in
+++ b/tools/CoqMakefile.in
@@ -62,7 +62,21 @@ VERBOSE ?=
# Time the Coq process (set to non empty), and how (see default value)
TIMED?=
TIMECMD?=
-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
# Coq binaries
COQC ?= "$(COQBIN)coqc"