author | timothy.murphy@nokia.com |
Tue, 19 Jan 2010 23:54:45 +0000 | |
branch | wip |
changeset 149 | d082b140eb98 |
parent 40 | afaf81347e0a |
child 161 | 62c28226cde4 |
permissions | -rw-r--r-- |
3 | 1 |
# Copyright (c) 2007-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 the License "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 |
# WINSCW EXE/DLL/IMPLIB/LIB Function Like Makefile (FLM) |
|
15 |
# Knows how to build all possible executables for the WINSCW emulator build |
|
16 |
# |
|
17 |
# |
|
18 |
||
19 |
# passed in values, stripped of whitespace |
|
20 |
COPY_FOR_STATIC_LINKAGE:=$(strip $(COPY_FOR_STATIC_LINKAGE)) |
|
21 |
DEFFILE:=$(strip $(DEFFILE)) |
|
22 |
DEFFILEKEYWORD:=$(strip $(DEFFILEKEYWORD)) |
|
23 |
EPOCALLOWDLLDATA:=$(strip $(EPOCALLOWDLLDATA)) |
|
24 |
EXPORTLIBRARY:=$(strip $(EXPORTLIBRARY)) |
|
25 |
BASEADDRESS:=$(strip $(BASEADDRESS)) |
|
26 |
LINKAS:=$(strip $(LINKAS)) |
|
27 |
NOEXPORTLIBRARY:=$(strip $(NOEXPORTLIBRARY)) |
|
28 |
SECUREID:=$(strip $(SECUREID)) |
|
29 |
UID2:=$(strip $(UID2)) |
|
30 |
UID3:=$(strip $(UID3)) |
|
31 |
VENDORID:=$(strip $(VENDORID)) |
|
32 |
VID:=$(strip $(VID)) |
|
33 |
WIN32_HEADERS:=$(strip $(WIN32_HEADERS)) |
|
34 |
||
35 |
# local variables |
|
36 |
BINDIR:= |
|
37 |
BINDIRSTATICLINK:= |
|
38 |
BINTARGET:= |
|
39 |
BINTARGETSTATICLINK:= |
|
40 |
BLDDIR:= |
|
41 |
CHECKLIB_TYPE:= |
|
42 |
CREATABLEPATHS:= |
|
43 |
CLEANTARGETS:= |
|
44 |
CW_RUNTIME:= |
|
45 |
ENTRYSYMBOL:= |
|
46 |
IMPORTLIBLINKAS:= |
|
47 |
IMPORTLIBTARGET:= |
|
48 |
LIBDIR:= |
|
49 |
LINKER_FIRSTSTATLIB:= |
|
50 |
MAINLINKAS:= |
|
51 |
NEWLIBFILE:= |
|
52 |
RELEASABLES:= |
|
53 |
STATLIBDIR:= |
|
54 |
STDCPP_BUILD:= |
|
55 |
STDCPPTAGFILE:= |
|
56 |
UID1:= |
|
57 |
WIN32_LIBRARIES:= |
|
58 |
||
59 |
# FIVESPACES variable created to ensure that a suitable gap of space characters can |
|
60 |
# be placed between the separate arguments in the call to a tool (if required). |
|
61 |
# This is a workaround for a problem in Cygwin, where separate arguments are interpreted |
|
62 |
# as a single argument when passed to bash. |
|
63 |
FIVESPACES=$(BLANK) $(BLANK) |
|
64 |
||
65 |
# CW runtime varies based on TARGETTYPE requirements, with wrapper FLMs dictating the choice |
|
66 |
# We override a CW-specific environment variable to do this, in common with ABLD |
|
67 |
ifeq ($(CW_STATIC_RUNTIME),1) |
|
68 |
CW_RUNTIME:=$(CW_RUNTIME_STATIC) |
|
69 |
CFLAGS:=$(CFLAGS) $(OPT.RUNTIME)staticmulti |
|
70 |
else |
|
71 |
CW_RUNTIME:=$(CW_RUNTIME_NONSTATIC) |
|
72 |
CFLAGS:=$(CFLAGS) $(OPT.RUNTIME)dllmulti |
|
73 |
endif |
|
74 |
MWSym2LibraryFiles:=$(subst $(CHAR_SPACE),$(DIRSEP),$(CW_RUNTIME) $(CW_DEFAULT_LIBS)) |
|
75 |
ifneq ($(WIN32_LIBRARY),) |
|
76 |
WIN32_HEADERS:=1 |
|
77 |
WIN32_LIBRARIES:=$(addprefix $(OPT.LIBFILE),$(WIN32_LIBRARY)) |
|
78 |
endif |
|
79 |
||
80 |
# top-level definitions |
|
81 |
BINDIR:=$(RELEASEPATH)/$(FULLVARIANTPATH) |
|
82 |
||
83 |
# TARGETPATH and COPY_FOR_STATIC_LINKAGE only apply when TARGETPATH is a sub-directory of /sys/bin |
|
84 |
TARGETPATH_APPEND:=$(subst \,/,$(TARGETPATH)) |
|
85 |
ifneq ($(findstring /sys/bin/,$(TARGETPATH_APPEND)),) |
|
86 |
ifeq ($(COPY_FOR_STATIC_LINKAGE),1) |
|
87 |
BINDIRSTATICLINK:=$(BINDIR) |
|
88 |
endif |
|
89 |
BINDIR:=$(BINDIR)/z$(TARGETPATH_APPEND) |
|
90 |
else |
|
91 |
COPY_FOR_STATIC_LINKAGE:=0 |
|
92 |
endif |
|
93 |
||
94 |
BLDDIR:=$(OUTPUTPATH)/$(FULLVARIANTPATH) |
|
95 |
LIBDIR:=$(RELEASEPATH)/$(LINKPATH) |
|
96 |
STATLIBDIR:=$(RELEASEPATH)/$(FULLVARIANTPATH) |
|
97 |
CREATABLEPATHS:=$(BLDDIR) $(BINDIR) $(BINDIRSTATICLINK) |
|
98 |
||
99 |
# Deduce whether we should be performing a build with standard CPP characteristics |
|
100 |
# This operates differently per-OS release, although OE TARGETTYPEs always build with standard CPP traits |
|
101 |
ifeq ($(OPEN_ENVIRONMENT),1) |
|
102 |
STDCPP_BUILD:=1 |
|
103 |
endif |
|
104 |
||
105 |
ifeq ($(SUPPORTS_STDCPP_NEWLIB),1) |
|
106 |
ifeq ($(NOSTDCPP),1) |
|
107 |
STDCPP_BUILD:= |
|
108 |
else |
|
109 |
ifeq ($(STDCPP),1) |
|
110 |
STDCPP_BUILD:=1 |
|
111 |
endif |
|
112 |
endif |
|
113 |
||
40
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
114 |
# Operator new linking depends on both the use of the NEWLIB keyword and whether a component supports a standard |
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
115 |
# CPP build. |
3 | 116 |
ifneq ($(NEWLIB),) |
40
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
117 |
# If specified, always use the NEWLIB keyword value for operator new library linking |
3 | 118 |
NEWLIBFILE:=$(STATLIBDIR)/$(NEWLIB) |
119 |
else |
|
40
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
120 |
# If not performing a standard CPP build, link to an appropriate default Symbian new library. |
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
121 |
# Standard CPP components defer to the toolchain supplied libraries. |
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
122 |
ifneq ($(STDCPP_BUILD),1) |
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
123 |
ifeq ($(SYSTEM_TARGET),1) |
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
124 |
NEWLIBFILE:=$(STATLIBDIR)/$(DEFAULT_SYSTEM_NEWLIB) |
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
125 |
else |
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
126 |
NEWLIBFILE:=$(STATLIBDIR)/$(DEFAULT_NORMAL_NEWLIB) |
afaf81347e0a
DPDEF143176 raptor does not respect STDCPP mmp file keyword
jchatten
parents:
9
diff
changeset
|
127 |
endif |
3 | 128 |
endif |
129 |
endif |
|
130 |
endif |
|
131 |
||
132 |
ifeq ($(STDCPP_BUILD),1) |
|
133 |
CDEFS:=$(CDEFS) $(STDCPP_DEF) |
|
134 |
SYSTEMINCLUDE:=$(SYSTEMINCLUDE) $(STDCPP_INCLUDE) |
|
135 |
CFLAGS:=$(CFLAGS) $(OPT.WCHAR) on |
|
136 |
CHECKLIB_TYPE:=$(OPT.CHECKLIB.STDCPP) |
|
137 |
STDCPPTAGFILE:=$(OPT.LIBPATH)$(EPOCROOT)/epoc32/tools/tag $(OPT.SEARCH) tag_coff |
|
138 |
else |
|
139 |
CFLAGS:=$(CFLAGS) $(OPT.WCHAR) off |
|
140 |
CHECKLIB_TYPE:=$(OPT.CHECKLIB.SYMCPP) |
|
141 |
endif |
|
142 |
||
143 |
ifeq ($(WIN32_HEADERS),1) |
|
144 |
CDEFS:=$(CDEFS) WIN32 |
|
145 |
CDEFS:=$(CDEFS) _WINDOWS |
|
146 |
CFLAGS:=$(CFLAGS) $(OPT.STDINC) |
|
147 |
else |
|
148 |
CFLAGS:=$(CFLAGS) $(OPT.NOSTDINC) |
|
149 |
endif |
|
150 |
||
151 |
# get the compiler to generate dependencies for us? |
|
152 |
ifeq ($(DEPEND_SKIP),) |
|
153 |
CFLAGS:=$(CFLAGS) $(OPT.DEPEND) |
|
154 |
endif |
|
155 |
||
156 |
# specifics relating to the base type of the target being processed |
|
157 |
ifeq ($(BASE_TYPE),dll) |
|
158 |
# Special case, although this should be dealt with in the wrapper FLM in a better way |
|
159 |
ifeq ($(TARGETTYPE),exexp) |
|
160 |
CDEFS:=$(CDEFS) __EXE__ |
|
161 |
ENTRYSYMBOL:=__E32Startup |
|
162 |
LFLAGS:=$(LFLAGS) $(OPT.NOENTRY) |
|
163 |
UID1:=1000007a |
|
164 |
else |
|
165 |
CDEFS:=$(CDEFS) __DLL__ |
|
166 |
ENTRYSYMBOL:=__E32Dll |
|
167 |
LFLAGS:=$(LFLAGS) $(OPT.MAINENTRYPOINT)__Win32DllMain@12 |
|
168 |
UID1:=10000079 |
|
169 |
endif |
|
170 |
LFLAGS:=$(LFLAGS) $(OPT.SHARED) |
|
171 |
||
172 |
ifneq ($(BASEADDRESS),) |
|
173 |
LFLAGS:=$(LFLAGS) $(OPT.IMAGEBASE)$(BASEADDRESS) |
|
174 |
endif |
|
175 |
||
176 |
ifeq ($(FIRST_STATLIB),) |
|
177 |
BASE_TYPE_STATLIB:=edll.lib |
|
178 |
else |
|
179 |
BASE_TYPE_STATLIB:=$(FIRST_STATLIB) |
|
180 |
endif |
|
181 |
endif |
|
182 |
ifeq ($(BASE_TYPE),exe) |
|
183 |
CDEFS:=$(CDEFS) __EXE__ |
|
184 |
ENTRYSYMBOL:=?_E32Bootstrap@@YGXXZ |
|
185 |
UID1:=1000007a |
|
186 |
||
187 |
ifeq ($(FIRST_STATLIB),) |
|
188 |
BASE_TYPE_STATLIB:=eexe.lib |
|
189 |
else |
|
190 |
BASE_TYPE_STATLIB:=$(FIRST_STATLIB) |
|
191 |
endif |
|
192 |
endif |
|
193 |
||
194 |
ifeq ($(FIRSTLIB),) |
|
195 |
LINKER_FIRSTSTATLIB:=$(BASE_TYPE_STATLIB) |
|
196 |
else |
|
197 |
LINKER_FIRSTSTATLIB:=$(FIRSTLIB) |
|
198 |
endif |
|
199 |
||
200 |
||
201 |
BINTARGET:=$(BINDIR)/$(TARGET).$(if $(REQUESTEDTARGETEXT),$(REQUESTEDTARGETEXT),$(TARGETTYPE)) |
|
202 |
||
203 |
||
204 |
# Run trace compiler ##################################### |
|
205 |
TRACE_MARKER_PATH:=$(OUTPUTPATH) |
|
206 |
||
207 |
ifeq ($(UID3),) |
|
208 |
ifeq ($(UID2),) |
|
209 |
USE_TRACE_COMPILER:= |
|
210 |
else |
|
211 |
UID_TC:=$(UID2) |
|
212 |
endif |
|
213 |
else |
|
214 |
UID_TC:=$(UID3) |
|
215 |
endif |
|
216 |
||
217 |
# USE_TRACE_COMPILER defaults to blank in Raptor config. |
|
218 |
# Users can turn TC on by setting it to 1 in user config. |
|
219 |
ifneq ($(USE_TRACE_COMPILER),) |
|
220 |
include $(FLMHOME)/tracecompiler.mk |
|
221 |
endif |
|
222 |
||
223 |
||
224 |
#################### |
|
225 |
## IMPORT LIBRARY ## |
|
226 |
#################### |
|
227 |
||
228 |
IMPORTLIBLINKAS:=$(TARGET).$(if $(REQUESTEDTARGETEXT),$(REQUESTEDTARGETEXT),$(TARGETTYPE)) |
|
229 |
# LINKAS, if supplied, only applies to IMPLIB TARGETTYPEs |
|
230 |
ifeq ($(BASE_TYPE),importlib) |
|
231 |
ifneq ($(LINKAS),) |
|
232 |
IMPORTLIBLINKAS:=$(LINKAS) |
|
233 |
else |
|
234 |
IMPORTLIBLINKAS:=$(TARGET).dll |
|
235 |
endif |
|
236 |
endif |
|
237 |
||
238 |
ifneq ($(EXPORTLIBRARY),) |
|
239 |
IMPORTLIBTARGET:=$(LIBDIR)/$(EXPORTLIBRARY).lib |
|
240 |
else |
|
241 |
IMPORTLIBTARGET:=$(LIBDIR)/$(TARGET).lib |
|
242 |
endif |
|
243 |
||
244 |
# Regardless of whether a TARGETTYPE normally supports an import library, always attempt |
|
245 |
# to generate one if an explicit DEFFILE keyword was listed |
|
246 |
ifeq ($(DEFFILEKEYWORD),1) |
|
247 |
SUPPORTS_IMPORT_LIBRARY:=1 |
|
248 |
endif |
|
249 |
||
250 |
ifeq ($(SUPPORTS_IMPORT_LIBRARY),1) |
|
251 |
ifneq ($(NOEXPORTLIBRARY),1) |
|
252 |
ifneq ($(TARGET_$(call sanitise,$(IMPORTLIBTARGET))),1) |
|
253 |
RELEASABLES:=$(RELEASABLES) $(if $(or $(EXPORTUNFROZEN),$(DEFFILE)),$(IMPORTLIBTARGET)) |
|
254 |
||
255 |
# import libraries are generated to the UDEB release directory |
|
256 |
ifneq ($(VARIANTTYPE),udeb) |
|
257 |
CREATABLEPATHS:=$(CREATABLEPATHS) $(if $(or $(EXPORTUNFROZEN),$(DEFFILE)),$(LIBDIR)) |
|
258 |
endif |
|
259 |
||
260 |
ifneq ($(EXPORTUNFROZEN),) |
|
261 |
# EXPORTUNFROZEN amounts to doing the stage-two link with the makedef generated temporary .def file but creating a .lib |
|
262 |
# file as a side-effect of linking. The import library is therefore dependent on the final binary in this instance. |
|
263 |
$(info <warning project='$(PROJECT_META)' component='$(COMPONENT_META)'>EXPORTUNFROZEN present in $(PROJECT_META) - unfrozen exports will be represented in import library.</warning> ) |
|
264 |
$(IMPORTLIBTARGET): $(BINTARGET) |
|
265 |
$(eval TARGET_$(call sanitise,$(IMPORTLIBTARGET)):=1) |
|
266 |
else |
|
267 |
ifneq ($(DEFFILE),) |
|
268 |
# If a .def file physically exists (either explicitly via DEFFILE or implicitly in the correct place) then we |
|
269 |
# generate an import library with reference to it |
|
270 |
PREPPEDDEFFILE:=$(BLDDIR)/$(TARGET).prep.def |
|
271 |
CLEANTARGETS:=$(CLEANTARGETS) $(PREPPEDDEFFILE) |
|
272 |
||
273 |
define win32def2lib |
|
274 |
$(IMPORTLIBTARGET): $(DEFFILE) |
|
275 |
$(call startrule,win32def2lib) \ |
|
276 |
$(PREPDEF) "$(DEFFILE)" "$(PREPPEDDEFFILE)" && \ |
|
277 |
$(LD) $(PREPPEDDEFFILE) $(OPT.IMPORTLIB) -o "$$@" $(OPT.ADDCOMMAND) "out:$(IMPORTLIBLINKAS)" $(OPT.WARNINGS) off \ |
|
278 |
$(call endrule,win32def2lib) |
|
279 |
endef |
|
280 |
$(eval $(win32def2lib)) |
|
281 |
$(eval TARGET_$(call sanitise,$(IMPORTLIBTARGET)):=1) |
|
282 |
endif |
|
283 |
endif |
|
284 |
endif |
|
285 |
endif |
|
286 |
endif |
|
287 |
||
288 |
||
289 |
ifneq ($(BASE_TYPE),importlib) |
|
290 |
||
291 |
############# |
|
292 |
## COMPILE ## |
|
293 |
############# |
|
294 |
||
295 |
ifeq ($(COPY_FOR_STATIC_LINKAGE),1) |
|
296 |
BINTARGETSTATICLINK:=$(BINDIRSTATICLINK)/$(TARGET).$(if $(REQUESTEDTARGETEXT),$(REQUESTEDTARGETEXT),$(TARGETTYPE)) |
|
297 |
endif |
|
298 |
||
299 |
RELEASABLES:=$(RELEASABLES) $(BINTARGET) $(BINTARGETSTATICLINK) |
|
300 |
||
301 |
# work on a local source files list |
|
302 |
SRCFILES:=$(SOURCE) |
|
303 |
# and there may be more source for stage 2 in OE builds |
|
304 |
SRCFILES_OE:= |
|
305 |
||
306 |
ifneq ($(BASE_TYPE),staticlib) |
|
307 |
# add the generated UID source file |
|
308 |
GENSOURCE:=$(BLDDIR)/$(TARGET).UID.CPP |
|
309 |
SRCFILES:=$(SRCFILES) $(GENSOURCE) |
|
310 |
||
311 |
# the generated symbol lookup source file for Open Environment. |
|
312 |
# this only gets linked in at stage 2 |
|
313 |
SYMSOURCE:=$(if $(OPEN_ENVIRONMENT),$(BLDDIR)/$(TARGET)_SYM_.cpp,) |
|
314 |
SRCFILES_OE:=$(SYMSOURCE) |
|
315 |
||
316 |
CLEANTARGETS:=$(CLEANTARGETS) $(GENSOURCE) $(SYMSOURCE) |
|
317 |
||
318 |
ifeq ($(UID2),00000000) |
|
319 |
ifneq ($(UID2_DEFAULT),) |
|
320 |
UID2:=$(UID2_DEFAULT) |
|
321 |
endif |
|
322 |
endif |
|
323 |
||
324 |
ifeq ($(SECUREID),) |
|
325 |
SECUREID:=$(UID3) |
|
326 |
endif |
|
327 |
||
328 |
define win32generateUIDcpp |
|
329 |
$(GENSOURCE): $(PROJECT_META) |
|
330 |
$(call startrule,win32generateUIDcpp,,) \ |
|
331 |
echo "// SBS-generated uid source file" > $$@ && \ |
|
332 |
echo "#include <e32cmn.h>" >> $$@ && \ |
|
333 |
echo "#pragma data_seg(\".SYMBIAN\")" >> $$@ && \ |
|
334 |
echo "__EMULATOR_IMAGE_HEADER2(0x$(UID1),0x$(UID2),0x$(UID3),EPriority$(EPOCPROCESSPRIORITY),0x$(CAPABILITYFLAG1),0x$(CAPABILITYFLAG2),0x$(SECUREID),0x$(VENDORID),0x$(VERSIONHEX),$(EPOCALLOWDLLDATA))" >> $$@ && \ |
|
335 |
echo "#pragma data_seg()" >> $$@ \ |
|
336 |
$(call endrule,win32generateUIDcpp) |
|
337 |
endef |
|
338 |
$(eval $(win32generateUIDcpp)) |
|
339 |
endif # neq $(BASE_TYPE),staticlib |
|
340 |
||
341 |
# object files |
|
342 |
OBJECTFILES:=$(patsubst %,$(BLDDIR)/%,$(addsuffix .o,$(basename $(notdir $(call allsuffixsubst,.cia .CIA .Cia,_.cia,$(SRCFILES)))))) |
|
343 |
OBJECTFILES:=$(patsubst %.UID.o,%_UID_.o,$(OBJECTFILES)) |
|
344 |
||
345 |
# object file extras for stage 2 |
|
346 |
OBJECTFILES_OE:=$(patsubst %,$(BLDDIR)/%,$(addsuffix .o,$(basename $(notdir $(SRCFILES_OE))))) |
|
347 |
||
348 |
CLEANTARGETS:=$(CLEANTARGETS) $(OBJECTFILES) $(OBJECTFILES_OE) |
|
349 |
||
350 |
# include paths and preinclude file |
|
351 |
UINCLUDE:=$(patsubst %,$(OPT.USERINCLUDE)%,$(USERINCLUDE)) |
|
352 |
SINCLUDE:=$(patsubst %,$(OPT.SYSINCLUDE)%,$(SYSTEMINCLUDE)) |
|
353 |
PINCLUDE:=$(OPT.PREINCLUDE)$(notdir $(PRODUCT_INCLUDE)) |
|
354 |
||
355 |
#INCLUDES:=$(UINCLUDE) $(OPT.SPLITINCLUDE) $(SINCLUDE) $(PINCLUDE) |
|
356 |
INCLUDES:=$(OPT.SPLITINCLUDE) $(UINCLUDE) $(SINCLUDE) $(PINCLUDE) |
|
357 |
||
358 |
# macro definitions |
|
359 |
DEFINES:=$(call makemacrodef,$(OPT.DEFINE),$(CDEFS) $(TARGET_MACRO)) |
|
360 |
||
361 |
||
362 |
# $(1) is the name of the source file, $(2) is the extension to map it to e.g. .o |
|
363 |
# no space in front of function body |
|
364 |
define mapwin32file |
|
365 |
$(patsubst %.UID$(2),%_UID_$(2),$(BLDDIR)/$(addsuffix $2,$(basename $(notdir $(call allsuffixsubst,.cia .CIA .Cia,_.cia,$(1)))))) |
|
366 |
endef |
|
367 |
||
368 |
# compile all source files, creating and including compiler generated dependency files along the way |
|
369 |
# SED is used to (a) remove relatively pathed "object_file: source_file" references that can appear |
|
370 |
# with some versions of mwccsym2 and (b) convert slashes |
|
371 |
define win32compile2object |
|
372 |
||
373 |
$(eval DEPENDFILENAME:=$(call mapwin32file,$(1),.o.d)) |
|
374 |
$(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
|
375 |
||
376 |
$(call mapwin32file,$(1),.o): $(1) $(PROJECT_META) $(if $(DEPENDFILE),,RESOURCE BITMAP EXPORT) $(if $(USE_TRACE_COMPILER),$(TRACE_MARKER)) |
|
377 |
$(call startrule,win32compile2object,,$(1)) \ |
|
378 |
$(CC) $$(if $$(filter %.C,$(1)),-lang c) $(CFLAGS) $(OPTION_CW) \ |
|
379 |
$(if $(STDCPP_BUILD),$$(if $$(filter %.c %.C,$(1)),,$$(call makemacrodef,$(OPT.DEFINE),$(STDCPP_WCHAR_DEF))),) \ |
|
380 |
$(DEFINES) $(INCLUDES) $(OPT.OUT)"$$@" "$(1)" && \ |
|
381 |
$(GNUSED) 's#\\\\\(.\)#/\1#g;s#/ #\\\ #g;s#\([A-Za-z]:\)\\\\#\1/#g;1,1s#.*: .* \(.\)\?$$$$#$(call mapwin32file,$(1),.o): $1 \1#' $(call mapwin32file,$(1),.dep) > $(call mapwin32file,$(1),.o.d) \ |
|
382 |
$(call endrule,win32compile2object) |
|
383 |
||
384 |
CLEANTARGETS:=$$(CLEANTARGETS) $(call mapwin32file,$(1),.dep) |
|
385 |
||
386 |
CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
|
387 |
ifneq "$(DEPENDFILE)" "" |
|
388 |
ifeq ($(NO_DEPEND_INCLUDE),) |
|
389 |
ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
|
390 |
-include $(DEPENDFILE) |
|
391 |
endif |
|
392 |
endif |
|
393 |
endif |
|
394 |
||
395 |
# individual source file compilation |
|
396 |
SOURCETARGET_$(call sanitise,$(1)): $(call mapwin32file,$(1),.o) |
|
397 |
||
398 |
endef |
|
399 |
||
400 |
# List target, depends on object file |
|
401 |
define win32list |
|
402 |
LISTING:: $(OBJECTFILES) $(OBJECTFILES_OE) |
|
403 |
$(call startrule,win32listing) \ |
|
404 |
$(CC) $(OPT.LISTING) $(patsubst %.UID.o,%_UID_.o,$(BLDDIR)/$(addsuffix .o,$(basename $(notdir $(1))))) -o $(basename $1).WINSCW.lst \ |
|
405 |
$(call endrule,win32listing) |
|
406 |
endef |
|
407 |
||
408 |
$(foreach SRCFILE,$(SRCFILES) $(SRCFILES_OE),$(eval $(call win32compile2object,$(SRCFILE)))) |
|
409 |
$(foreach SRCFILE,$(SRCFILES) $(SRCFILES_OE),$(eval $(call win32list,$(SRCFILE)))) |
|
410 |
||
411 |
###################### |
|
412 |
## RESOURCE COMPILE ## |
|
413 |
###################### |
|
414 |
||
415 |
# If Python has been used to construct the environment on Windows then the standard MW include path environment |
|
416 |
# variable will have been munged to UPPERCASE. |
|
417 |
STDMWCINCLUDEPATHS:=$(if $(MWCSym2Includes),$(MWCSym2Includes),$(MWCSYM2INCLUDES)) |
|
418 |
||
419 |
define win32resourcecompile |
|
420 |
# Note that two calls are made to the resource compiler here. There seems to be no means to override the |
|
421 |
# default behaviour of dumping dependency files into the CWD when using -MD. So - we compile once for real, |
|
422 |
# and then pipe dependency output through SED afterwards to create the dependency file where we want it |
|
423 |
||
424 |
$(eval DEPENDFILENAME:=$(call mapwin32file,$(1),.res.d)) |
|
425 |
$(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
|
426 |
||
427 |
$(call mapwin32file,$(1),.res): $(1) $(PROJECT_META) $(if $(DEPENDFILE),,RESOURCE BITMAP EXPORT) |
|
428 |
$(call startrule,win32resourcecompile,,$(1)) \ |
|
429 |
MWCIncludes='$(STDMWCINCLUDEPATHS)' $(RC) $(OPT.OUT)"$$@" "$(1)" && \ |
|
430 |
MWCIncludes='$(STDMWCINCLUDEPATHS)' $(RC) -make $(OPT.OUT)"$$@" "$(1)" | \ |
|
431 |
$(GNUSED) 's#\\\\\(.\)#/\1#g;s#/ #\\\ #g;s#\([A-Za-z]:\)\\\\#\1/#g;1,1s#.*: .* \(.\)\?$$$$#$(call mapwin32file,$(1),.res): $1 \1#' > $(call mapwin32file,$(1),.res.d) \ |
|
432 |
$(call endrule,win32resourcecompile) |
|
433 |
||
434 |
CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
|
435 |
ifneq "$(DEPENDFILE)" "" |
|
436 |
ifeq ($(NO_DEPEND_INCLUDE),) |
|
437 |
ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
|
438 |
-include $(DEPENDFILE) |
|
439 |
endif |
|
440 |
endif |
|
441 |
endif |
|
442 |
||
443 |
endef |
|
444 |
||
445 |
$(foreach WIN32RESOURCEFILE,$(WIN32_RESOURCE),$(eval $(call win32resourcecompile,$(WIN32RESOURCEFILE)))) |
|
446 |
OBJECTFILES:=$(OBJECTFILES) $(patsubst %,$(BLDDIR)/%,$(addsuffix .res,$(basename $(notdir $(WIN32_RESOURCE))))) |
|
447 |
||
448 |
################## |
|
449 |
## LINK/ARCHIVE ## |
|
450 |
################## |
|
451 |
||
452 |
# libraries |
|
453 |
STATICLIBS:=$(patsubst %,%.lib,$(STATICLIBRARY)) |
|
454 |
STATICLIBFILES:=$(patsubst %,$(STATLIBDIR)/%,$(STATICLIBS)) |
|
455 |
LINKER_FIRSTSTATLIBFILE:=$(STATLIBDIR)/$(LINKER_FIRSTSTATLIB) |
|
456 |
||
457 |
ifeq ($(VARIANTTYPE),urel) |
|
458 |
LINKLIBS:=$(patsubst %.dso,%.lib,$(LIBRARY)) |
|
459 |
else |
|
460 |
LINKLIBS:=$(patsubst %.dso,%.lib,$(LIBRARY_DEBUG)) |
|
461 |
endif |
|
462 |
||
463 |
LINKLIBFILES:=$(patsubst %,$(LIBDIR)/%,$(LINKLIBS)) |
|
464 |
||
465 |
MAP:= |
|
466 |
ifneq ($(BASE_TYPE),staticlib) |
|
467 |
ifneq ($(BASE_TYPE),importlib) |
|
468 |
# link map file (urel only) |
|
469 |
ifeq ($(VARIANTTYPE),urel) |
|
470 |
MAP:=$(OPT.MAP)$(BINTARGET).map |
|
471 |
RELEASABLES:=$(RELEASABLES) $(BINTARGET).map |
|
472 |
endif |
|
473 |
endif |
|
474 |
endif |
|
475 |
||
476 |
# all object files are listed in a response file to minimise the length of linker calls |
|
477 |
OBJECTFILES_LRF:=$(BLDDIR)/$(TARGET)_$(VARIANTTYPE)_objects.lrf |
|
478 |
CLEANTARGET:=$(CLEANTARGETS) $(OBJECTFILES_LRF) |
|
479 |
||
480 |
define groupin10 |
|
481 |
$(if $1,@echo -e $(foreach L,$(wordlist 1,10,$1),"$(L)\\n") >> $(OBJECTFILES_LRF),) |
|
482 |
$(if $1,$(call groupin10,$(wordlist 11,$(words $1),$1)),@true) |
|
483 |
endef |
|
484 |
||
485 |
# |
|
486 |
# Archive |
|
487 |
# |
|
488 |
ifeq ($(BASE_TYPE),staticlib) |
|
489 |
define win32archive |
|
490 |
$(BINTARGET): $(OBJECTFILES) |
|
491 |
@echo "" > $(OBJECTFILES_LRF); |
|
492 |
$(call groupin10,$(notdir $(OBJECTFILES))) ; |
|
493 |
$(call startrule,win32archive) \ |
|
494 |
$(LD) $(OPT.STATICLIBRARY) $(LFLAGS) $(OPT.NOIMPLIB) $(WIN32_LIBRARIES) $(OPT.OUT)"$$@" $(STDCPPTAGFILE) $(OPT.LIBPATH)$(BLDDIR) $(OPT.SEARCH) @$(OBJECTFILES_LRF) \ |
|
495 |
$(if $(SAVESPACE),; $(GNURM) -rf $(BLDDIR); true,) \ |
|
496 |
$(call endrule,win32archive) |
|
497 |
endef |
|
498 |
$(eval $(win32archive)) |
|
499 |
endif |
|
500 |
||
501 |
ifneq ($(EPOCHEAPSIZEMIN_DEC_KB),) |
|
502 |
LFLAGS:=$(LFLAGS) $(OPT.HEAPRESERVE)$(EPOCHEAPSIZEMAX_DEC_KB) $(OPT.HEAPCOMMIT)$(EPOCHEAPSIZEMIN_DEC_KB) |
|
503 |
endif |
|
504 |
||
505 |
# |
|
506 |
# Simple link |
|
507 |
# |
|
508 |
ifeq ($(BASE_TYPE),exe) |
|
509 |
define win32simplelink |
|
510 |
$(BINTARGET).map: $(BINTARGET) |
|
511 |
||
512 |
$(BINTARGET): $(OBJECTFILES) $(LINKER_FIRSTSTATLIBFILE) $(NEWLIBFILE) $(STATICLIBFILES) $(LINKLIBFILES) |
|
513 |
@echo "" > $(OBJECTFILES_LRF); |
|
514 |
$(call groupin10,$(notdir $(OBJECTFILES))) ; |
|
515 |
$(call startrule,win32simplelink) \ |
|
516 |
$(if $(SUPPORTS_STDCPP_NEWLIB),$(if $(STATICLIBFILES),$(CHECKLIB) $(CHECKLIB_TYPE) $(OPT.CHECKLIB.WIN32) $(STATICLIBFILES) &&,),) \ |
|
517 |
MWSym2LibraryFiles="$(MWSym2LibraryFiles)" $(LD) $(LFLAGS) $(OPT.MENTRYPOINT)$(ENTRYSYMBOL) $(MAP) $(LINKER_FIRSTSTATLIBFILE) $(NEWLIBFILE) $(WIN32_LIBRARIES) $(STATICLIBFILES) $(LINKLIBFILES) $(OPT.OUT)"$$@" $(OPT.NOIMPLIB) $(OPT.LIBPATH)$(BLDDIR) $(OPT.SEARCH) @$(OBJECTFILES_LRF) \ |
|
518 |
$(if $(SAVESPACE),; $(GNURM) -rf $(BLDDIR); true,) \ |
|
519 |
$(call endrule,win32simplelink) |
|
520 |
endef |
|
521 |
$(eval $(win32simplelink)) |
|
522 |
endif |
|
523 |
||
524 |
# |
|
525 |
# Two stage link |
|
526 |
# |
|
527 |
ifeq ($(BASE_TYPE),dll) |
|
528 |
TMP_IMPLIB:=$(BLDDIR)/$(TARGET).lib |
|
529 |
TMP_INFFILE:=$(BLDDIR)/$(TARGET).inf |
|
530 |
TMP_SYMFILE:=$(if $(OPEN_ENVIRONMENT),$(BLDDIR)/$(TARGET).sym,) |
|
531 |
TMP_TARGET:=$(BLDDIR)/$(TARGET).$(if $(REQUESTEDTARGETEXT),$(REQUESTEDTARGETEXT),$(TARGETTYPE)) |
|
532 |
TMP_DEFFILE:=$(BLDDIR)/$(TARGET).def |
|
533 |
||
534 |
CLEANTARGETS:=$(CLEANTARGETS) $(TMP_IMPLIB) $(TMP_INFFILE) $(TMP_TARGET) $(TMP_DEFFILE) $(TMP_SYMFILE) |
|
535 |
||
536 |
MAKEDEF_ARGS:=-absent $(ENTRYSYMBOL) -Inffile $(call dblquote,$(TMP_INFFILE)) $(NAME_LOOKUP) |
|
537 |
||
538 |
ifeq ($(SYSTEM_TARGET),1) |
|
539 |
MAKEDEF_ARGS:=$(MAKEDEF_ARGS) -SystemTargetType |
|
540 |
endif |
|
541 |
||
542 |
ifneq ($(FIXED_EXPORT),) |
|
543 |
# Fixed export TARGETTYPE, but with possibility of a .def file if explicitly specified and available |
|
544 |
ifeq ($(DEFFILEKEYWORD),1) |
|
545 |
ifneq ($(DEFFILE),) |
|
546 |
MAKEDEF_ARGS:=$(MAKEDEF_ARGS) -Frzfile $(call dblquote,$(DEFFILE)) |
|
547 |
endif |
|
548 |
endif |
|
549 |
MAKEDEF_ARGS:=$(MAKEDEF_ARGS) -1 $(FIXED_EXPORT) |
|
550 |
else |
|
551 |
# Variable export TARGETTYPE with either deduced or explicitly specified .def file (if available) |
|
552 |
ifneq ($(DEFFILE),) |
|
553 |
MAKEDEF_ARGS:=$(MAKEDEF_ARGS) -Frzfile $(call dblquote,$(DEFFILE)) |
|
554 |
endif |
|
555 |
endif |
|
556 |
||
557 |
||
558 |
ifneq ($(EXPORTSUNFROZEN),) |
|
559 |
LIBRARY: $(TMP_IMPLIB) |
|
560 |
endif |
|
561 |
||
562 |
define win32stageonelink |
|
563 |
# Stage One |
|
564 |
# Link by name, generating temporary main binary and import library. |
|
565 |
$(TMP_IMPLIB): $(TMP_TARGET) |
|
566 |
||
567 |
$(TMP_TARGET): $(OBJECTFILES) $(LINKER_FIRSTSTATLIBFILE) $(NEWLIBFILE) $(STATICLIBFILES) $(LINKLIBFILES) |
|
568 |
@echo "" > $(OBJECTFILES_LRF); |
|
569 |
$(call groupin10,$(notdir $(OBJECTFILES))) ; |
|
570 |
$(call startrule,win32stageonelink) \ |
|
571 |
$(if $(SUPPORTS_STDCPP_NEWLIB),$(if $(STATICLIBFILES),$(CHECKLIB) $(CHECKLIB_TYPE) $(OPT.CHECKLIB.WIN32) $(STATICLIBFILES) &&,),) \ |
|
572 |
MWSym2LibraryFiles="$(MWSym2LibraryFiles)" $(LD) $(LFLAGS) $(OPT.MENTRYPOINT)$(ENTRYSYMBOL) $(OPT.EXPORT)$(EXPORT_TYPE) $(OPT.NOCOMPACTIMPORTLIB) $(OPT.ADDCOMMAND) "out:$(TARGET).$(if $(REQUESTEDTARGETEXT),$(REQUESTEDTARGETEXT),$(TARGETTYPE))" $(OPT.WARNINGS) off $(OPT.IMPLIB)"$(TMP_IMPLIB)" $(OPT.OUT)"$(TMP_TARGET)" $(LINKER_FIRSTSTATLIBFILE) $(NEWLIBFILE) $(WIN32_LIBRARIES) $(STATICLIBFILES) $(LINKLIBFILES) $(OPT.LIBPATH)$(BLDDIR) $(OPT.SEARCH) @$(OBJECTFILES_LRF) \ |
|
573 |
$(call endrule,win32stageonelink) |
|
574 |
endef |
|
575 |
$(eval $(win32stageonelink)) |
|
576 |
||
577 |
define win32processexports |
|
578 |
# Process exports |
|
579 |
# Generate a descriptive info file from the import library. |
|
580 |
# Push info file through MAKEDEF to generated a valid .def file for link by ordinal. |
|
581 |
$(TMP_DEFFILE): $(TMP_IMPLIB) |
|
582 |
$(call startrule,win32processexports) \ |
|
583 |
$(LD) $(LFLAGS_INFGEN) $(OPT.OUT)"$(TMP_INFFILE)" "$(TMP_IMPLIB)" && \ |
|
584 |
$(MAKEDEF) $(MAKEDEF_ARGS) "$$@" \ |
|
585 |
$(call endrule,win32processexports) |
|
586 |
endef |
|
587 |
$(eval $(win32processexports)) |
|
588 |
||
589 |
ifeq ($(OPEN_ENVIRONMENT),1) |
|
590 |
define win32processoeexports |
|
591 |
# Process additional exports for Open Environment |
|
592 |
# Generate a symbol file from the temporary DLL. |
|
593 |
# Generate a C++ source file from the symbol file |
|
594 |
||
595 |
$(TMP_SYMFILE): $(TMP_TARGET) |
|
596 |
$(call startrule,win32generatesymfile) \ |
|
597 |
$(LD) $(LFLAGS_SYMGEN) $(OPT.OUT)"$(TMP_SYMFILE)" "$(TMP_TARGET)" \ |
|
598 |
$(call endrule,win32generatesymfile) |
|
599 |
||
600 |
$(SYMSOURCE): $(TMP_SYMFILE) |
|
601 |
$(call startrule,win32generatesymcpp) \ |
|
602 |
$(SYMLOOKUPUTIL) $(OPT.OUT)"$(SYMSOURCE)" $(OPT.SYM)"$(TMP_SYMFILE)" $(SYMLOOKUPARGS) \ |
|
603 |
$(call endrule,win32generatesymcpp) |
|
604 |
endef |
|
605 |
$(eval $(win32processoeexports)) |
|
606 |
endif |
|
607 |
||
608 |
define win32stagetwolink |
|
609 |
# Stage Two |
|
610 |
# Link by ordinal, based on a previously MAKEDEF-generated temporary .def file |
|
611 |
# Optionally create an import library if EXPORTUNFROZEN is specified |
|
612 |
# |
|
613 |
$(BINTARGET).map: $(BINTARGET) |
|
614 |
||
615 |
$(BINTARGET): $(OBJECTFILES) $(OBJECTFILES_OE) $(LINKER_FIRSTSTATLIBFILE) $(STATICLIBFILES) $(NEWLIBFILE) $(LINKLIBFILES) $(TMP_DEFFILE) |
|
616 |
@echo "" > $(OBJECTFILES_LRF); |
|
617 |
$(call groupin10,$(notdir $(OBJECTFILES) $(OBJECTFILES_OE))) ; |
|
618 |
$(call startrule,win32stagetwolink) \ |
|
619 |
MWSym2LibraryFiles="$(MWSym2LibraryFiles)" \ |
|
620 |
$(LD) $(LFLAGS) $(OPT.DEFFILE)$(TMP_DEFFILE) $(MAP) $(LINKER_FIRSTSTATLIBFILE) $(NEWLIBFILE) $(WIN32_LIBRARIES) $(STATICLIBFILES) $(LINKLIBFILES) \ |
|
621 |
$(OPT.OUT)"$$@" \ |
|
622 |
$(if $(EXPORTUNFROZEN),$(OPT.IMPLIB)$(IMPORTLIBTARGET),$(OPT.NOIMPLIB)) \ |
|
623 |
$(OPT.LIBPATH)$(BLDDIR) $(OPT.SEARCH) @$(OBJECTFILES_LRF) \ |
|
624 |
$(if $(SAVESPACE),; $(GNURM) -rf $(BLDDIR); true,) \ |
|
625 |
$(call endrule,win32stagetwolink) |
|
626 |
endef |
|
627 |
$(eval $(win32stagetwolink)) |
|
628 |
||
629 |
define win32copyforstaticlink |
|
630 |
# Copy additonal binary to "traditional" output location (if required) |
|
631 |
$(BINTARGETSTATICLINK): $(BINTARGET) |
|
632 |
$(call startrule,win32copyforstaticlink) \ |
|
633 |
$(GNUCP) $$< $$@ \ |
|
634 |
$(call endrule,win32copyforstaticlink) |
|
635 |
endef |
|
636 |
ifeq ($(COPY_FOR_STATIC_LINKAGE),1) |
|
637 |
$(eval $(win32copyforstaticlink)) |
|
638 |
endif |
|
639 |
||
640 |
define e32freeze |
|
641 |
# DLL-type targets that support import library generation support freezing of exports using EFREEZE |
|
642 |
FREEZE:: $(1) |
|
643 |
$(call startrule,freeze,,$(RESOLVED_DEFFILE)) \ |
|
644 |
$(EFREEZE) $(EFREEZE_REMOVE_OPTION) "$(RESOLVED_DEFFILE)" $(FIVESPACES) "$(2)" \ |
|
645 |
$(call endrule,freeze) |
|
646 |
endef |
|
647 |
# Create only one freeze target per urel/udeb variant as the interface won't differ between them |
|
648 |
# Only create a freeze target if the component supports import library generation |
|
649 |
ifneq ($(TARGET_$(call sanitise,$(IMPORTLIBTARGET))_FREEZE),1) |
|
650 |
ifeq ($(SUPPORTS_IMPORT_LIBRARY),1) |
|
651 |
$(eval $(call e32freeze,$(BINTARGET),$(TMP_DEFFILE))) |
|
652 |
$(eval TARGET_$(call sanitise,$(IMPORTLIBTARGET))_FREEZE:=1) |
|
653 |
endif |
|
654 |
endif |
|
655 |
endif |
|
656 |
endif # neq $(BASE_TYPE),importlib |
|
657 |
||
658 |
||
659 |
# Global targets |
|
660 |
.PHONY:: $(ALLTARGET) |
|
661 |
$(ALLTARGET):: $(RELEASABLES) |
|
662 |
TARGET:: $(RELEASABLES) |
|
663 |
||
664 |
ifeq ($(TARGET_$(call sanitise,$(IMPORTLIBTARGET))),1) |
|
665 |
LIBRARY:: $(IMPORTLIBTARGET) |
|
666 |
else |
|
667 |
ifeq ($(BASE_TYPE),staticlib) |
|
668 |
LIBRARY:: $(BINTARGET) |
|
669 |
endif |
|
670 |
endif |
|
671 |
||
672 |
||
673 |
# Deal with test code batch files generation. |
|
674 |
ifneq ($(TESTPATH),) |
|
675 |
EPOC_ROOT:=$(patsubst %/,%,$(EPOCROOT)) |
|
676 |
TOBLDINF:=$(dir $(subst :,,$(subst $(EPOC_ROOT)/,,$(COMPONENT_META)))) |
|
677 |
||
678 |
||
679 |
BATCHDIR:=$(EPOCROOT)/epoc32/release/$(VARIANTPLATFORM)/$(VARIANTTYPE)/z/test/ |
|
680 |
$(eval $(call MakeTestBatchFiles,$(TARGET),$(BATCHDIR)$(MODULE)/$(VARIANTPLATFORM).$(TESTPATH))) |
|
681 |
BATCHFILE_CREATED_$(BATCHDIR)$(MODULE)/$(VARIANTPLATFORM).$(TESTPATH):=1 |
|
682 |
TARGET_CREATED_$(EPOCROOT)/epoc32/release/$(VARIANTPLATFORM)/$(VARIANTTYPE)/z/test/$(MODULE)/$(VARIANTPLATFORM).$(TESTPATH)_$(TARGET):=1 |
|
683 |
RELEASABLES:=$(RELEASABLES) $(EPOCROOT)/epoc32/release/$(VARIANTPLATFORM)/$(VARIANTTYPE)/z/test/$(MODULE)/$(VARIANTPLATFORM).$(TESTPATH) |
|
684 |
endif |
|
685 |
||
686 |
# clean up |
|
9 | 687 |
$(call raptor_clean,$(CLEANTARGETS)) |
3 | 688 |
# make the output directories while reading makefile - some build engines prefer this |
689 |
$(call makepath,$(CREATABLEPATHS)) |
|
9 | 690 |
# for the --what option and the log file |
691 |
$(call raptor_release,$(RELEASABLES)) |