Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 #
0003 # This is a simple wrapper Makefile that calls the main Makefile.perf
0004 # with a -j option to do parallel builds
0005 #
0006 # If you want to invoke the perf build in some non-standard way then
0007 # you can use the 'make -f Makefile.perf' method to invoke it.
0008 #
0009 
0010 #
0011 # Clear out the built-in rules GNU make defines by default (such as .o targets),
0012 # so that we pass through all targets to Makefile.perf:
0013 #
0014 .SUFFIXES:
0015 
0016 #
0017 # We don't want to pass along options like -j:
0018 #
0019 unexport MAKEFLAGS
0020 
0021 #
0022 # Do a parallel build with multiple jobs, based on the number of CPUs online
0023 # in this system: 'make -j8' on a 8-CPU system, etc.
0024 #
0025 # (To override it, run 'make JOBS=1' and similar.)
0026 #
0027 ifeq ($(JOBS),)
0028   JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
0029   ifeq ($(JOBS),0)
0030     JOBS := 1
0031   endif
0032 endif
0033 
0034 #
0035 # Only pass canonical directory names as the output directory:
0036 #
0037 ifneq ($(O),)
0038   FULL_O := $(shell cd $(PWD); readlink -f $(O) || echo $(O))
0039 endif
0040 
0041 #
0042 # Only accept the 'DEBUG' variable from the command line:
0043 #
0044 ifeq ("$(origin DEBUG)", "command line")
0045   ifeq ($(DEBUG),)
0046     override DEBUG = 0
0047   else
0048     SET_DEBUG = "DEBUG=$(DEBUG)"
0049   endif
0050 else
0051   override DEBUG = 0
0052 endif
0053 
0054 define print_msg
0055   @printf '  BUILD:   Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
0056 endef
0057 
0058 define make
0059   @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
0060 endef
0061 
0062 #
0063 # Needed if no target specified:
0064 # (Except for tags and TAGS targets. The reason is that the
0065 # Makefile does not treat tags/TAGS as targets but as files
0066 # and thus won't rebuilt them once they are in place.)
0067 #
0068 all tags TAGS:
0069         $(print_msg)
0070         $(make)
0071 
0072 ifdef MAKECMDGOALS
0073 has_clean := 0
0074 ifneq ($(filter clean,$(MAKECMDGOALS)),)
0075   has_clean := 1
0076 endif # clean
0077 
0078 ifeq ($(has_clean),1)
0079   rest := $(filter-out clean,$(MAKECMDGOALS))
0080   ifneq ($(rest),)
0081 $(rest): clean
0082   endif # rest
0083 endif # has_clean
0084 endif # MAKECMDGOALS
0085 
0086 #
0087 # Explicitly disable parallelism for the clean target.
0088 #
0089 clean:
0090         $(make) -j1
0091 
0092 #
0093 # The build-test target is not really parallel, don't print the jobs info,
0094 # it also uses only the tests/make targets that don't pollute the source
0095 # repository, i.e. that uses O= or builds the tarpkg outside the source
0096 # repo directories.
0097 #
0098 # For a full test, use:
0099 #
0100 # make -C tools/perf -f tests/make
0101 #
0102 build-test:
0103         @$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk2 out
0104 
0105 build-test-tarball:
0106         @$(MAKE) -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory out
0107 
0108 #
0109 # All other targets get passed through:
0110 #
0111 %: FORCE
0112         $(print_msg)
0113         $(make)
0114 
0115 .PHONY: tags TAGS FORCE Makefile