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 non-debug versions.
19# "make NDEBUG=TRUE clean" cleans only non-debug 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     =  ai           \
37            amcnotstub   \
38            amcstubs     \
39            ax           \
40            base         \
41            card         \
42            cx           \
43            db           \
44            diemu        \
45            dsp          \
46            dvd          \
47            exi          \
48            fa           \
49            gx           \
50            kpad         \
51            kpadEmu      \
52            mem          \
53            midi         \
54            mtx          \
55            odemustubs   \
56            odenotstub   \
57            os           \
58            pad          \
59            padempty     \
60            si           \
61            vi           \
62            wpad         \
63            wpadEmu      \
64            G2D          \
65            axart        \
66            axfx         \
67            demo         \
68            gd           \
69            mix          \
70            perf         \
71            sample       \
72            seq          \
73            sp           \
74            syn          \
75            thp          \
76            tpl          \
77            nand         \
78            sc           \
79            euart        \
80            ipc          \
81            hio2         \
82            sdi          \
83            socket       \
84            usb          \
85            arc          \
86            dvdvideo     \
87            wud          \
88            bte          \
89            cx           \
90            enc          \
91			cnt
92
93
94LIBS_INTERNAL = wk       \
95                wkmc     \
96                cunit    \
97                smaEmu   \
98                isfsEmu  \
99                sdwp     \
100                simplekit \
101                ipcRegEmu \
102                es       \
103                wad      \
104                fs
105
106LIBS += ${LIBS_INTERNAL}
107
108DEMOS    =  axdemo        \
109            diemu         \
110            dvddemo       \
111            fademo        \
112            gxdemo        \
113            kpaddemo      \
114            memdemo       \
115            osdemo        \
116            sample        \
117            spdemo        \
118            videmo        \
119            wpaddemo      \
120            smaEmudemo    \
121            nanddemo      \
122            reldemo       \
123            paddemo       \
124            thpdemo       \
125            esEmudemo     \
126            scprivatedemo \
127            scdemo        \
128            carddemo      \
129            gddemo        \
130            hio2demo      \
131            arcdemo       \
132            wpadEmudemo   \
133            kpadEmudemo   \
134            encdemo       \
135            cxdemo
136
137TESTS    =  os        \
138            card      \
139            sample    \
140            exi       \
141            sdwp      \
142            isfsEmu   \
143            nand      \
144            pad       \
145            sc        \
146            dvd       \
147            di        \
148            fs        \
149            es        \
150            sdi       \
151            socket    \
152            usb       \
153            wpad      \
154            abuse
155#            wpadEmu   \
156#            sec       \
157
158endif
159
160ifdef X86
161HOST_LIBS =  gd         \
162             hio2Host
163#             fiottyHost \
164
165HOST_DEMOS = gddemo  \
166             hio2demo
167
168
169HOST_TOOLS =   sample       \
170               dls1wt       \
171               dspadpcm     \
172               dsptool      \
173               sndconv      \
174               soundfile    \
175               thpaudio     \
176               thpcore      \
177               thputilities \
178               THPConv      \
179               darch        \
180               ntcompress
181
182
183endif
184
185LIBDIRS     = $(addprefix $(LIB_ROOT)/,$(LIBS))
186TESTDIRS    = $(addprefix $(TEST_ROOT)/,$(TESTS))
187DEMODIRS    = $(addprefix $(DEMO_ROOT)/,$(DEMOS))
188
189HOSTLIBDIRS  = $(addprefix $(LIB_ROOT)/,$(HOST_LIBS))
190HOSTDEMODIRS = $(addprefix $(DEMO_ROOT)/,$(HOST_DEMOS))
191ADPCMLIBDIRS = $(addprefix $(LIB_ROOT)/,$(ADPCMLIB))
192SOUNDFILELIBDIRS = $(addprefix $(LIB_ROOT)/,$(SOUNDFILELIB))
193HOSTTOOLDIRS = $(addprefix $(TOOL_ROOT)/,$(HOST_TOOLS))
194
195# NOTE: the order of these directories determines build order.
196# In this case, we want libs first, tests second, demos last
197SUBDIRS     = $(addprefix $(LIB_ROOT)/,$(LIBS)) 	\
198              $(addprefix $(TEST_ROOT)/,$(TESTS))	\
199              $(addprefix $(DEMO_ROOT)/,$(DEMOS))	\
200              $(addprefix $(LIB_ROOT)/,$(HOST_LIBS))	\
201              $(addprefix $(DEMO_ROOT)/,$(HOST_DEMOS))	\
202              $(addprefix $(LIB_ROOT)/,$(SOUNDFILELIB))	\
203              $(addprefix $(LIB_ROOT)/,$(ADPCMLIB))
204
205
206# The following changes the Makefile include path to include a
207# definition of which architecture we're building for
208ARCH_PATH	= $(MAKE_ROOT)/$(ARCH_TARGET)
209
210all: setup subdirectories
211
212setup:
213	@if [ ! -d $(INSTALL_ROOT) ] ; then \
214		echo "Creating $(INSTALL_ROOT)" ; \
215		rm -rf $(INSTALL_ROOT) ; \
216		mkdir $(BASEINSTALL_ROOT) ; \
217		mkdir $(BASEINSTALL_ROOT)/$(ARCH_TARGET) ; \
218		mkdir $(INSTALL_ROOT)/lib ; \
219		mkdir $(INSTALL_ROOT)/bin ; \
220	else \
221		echo "Install directory ready" ;\
222	fi
223
224# the following lines build up the flags for the recursive make commands
225BUILDFLAGS	= X86=$(X86) PLATFORM=$(PLATFORM) DBREL="$(DBREL)" BUILDTOOLS_ROOT=$(MAKE_ROOT)
226
227ifdef NDEBUG
228BUILDFLAGS	+= NDEBUG=TRUE
229else
230BUILDFLAGS	+= DEBUG=TRUE
231endif
232
233ifdef BUILD
234BUILDFLAGS	+= build
235endif
236
237ifdef INSTALL
238BUILDFLAGS	+= install
239endif
240
241.PHONY: alllibs libraries demos tests hostlibs hostdemos adpcmlib
242
243subdirectories:
244	@for d in $(SUBDIRS) ; do \
245		echo "------------------------------------------------------------------" ; \
246		echo "Building $$d" ; \
247		if [ ! -d $$d ] ; then \
248			echo "Module $$d is missing...skipping" ; \
249		else \
250			$(MAKE) -C $$d $(BUILDFLAGS) ; \
251		fi ; \
252	done ;
253
254alllibs: libraries hostlibs
255
256libraries:
257	@for d in $(LIBDIRS) ; 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
267libraries.%:
268	@echo "------------------------------------------------------------------" ; \
269	echo "Building libraries/$*" ; \
270	$(MAKE) -C $(LIB_ROOT)/$* $(BUILDFLAGS)
271
272hostlibs:
273	@for d in $(HOSTLIBDIRS) ; do \
274		echo "------------------------------------------------------------------" ; \
275		echo "Building $$d" ; \
276		if [ ! -d $$d ] ; then \
277			echo "Module $$d is missing...skipping" ; \
278		else \
279			$(MAKE) -C $$d $(BUILDFLAGS) ; \
280		fi ; \
281	done ;
282
283hostlibs.%:
284	@echo "------------------------------------------------------------------" ; \
285	echo "Building libraries/$*" ; \
286	$(MAKE) -C $(LIB_ROOT)/$* $(BUILDFLAGS)
287
288demos:
289	@for d in $(DEMODIRS) ; do \
290		echo "------------------------------------------------------------------" ; \
291		echo "Building $$d" ; \
292		if [ ! -d $$d ] ; then \
293			echo "Module $$d is missing...skipping" ; \
294		else \
295			$(MAKE) -C $$d $(BUILDFLAGS) ; \
296		fi ; \
297	done ;
298
299demos.%:
300	@echo "------------------------------------------------------------------" ; \
301	echo "Building demos/$*" ; \
302	$(MAKE) -C $(DEMO_ROOT)/$* $(BUILDFLAGS)
303
304hostdemos:
305	@for d in $(HOSTDEMODIRS) ; do \
306		echo "------------------------------------------------------------------" ; \
307		echo "Building $$d" ; \
308		if [ ! -d $$d ] ; then \
309			echo "Module $$d is missing...skipping" ; \
310		else \
311			$(MAKE) -C $$d $(BUILDFLAGS) ; \
312		fi ; \
313	done ;
314
315hostdemos.%:
316	@echo "------------------------------------------------------------------" ; \
317	echo "Building demos/$*" ; \
318	$(MAKE) -C $(DEMO_ROOT)/$* $(BUILDFLAGS)
319
320hosttools:
321	@for d in $(HOSTTOOLDIRS) ; do \
322		echo "------------------------------------------------------------------" ; \
323		echo "Building $$d" ; \
324		if [ ! -d $$d ] ; then \
325			echo "Module $$d is missing...skipping" ; \
326		else \
327			$(MAKE) -C $$d $(BUILDFLAGS) ; \
328		fi ; \
329	done ;
330
331hosttools.%:
332	@echo "------------------------------------------------------------------" ; \
333	echo "Building demos/$*" ; \
334	$(MAKE) -C $(TOOL_ROOT)/$* $(BUILDFLAGS)
335
336tests:
337	@for d in $(TESTDIRS) ; do \
338		echo "------------------------------------------------------------------" ; \
339		echo "Building $$d" ; \
340		if [ ! -d $$d ] ; then \
341			echo "Module $$d is missing...skipping" ; \
342		else \
343			$(MAKE) -C $$d $(BUILDFLAGS) ; \
344		fi ; \
345	done ;
346
347tests.%:
348	@echo "------------------------------------------------------------------" ; \
349	echo "Building tests/$*" ; \
350	$(MAKE) -C $(TEST_ROOT)/$* $(BUILDFLAGS)
351
352adpcmlib:
353	@for d in $(ADPCMLIBDIRS) ; do \
354		echo "------------------------------------------------------------------" ; \
355		echo "Building $$d" ; \
356		if [ ! -d $$d ] ; then \
357			echo "Module $$d is missing...skipping" ; \
358		else \
359			$(MAKE) -C $$d $(BUILDFLAGS) ; \
360		fi ; \
361	done ;
362
363update:
364	@if [ ! -f $(SS) ] ; then \
365		echo "SourceSafe is not installed!  Please go to \\ntd-pdc\Vss\Dolphin Readme" ; \
366		exit 1; \
367	fi
368	@echo "Changing Sourcesafe project to $(SSROOT), performing full GET."
369	@$(SS) cp $(SSROOT) -I-Y -y$(SSUSER)
370	@cd $(ROOT)
371	@$(SS) get \*.\* -R -I-Y -y$(SSUSER) -r -gf
372
373clean clobber superclobber:
374	@echo ">>> Cleaning $(ARCH_TARGET) target" ;
375	@for d in $(SUBDIRS) ; do \
376		echo "------------------------------------------------------------------" ; \
377		echo "Cleaning $$d" ; \
378		if [ ! -d $$d ] ; then \
379			echo "Module $$d is missing...skipping" ; \
380		else \
381			$(MAKE) -C $$d $@ $(BUILDFLAGS) ; \
382		fi ; \
383	done ;
384