2013-10-04 11:11:32 +02: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 14:32:10 +02: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 11:11:32 +02:00
#
# We don't want to pass along options like -j:
#
u n export MAKEFLAGS
2012-10-02 01:32:51 +09:00
#
2013-10-02 11:49:08 +02: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 20:51:22 -05:00
#
2013-10-02 11:49:08 +02:00
# (To override it, run 'make JOBS=1' and similar.)
2013-05-24 14:35:24 +02:00
#
2013-10-02 11:49:08 +02:00
i f e q ( $( JOBS ) , )
2015-04-23 15:00:16 +01:00
JOBS := $( shell ( getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
2015-02-18 18:59:31 -05:00
ifeq ( $( JOBS) ,0)
2013-10-02 11:49:08 +02:00
JOBS := 1
2013-04-15 04:06:58 +02:00
endif
2012-08-07 15:20:43 +02:00
e n d i f
2010-08-21 03:38:20 +03:00
2013-10-04 12:08:05 +02:00
#
# Only pass canonical directory names as the output directory:
#
i f n e q ( $( O ) , )
2013-10-09 17:00:23 +02:00
FULL_O := $( shell readlink -f $( O) || echo $( O) )
2013-10-04 12:08:05 +02:00
e n d i f
2013-10-10 08:05:25 +02:00
#
# Only accept the 'DEBUG' variable from the command line:
#
i f e q ( "$(origin DEBUG)" , "command line" )
ifeq ( $( DEBUG) ,)
override DEBUG = 0
else
SET_DEBUG = " DEBUG= $( DEBUG) "
endif
e l s e
override DEBUG = 0
e n d i f
2013-10-02 11:58:30 +02:00
d e f i n e p r i n t _ m s g
2013-10-09 11:49:27 +02:00
@printf ' BUILD: Doing ' \' 'make \033[33m-j' $( JOBS) '\033[m' \' ' parallel build\n'
2013-10-02 11:58:30 +02:00
e n d e f
d e f i n e m a k e
2013-10-10 08:05:25 +02:00
@$( MAKE) -f Makefile.perf --no-print-directory -j$( JOBS) O = $( FULL_O) $( SET_DEBUG) $@
2013-10-02 11:58:30 +02:00
e n d e f
2009-04-20 13:32:07 +02:00
2013-10-02 09:43:23 +02:00
#
2013-10-02 11:49:08 +02:00
# Needed if no target specified:
2013-11-26 13:54:12 +01: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 09:43:23 +02:00
#
2013-11-26 13:54:12 +01:00
all tags TAGS :
2013-10-02 11:58:30 +02:00
$( print_msg)
$( make)
2016-02-04 12:30:36 +01:00
i f d e f M A K E C M D G O A L S
has_clean := 0
i f n e q ( $( filter clean ,$ ( MAKECMDGOALS ) ) , )
has_clean := 1
e n d i f # clean
i f e q ( $( has_clean ) , 1 )
rest := $( filter-out clean,$( MAKECMDGOALS) )
ifneq ( $( rest) ,)
$(rest) : clean
endif # rest
e n d i f # has_clean
e n d i f # MAKECMDGOALS
2013-10-02 11:58:30 +02:00
#
# The clean target is not really parallel, don't print the jobs info:
#
clean :
$( make)
2013-10-01 16:28:09 +02:00
2014-01-16 10:52:53 +09:00
#
2016-01-29 14:49:31 -03: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-16 10:52:53 +09:00
#
build-test :
2016-02-03 17:28:45 -03:00
@$( MAKE) SHUF = 1 -f tests/make REUSE_FEATURES_DUMP = 1 MK = Makefile SET_PARALLEL = 1 --no-print-directory tarpkg out
2014-01-16 10:52:53 +09:00
2013-10-02 11:58:30 +02:00
#
# All other targets get passed through:
#
2015-06-22 14:50:52 +02:00
% : FORCE
2013-10-02 11:58:30 +02:00
$( print_msg)
$( make)
2013-11-26 13:54:12 +01:00
2015-06-22 14:50:52 +02:00
.PHONY : tags TAGS FORCE Makefile