2013-10-04 03:11:32 -06:00
|
|
|
#
|
|
|
|
# This is a simple wrapper Makefile that calls the main Makefile.perf
|
|
|
|
# with a -j option to do parallel builds
|
|
|
|
#
|
|
|
|
# If you want to invoke the perf build in some non-standard way then
|
|
|
|
# you can use the 'make -f Makefile.perf' method to invoke it.
|
|
|
|
#
|
2013-10-03 06:32:10 -06:00
|
|
|
|
|
|
|
#
|
|
|
|
# Clear out the built-in rules GNU make defines by default (such as .o targets),
|
|
|
|
# so that we pass through all targets to Makefile.perf:
|
|
|
|
#
|
|
|
|
.SUFFIXES:
|
|
|
|
|
2013-10-04 03:11:32 -06:00
|
|
|
#
|
|
|
|
# We don't want to pass along options like -j:
|
|
|
|
#
|
|
|
|
unexport MAKEFLAGS
|
|
|
|
|
2012-10-01 10:32:51 -06:00
|
|
|
#
|
2013-10-02 03:49:08 -06:00
|
|
|
# Do a parallel build with multiple jobs, based on the number of CPUs online
|
|
|
|
# in this system: 'make -j8' on a 8-CPU system, etc.
|
2013-01-27 18:51:22 -07:00
|
|
|
#
|
2013-10-02 03:49:08 -06:00
|
|
|
# (To override it, run 'make JOBS=1' and similar.)
|
2013-05-24 06:35:24 -06:00
|
|
|
#
|
2013-10-02 03:49:08 -06:00
|
|
|
ifeq ($(JOBS),)
|
2015-04-23 08:00:16 -06:00
|
|
|
JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
|
2015-02-18 16:59:31 -07:00
|
|
|
ifeq ($(JOBS),0)
|
2013-10-02 03:49:08 -06:00
|
|
|
JOBS := 1
|
2013-04-14 20:06:58 -06:00
|
|
|
endif
|
2012-08-07 07:20:43 -06:00
|
|
|
endif
|
2010-08-20 18:38:20 -06:00
|
|
|
|
2013-10-04 04:08:05 -06:00
|
|
|
#
|
|
|
|
# Only pass canonical directory names as the output directory:
|
|
|
|
#
|
|
|
|
ifneq ($(O),)
|
2013-10-09 09:00:23 -06:00
|
|
|
FULL_O := $(shell readlink -f $(O) || echo $(O))
|
2013-10-04 04:08:05 -06:00
|
|
|
endif
|
|
|
|
|
2013-10-10 00:05:25 -06:00
|
|
|
#
|
|
|
|
# Only accept the 'DEBUG' variable from the command line:
|
|
|
|
#
|
|
|
|
ifeq ("$(origin DEBUG)", "command line")
|
|
|
|
ifeq ($(DEBUG),)
|
|
|
|
override DEBUG = 0
|
|
|
|
else
|
|
|
|
SET_DEBUG = "DEBUG=$(DEBUG)"
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
override DEBUG = 0
|
|
|
|
endif
|
|
|
|
|
2013-10-02 03:58:30 -06:00
|
|
|
define print_msg
|
2013-10-09 03:49:27 -06:00
|
|
|
@printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
|
2013-10-02 03:58:30 -06:00
|
|
|
endef
|
|
|
|
|
|
|
|
define make
|
2013-10-10 00:05:25 -06:00
|
|
|
@$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
|
2013-10-02 03:58:30 -06:00
|
|
|
endef
|
2009-04-20 05:32:07 -06:00
|
|
|
|
2013-10-02 01:43:23 -06:00
|
|
|
#
|
2013-10-02 03:49:08 -06:00
|
|
|
# Needed if no target specified:
|
2013-11-26 05:54:12 -07:00
|
|
|
# (Except for tags and TAGS targets. The reason is that the
|
|
|
|
# Makefile does not treat tags/TAGS as targets but as files
|
|
|
|
# and thus won't rebuilt them once they are in place.)
|
2013-10-02 01:43:23 -06:00
|
|
|
#
|
2013-11-26 05:54:12 -07:00
|
|
|
all tags TAGS:
|
2013-10-02 03:58:30 -06:00
|
|
|
$(print_msg)
|
|
|
|
$(make)
|
|
|
|
|
2016-02-04 04:30:36 -07:00
|
|
|
ifdef MAKECMDGOALS
|
|
|
|
has_clean := 0
|
|
|
|
ifneq ($(filter clean,$(MAKECMDGOALS)),)
|
|
|
|
has_clean := 1
|
|
|
|
endif # clean
|
|
|
|
|
|
|
|
ifeq ($(has_clean),1)
|
|
|
|
rest := $(filter-out clean,$(MAKECMDGOALS))
|
|
|
|
ifneq ($(rest),)
|
|
|
|
$(rest): clean
|
|
|
|
endif # rest
|
|
|
|
endif # has_clean
|
|
|
|
endif # MAKECMDGOALS
|
|
|
|
|
2013-10-02 03:58:30 -06:00
|
|
|
#
|
|
|
|
# The clean target is not really parallel, don't print the jobs info:
|
|
|
|
#
|
|
|
|
clean:
|
|
|
|
$(make)
|
2013-10-01 08:28:09 -06:00
|
|
|
|
2014-01-15 18:52:53 -07:00
|
|
|
#
|
2016-01-29 10:49:31 -07:00
|
|
|
# The build-test target is not really parallel, don't print the jobs info,
|
|
|
|
# it also uses only the tests/make targets that don't pollute the source
|
|
|
|
# repository, i.e. that uses O= or builds the tarpkg outside the source
|
|
|
|
# repo directories.
|
|
|
|
#
|
|
|
|
# For a full test, use:
|
|
|
|
#
|
|
|
|
# make -C tools/perf -f tests/make
|
2014-01-15 18:52:53 -07:00
|
|
|
#
|
|
|
|
build-test:
|
2016-02-03 13:28:45 -07:00
|
|
|
@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg out
|
2014-01-15 18:52:53 -07:00
|
|
|
|
2013-10-02 03:58:30 -06:00
|
|
|
#
|
|
|
|
# All other targets get passed through:
|
|
|
|
#
|
2015-06-22 06:50:52 -06:00
|
|
|
%: FORCE
|
2013-10-02 03:58:30 -06:00
|
|
|
$(print_msg)
|
|
|
|
$(make)
|
2013-11-26 05:54:12 -07:00
|
|
|
|
2015-06-22 06:50:52 -06:00
|
|
|
.PHONY: tags TAGS FORCE Makefile
|