1###############################################################################
2#
3# call sub makefiles automatically
4#
5# Copyright 2010 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
15MODULE_DEPTH    := ..
16BUILD_MAKE_PATH := $(MODULE_DEPTH)/build/make
17
18include $(BUILD_MAKE_PATH)/commondefs.mk
19
20# Recognized targets called by meta-build
21.PHONY: default headers install clean clobber
22
23# Parallel build by default (make fast -> make default)
24include $(BUILD_MAKE_PATH)/target_fast.mk
25
26# Default target
27default: headers install
28
29###############################################################################
30#
31#  help
32#
33###############################################################################
34
35.PHONY: help
36
37help:
38	$(_@)echo "------------------------------------------------------------------" ; \
39	 echo "Usage:" ; \
40	 echo "" ; \
41	 echo "  To build" ; \
42	 echo "    make                           - build debug version"; \
43	 echo "    make NDEBUG=TRUE               - build non-debug version"; \
44	 echo "    make default                   - build in serial (without parallel jobs) with compiler+linker output" ; \
45	 echo "    make clean                     - remove object and dependency files"; \
46	 echo "    make clobber                   - return to checkout state"; \
47	 echo "    export CAFE_MAKE_JOBS=<n>      - set maximum number of parallel jobs"; \
48	 echo "" ; \
49	 echo "  To make subset" ; \
50	 echo "    make -j <n> headers            - pass 1 (export headers)" ; \
51	 echo "    make -j <n> install            - pass 2 (build everything internally)" ; \
52	 echo "    make -j <n> install_<dir>      - install binaries for immediate subdirectory" ; \
53
54###############################################################################
55#
56#  directories
57#
58###############################################################################
59
60MAKE_DIRS := libsys \
61             def_malloc \
62             demo/shaders \
63             demo \
64             gfd \
65             gx2ut \
66             lcstream \
67             mtx \
68             pmcpu \
69             zipfile \
70             szfile
71
72###############################################################################
73#
74#  headers
75#
76###############################################################################
77
78MAKE_HEADERS_DIRS_TARGET := $(addprefix headers_,$(MAKE_DIRS))
79
80.PHONY: $(MAKE_HEADERS_DIRS_TARGET)
81
82$(MAKE_HEADERS_DIRS_TARGET):
83	$(MAKE) -C $(subst headers_,,$@) headers
84
85headers: $(MAKE_HEADERS_DIRS_TARGET)
86
87###############################################################################
88#
89#  install
90#
91###############################################################################
92
93MAKE_INSTALL_DIRS_TARGET := $(addprefix install_,$(MAKE_DIRS))
94
95.PHONY: $(MAKE_INSTALL_DIRS_TARGET)
96
97$(MAKE_INSTALL_DIRS_TARGET):
98	$(MAKE) -C $(subst install_,,$@) install
99
100install_audio: $(filter-out install_audio, $(MAKE_INSTALL_DIRS_TARGET))
101
102install: $(MAKE_INSTALL_DIRS_TARGET)
103
104###############################################################################
105#
106#  clean
107#
108###############################################################################
109
110MAKE_CLEAN_DIRS_TARGET   := $(addprefix clean_,$(MAKE_DIRS))
111
112.PHONY: $(MAKE_CLEAN_DIRS_TARGET)
113
114$(MAKE_CLEAN_DIRS_TARGET):
115	$(_@)$(MAKE) -C $(subst clean_,,$@) clean
116
117clean: $(MAKE_CLEAN_DIRS_TARGET)
118
119###############################################################################
120#
121#  clobber
122#
123###############################################################################
124
125MAKE_CLOBBER_DIRS_TARGET := $(addprefix clobber_,$(MAKE_DIRS))
126
127.PHONY: $(MAKE_CLOBBER_DIRS_TARGET)
128
129$(MAKE_CLOBBER_DIRS_TARGET):
130	$(_@)$(MAKE) -C $(subst clobber_,,$@) clobber
131
132clobber: $(MAKE_CLOBBER_DIRS_TARGET)
133