1###############################################################################
2# Makefile for sampledemo
3#
4# Copyright (C) 2005-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# $Log: makefile,v $
13# Revision 1.13  2009/01/14 05:58:00  wada_jumpei
14# Modified datatitle target to change default access title game code to "RABA".
15#
16# Revision 1.12  2008/09/05 09:40:28  nrs_buildsystem
17# Changed all command to adopt "make -j option(parallel processing)" (by yasuh-to).
18#
19# Revision 1.11  2008/07/30 02:36:45  wada_jumpei
20# Modified ACCESS_GAMECODE.
21#
22# Revision 1.10  2008/07/23 06:42:32  nakano_yoshinobu
23# Merged strapcntdemo with cntdemo.
24#
25# Revision 1.9  2008/07/23 00:32:21  wada_jumpei
26# Merged datatitledemo with cntdemo.
27#
28# Revision 1.8  2008/01/08 10:59:01  wada_jumpei
29# Added compressing a dol file to "makewad" target.
30#
31# Revision 1.7  2007/10/11 02:16:14  wada_jumpei
32# Added makewad_simple target.
33#
34# Revision 1.3  2007/08/07 05:18:11  wada_jumpei
35# Fixed makewad target.
36#
37# Revision 1.2  2007/08/06 02:33:13  wada_jumpei
38# Added detailed examples of making wad file with some settings.
39#
40# Revision 1.1  2006/09/08 13:48:30  wada_jumpei
41# Intial revision
42#
43###############################################################################
44
45# All modules have "setup" and "build" as targets.  System libraries
46# and demo programs also have an "install" target that copies the compiled
47# binaries to the binary tree (/$(ARCH_TARGET)).
48
49all:
50	$(MAKE) setup
51	$(MAKE) build
52	$(MAKE) install
53
54# commondefs must be included near the top so that all common variables
55# will be defined before their use.
56
57include $(REVOLUTION_SDK_ROOT)/build/buildtools/commondefs
58
59# module name should be set to the name of this subdirectory
60# DEMO = TRUE indicates that this module resides under the "demos" subtree.
61# The list of selectable paths can be found in modulerules.
62
63MODULENAME	= cntdemo
64DEMO		= TRUE
65
66
67# CSRCS lists all C files that should be built
68# The makefile determines which objects are linked into which binaries
69# based on the dependencies you fill in at the bottom of this file
70
71CSRCS		= cntdemo.c datatitledemo.c strapcntdemo.c
72
73
74# BINNAMES lists all binaries that will be linked.  Note that no suffix is
75# required, as that will depend on whether this is a DEBUG build or not.
76# The final name of the binaries will be $(BINNAME)$(BINSUFFIX)
77
78BINNAMES 	= cntdemo datatitledemo strapcntdemo
79
80
81# defining a linker command file will have the build system generate it
82# automatically and include it on the linker invocation line
83
84LCF_FILE	= $(INC_ROOT)/revolution/eppc.$(ARCH_TARGET).lcf
85
86
87# modulerules contains the rules that will use the above variables
88# and dependencies below to construct the binaries specified.
89
90include $(REVOLUTION_SDK_ROOT)/build/buildtools/modulerules
91
92# additional libraries not defined as REVOLUTION_LIBS
93TPL_LIB     = $(INSTALL_ROOT)/lib/tpl$(LIBSUFFIX)
94
95# Dependencies for the binaries listed in BINNAMES should come here
96# They are your typical makefile rule, with extra variables to ensure
97# that the names and paths match up.
98# $(FULLBIN_ROOT) is the location of the local bin directory
99# $(BINSUFFIX) depends on whether this is a debug build or not
100# $(REVOLUTION_LIBS) includes all the Revolution libraries.
101
102REVOLUTION_LIBS += $(INSTALL_ROOT)/lib/cnt$(LIBSUFFIX)
103
104$(FULLBIN_ROOT)/cntdemo$(BINSUFFIX):	cntdemo.o $(REVOLUTION_LIBS)
105$(FULLBIN_ROOT)/datatitledemo$(BINSUFFIX):	datatitledemo.o $(REVOLUTION_LIBS)
106$(FULLBIN_ROOT)/strapcntdemo$(BINSUFFIX):	strapcntdemo.o $(REVOLUTION_LIBS) $(TPL_LIB)
107
108###############################################################################
109# common settings for demos
110###############################################################################
111
112DVDROOT_DIR = $(subst \,/,$(REVOLUTION_SDK_ROOT))/dvddata
113ARCFILE_DIR = $(DVDROOT_DIR)/archives
114
115###############################################################################
116# "makewad" target will show how to make a WAD file in detailed steps.
117# "makewad_simple" target shows how to make a WAD file using makefile rules.
118#
119# When switching between compiling as Disc or NAND application,
120# please make sure to "make clean"
121###############################################################################
122
123makewad:
124	@echo "------------------------------------------"
125	@echo " 1. build program as a NAND application"
126	@echo "------------------------------------------"
127	make NANDAPP=TRUE NOEXPORT=TRUE
128
129	@echo ""
130	@echo "------------------------------------------"
131	@echo " 2. convert elf file to dol file"
132	@echo "------------------------------------------"
133	makedol -f $(FULLBIN_ROOT)/cntdemo$(BINSUFFIX) -d $(FULLBIN_ROOT)/cntdemo$(DOLSUFFIX)
134
135	@echo ""
136	@echo "------------------------------------------"
137	@echo " 3. compress the dol file"
138	@echo "------------------------------------------"
139	ntcompress -lex -A32 -o $(FULLBIN_ROOT)/cntdemo$(DOLSUFFIX)$(LZ77SUFFIX) $(FULLBIN_ROOT)/cntdemo$(DOLSUFFIX)
140
141	@echo ""
142	@echo "------------------------------------------"
143	@echo " 4. archive content2 directory"
144	@echo "------------------------------------------"
145	@if [ ! -e $(ARCFILE_DIR) ] ; then \
146		echo "mkdir $(ARCFILE_DIR)"; \
147		mkdir $(ARCFILE_DIR); \
148	fi
149	cd $(DVDROOT_DIR)/content2; \
150	darchD -c * $(DVDROOT_DIR)/archives/content2.arc
151	darchD -tv $(DVDROOT_DIR)/archives/content2.arc
152
153	@echo ""
154	@echo "------------------------------------------"
155	@echo " 5. make a wad file"
156	@echo "------------------------------------------"
157	makeWad -n cntdemo$(ASUFFIX) -l $(FULLBIN_ROOT)/cntdemo$(DOLSUFFIX)$(LZ77SUFFIX),$(DVDROOT_DIR)/archives/content2.arc
158	mv cntdemo$(WADSUFFIX) $(FULLBIN_ROOT)/
159
160makewad_simple:
161	@echo "------------------------------------------"
162	@echo " Same as make makewad, but simpler usage"
163	@echo "------------------------------------------"
164	make NANDAPP=TRUE CNT_IDX=2
165
166
167###############################################################################
168# "datatitle" target will show how to make a data title WAD file
169###############################################################################
170
171DVDROOT_DIR = $(subst \,/,$(REVOLUTION_SDK_ROOT))/dvddata
172ARCFILE_DIR = $(DVDROOT_DIR)/archives
173
174# Data title's game code must start with lowercase 'a' through 'z'
175DATATITLE_GAMECODE = a000
176
177ACCESS_GAMECODE    = RABA
178ACCESS_TITLEMASK   = 0x000000ff
179
180datatitle: setup
181	@echo "---------------------------------------------"
182	@echo " 1. manually archive content index 1 of $(DATATITLE_GAMECODE) "
183	@echo "---------------------------------------------"
184	@if [ ! -e $(ARCFILE_DIR) ] ; then \
185		echo "mkdir $(ARCFILE_DIR)"; \
186		mkdir $(ARCFILE_DIR); \
187	fi
188	cd $(DVDROOT_DIR)/datatitle/$(DATATITLE_GAMECODE)/content1; \
189	darchD -c * $(DVDROOT_DIR)/archives/content1_$(DATATITLE_GAMECODE).arc
190	darchD -tv $(DVDROOT_DIR)/archives/content1_$(DATATITLE_GAMECODE).arc
191
192	@echo ""
193	@echo "------------------------------------------"
194	@echo " 2. make a data title wad file"
195	@echo "------------------------------------------"
196	makeWad -f -n $(DATATITLE_GAMECODE) -l $(DVDROOT_DIR)/archives/content1_$(DATATITLE_GAMECODE).arc -gc $(DATATITLE_GAMECODE) -E $(ACCESS_GAMECODE) -e $(ACCESS_TITLEMASK)
197	mv $(DATATITLE_GAMECODE).wad $(FULLBIN_ROOT)/
198
199#======== End of makefile ========#
200