|
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 # Code execute address also set in the linker file |
|
15 # |
|
16 # |
|
17 |
|
18 # To guarantee there is a slash at the end of EPOCROOT in case there is not. |
|
19 # This is needed to ensure compatibility with SBSv1. |
|
20 TMPROOT:=$(subst \,/,$(EPOCROOT)) |
|
21 EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/ |
|
22 |
|
23 include $(EPOCROOT)epoc32/tools/shell/$(notdir $(basename $(SHELL))).mk |
|
24 |
|
25 |
|
26 #Set the directories |
|
27 GENSRCDIR := $(EXTENSION_ROOT)/../e32utils/nandboot/coreldr |
|
28 SPECSRCDIR := $(EXTENSION_ROOT)/nandboot/coreldr |
|
29 VARIANTINC := $(EXTENSION_ROOT)/inc |
|
30 DRIVERDIR := $(VARIANTINC) |
|
31 EPOCINCDIR = $(EPOCROOT)epoc32/include/lubbock/nand |
|
32 GENINC1 := $(EPOCROOT)epoc32/include |
|
33 GENINC2 := $(EPOCROOT)epoc32/include/lubbock/nand |
|
34 GENDRIVERINC := $(EPOCROOT)epoc32/include/drivers |
|
35 GENINCPATH:= $(GENSRCDIR) $(SPECSRCDIR) $(VARIANTINC) $(GENINC1) $(GENDRIVERINC) |
|
36 ASMINCPATH := $(GENINC2) |
|
37 |
|
38 # Build directory = EPOCBLD |
|
39 BUILDLOC = $(EPOCBLD)$(call sbsadd,/$(PLATFORM_PATH)/$(CFG_PATH)) |
|
40 |
|
41 # Set the target name |
|
42 TARGETDIR := $(EPOCROOT)epoc32/release/$(PLATFORM_PATH) |
|
43 TARGET = $(TARGETDIR)/lubbock_coreldr.bin |
|
44 TMPTARGET = $(BUILDLOC)/coreldr.tmp |
|
45 |
|
46 #Rules |
|
47 vpath %.s . $(SPECSRCDIR) $(SRCDIR) |
|
48 vpath %.inc . $(SPECSRCDIR) $(VARIANTINC) $(EPOCINCDIR) |
|
49 vpath %.ginc . $(BUILDLOC) |
|
50 |
|
51 INCLUDES := nand.inc |
|
52 DRIVERINCLUDES := nand_fbr_offset.h |
|
53 |
|
54 VHEADERS := nanddevice.h |
|
55 BUILTINCLUDES := nanddevice.inc |
|
56 |
|
57 ASMSOURCE := coreldrasm.s |
|
58 GENCPPSOURCE := coreldr.cpp inflate.cpp |
|
59 HEADERS := inflate.h coreldr.h |
|
60 SPECHEADERS := nand_plat.h |
|
61 |
|
62 #Execution address (top 1M of Lubbock RAM) |
|
63 LINKBASE = 0xA3F00000 |
|
64 |
|
65 |
|
66 |
|
67 ARMASM_OUT := $(shell armasm 2>&1) |
|
68 ARMASM_OUT_4 := $(word 4,$(ARMASM_OUT)) |
|
69 # Use GCC toolchain if no other is available |
|
70 TOOLVER := GCC |
|
71 RVCTSTR := $(strip $(findstring RVCT, $(ARMASM_OUT_4))) |
|
72 ifeq "$(RVCTSTR)" "RVCT" |
|
73 TOOLVER := RVCT |
|
74 OP := -- |
|
75 OB := o |
|
76 endif |
|
77 |
|
78 #Arm RVCT tools |
|
79 ifeq "$(TOOLVER)" "RVCT" |
|
80 ASM_MACROS += USE_CXSF |
|
81 ASM := armasm |
|
82 LINK := armlink |
|
83 FROMELF := fromelf |
|
84 CPP := armcc |
|
85 |
|
86 OBJEXT := o |
|
87 INCEXT := inc |
|
88 |
|
89 ARMCCFLAGS := --arm -c -Otime --cpp |
|
90 |
|
91 ARMCCFLAGS := $(ARMCCFLAGS) $(foreach dir,$(GENINCPATH),$(join -I, $(dir))) |
|
92 |
|
93 ARMCCFLAGS := $(ARMCCFLAGS) -DEKA2 |
|
94 |
|
95 ARMCCFLAGS := $(ARMCCFLAGS) --preinclude $(EPOCROOT)epoc32/include/rvct/rvct.h |
|
96 |
|
97 |
|
98 ifeq "$(CFG)" "UDEB" |
|
99 ARMCCFLAGS := $(ARMCCFLAGS) -D_DEBUG |
|
100 endif |
|
101 |
|
102 ASM_MACRO_CMD := $(foreach macro,$(ASM_MACROS),$(OP)predefine "$(macro) SETL {TRUE}") |
|
103 AFLAGS := -g $(OP)keep $(ASM_MACRO_CMD) -I$(BUILDLOC) -I$(ASMINCPATH) |
|
104 LFLAGS := $(OP)entry BootEntry $(OP)ro-base $(LINKBASE) $(OP)FIRST BootEntry $(OP)map |
|
105 SYMOPT := $(OP)symdefs |
|
106 ASMTYP := ARMASM |
|
107 LINKFILE := |
|
108 |
|
109 define do_compile |
|
110 $(CPP) $(ARMCCFLAGS) $< -o $@ |
|
111 endef |
|
112 define do_h2inc |
|
113 perl $(EPOCROOT)epoc32/tools/h2inc.pl $< $@ ARMASM |
|
114 endef |
|
115 define do_asm |
|
116 $(ASM) $(AFLAGS) -$(OB) $@ $(OP)LIST $(join $(basename $@),.lst) $< |
|
117 endef |
|
118 define do_link |
|
119 $(LINK) $(LFLAGS) -$(OB) $@ $(FULLOBJECTS) |
|
120 endef |
|
121 define do_strip |
|
122 $(FROMELF) $(OP)bin $(OP)output $@ $< |
|
123 endef |
|
124 endif |
|
125 |
|
126 |
|
127 #GCC build options |
|
128 ifeq "$(TOOLVER)" "GCC" |
|
129 ASM := as |
|
130 AFLAGS := -mapcs-32 -R -n -I$(BUILDLOC) |
|
131 |
|
132 LINKFLAGS = -n --section-alignment 4 --file-alignment 2 -no-whole-archive |
|
133 GCCFLAGS=-march=armv4 -nostdinc -pipe -c -Wall -Wno-ctor-dtor-privacy -Wno-unknown-pragmas |
|
134 GCCFLAGS := $(GCCFLAGS) $(foreach dir,$(GENINCPATH),$(join -I, $(dir))) |
|
135 GCCDEFS = -D__SYMBIAN32__ -D__GCC32__ -D__EPOC32__ -D__MARM__ -D__MARM_ARM4__ -DEKA2 |
|
136 ifeq "$(CFG)" "UDEB" |
|
137 GCC = gcc -x c++ -g -O2 $(GCCFLAGS) -D_DEBUG -D_UNICODE $(GCCDEFS) |
|
138 else |
|
139 GCC = gcc -x c++ -s -fomit-frame-pointer -O2 $(GCCFLAGS) -DNDEBUG -D_UNICODE $(GCCDEFS) |
|
140 endif |
|
141 |
|
142 LINKFILE = $(SPECSRCDIR)/coreldr.lnk |
|
143 OBJEXT := o |
|
144 INCEXT := ginc |
|
145 |
|
146 PROCESS_INCLUDES := 1 |
|
147 define do_compile |
|
148 $(GCC) -o $@ $< |
|
149 endef |
|
150 define do_h2inc |
|
151 perl $(EPOCROOT)epoc32/tools/h2inc.pl $< $@ AS |
|
152 perl $(EPOCROOT)epoc32/tools/armasm2as.pl $@ $(join $(basename $@),.ginc) |
|
153 endef |
|
154 define do_includes |
|
155 perl $(EPOCROOT)epoc32/tools/armasm2as.pl $< $@ |
|
156 endef |
|
157 define do_asm |
|
158 perl $(EPOCROOT)epoc32/tools/armasm2as.pl $< $(join $(basename $@),.s) |
|
159 $(AS) $(AFLAGS) -o $@ $(join $(basename $@),.s) |
|
160 endef |
|
161 define do_strip |
|
162 strip -O binary -o "$(TARGET)" "$(TMPTARGET)" |
|
163 $(ERASE) $(call slash2generic,"$(TMPTARGET)") |
|
164 echo Built $(TARGET) |
|
165 endef |
|
166 define do_link |
|
167 ld -o "$(TMPTARGET)" --start $(FULLOBJECTS) --script=$(LINKFILE) |
|
168 endef |
|
169 endif |
|
170 |
|
171 |
|
172 #CPP source processing |
|
173 FULLCPPSOURCE := $(addprefix $(GENSRCDIR)/,$(GENCPPSOURCE)) |
|
174 |
|
175 #Header processing |
|
176 FULLHEADERS := $(addprefix $(GENSRCDIR)/,$(HEADERS)) |
|
177 FULLSPECHEADERS := $(addprefix $(VARIANTINC)/,$(SPECHEADERS)) |
|
178 |
|
179 FULLVHEADERS := $(addprefix $(GENDRIVERINC)/,$(VHEADERS)) |
|
180 FULLBUILTINCLUDES := $(addprefix $(BUILDLOC)/,$(BUILTINCLUDES)) |
|
181 $(FULLBUILTINCLUDES) : $(FULLVHEADERS) |
|
182 $(do_h2inc) |
|
183 |
|
184 |
|
185 #object names |
|
186 GENCPPOBJECTS := $(foreach f,$(GENCPPSOURCE),$(basename $(f)).$(OBJEXT)) |
|
187 FULLGENCPPOBJECTS := $(addprefix $(BUILDLOC)/,$(GENCPPOBJECTS)) |
|
188 |
|
189 ASMOBJECTS := $(foreach f,$(ASMSOURCE),$(basename $(f)).$(OBJEXT)) |
|
190 FULLASMOBJECTS := $(addprefix $(BUILDLOC)/,$(ASMOBJECTS)) |
|
191 |
|
192 FULLOBJECTS := $(FULLASMOBJECTS) $(FULLGENCPPOBJECTS) |
|
193 |
|
194 ifdef PROCESS_INCLUDES |
|
195 |
|
196 GCCSRC := $(addprefix $(BUILDLOC)/,$(SRC)) |
|
197 |
|
198 #Creation of headers |
|
199 FULLINCLUDES := $(foreach f,$(INCLUDES),$(basename $(f)).$(INCEXT)) |
|
200 FULLINCLUDES := $(addprefix $(BUILDLOC)/,$(FULLINCLUDES)) |
|
201 |
|
202 FULLDRIVERINCLUDES := $(foreach f,$(DRIVERINCLUDES),$(basename $(f)).$(INCEXT)) |
|
203 FULLDRIVERINCLUDES := $(addprefix $(BUILDLOC)/,$(FULLDRIVERINCLUDES)) |
|
204 |
|
205 $(FULLINCLUDES) : $(BUILDLOC)/%.$(INCEXT) : %.inc $(call pipe,$(BUILDLOC)) |
|
206 $(do_includes) |
|
207 |
|
208 $(FULLDRIVERINCLUDES) : $(BUILDLOC)/%.$(INCEXT) : %.inc $(call pipe,$(BUILDLOC)) |
|
209 $(do_includes) |
|
210 |
|
211 else |
|
212 FULLINCLUDES:= $(addprefix $(SPECSRCDIR)/,$(INCLUDES)) |
|
213 FULLDRIVERINCLUDES:= $(addprefix $(DRIVERDIR)/,$(DRIVERINCLUDES)) |
|
214 |
|
215 #Arm RVCT specifics here |
|
216 |
|
217 endif |
|
218 |
|
219 |
|
220 #Link |
|
221 $(TMPTARGET) : $(FULLOBJECTS) |
|
222 $(do_link) |
|
223 |
|
224 #strip |
|
225 $(TARGET) : $(TMPTARGET) |
|
226 $(do_strip) |
|
227 |
|
228 #CPP objects |
|
229 $(FULLGENCPPOBJECTS) : $(BUILDLOC)/%.$(OBJEXT) : $(GENSRCDIR)/%.cpp $(FULLHEADERS) $(FULLSPECHEADERS) |
|
230 $(do_compile) |
|
231 |
|
232 |
|
233 #Asm objects |
|
234 $(FULLASMOBJECTS) : $(BUILDLOC)/%.$(OBJEXT) : $(SPECSRCDIR)/$(ASMSOURCE) $(FULLINCLUDES) $(FULLBUILTINCLUDES) $(FULLDRIVERINCLUDES) |
|
235 $(do_asm) |
|
236 |
|
237 # make the work directories |
|
238 $(TARGETDIR) : |
|
239 @$(call ifnotexistd,"$(TARGETDIR)") |
|
240 |
|
241 $(BUILDLOC) : |
|
242 @$(call ifnotexistd,"$(BUILDLOC)") |
|
243 |
|
244 |
|
245 |
|
246 MAKMAKE : |
|
247 echo Nothing to do |
|
248 |
|
249 FREEZE : |
|
250 echo Nothing to do |
|
251 |
|
252 LIB : |
|
253 echo Nothing to do |
|
254 |
|
255 CLEANLIB : |
|
256 echo Nothing to do |
|
257 |
|
258 RESOURCE : |
|
259 echo Nothing to do |
|
260 |
|
261 FINAL : |
|
262 echo Nothing to do |
|
263 |
|
264 ifneq "$(PLATFORM)" "GCCXML" |
|
265 BLD SAVESPACE : $(TARGETDIR) $(BUILDLOC) $(TARGET) |
|
266 |
|
267 RELEASABLES : |
|
268 @echo "$(TARGET)" |
|
269 |
|
270 CLEAN : |
|
271 -$(ERASE) $(call slash2generic,"$(TARGET)") |
|
272 -$(ERASE) $(call slash2generic,"$(BUILDLOC)/*.*") |
|
273 # -$(ERASE) "$(TARGET)" |
|
274 # -$(ERASE) "$(BUILDLOC)/*.*" |
|
275 |
|
276 else |
|
277 |
|
278 BLD SAVESPACE : |
|
279 echo Nothing to do |
|
280 |
|
281 RELEASABLES : |
|
282 |
|
283 CLEAN : |
|
284 echo Nothing to do |
|
285 endif |
|
286 |