1#----------------------------------------------------------------------------
2# Project:  Horizon
3# File:     commondefs.cctype.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: 46159 $
14#----------------------------------------------------------------------------
15
16#----------------------------------------------------------------------------
17# Class definitions
18#----------------------------------------------------------------------------
19
20Compiler. =
21    class Compiler
22
23    #----------------------------------------------------------------------------
24    # Function definitions
25    #----------------------------------------------------------------------------
26
27    #-------------------------------------------------------
28    # New.
29    #
30    # Overview
31    #   |
32    #
33    # Referenced global variables
34    #   None.
35    #-------------------------------------------------------
36    new() =
37        return $(this)
38
39    #-------------------------------------------------------
40    # getCCFlagsDebug
41    #
42    # Overview
43    #   |
44    #
45    # Referenced global variables
46    #   BUILD_APPLICATION, CCFLAGS_DEV_OPT
47    #-------------------------------------------------------
48    getCCFlagsDebug(config) =
49        private.eff =
50            switch($(config.effort))
51            case fast
52                value -Otime
53            case small
54                value -Ospace
55        eff +=
56            switch($(config.buildtype))
57            case $"Debug"
58                value -O0 --retain=calls
59            case $"Development"
60                if $(BUILD_APPLICATION)
61                    value $(CCFLAGS_DEV_OPT)
62                else
63                    value -O3
64            case $"Release"
65                value -O3
66        return $(eff)
67
68    #-------------------------------------------------------
69    # getLDFlagsDebug
70    #
71    # Overview
72    #   |
73    #
74    # Referenced global variables
75    #   None.
76    #-------------------------------------------------------
77    getLDFlagsDebug(config) =
78        return $(EMPTY)
79
80    #-------------------------------------------------------
81    # toSymbol
82    #
83    # Overview
84    #   |
85    #
86    # Referenced global variables
87    #   stdout
88    #-------------------------------------------------------
89    toSymbol(str) =
90        stdout = $(open-out-string)
91        fsubst($(open-in-string $(str)))
92        case $'[-\.]' g
93            value $'_'
94        private.result = $(out-contents $(stdout))
95        close($(stdout))
96        return $(uppercase $(result))
97
98    #-------------------------------------------------------
99    # getCCFlags
100    #
101    # Overview
102    #   |
103    #
104    # Referenced global variables
105    #   None.
106    #-------------------------------------------------------
107    getCCFlags(config) =
108        return $(getCCFlagsDebug $(config)) $(getCCFlagsLtcg $(config)) $(getCCFlagsCPU $(config)) $(getCCFlagsLazy)
109
110    #-------------------------------------------------------
111    # getLDFlags
112    #
113    # Overview
114    #   |
115    #
116    # Referenced global variables
117    #   None.
118    #-------------------------------------------------------
119    getLDFlags(config) =
120        return $(getLDFlagsDebug $(config)) $(getLDFlagsLtcg $(config)) $(getLDFlagsCPU $(config)) $(getLDFlagsLazy)
121
122    #-------------------------------------------------------
123    # getASFlags
124    #
125    # Overview
126    #   |
127    #
128    # Referenced global variables
129    #   None.
130    #-------------------------------------------------------
131    getASFlags(config) =
132        return $(getASFlagsCPU $(config))
133
134    #-------------------------------------------------------
135    # getMacroFlags
136    #
137    # Overview
138    #   |
139    #
140    # Referenced global variables
141    #   DEBUG_PRINT_DEFAULT, DEBUG_PRINT_SDK_DEFAULT,
142    #   ASSERT_WARNING_DEFAULT, ASSERT_WARNING_SDK_DEFAULT
143    #   DEBUG_PRINT, DEBUG_PRINT_SDK, ASSERT_WARNING,
144    #   ASSERT_WARNING_SDK, BUILD_APPLICATION,
145    #   BUILD_KERNEL, CTR_BUILD_1ST_STAGE_UPDATER,
146    #-------------------------------------------------------
147    getMacroFlags(config) =
148        private.flags = $(EMPTY)
149        section
150            export flags
151            flags  =
152                switch($(config.effort))
153                case fast
154                    value -DNN_EFFORT_FAST
155                case small
156                    value -DNN_EFFORT_SMALL
157
158            flags += -DNN_PLATFORM_$(toSymbol $(config.platform))
159            flags += -DNN_HARDWARE_$(toSymbol $(config.hardware))
160            flags += -DNN_SYSTEM_$(toSymbol $(config.systemname))
161
162            #                     noopt   verbose release Debug   Dev.    Release
163            # DISABLE_DEBUG       �~      �~      ��      �~      �~      ��
164            # DISABLE_DEBUG_SDK   �~      �~      ��      �~      �~      ��
165            # DISABLE_ASSERT      �~      �~      ��      �~      �~      ��
166            # DISABLE_ASSERT_SDK  �~      �~      ��      �~      �~      ��
167            # ENABLE_HOST         ��      ��      �~      ��      ��      �~
168            #
169            # BUILD_NOOPT         ��      �~      �~      ��      �~      �~
170            # BUILD_VERBOSE       ��      ��      �~      ��      ��      �~
171            # BUILD_DEBUG         �~      �~      �~      ��      �~      �~
172            # BUILD_DEVELOPMENT   �~      �~      �~      �~      ��      �~
173            # BUILD_RELEASE       �~      �~      �~      �~      �~      ��
174            #
175
176            if $(equal $(config.buildtype),Release)
177                DEBUG_PRINT_DEFAULT        = false
178                DEBUG_PRINT_SDK_DEFAULT    = false
179                ASSERT_WARNING_DEFAULT     = false
180                ASSERT_WARNING_SDK_DEFAULT = false
181                export
182            else
183                DEBUG_PRINT_DEFAULT        = true
184                DEBUG_PRINT_SDK_DEFAULT    = true
185                ASSERT_WARNING_DEFAULT     = true
186                ASSERT_WARNING_SDK_DEFAULT = true
187                export
188
189            if $(not $(DEBUG_PRINT))
190                flags += -DNN_SWITCH_DISABLE_DEBUG_PRINT=1
191            if $(not $(DEBUG_PRINT_SDK))
192                flags += -DNN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK=1
193            if $(not $(ASSERT_WARNING))
194                flags += -DNN_SWITCH_DISABLE_ASSERT_WARNING=1
195            if $(not $(ASSERT_WARNING_SDK))
196                flags += -DNN_SWITCH_DISABLE_ASSERT_WARNING_FOR_SDK=1
197            if $(config.isHostIoEnable)
198                flags += -DNN_SWITCH_ENABLE_HOST_IO=1
199
200            if $(or $(BUILD_APPLICATION), $(BUILD_KERNEL))
201                flags += -DNN_BUILD_$(toSymbol $(config.buildtype))
202
203            if $(and $(defined CTR_BUILD_1ST_STAGE_UPDATER), $(CTR_BUILD_1ST_STAGE_UPDATER))
204                flags += -DCTR_BUILD_1ST_STAGE_UPDATER
205
206            flags +=
207                switch($(config.buildtype))
208                case Debug          # noopt
209                    value -DNN_BUILD_VERBOSE -DNN_BUILD_NOOPT
210                case Development    # verbose
211                    value -DNN_BUILD_VERBOSE
212                case Release        # release
213                    value $(EMPTY)
214
215        return $(flags)
216
217
218#----------------------------------------------------------------------------
219# Load the target compiler settings
220#----------------------------------------------------------------------------
221
222include $(ROOT_OMAKE)/compilers/commondefs.cctype.$(TARGET_PLATFORM.GetCompilerType)
223
224private.CompilerClass = $(getvar Compiler$(TARGET_PLATFORM.GetCompilerType))
225global.COMPILER = $(CompilerClass.new)
226
227
228
229#----------------------------------------------------------------------------
230# Constant definitions
231#----------------------------------------------------------------------------
232
233global.CC               = $`(COMPILER.CC)
234global.CXX              = $`(COMPILER.CXX)
235global.CPP              = $`(COMPILER.CPP)
236global.AR               = $`(COMPILER.AR)
237global.LD               = $`(COMPILER.LD)
238global.AS               = $`(COMPILER.AS)
239
240global.STRIP            = $`(COMPILER.STRIP)
241global.DISAS            = $`(COMPILER.DISAS)
242
243global.CCFLAGS_MACRO    = $`(COMPILER.CCFLAGS_MACRO)
244global.CCFLAGS_WARNING  = $`(COMPILER.CCFLAGS_WARNING)
245global.CCFLAGS_DEV_OPT  = $`(COMPILER.CCFLAGS_DEV_OPT)
246
247global.CCFLAGS          = $`(COMPILER.CCFLAGS) $`(CCFLAGS_MACRO)
248global.CCFLAGS_BUILD    =
249
250global.CFLAGS           = $`(COMPILER.CFLAGS) $`(CCFLAGS)
251global.CXXFLAGS         = $`(COMPILER.CXXFLAGS) $`(CCFLAGS)
252global.CSCANFLAGS       = $`(COMPILER.CSCANFLAGS)
253
254global.LDFLAGS_WARNING  = $`(COMPILER.LDFLAGS_WARNING)
255global.LDFLAGS_INFO     = $`(COMPILER.LDFLAGS_INFO)
256global.ARFLAGS          = $`(COMPILER.ARFLAGS)
257global.RANLIB           = $`(COMPILER.RANLIB)
258global.INCLUDES_OPT     = $`(COMPILER.INCLUDES_OPT)
259global.YACC             = $`(COMPILER.YACC)
260global.LEX              = $`(COMPILER.LEX)
261global.LDFLAGS          = $`(COMPILER.LDFLAGS)
262global.LDRESP           = $`(COMPILER.LDRESP)
263
264global.CCOUT            = $`(COMPILER.CCOUT)
265global.LDOUT            = $`(COMPILER.LDOUT)
266global.ASOUT            = $`(COMPILER.ASOUT)
267global.ASFLAGS          = $`(COMPILER.ASFLAGS)
268
269
270global.ENTRYPOINT       = __ctr_start
271global.INCLUDES[]       = $(ROOT_INCLUDE) $(HORIZON_ROOT_INCLUDE)
272global.LIBS             = $`(DEFAULT_LIBS)
273global.LIBFILES         =
274global.LIBRARY_LIBFILES =
275global.MINIMUM_LIBS     =
276global.DEFAULT_LIBS     =
277global.LLIBS            =
278
279global.USE_GNU_EXTENTIONS = true
280global.PREFIXED_INCLUDES = $`(addprefix $(INCLUDES_OPT), $(set $(absname $(INCLUDES))))
281
282
283
284