build: add busybox support to `time` prereq-check
authorAndy Boyett <agb@agb.io>
Thu, 17 May 2018 05:09:57 +0000 (22:09 -0700)
committerJohn Crispin <john@phrozen.org>
Mon, 18 Jun 2018 19:31:49 +0000 (21:31 +0200)
Busybox time supports the GNU time '-f' syntax used by the build time
logging implemented in ff6e62b288c, however the prerequisite check added
only works with GNU time installed as `time` or `gtime`.

As busybox is a multicall binary, the name of the symlink setup by
SetupHostCommand also must be changed from `gtime` to `time` to fix the
value of argv[0]. This causes a number of shells (including bash) to use
their builtin impelementation of time, so the sole invocation has been
changed to use `env time` to use the value found on the $PATH.

Signed-off-by: Andy Boyett <agb@agb.io>
(cherry picked from commit 591780615b304fb4624e363135942e9ee8f6caa3)

include/prereq-build.mk
include/subdir.mk

index bac5fdc84c651d29a66a52883c4ecd6caf90bb1d..72875aef4e67b0f20bf1ce63a770aacd9d0ad42e 100644 (file)
@@ -138,9 +138,10 @@ $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
 $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
        wget --version | grep GNU))
 
-$(eval $(call SetupHostCommand,gtime,Please install GNU 'time', \
+$(eval $(call SetupHostCommand,time,Please install GNU 'time' or BusyBox 'time', \
        gtime --version 2>&1 | grep GNU, \
-       time --version 2>&1 | grep GNU))
+       time --version 2>&1 | grep GNU, \
+       busybox time 2>&1 | grep BusyBox))
 
 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
        perl --version | grep "perl.*v5"))
index ed4f7537d5c746b00b586a49ff89004895eaec21..dde3e50b0bea12bee1744b0a469fde66c354635c 100644 (file)
@@ -43,7 +43,7 @@ log_make = \
         $(if $(BUILD_LOG), \
                set -o pipefail; \
                mkdir -p $(BUILD_LOG_DIR)/$(1)$(if $(4),/$(4));) \
-       gtime -f "time: $(1)$(if $(4),/$(4))/$(if $(3),$(3)-)$(2)\#%U\#%S\#%e" -- \
+       env time -f "time: $(1)$(if $(4),/$(4))/$(if $(3),$(3)-)$(2)\#%U\#%S\#%e" -- \
        $$(SUBMAKE) $(subdir_make_opts) $(if $(3),$(3)-)$(2) \
                $(if $(BUILD_LOG),SILENT= 2>&1 | tee $(BUILD_LOG_DIR)/$(1)$(if $(4),/$(4))/$(if $(3),$(3)-)$(2).txt)