1# 2# This is a simple wrapper Makefile that calls the main Makefile.perf 3# with a -j option to do parallel builds 4# 5# If you want to invoke the perf build in some non-standard way then 6# you can use the 'make -f Makefile.perf' method to invoke it. 7# 8 9# 10# Clear out the built-in rules GNU make defines by default (such as .o targets), 11# so that we pass through all targets to Makefile.perf: 12# 13.SUFFIXES: 14 15# 16# We don't want to pass along options like -j: 17# 18unexport MAKEFLAGS 19 20# 21# Do a parallel build with multiple jobs, based on the number of CPUs online 22# in this system: 'make -j8' on a 8-CPU system, etc. 23# 24# (To override it, run 'make JOBS=1' and similar.) 25# 26ifeq ($(JOBS),) 27 JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null) 28 ifeq ($(JOBS),) 29 JOBS := 1 30 endif 31endif 32 33# 34# Only pass canonical directory names as the output directory: 35# 36ifneq ($(O),) 37 FULL_O := $(shell readlink -f $(O)) 38endif 39 40define print_msg 41 @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n' 42endef 43 44define make 45 @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $@ 46endef 47 48# 49# Needed if no target specified: 50# 51all: 52 $(print_msg) 53 $(make) 54 55# 56# The clean target is not really parallel, don't print the jobs info: 57# 58clean: 59 $(make) 60 61# 62# All other targets get passed through: 63# 64%: 65 $(print_msg) 66 $(make) 67