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