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