1#! make -f
2#----------------------------------------------------------------------------
3# Project:  TwlSDK - MB - demos - cloneboot
4# File:     Makefile
5#
6# Copyright 2007-2008 Nintendo. All rights reserved.
7#
8# These coded instructions, statements, and computer programs contain
9# proprietary information of Nintendo of America Inc. and/or Nintendo
10# Company Ltd., and are protected by Federal copyright law. They may
11# not be disclosed to third parties or copied or duplicated in any form,
12# in whole or in part, without the prior written consent of Nintendo.
13#
14# $Date:: 2008-12-24#$
15# $Rev: 9728 $
16# $Author: okubata_ryoma $
17#----------------------------------------------------------------------------
18
19SUBDIRS		=
20
21# Because the MB library samples use the multiboot functionality, multiple development units with the same communications environment (wired or wireless) are required.
22# The mb_child.bin sample program in the $TwlSDK/bin/ARM9-TS/Release directory provides the same functionality as a commercial system that is a multiboot child. Load this binary on other systems just like a sample program and run them together.
23#
24#
25#
26#
27#
28
29#----------------------------------------------------------------------------
30
31TWL_ARCHGEN	:=	HYBRID
32
33#----------------------------------------------------------------------------
34# The source files used with this program are shown below
35#----------------------------------------------------------------------------
36
37SRCDIR		 = ./src
38INCDIR		 = ./include
39
40SRCS		 = main.c		\
41			   common.c		\
42			   disp.c		\
43			   font.c		\
44			   child.c		\
45			   parent.c		\
46			   gmain.c
47
48# To simplify the samples, use WH modules
49
50WH_DIR		 = $(ROOT)/build/demos/wireless_shared/wh
51SRCDIR		+= $(WH_DIR)
52INCDIR		+= $(WH_DIR)
53SRCS		+= $(WH_DIR)/wh.c
54
55# To simplify the samples, use MBP modules
56
57MBP_DIR		 = $(ROOT)/build/demos/wireless_shared/mbp
58SRCDIR		+= $(MBP_DIR)
59INCDIR		+= $(MBP_DIR)
60SRCS		+= $(MBP_DIR)/mbp.c
61
62
63#----------------------------------------------------------------------------
64# The general application settings are shown below
65#----------------------------------------------------------------------------
66
67TARGET_NEF		 = main.nef
68TARGET_BIN		 = main.srl
69
70TWL_MAKEROM		 = TRUE
71
72# To compress each segment of a program, enable this flag.
73# With a reduced binary size on the CARD-ROM, compressed segments reduce load times via wireless transfers or CARD-ROM but requires some CPU time to extract their contents at runtime.
74#
75#
76TWL_COMPRESS	 = TRUE
77
78# You must enable NITRO_DIGEST when using overlays as wireless download children
79#
80TWL_DIGEST		 = TRUE
81
82#----------------------------------------------------------------------------
83
84include	$(TWLSDK_ROOT)/build/buildtools/commondefs
85
86do-build:	$(TARGETS)
87
88#----------------------------------------------------------------------------
89
90ifeq ($(TARGET_PLATFORM),TWL)
91ROM_SPEC		 = main.TWL.rsf
92#LCFILE_SPEC	 = main.TWL.lsf
93else
94ROM_SPEC		 = main.rsf
95#LCFILE_SPEC	 = main.lsf
96endif
97
98# It is safer to set a slightly large IRQ stack size in the LCF file when running complex processes within the MB callback.
99# Because OS_Printf() in particular consumes a large amount of stack, try using the lighter version, OS_TPrintf(), in callbacks whenever possible.
100#
101#
102
103#----------------------------------------------------------------------------
104# Special settings for the clone boot parent are shown below
105#----------------------------------------------------------------------------
106
107# Specifies the link settings template for clone booting in order to place the .parent section, which is specific to parent devices and used for security purposes.
108#
109#
110# The contents of the .parent section are not sent to the child machine in DS Download Play.
111# Placing essential and parent-specific functions in this section makes it impossible to duplicate the parent device from intercepted transmission data.
112#
113# When positioning the code, please note the following:
114#   -Do not include anything other than the .text/.rodata section
115#   -Include important process required only by the parent
116#
117# Code in the .parent section is arranged as follows.
118#
119#     #include <nitro/parent_begin.h>
120#
121#     void  ForParentOnly(void)
122#     {
123#         /* Processing exclusive to the parent goes here */
124#     }
125#
126#     #include <nitro/parent_end.h>
127#
128# In this sample demo, all the functions in parent.c are placed in the .parent section.
129# For details, see the source code.
130
131ifeq	($(TARGET_PLATFORM),TWL)
132LCFILE_TEMPLATE	= $(TWL_SPECDIR)/ARM9-TS-cloneboot-C.lcf.template
133else
134LCFILE_TEMPLATE	= $(NITRO_SPECDIR)/ARM9-TS-cloneboot-C.lcf.template
135endif
136
137# Official system call libraries, distributed for every retail application, are specified here.
138# In this sample, a copy of the version included in the SDK (lib/ARM9-TS/etc/libsyscall.a) has been provisionally placed in this directory in advance.
139# When creating an application based on this demo, overwrite these provisional system calls with the libsyscal.a provided by Nintendo.
140#
141#
142#
143#
144
145LIBSYSCALL			 = ./etc/libsyscall.a
146LIBSYSCALL_CHILD	 = ./etc/libsyscall_child.bin
147
148#----------------------------------------------------------------------------
149# Here we describe the pre-authentication process used to run the application on the production model
150#----------------------------------------------------------------------------
151
152# The following a is rough outline of pre-authentication.
153# For details, see "DS Download Play".
154# (/docs/TechnicalNotes/AboutMultiBoot.doc)
155#
156# (0) If clone boot, use the emuchild command to prepare the program to send.
157#     If not, use main.srl without modification.
158#     In this makefile, the prepared program is bin/sign.srl.
159#
160# (1) To obtain the authentication code, send tmp/sign.srl, which was prepared in Step 0, to the server.
161#     You must do this by hand using your browser.
162#     In this makefile, the received authentication code is bin/sign.sgn.
163#
164# (2) Use the attachsign command to combine main.srl and bin/sign.sgn, obtained in step (1), and create the final program.
165#
166#     In this makefile, the product is main_with_sign.srl.
167#
168
169# When clone booting, the program will send a program modified using emuchild, instead of itself, to the server; this differs slightly from an ordinary DS Download Play program.
170#
171
172presign:
173	$(EMUCHILD) \
174		bin/$(TWL_BUILDTYPE)/$(TARGET_BIN) \
175		$(LIBSYSCALL_CHILD) \
176		bin/sign.srl
177
178# The process of including the obtained authentication code in the binary is the same in both clone boot and normal operation
179postsign:
180	$(ATTACHSIGN) \
181		bin/$(TWL_BUILDTYPE)/$(TARGET_BIN) \
182		bin/sign.sgn  \
183		main_with_sign.srl
184
185#----------------------------------------------------------------------------
186
187include	$(TWLSDK_ROOT)/build/buildtools/modulerules
188
189ifdef	TWL_ELFTOBIN
190$(TARGETS): $(ELFTOBIN_ARM7)
191
192else	#TWL_ELFTOBIN
193$(TARGETS): $(MAKEROM_ARM7)
194
195endif	#TWL_ELFTOBIN
196
197
198#===== End of Makefile =====
199