599
|
1 |
# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
# All rights reserved.
|
|
3 |
# This component and the accompanying materials are made available
|
|
4 |
# under the terms of "Eclipse Public License v1.0"
|
|
5 |
# which accompanies this distribution, and is available
|
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
#
|
|
8 |
# Initial Contributors:
|
|
9 |
# Nokia Corporation - initial contribution.
|
|
10 |
#
|
|
11 |
# Contributors:
|
|
12 |
#
|
|
13 |
# Description:
|
|
14 |
#
|
|
15 |
|
|
16 |
# To ensure that EPOCROOT always ends with a forward slash.
|
|
17 |
TMPROOT:=$(subst \,/,$(EPOCROOT))
|
|
18 |
EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/
|
|
19 |
|
|
20 |
ifndef CPU
|
|
21 |
CPU := arm
|
|
22 |
endif
|
|
23 |
|
|
24 |
ifndef LINKBASE
|
|
25 |
LINKBASE := 0x00000000
|
|
26 |
endif
|
|
27 |
|
|
28 |
include $(EPOCROOT)epoc32/tools/shell/$(notdir $(basename $(SHELL))).mk
|
|
29 |
|
|
30 |
PROCEED:=build
|
|
31 |
ifneq "$(PBUILDPID)" ""
|
|
32 |
ifneq "$(CFG)" "UREL"
|
|
33 |
PROCEED:=skip
|
|
34 |
endif
|
|
35 |
endif
|
|
36 |
|
|
37 |
COPY := $(call ecopy)
|
|
38 |
|
|
39 |
ifeq "$(CPU)" "x86"
|
|
40 |
ifeq "$(MEMMODEL)" "direct"
|
|
41 |
BLDSGL:=s
|
|
42 |
else
|
|
43 |
ifeq "$(MEMMODEL)" "flexible"
|
|
44 |
BLDSGL:=f
|
|
45 |
else
|
|
46 |
BLDSGL:=
|
|
47 |
endif
|
|
48 |
endif
|
|
49 |
ifdef SMP
|
|
50 |
BLDSMP:=smp
|
|
51 |
else
|
|
52 |
BLDSMP:=
|
|
53 |
endif
|
|
54 |
EPOCROOT:=$(subst /,\,$(EPOCROOT))
|
|
55 |
EPOCBLDABS := $(EPOCROOT)epoc32\build\tasm$(PBUILDPID)\$(BLDSGL)$(VNAME)$(BLDSMP)
|
|
56 |
else
|
|
57 |
DRIVELETTER := $(shell cd 2>NUL)
|
|
58 |
DRIVELETTER_2 := $(word 1,$(subst \, ,$(DRIVELETTER)))
|
|
59 |
EPOCBLDABS_1 := $(subst $(TO_ROOT),,$(EPOCBLD))
|
|
60 |
EPOCBLDABS_2 := $(subst $(DRIVELETTER_2),,$(EPOCBLDABS_1))
|
|
61 |
|
|
62 |
EPOCBLDABS := $(call epocbldabs,$(DRIVELETTER_2),$(EPOCBLDABS_2))/$(NAME)
|
|
63 |
endif
|
|
64 |
|
|
65 |
EPOCINC := $(INC_PATH)
|
|
66 |
EPOCKERNINC := $(EPOCINC)/kernel
|
|
67 |
EPOCCPUINC := $(EPOCKERNINC)/$(CPU)
|
|
68 |
EPOCMMINC := $(INC_PATH)/memmodel/epoc/$(MEMMODEL)/$(CPU)
|
|
69 |
EPOCTRG := $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)
|
|
70 |
TRG := $(EPOCTRG)/$(NAME).bin
|
|
71 |
TEMPTRG := $(EPOCBLDABS)/$(NAME).bin
|
|
72 |
|
|
73 |
ifdef EXTRA_INC_PATH
|
|
74 |
ASMINCPATH := $(EXTRA_INC_PATH)
|
|
75 |
endif
|
|
76 |
|
|
77 |
ifeq "$(CPU)" "arm"
|
|
78 |
ASMINCPATH := . $(EPOCBLDABS) $(ASMINCPATH) $(EXTENSION_ROOT) $(EPOCCPUINC)
|
|
79 |
ARMASM_OUT := $(shell armasm 2>&1)
|
|
80 |
ARMASM_OUT_4 := $(word 4,$(ARMASM_OUT))
|
|
81 |
ARMASM_OUT_6 := $(word 6,$(ARMASM_OUT))
|
|
82 |
|
|
83 |
# Use GCC toolchain if no other is available
|
|
84 |
TOOLVER := GCC
|
|
85 |
|
|
86 |
RVCTSTR := $(strip $(findstring RVCT, $(ARMASM_OUT_4)))
|
|
87 |
ifeq "$(RVCTSTR)" "RVCT"
|
|
88 |
TOOLVER := RVCT
|
|
89 |
OP := --
|
|
90 |
endif
|
|
91 |
ifeq "$(ARMASM_OUT_6)" "2.37"
|
|
92 |
TOOLVER := 211
|
|
93 |
endif
|
|
94 |
endif
|
|
95 |
|
|
96 |
ifeq "$(MEMMODEL)" "direct"
|
|
97 |
CFG_MM := CFG_MMDirect
|
|
98 |
endif
|
|
99 |
ifeq "$(MEMMODEL)" "moving"
|
|
100 |
CFG_MM := CFG_MMMoving
|
|
101 |
endif
|
|
102 |
ifeq "$(MEMMODEL)" "multiple"
|
|
103 |
CFG_MM := CFG_MMMultiple
|
|
104 |
endif
|
|
105 |
ifeq "$(MEMMODEL)" "flexible"
|
|
106 |
CFG_MM := CFG_MMFlexible
|
|
107 |
endif
|
|
108 |
ifndef CFG_MM
|
|
109 |
$(error Memory model unknown)
|
|
110 |
endif
|
|
111 |
|
|
112 |
ASM_MACROS += $(CFG_MM)
|
|
113 |
ifdef SMP
|
|
114 |
ASM_MACROS += SMP
|
|
115 |
endif
|
|
116 |
|
|
117 |
ifeq "$(CPU)" "x86"
|
|
118 |
ifndef BASEINCLUDES
|
|
119 |
BASEINCLUDES := bootcpu.inc bootmacr.inc
|
|
120 |
endif
|
|
121 |
ifndef BASESOURCES
|
|
122 |
BASESOURCES := bootmain.asm bootcpu.asm bootutil.asm
|
|
123 |
endif
|
|
124 |
GENINCLUDES := $(GENINCLUDES) x86boot.h
|
|
125 |
ASMINCPATH := .
|
|
126 |
ASM := tasm
|
|
127 |
LINK := tlink
|
|
128 |
EXE2BIN := exe2bin
|
|
129 |
SRCEXT := asm
|
|
130 |
INCEXT := inc
|
|
131 |
OBJEXT := obj
|
|
132 |
EXEEXT := exe
|
|
133 |
|
|
134 |
ASMINCPATHCMD := $(foreach dir,$(ASMINCPATH),$(join /i,$(call slash2generic,$(dir))))
|
|
135 |
ASM_MACRO_CMD := $(foreach macro,$(ASM_MACROS),/d$(macro)=1)
|
|
136 |
AFLAGS := /l /m3 /ML /W-PDC $(ASM_MACRO_CMD) $(ASMINCPATHCMD)
|
|
137 |
LFLAGS := /m /s /n /3 /c
|
|
138 |
ASMTYP := TASM
|
|
139 |
LINKFILE :=
|
|
140 |
define do_asm
|
|
141 |
cd $(EPOCBLDABS) && $(CP) $(call slash2generic,$<) .
|
|
142 |
cd $(EPOCBLDABS) && $(ASM) $(AFLAGS) $(notdir $<)
|
|
143 |
endef
|
|
144 |
define do_link
|
|
145 |
cd $(EPOCBLDABS) && $(LINK) $(LFLAGS) $(filter %.$(OBJEXT),$(foreach obj,$^,$(notdir $(obj)))), temp.exe
|
|
146 |
cd $(EPOCBLDABS) && $(COPY) temp.exe $@
|
|
147 |
cd $(EPOCBLDABS) && $(ERASE) temp.exe
|
|
148 |
endef
|
|
149 |
define do_strip
|
|
150 |
cd $(EPOCBLDABS) && $(COPY) $< temp.exe
|
|
151 |
cd $(EPOCBLDABS) && $(EXE2BIN) temp.exe temp.bin
|
|
152 |
cd $(EPOCBLDABS) && $(COPY) temp.bin $@
|
|
153 |
cd $(EPOCBLDABS) && $(ERASE) temp.exe temp.bin
|
|
154 |
endef
|
|
155 |
endif
|
|
156 |
ifeq "$(CPU)" "arm"
|
|
157 |
ifeq "$(TOOLVER)" "211"
|
|
158 |
ASM := armasm
|
|
159 |
LINK := armlink
|
|
160 |
SRCEXT := s
|
|
161 |
INCEXT := inc
|
|
162 |
OBJEXT := o
|
|
163 |
EXEEXT := in
|
|
164 |
ASMINCPATHCMD := $(foreach dir,$(ASMINCPATH),$(join -I ,$(dir)))
|
|
165 |
ASM_MACRO_CMD := $(foreach macro,$(ASM_MACROS),-predefine "$(macro) SETL {TRUE}")
|
|
166 |
AFLAGS := $(ASM_ARM211_VARIANTFLAGS) -apcs 3/32bit/nosw -Length 0 -Width 200 $(ASM_MACRO_CMD) $(ASMINCPATHCMD)
|
|
167 |
LFLAGS := -Base $(LINKBASE) -Data 0xf0000000 -Entry $(LINKBASE) -Bin -map
|
|
168 |
SYMOPT := -symbols
|
|
169 |
ASMTYP := ARMASM
|
|
170 |
LINKFILE :=
|
|
171 |
define do_asm
|
|
172 |
$(ASM) $(AFLAGS) -o $@ -LIST $(join $(basename $@),.lst) $<
|
|
173 |
endef
|
|
174 |
define do_link
|
|
175 |
$(LINK) $(LFLAGS) $(SYMOPT) $(join $(basename $@),.sym) -o $@ $(filter %.$(OBJEXT),$^)
|
|
176 |
endef
|
|
177 |
define do_strip
|
|
178 |
@if exist $@ $(ERASE) $(call slash2generic,$@)
|
|
179 |
$(COPY) $< $@
|
|
180 |
endef
|
|
181 |
endif
|
|
182 |
ifeq "$(TOOLVER)" "RVCT"
|
|
183 |
ASM_MACROS += USE_CXSF
|
|
184 |
ASM := armasm
|
|
185 |
LINK := armlink
|
|
186 |
FROMELF := fromelf
|
|
187 |
SRCEXT := s
|
|
188 |
INCEXT := inc
|
|
189 |
OBJEXT := o
|
|
190 |
EXEEXT := in
|
|
191 |
ASMINCPATHCMD := $(foreach dir,$(ASMINCPATH),$(join -I ,$(dir)))
|
|
192 |
ASM_MACRO_CMD := $(foreach macro,$(ASM_MACROS),$(OP)predefine "$(macro) SETL {TRUE}")
|
|
193 |
AFLAGS := -g $(OP)keep $(ASM_MACRO_CMD) $(ASMINCPATHCMD) $(ASM_RVCT_VARIANTFLAGS)
|
|
194 |
LFLAGS := $(OP)ro-base $(LINKBASE) $(OP)entry $(LINKBASE) $(OP)map
|
|
195 |
SYMOPT := $(OP)symdefs
|
|
196 |
ASMTYP := ARMASM
|
|
197 |
LINKFILE :=
|
|
198 |
define do_asm
|
|
199 |
$(ASM) $(AFLAGS) -o $@ $(OP)LIST $(join $(basename $@),.lst) $<
|
|
200 |
endef
|
|
201 |
define do_link
|
|
202 |
$(LINK) $(LFLAGS) $(SYMOPT) $(join $(basename $@),.sym) -o $@ $(filter %.$(OBJEXT),$^)
|
|
203 |
$(COPY) $@ $(join $(basename $(TRG)),.sym)
|
|
204 |
endef
|
|
205 |
define do_strip
|
|
206 |
$(FROMELF) $(OP)bin $(OP)output $@ $<
|
|
207 |
endef
|
|
208 |
endif
|
|
209 |
ifeq "$(TOOLVER)" "GCC"
|
|
210 |
ASM_MACROS += USE_CXSF GNU_ASM
|
|
211 |
ASM := as
|
|
212 |
LINK := ld
|
|
213 |
STRIP := strip
|
|
214 |
SRCEXT := s
|
|
215 |
INCEXT := ginc
|
|
216 |
OBJEXT := o
|
|
217 |
EXEEXT := in
|
|
218 |
ASMINCPATHCMD := $(foreach dir,$(ASMINCPATH),$(join -I ,$(dir)))
|
|
219 |
ASM_MACRO_CMD := $(foreach macro,$(ASM_MACROS),--defsym $(macro)=1 )
|
|
220 |
AFLAGS := -mapcs-32 -R -n $(ASM_MACRO_CMD) -I- $(ASMINCPATHCMD)
|
|
221 |
LFLAGS := -n -x --section-alignment 4 --file-alignment 2 -no-whole-archive
|
|
222 |
SYMOPT := -symdefs
|
|
223 |
ASMTYP := AS
|
|
224 |
PROCESS_INCLUDES := 1
|
|
225 |
ifndef LINKFILE
|
|
226 |
LINKFILE := bootstrap.lnk
|
|
227 |
endif
|
|
228 |
define do_asm
|
|
229 |
perl $(EPOCROOT)epoc32/tools/armasm2as.pl $< $(join $(basename $@),.ss)
|
|
230 |
$(ASM) $(AFLAGS) -acdhlms=$(join $(basename $@),.lst) -o $@ $(join $(basename $@),.ss)
|
|
231 |
endef
|
|
232 |
define do_link
|
|
233 |
if exist $(join $(basename $@),.lnk) $(ERASE) $(call slash2generic,$(join $(basename $@),.lnk))
|
|
234 |
$(COPY) $(subst /,\,$(filter %.lnk,$^)) $(join $(basename $@),.lnk)
|
|
235 |
$(LINK) -M -o $@ $(filter %.$(OBJEXT),$^) $(LFLAGS) --script=$(join $(basename $@),.lnk) >$(join $(basename $@),.map)
|
|
236 |
endef
|
|
237 |
define do_strip
|
|
238 |
$(STRIP) -O binary -o $(TEMPTRG) $<
|
|
239 |
$(COPY) $(TEMPTRG) $@
|
|
240 |
$(ERASE) $(call slash2generic,$(TEMPTRG))
|
|
241 |
endef
|
|
242 |
endif
|
|
243 |
endif
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
# Generic source files
|
|
248 |
ifndef BASESOURCES
|
|
249 |
BASESOURCES := bootmain.s bootcpu.s bootutils.s
|
|
250 |
endif
|
|
251 |
|
|
252 |
# Path for generic source files
|
|
253 |
ifndef BASESRCPATH
|
|
254 |
BASESRCPATH := $(E32PATH)/eka/kernel/$(CPU)
|
|
255 |
endif
|
|
256 |
|
|
257 |
|
|
258 |
# Generated include files
|
|
259 |
GENINCLUDES := $(foreach f,$(GENINCLUDES),$(basename $(f)).$(INCEXT))
|
|
260 |
GENINCLUDES := $(GENINCLUDES) e32rom.$(INCEXT) kernboot.$(INCEXT)
|
|
261 |
GENINCLUDES := $(GENINCLUDES) bootdefs.$(INCEXT)
|
|
262 |
ifneq "$(MEMMODEL)" "direct"
|
|
263 |
GENINCLUDES := $(GENINCLUDES) mmboot.$(INCEXT)
|
|
264 |
endif
|
|
265 |
|
|
266 |
# Headers from which GENINCLUDES are generated
|
|
267 |
GENHEADERS = $(foreach inc,$(GENINCLUDES),$(basename $(inc)).h)
|
|
268 |
|
|
269 |
# Non-generated generic include files
|
|
270 |
ifndef BASEINCLUDES
|
|
271 |
BASEINCLUDES := bootcpu.inc bootmacro.inc
|
|
272 |
endif
|
|
273 |
BASEINCLUDES := $(foreach f,$(BASEINCLUDES),$(basename $(f)).$(INCEXT))
|
|
274 |
INCLUDES := $(foreach f,$(INCLUDES),$(basename $(f)).$(INCEXT))
|
|
275 |
|
|
276 |
# Generic object files
|
|
277 |
BASEOBJECTS = $(foreach src, $(BASESOURCES), $(basename $(src)).$(OBJEXT))
|
|
278 |
|
|
279 |
# Platform specific object files
|
|
280 |
OBJECTS = $(foreach src, $(SOURCES), $(basename $(src)).$(OBJEXT))
|
|
281 |
|
|
282 |
# Object files with paths
|
|
283 |
FULLBASEOBJECTS = $(addprefix $(EPOCBLDABS)/,$(BASEOBJECTS))
|
|
284 |
FULLOBJECTS = $(addprefix $(EPOCBLDABS)/,$(OBJECTS))
|
|
285 |
LINKOBJECTS = $(FULLBASEOBJECTS) $(FULLOBJECTS)
|
|
286 |
|
|
287 |
# Generated include files with paths
|
|
288 |
FULLGENINCLUDES = $(addprefix $(EPOCBLDABS)/,$(GENINCLUDES))
|
|
289 |
|
|
290 |
# Tell make where to look for things
|
|
291 |
vpath %.h . $(EXTRA_INC_PATH) $(EPOCINC) $(EPOCKERNINC) $(EPOCCPUINC) $(EPOCMMINC)
|
|
292 |
vpath %.inc . $(EXTRA_INC_PATH) $(EXTENSION_ROOT) $(EPOCINC) $(EPOCKERNINC) $(EPOCCPUINC) $(EPOCMMINC) $(EPOCBLDABS)
|
|
293 |
vpath %.ginc $(EPOCBLDABS)
|
|
294 |
vpath %.$(SRCEXT) . $(EXTRA_SRC_PATH) $(EXTENSION_ROOT) $(BASESRCPATH)
|
|
295 |
vpath %.$(OBJEXT) $(EPOCBLDABS)
|
|
296 |
vpath %.lnk . $(EXTENSION_ROOT) $(EPOCCPUINC)
|
|
297 |
|
|
298 |
# How to link the object files
|
|
299 |
$(EPOCBLDABS)/$(NAME).$(EXEEXT): $(LINKOBJECTS) $(LINKFILE) $(call pipe,$(EPOCBLDABS))
|
|
300 |
$(do_link)
|
|
301 |
|
|
302 |
# How to strip linked object to binary
|
|
303 |
$(TRG): $(EPOCBLDABS)/$(NAME).$(EXEEXT)
|
|
304 |
$(do_strip)
|
|
305 |
|
|
306 |
# How to assemble the source files
|
|
307 |
ifdef PROCESS_INCLUDES
|
|
308 |
FULLBASEINCLUDES := $(addprefix $(EPOCBLDABS)/,$(BASEINCLUDES))
|
|
309 |
FULLINCLUDES := $(addprefix $(EPOCBLDABS)/,$(INCLUDES))
|
|
310 |
|
|
311 |
$(FULLBASEINCLUDES) : $(EPOCBLDABS)/%.$(INCEXT) : %.inc $(call pipe,$(EPOCBLDABS))
|
|
312 |
perl $(EPOCROOT)epoc32/tools/armasm2as.pl $< $@
|
|
313 |
|
|
314 |
$(FULLINCLUDES) : $(EPOCBLDABS)/%.$(INCEXT) : %.inc $(call pipe,$(EPOCBLDABS))
|
|
315 |
perl $(EPOCROOT)epoc32/tools/armasm2as.pl $< $@
|
|
316 |
|
|
317 |
$(FULLBASEOBJECTS) : $(EPOCBLDABS)/%.$(OBJEXT) : %.$(SRCEXT) $(FULLINCLUDES) $(FULLBASEINCLUDES) $(FULLGENINCLUDES) $(call pipe,$(EPOCBLDABS))
|
|
318 |
$(do_asm)
|
|
319 |
|
|
320 |
$(FULLOBJECTS) : $(EPOCBLDABS)/%.$(OBJEXT) : %.$(SRCEXT) $(FULLINCLUDES) $(FULLBASEINCLUDES) $(FULLGENINCLUDES) $(call pipe,$(EPOCBLDABS))
|
|
321 |
$(do_asm)
|
|
322 |
|
|
323 |
else
|
|
324 |
|
|
325 |
ifeq "$(CPU)" "x86"
|
|
326 |
FULLBASEINCLUDES := $(addprefix $(EPOCBLDABS)/,$(BASEINCLUDES))
|
|
327 |
FULLINCLUDES := $(addprefix $(EPOCBLDABS)/,$(INCLUDES))
|
|
328 |
|
|
329 |
$(FULLBASEINCLUDES) $(FULLINCLUDES) : $(EPOCBLDABS)/%.inc : %.inc
|
|
330 |
$(CP) $(call slash2generic,$<) $(call slash2generic,$@)
|
|
331 |
|
|
332 |
$(FULLBASEOBJECTS) $(FULLOBJECTS) : $(EPOCBLDABS)/%.$(OBJEXT) : %.$(SRCEXT) $(FULLBASEINCLUDES) $(FULLGENINCLUDES) $(FULLINCLUDES)
|
|
333 |
$(do_asm)
|
|
334 |
|
|
335 |
else
|
|
336 |
$(FULLBASEOBJECTS) $(FULLOBJECTS) : $(EPOCBLDABS)/%.$(OBJEXT) : %.$(SRCEXT) $(BASEINCLUDES) $(FULLGENINCLUDES) $(INCLUDES) $(call pipe,$(EPOCBLDABS))
|
|
337 |
$(do_asm)
|
|
338 |
|
|
339 |
endif
|
|
340 |
endif
|
|
341 |
|
|
342 |
# How to translate the .h files to .inc
|
|
343 |
$(FULLGENINCLUDES) : $(EPOCBLDABS)/%.$(INCEXT) : %.h $(call pipe,$(EPOCBLDABS))
|
|
344 |
perl $(EPOCROOT)epoc32/tools/h2inc.pl $< $@ $(ASMTYP)
|
|
345 |
|
|
346 |
|
|
347 |
# How to make the working directories
|
|
348 |
$(EPOCBLDABS) $(EPOCTRG) :
|
|
349 |
$(call ifnotexistd,$(call slash2generic,$@))
|
|
350 |
|
|
351 |
# Makmake targets
|
|
352 |
.PHONY : MAKMAKE FREEZE LIB CLEANLIB RESOURCE FINAL BLD SAVESPACE RELEASABLES CLEAN
|
|
353 |
.PHONY : build skip
|
|
354 |
|
|
355 |
MAKMAKE :
|
|
356 |
echo Nothing to do
|
|
357 |
echo $(BASESRCPATH)
|
|
358 |
|
|
359 |
FREEZE :
|
|
360 |
echo Nothing to do
|
|
361 |
echo $(BASESRCPATH)
|
|
362 |
|
|
363 |
LIB :
|
|
364 |
echo Nothing to do
|
|
365 |
echo $(BASESRCPATH)
|
|
366 |
|
|
367 |
CLEANLIB :
|
|
368 |
echo Nothing to do
|
|
369 |
echo $(BASESRCPATH)
|
|
370 |
|
|
371 |
RESOURCE :
|
|
372 |
echo Nothing to do
|
|
373 |
echo $(BASESRCPATH)
|
|
374 |
|
|
375 |
FINAL :
|
|
376 |
echo Nothing to do
|
|
377 |
|
|
378 |
BLD SAVESPACE : $(PROCEED)
|
|
379 |
|
|
380 |
RELEASABLES :
|
|
381 |
@echo $(TRG)
|
|
382 |
|
|
383 |
CLEAN :
|
|
384 |
-$(ERASE) $(call slash2generic,$(TRG))
|
|
385 |
-$(ERASE) $(call slash2generic,$(EPOCBLDABS)/*.*)
|
|
386 |
|
|
387 |
build: $(EPOCTRG) $(EPOCBLDABS) $(TRG)
|
|
388 |
echo Bootstrap built for $(PLATFORM) $(CFG)
|
|
389 |
|
|
390 |
skip:
|
|
391 |
echo Bootstrap build skipped for $(PLATFORM) $(CFG)
|