1###############################################################################
2#
3# make fast target
4#
5# Copyright 2011 Nintendo.  All rights reserved.
6#
7# These coded instructions, statements, and computer programs contain
8# proprietary information of Nintendo of America Inc. and/or Nintendo
9# Company Ltd., and are protected by Federal copyright law.  They may
10# not be disclosed to third parties or copied or duplicated in any form,
11# in whole or in part, without the prior written consent of Nintendo.
12#
13###############################################################################
14
15.PHONY: fast fast_print fast_print_save_log
16
17# use $(_@) to hide echo commands etc (can be overriden if needed)
18# don't use $(_@) or $(_@) to hide real build commands -s will hide these commands
19_@=@
20
21ifndef CAFE_MAKE_JOBS
22export CAFE_MAKE_JOBS=$(shell echo $$(($(NUMBER_OF_PROCESSORS)*4)))
23endif
24
25ifndef IN_FAST_BUILD
26define DO_FAST_BUILD
27	$(info ------------------------------------------------------------------)
28	$(_@) echo make $@ with $(CAFE_MAKE_JOBS) jobs:  $(CURDIR) ; \
29	 export IN_FAST_BUILD=1; \
30	 _BUILD_START=`date +%s` ; \
31	 $(MAKE) $(_SILENT) -j $$CAFE_MAKE_JOBS $(_TARGET) 2>&1 | tee .make_fast.txt ; \
32	 MAKE_FAST_RESULT=$$PIPESTATUS ; \
33	 $(CAFE_ROOT)/system/src/build/make/check_build_errors.sh .make_fast.txt ; \
34	 _BUILD_TIME=$$((`date +%s`-$${_BUILD_START})) ; \
35	 printf "make $(CURDIR) $(BUILD_TYPE) $(_TARGET) build time %01d:%02d:%02d $(CAFE_MAKE_JOBS) jobs.\n" $$(($${_BUILD_TIME}/3600)) $$(($$(($${_BUILD_TIME}%3600))/60)) $$(($${_BUILD_TIME}%60)) >> .make_fast.txt ; \
36	 printf "make $(CURDIR) $(BUILD_TYPE) $(_TARGET) build time %01d:%02d:%02d $(CAFE_MAKE_JOBS) jobs.\n" $$(($${_BUILD_TIME}/3600)) $$(($$(($${_BUILD_TIME}%3600))/60)) $$(($${_BUILD_TIME}%60)) ; \
37	 exit $$MAKE_FAST_RESULT
38endef
39else
40define DO_FAST_BUILD
41	@echo -e "**** RECURSIVE MAKE FAST ****\nmake $@ with $(CAFE_MAKE_JOBS) jobs:  $(CURDIR)"
42	+$(_@)export IN_FAST_BUILD=1; \
43	 _BUILD_START=`date +%s` ; \
44	 $(MAKE) $(_SILENT) -j $$CAFE_MAKE_JOBS $(_TARGET) ; \
45	 MAKE_FAST_RESULT=$$PIPESTATUS ; \
46	 _BUILD_TIME=$$((`date +%s`-$${_BUILD_START})) ; \
47	 printf "**** RECURSIVE MAKE FAST ****\nmake $(CURDIR) $(BUILD_TYPE) $(_TARGET) build time %01d:%02d:%02d\n" $$(($${_BUILD_TIME}/3600)) $$(($$(($${_BUILD_TIME}%3600))/60)) $$(($${_BUILD_TIME}%60)) ; \
48	 exit $$MAKE_FAST_RESULT
49endef
50endif
51
52fast_print: _SILENT = _@=
53fast_print: _TARGET = default
54fast_print:
55	$(DO_FAST_BUILD)
56
57# usage fast_target to call a parallel build "fast_print"
58# on a differnt target than default Write it like:
59#
60#	cos: _TARGET = install_cos
61#	cos: fast_target
62fast_target: _SILENT = _@=
63fast_target:
64	$(DO_FAST_BUILD)
65
66fast: _SILENT = -s _@=@
67fast: _TARGET = default
68fast:
69	$(DO_FAST_BUILD)
70
71# For backwards compatibility:
72fast_print_save_log: fast_print
73	mv -f .make_fast.txt make_fast_print_save_log.txt
74