1###############################################################################
2# Top level makefile for build system
3#
4# Copyright 2006 Nintendo.  All rights reserved.
5#
6# These coded instructions, statements, and computer programs contain
7# proprietary information of Nintendo of America Inc. and/or Nintendo
8# Company Ltd., and are protected by Federal copyright law.  They may
9# not be disclosed to third parties or copied or duplicated in any form,
10# in whole or in part, without the prior written consent of Nintendo.
11###############################################################################
12
13# Valid targets
14# "make" by itself builds and installs everything listed in LIBS, DEMOS and
15# TESTS.  Default target is HW1 DEBUG
16# "make clean" cleans everything listed in LIBS, DEMOS and
17# TESTS.  Only MACOS DEBUG versions are cleaned
18# "make NDEBUG=TRUE" builds nondebug versions.
19# "make NDEBUG=TRUE clean" cleans only nondebug versions.
20
21include buildtools/commondefs
22
23###############################################################################
24# Dependencies
25###############################################################################
26
27# THE ORDER OF THE LIBRARIES LISTED IS ALSO THE LIBRARY BUILD ORDER
28
29# XXX All libraries that are included in commondefs->REVOLUTION_LIBS must be listed
30# XXX here under $(LIBS), or else executables will fail to link
31
32ifdef EPPC
33###################
34# EPPC BUILDS
35###################
36LIBS     =  precompile   \
37            ai           \
38            amcnotstub   \
39            amcstubs     \
40            ax           \
41            base         \
42            card         \
43            cx           \
44            db           \
45            dsp          \
46            dvd          \
47            exi          \
48            fa           \
49            gx           \
50            kpad         \
51            kpadOld      \
52            mem          \
53            midi         \
54            mtx          \
55            odemustubs   \
56            odenotstub   \
57            os           \
58            pad          \
59            si           \
60            vi           \
61            wpad         \
62            G2D          \
63            axart        \
64            axfx         \
65            demo         \
66            gd           \
67            mix          \
68            perf         \
69            sample       \
70            seq          \
71            sp           \
72            syn          \
73            thp          \
74            tpl          \
75            nand         \
76            sc           \
77            euart        \
78            ipc          \
79            hio2         \
80            sdi          \
81            socket       \
82            usb          \
83            arc          \
84            dvdvideo     \
85            wud          \
86            bte          \
87            cx           \
88            enc          \
89            cnt          \
90            fnt          \
91            esp          \
92            usbcmn       \
93            scutil       \
94            usbkbd       \
95            kbd          \
96            kpr          \
97            darch        \
98            hid
99
100LIBS_INTERNAL = wk        \
101                wkmc      \
102                sdwp      \
103                simplekit \
104                es        \
105                wad       \
106                cunit     \
107                fs
108
109LIBS += ${LIBS_INTERNAL}
110
111DEMOS    =  axdemo        \
112            dvddemo       \
113            fademo        \
114            gxdemo        \
115            kpaddemo      \
116            kpadOlddemo   \
117            memdemo       \
118            osdemo        \
119            sample        \
120            spdemo        \
121            videmo        \
122            wpaddemo      \
123            nanddemo      \
124            reldemo       \
125            paddemo       \
126            thpdemo       \
127            scprivatedemo \
128            scdemo        \
129            carddemo      \
130            gddemo        \
131            hio2demo      \
132            arcdemo       \
133            encdemo       \
134            cxdemo        \
135            fntdemo       \
136            kbddemo       \
137            kprdemo       \
138            mididemo      \
139            limitdemo     \
140            launchdemo    \
141            installdemo   \
142            rsodemo
143
144
145#             esEmudemo     \
146#             smaEmudemo    \
147#             wpadEmudemo   \
148#             kpadEmudemo   \
149#             diemu         \
150
151TESTS    =  os        \
152            card      \
153            sample    \
154            exi       \
155            sdwp      \
156            nand      \
157            pad       \
158            sc        \
159            dvd       \
160            di        \
161            fs        \
162            es        \
163            sdi       \
164            socket    \
165            usb       \
166            wpad      \
167            abuse     \
168            Nmenu     \
169            enc       \
170            installer \
171            cx        \
172            updatecheck
173
174endif # EPPC
175
176ifdef X86
177
178HOST_LIBS =  gd         \
179             hio2Host
180
181HOST_DEMOS = gddemo     \
182             hio2demo
183
184HOST_TOOLS = sample       \
185             dls1wt       \
186             dspadpcm     \
187             dsptool      \
188             sndconv      \
189             soundfile    \
190             thpaudio     \
191             thpcore      \
192             thputilities \
193             THPConv      \
194             darch        \
195             ntcompress
196
197endif # X86
198
199LIBDIRS     = $(addprefix $(LIB_ROOT)/,$(LIBS))
200TESTDIRS    = $(addprefix $(TEST_ROOT)/,$(TESTS))
201DEMODIRS    = $(addprefix $(DEMO_ROOT)/,$(DEMOS))
202
203HOSTLIBDIRS  = $(addprefix $(LIB_ROOT)/,$(HOST_LIBS))
204HOSTDEMODIRS = $(addprefix $(DEMO_ROOT)/,$(HOST_DEMOS))
205ADPCMLIBDIRS = $(addprefix $(LIB_ROOT)/,$(ADPCMLIB))
206SOUNDFILELIBDIRS = $(addprefix $(LIB_ROOT)/,$(SOUNDFILELIB))
207HOSTTOOLDIRS = $(addprefix $(TOOL_ROOT)/,$(HOST_TOOLS))
208
209# NOTE: the order of these directories determines build order.
210# In this case, we want libs first, tests second, demos last
211SUBDIRS     = $(addprefix $(LIB_ROOT)/,$(LIBS)) 	\
212              $(addprefix $(TEST_ROOT)/,$(TESTS))	\
213              $(addprefix $(DEMO_ROOT)/,$(DEMOS))	\
214              $(addprefix $(LIB_ROOT)/,$(HOST_LIBS))	\
215              $(addprefix $(DEMO_ROOT)/,$(HOST_DEMOS))	\
216              $(addprefix $(LIB_ROOT)/,$(SOUNDFILELIB))	\
217              $(addprefix $(LIB_ROOT)/,$(ADPCMLIB))
218
219# The following changes the Makefile include path to include a
220# definition of which architecture we're building for
221ARCH_PATH	= $(MAKE_ROOT)/$(ARCH_TARGET)
222
223all: setup subdirectories
224
225setup:
226	@if [ ! -d $(INSTALL_ROOT) ] ; then \
227		echo "Creating $(INSTALL_ROOT)" ; \
228		rm -rf $(INSTALL_ROOT) ; \
229		mkdir $(BASEINSTALL_ROOT) ; \
230		mkdir $(BASEINSTALL_ROOT)/$(ARCH_TARGET) ; \
231		mkdir $(INSTALL_ROOT)/lib ; \
232		mkdir $(INSTALL_ROOT)/bin ; \
233	else \
234		echo "Install directory ready" ;\
235	fi
236
237# the following lines build up the flags for the recursive make commands
238BUILDFLAGS	= X86=$(X86) PLATFORM=$(PLATFORM) DBREL="$(DBREL)" BUILDTOOLS_ROOT=$(MAKE_ROOT)
239
240ifdef NDEBUG
241BUILDFLAGS	+= NDEBUG=TRUE
242else
243BUILDFLAGS	+= DEBUG=TRUE
244endif
245
246ifdef BUILD
247BUILDFLAGS	+= build
248endif
249
250ifdef INSTALL
251BUILDFLAGS	+= install
252endif
253
254.PHONY: alllibs libraries demos tests hostlibs hostdemos adpcmlib
255
256subdirectories:
257	@for d in $(SUBDIRS) ; do \
258		echo "------------------------------------------------------------------" ; \
259		echo "Building $$d" ; \
260		if [ ! -d $$d ] ; then \
261			echo "Module $$d is missing...skipping" ; \
262		else \
263			$(MAKE) -C $$d $(BUILDFLAGS) ; \
264		fi ; \
265	done ;
266
267alllibs: libraries hostlibs
268
269libraries:
270	@for d in $(LIBDIRS) ; do \
271		echo "------------------------------------------------------------------" ; \
272		echo "Building $$d" ; \
273		if [ ! -d $$d ] ; then \
274			echo "Module $$d is missing...skipping" ; \
275		else \
276			$(MAKE) -C $$d $(BUILDFLAGS) ; \
277		fi ; \
278	done ;
279
280libraries.%:
281	@echo "------------------------------------------------------------------" ; \
282	echo "Building libraries/$*" ; \
283	$(MAKE) -C $(LIB_ROOT)/$* $(BUILDFLAGS)
284
285hostlibs:
286	@for d in $(HOSTLIBDIRS) ; do \
287		echo "------------------------------------------------------------------" ; \
288		echo "Building $$d" ; \
289		if [ ! -d $$d ] ; then \
290			echo "Module $$d is missing...skipping" ; \
291		else \
292			$(MAKE) -C $$d $(BUILDFLAGS) ; \
293		fi ; \
294	done ;
295
296hostlibs.%:
297	@echo "------------------------------------------------------------------" ; \
298	echo "Building libraries/$*" ; \
299	$(MAKE) -C $(LIB_ROOT)/$* $(BUILDFLAGS)
300
301demos:
302	@for d in $(DEMODIRS) ; do \
303		echo "------------------------------------------------------------------" ; \
304		echo "Building $$d" ; \
305		if [ ! -d $$d ] ; then \
306			echo "Module $$d is missing...skipping" ; \
307		else \
308			$(MAKE) -C $$d $(BUILDFLAGS) ; \
309		fi ; \
310	done ;
311
312demos.%:
313	@echo "------------------------------------------------------------------" ; \
314	echo "Building demos/$*" ; \
315	$(MAKE) -C $(DEMO_ROOT)/$* $(BUILDFLAGS)
316
317hostdemos:
318	@for d in $(HOSTDEMODIRS) ; do \
319		echo "------------------------------------------------------------------" ; \
320		echo "Building $$d" ; \
321		if [ ! -d $$d ] ; then \
322			echo "Module $$d is missing...skipping" ; \
323		else \
324			$(MAKE) -C $$d $(BUILDFLAGS) ; \
325		fi ; \
326	done ;
327
328hostdemos.%:
329	@echo "------------------------------------------------------------------" ; \
330	echo "Building demos/$*" ; \
331	$(MAKE) -C $(DEMO_ROOT)/$* $(BUILDFLAGS)
332
333hosttools:
334	@for d in $(HOSTTOOLDIRS) ; do \
335		echo "------------------------------------------------------------------" ; \
336		echo "Building $$d" ; \
337		if [ ! -d $$d ] ; then \
338			echo "Module $$d is missing...skipping" ; \
339		else \
340			$(MAKE) -C $$d $(BUILDFLAGS) ; \
341		fi ; \
342	done ;
343
344hosttools.%:
345	@echo "------------------------------------------------------------------" ; \
346	echo "Building demos/$*" ; \
347	$(MAKE) -C $(TOOL_ROOT)/$* $(BUILDFLAGS)
348
349tests:
350	@for d in $(TESTDIRS) ; do \
351		echo "------------------------------------------------------------------" ; \
352		echo "Building $$d" ; \
353		if [ ! -d $$d ] ; then \
354			echo "Module $$d is missing...skipping" ; \
355		else \
356			$(MAKE) -C $$d $(BUILDFLAGS) ; \
357		fi ; \
358	done ;
359
360tests.%:
361	@echo "------------------------------------------------------------------" ; \
362	echo "Building tests/$*" ; \
363	$(MAKE) -C $(TEST_ROOT)/$* $(BUILDFLAGS)
364
365adpcmlib:
366	@for d in $(ADPCMLIBDIRS) ; do \
367		echo "------------------------------------------------------------------" ; \
368		echo "Building $$d" ; \
369		if [ ! -d $$d ] ; then \
370			echo "Module $$d is missing...skipping" ; \
371		else \
372			$(MAKE) -C $$d $(BUILDFLAGS) ; \
373		fi ; \
374	done ;
375
376update:
377	@if [ ! -f $(SS) ] ; then \
378		echo "SourceSafe is not installed!  Please go to \\ntd-pdc\Vss\Dolphin Readme" ; \
379		exit 1; \
380	fi
381	@echo "Changing Sourcesafe project to $(SSROOT), performing full GET."
382	@$(SS) cp $(SSROOT) -I-Y -y$(SSUSER)
383	@cd $(ROOT)
384	@$(SS) get \*.\* -R -I-Y -y$(SSUSER) -r -gf
385
386clean clobber superclobber:
387	@echo ">>> Cleaning $(ARCH_TARGET) target" ;
388	@for d in $(SUBDIRS) ; do \
389		echo "------------------------------------------------------------------" ; \
390		echo "Cleaning $$d" ; \
391		if [ ! -d $$d ] ; then \
392			echo "Module $$d is missing...skipping" ; \
393		else \
394			$(MAKE) -C $$d $@ $(BUILDFLAGS) ; \
395		fi ; \
396	done ;
397
398clean_libraries:
399	@echo ">>> Cleaning $(ARCH_TARGET) target" ;
400	@for d in $(LIBDIRS) ; do \
401		echo "------------------------------------------------------------------" ; \
402		echo "Cleaning $$d" ; \
403		if [ ! -d $$d ] ; then \
404			echo "Module $$d is missing...skipping" ; \
405		else \
406			$(MAKE) -C $$d clean $(BUILDFLAGS) ; \
407		fi ; \
408	done ;
409