1#----------------------------------------------------------------------------
2# Project:  Horizon
3# File:     commondefs.om
4#
5# Copyright (C)2009-2011 Nintendo Co., Ltd.  All rights reserved.
6#
7# These coded instructions, statements, and computer programs contain
8# proprietary information of Nintendo of America Inc. and/or Nintendo
9# Company Ltd., and are protected by Federal copyright law. They may
10# not be disclosed to third parties or copied or duplicated in any form,
11# in whole or in part, without the prior written consent of Nintendo.
12#
13# $Rev: 45144 $
14#----------------------------------------------------------------------------
15
16#----------------------------------------------------------------------------
17# omake settings
18#----------------------------------------------------------------------------
19
20# Load the OMake default library once only
21open build/Common
22
23SCANNER_MODE=disabled
24
25
26
27#----------------------------------------------------------------------------
28# Root specification
29#----------------------------------------------------------------------------
30
31# Defined constants
32#
33#   CTRSDK_ROOT
34#   HORIZON_ROOT
35#   CTRSDK_TARGETS
36#   HORIZON_TARGETS
37#   HORIZON_ADDINS_ROOT
38#
39
40# Get directory root/environmental variable (can build even if not defined)
41HORIZON_ROOT =
42    if $(defined-env HORIZON_ROOT)
43        value $(absname $(string $(getenv HORIZON_ROOT)))
44
45if $(defined-env CTRSDK_ROOT)
46    CTRSDK_ROOT = $(absname $(string $(getenv CTRSDK_ROOT)))
47    if $(and $(defined-env HORIZON_ROOT), $(not $(equal $(HORIZON_ROOT), $(CTRSDK_ROOT))))
48        eprintln(HORIZON_ROOT �� CTRSDK_ROOT ����v���܂���B�����p�X��ݒ肷�邩�A�ǂ��炩����������`���ĉ������B)
49        exit(1)
50    HORIZON_ROOT = $(CTRSDK_ROOT)
51    export HORIZON_ROOT CTRSDK_ROOT
52
53if $(defined-env CTRSDK_TARGETS)
54    private.targets = $(absname $(string $(getenv CTRSDK_TARGETS)))
55    if $(defined-env HORIZON_TARGETS)
56        eprintln(HORIZON_TARGETS �� CTRSDK_TARGETS �͓����Ɏg�p�ł��܂���̂ŁA�ǂ��炩����������`���ĉ������B)
57        exit(1)
58    global.HORIZON_TARGETS = $(targets)
59    export HORIZON_TARGETS
60
61if $(not $(HORIZON_ROOT))
62    eprintln($"$$CTRSDK_ROOT is not defined")
63    HORIZON_ROOT = $(absname $(ROOT))
64    export HORIZON_ROOT
65
66global.HORIZON_ADDINS_ROOT =
67    if $(defined-env HORIZON_ADDINS_ROOT)
68        value $(absname $(string $(getenv HORIZON_ADDINS_ROOT)))
69    else
70        private.path = $(absname $(HORIZON_ROOT)/../CTR/Addins)
71        value $(if $(file-exists $(path)),$(path),$(EMPTY))
72
73
74
75
76#----------------------------------------------------------------------------
77# Global constant definition
78#----------------------------------------------------------------------------
79
80# Define directory
81
82global.SUBDIR_IMAGES        = images
83global.SUBDIR_OBJECTS       = objects
84global.SUBDIR_LIBRARIES     = libraries
85global.SUBDIR_INCLUDE       = include
86global.SCANNER_PREFIX       = scan
87
88global.AROOT                = $(absname $(ROOT))
89
90global.ROOT_IMAGES          = $(absname $(ROOT)$(DIRSEP)$(SUBDIR_IMAGES))
91global.ROOT_OBJECTS         = $(absname $(ROOT)$(DIRSEP)$(SUBDIR_OBJECTS))
92global.ROOT_LIBRARIES       = $(absname $(HORIZON_ROOT)$(DIRSEP)$(SUBDIR_LIBRARIES))
93global.ROOT_BUILD           = $(absname $(HORIZON_ROOT)$(DIRSEP)build)
94global.ROOT_OMAKE           = $(absname $(ROOT_BUILD)$(DIRSEP)omake)
95global.ROOT_OMAKE_PUBLIC    = $(absname $(ROOT_BUILD)$(DIRSEP)omake)
96global.ROOT_INCLUDE         = $(absname $(ROOT)$(DIRSEP)$(SUBDIR_INCLUDE))
97global.ROOT_SOURCES         = $(absname $(ROOT)$(DIRSEP)sources)
98global.ROOT_TOOLS           = $(absname $(HORIZON_ROOT)$(DIRSEP)tools)
99global.ROOT_TARGETTOOLS     = $(absname $(HORIZON_ROOT)$(DIRSEP)tools$(DIRSEP)TargetTools)
100global.ROOT_COMMANDS        = $(absname $(ROOT_TOOLS)$(DIRSEP)CommandLineTools)
101global.ROOT_RESOURCES       = $(absname $(HORIZON_ROOT)$(DIRSEP)resources)
102
103global.HORIZON_ROOT_INCLUDE     = $(HORIZON_ROOT)$(DIRSEP)$(SUBDIR_INCLUDE)
104global.HORIZON_ROOT_IMAGES      = $(HORIZON_ROOT)$(DIRSEP)$(SUBDIR_IMAGES)
105global.HORIZON_ROOT_LIBRARIES   = $(HORIZON_ROOT)$(DIRSEP)$(SUBDIR_LIBRARIES)
106
107
108
109# Extension settings
110
111global.EXT_OBJ          = .o
112global.EXT_LIB          = .a
113global.EXT_ASM          = .s
114global.EXT_C            = .c
115
116global.EXT_EXE          = $(EXE)
117global.EXT_ELF          = .axf
118global.EXT_PLF          = .plf
119global.EXT_MAP          = .map
120global.EXT_DASM         = .dasm
121global.EXT_LDS          = .autogen.ldscript
122
123
124
125# Tool path setting
126
127global.BIN2OBJ          = $(file $(ROOT_COMMANDS)/ctr_bin2obj32$(EXE))
128global.BIN2OBJ_FLAGS    =
129global.RUNNER           = $(file $(ROOT_BUILD)/runner/run.sh)
130global.RUNNER_LOCK      = $(file $(ROOT_BUILD)/runner/.lock)
131
132
133
134
135
136# Defined constants
137#
138#   INSTALL_ROOT
139#   INSTALL_IMAGES_DIR
140#   INSTALL_ROOT_IMAGES
141#   INSTALL_ROOT_LIBRARIES
142#
143
144declare global.INSTALL_ROOT
145# Installation destination settings (prioritized as follows)
146# 1. Environmental variable HORIZON_INSTALL_ROOT
147# 2. Variable INSTALL_ROOT
148# 3. Variable HORIZON_ROOT
149if $(defined-env HORIZON_INSTALL_ROOT)
150    INSTALL_ROOT = $(dir $(string $(getenv HORIZON_INSTALL_ROOT)))
151    export INSTALL_ROOT
152else
153    if $(defined INSTALL_ROOT)
154        INSTALL_ROOT = $(dir $(INSTALL_ROOT))
155        export
156    elseif $(equal $(AROOT), $(HORIZON_ROOT))
157        INSTALL_ROOT = $(ROOT)
158        export
159    export
160
161if $(not $(defined INSTALL_IMAGES_DIR))
162    INSTALL_IMAGES_DIR = $(SUBDIR_IMAGES)
163    export
164
165if $(defined INSTALL_ROOT)
166    INSTALL_ROOT_IMAGES     = $(dir $(INSTALL_ROOT)$(DIRSEP)$(INSTALL_IMAGES_DIR))
167    INSTALL_ROOT_LIBRARIES  = $(dir $(INSTALL_ROOT)$(DIRSEP)$(SUBDIR_LIBRARIES))
168    export
169
170
171
172
173
174#----------------------------------------------------------------------------
175# Global variable declaration and initialization
176#----------------------------------------------------------------------------
177
178global.HORIZON_ADDITIONAL_RULES         = $(EMPTY)
179global.HORIZON_POST_ADDITIONAL_RULES    = $(EMPTY)
180
181global.SOURCES              =
182global.OBJECTS              =
183
184# Variable to have the user specify a directory matching the build target and build type
185global.BUILD_TARGET_DIR     =   $`(TARGET.getFullnameWithSystem Process)
186global.BUILD_TYPE_DIR       =   $`(TARGET.buildtype)
187
188global.DEFAULT_TARGETS      = $(EMPTY)
189global.DEFAULT_FILTER       = CTR-TS*MPCore*
190
191global.ENABLE_CPP_EXCEPTION = false
192
193
194# Defined variables
195#
196#   SKIP_BUILD
197#   DEBUG_PRINT
198#   DEBUG_PRINT_SDK
199#   ASSERT_WARNING
200#   ASSERT_WARNING_SDK
201#   HOST_IO
202#   TRACE_PRODUCTCODE
203#
204
205if $(not $(defined SKIP_BUILD))
206    global.SKIP_BUILD       = false
207    export
208
209if $(not $(defined DEBUG_PRINT))
210    global.DEBUG_PRINT      = $`(DEBUG_PRINT_DEFAULT)
211    export
212
213if $(not $(defined DEBUG_PRINT_SDK))
214    global.DEBUG_PRINT_SDK  = $`(DEBUG_PRINT_SDK_DEFAULT)
215    export
216
217if $(not $(defined ASSERT_WARNING))
218    global.ASSERT_WARNING   = $`(ASSERT_WARNING_DEFAULT)
219    export
220
221if $(not $(defined ASSERT_WARNING_SDK))
222    global.ASSERT_WARNING_SDK = $`(ASSERT_WARNING_SDK_DEFAULT)
223    export
224
225if $(not $(defined HOST_IO))
226    global.HOST_IO          = $`(HOST_IO_DEFAULT)
227    export
228
229
230
231global.TARGET_FILTER =
232    if $(defined FILTER)
233        value $(FILTER)
234    elseif $(defined targets)
235        eprintln($"Warning: Use 'FILTER' instead of 'targets.'")
236        value $(targets)
237    else
238        if $(defined-env HORIZON_TARGETS)
239            value $(getenv HORIZON_TARGETS)
240        elseif $(defined-env CTRSDK_TARGETS)
241            value $(getenv CTRSDK_TARGETS)
242        else
243            value $`(DEFAULT_FILTER)
244
245
246if $(grep q, $",", $(open-in-string $(TARGET_FILTER)))
247    TARGET_FILTER = $(split $",", $(TARGET_FILTER))
248    export
249
250
251BUILDTYPES =
252    if $(defined BUILD)
253        value $(BUILD)
254    else
255        value Development
256
257section
258    RS=$'[ \t,]+'
259    TARGET_BUILDTYPES =
260    export TARGET_BUILDTYPES
261    awk($(open-in-string $(lowercase $(BUILDTYPES))))
262    case $'(debug)|(dbg)'
263        TARGET_BUILDTYPES += Debug
264    case $'dev(elop)?'
265        TARGET_BUILDTYPES += Development
266    case $'rel(ease)?'
267        TARGET_BUILDTYPES += Release
268    case $'full'
269        TARGET_BUILDTYPES += Debug Development Release
270
271    TARGET_BUILDTYPES = $(set $(TARGET_BUILDTYPES))
272
273
274
275
276.PHONY: CGeneratedFilesTarget
277.PHONY: build
278.PHONY: build-romfs
279.PHONY: show-config
280.PHONY: build-setup
281.PHONY: tests
282
283.PHONY: all build clean clean-autogen clobber install
284
285
286
287
288
289#----------------------------------------------------------------------------
290# Platform branching
291#----------------------------------------------------------------------------
292
293include $(ROOT_OMAKE)/platformdefs
294
295global.TARGET_PLATFORM = $(NN_PLATFORM_MANAGER.Select $(TARGET_FILTER))
296
297
298#----------------------------------------------------------------------------
299# Load sub-rules
300#----------------------------------------------------------------------------
301
302# Library for Horizon
303include $(ROOT_OMAKE)/utildefs
304include $(ROOT_OMAKE)/commondefs.funcs
305include $(ROOT_OMAKE)/commondefs.cctype
306include $(makePlatformDefsPath commondefs)
307include $(ROOT_OMAKE)/targetdefs
308include $(ROOT_OMAKE)/packagedefs
309include $(ROOT_OMAKE)/debuggerdefs
310
311# Incorporate individual settings
312if $(test -f $(ROOT_OMAKE)/localdefs.om)
313    include $(ROOT_OMAKE)/localdefs
314    export
315
316
317
318#----------------------------------------------------------------------------
319# Common rule definitions
320#----------------------------------------------------------------------------
321
322%.c: %.y
323    $(YACC) $<
324
325%.c: %.l
326    $(LEX) $<
327
328show-config:
329    $(ShowConfig)
330
331