Skip to content
Snippets Groups Projects
Commit 0a8a5624 authored by Virgile Prevosto's avatar Virgile Prevosto Committed by Andre Maroneze
Browse files

[scripts] more portable detection of 'time' command, take 2

parent ec24b5df
No related branches found
No related tags found
No related merge requests found
...@@ -70,12 +70,12 @@ endif ...@@ -70,12 +70,12 @@ endif
SED_UNBUFFERED:=sed$(shell sed --unbuffered //p /dev/null 2>/dev/null && echo " --unbuffered" || true) SED_UNBUFFERED:=sed$(shell sed --unbuffered //p /dev/null 2>/dev/null && echo " --unbuffered" || true)
# If there is a GNU time in the PATH, which contains the desired options # If there is a GNU time in the PATH, which contains the desired options
# (-f and -o, whose presence is tested using the --help message), # (-f and -o), use them; otherwise, use any time (be it a shell builtin
# use them; otherwise, use any time (be it a shell builtin or a command). # or a command). 'env' allows bypassing shell builtins (if they exist),
# Note: usage of 'env' is necessary to avoid invoking a shell builtin. # since they usually don't have the required options.
ifneq (1,$(shell env time --help | grep -C100 '\-f' | grep '\-o' -q; echo $$?)) ifeq (OK,$(shell env time -f 'test' -o '/dev/null' echo OK || echo KO))
define time_with_output define time_with_output
$(shell which time) -f 'user_time=%U\nmemory=%M' -o "$(1)" env time -f 'user_time=%U\nmemory=%M' -o "$(1)"
endef endef
else else
define time_with_output define time_with_output
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment