|
1 # Copyright (c) 2008-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 # /epoc32/tools/makefile_templates/tools/x86tool.mk |
|
15 # SBSv2 issues and differences from SBSv1 |
|
16 # 1/ The shell is different |
|
17 # 2/ The msys shell can't handle absolute paths from root without the drive letter e.g. it can't find /epoc32 but it can find x:/epoc32 |
|
18 # workaround is to go back to TO_ROOT |
|
19 # 3/ The current directory is at the bld.inf rather than /epoc32/build |
|
20 # 4/ Backslash is problematic |
|
21 # 5/ Path variables include the drive letter x: which causes problems for make when used in targets due to : |
|
22 # 6/ TO_ROOT is not defined |
|
23 # 7/ Some tool compatibility is problematic e.g. createdir doesn't work with paths containing forward slash |
|
24 # |
|
25 # |
|
26 |
|
27 # If this environment variable is defined we're definitely building for win32 |
|
28 ifdef ComSpec |
|
29 WIN32:=1 |
|
30 endif |
|
31 |
|
32 space:= |
|
33 space+= |
|
34 LETTERS:=a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
|
35 |
|
36 # If win32 isn't defined yet - then we're probably building on sbsv2 |
|
37 # So see if EPOCROOT starts with a drive letter to work out if we're building for win32 |
|
38 ifndef WIN32 |
|
39 ifneq ($(subst $(space),,$(foreach let,$(LETTERS),$(if $(findstring $(let):,$(EPOCROOT)),1,))),) |
|
40 WIN32:=1 |
|
41 endif |
|
42 endif |
|
43 |
|
44 # To guarantee there is a slash at the end of EPOCROOT in case there is not. |
|
45 # This is needed to ensure compatibility with SBSv1. |
|
46 TMPROOT:=$(subst \,/,$(EPOCROOT)) |
|
47 EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/ |
|
48 |
|
49 # Get standard shell definitions |
|
50 include $(EPOCROOT)epoc32/tools/shell/$(notdir $(basename $(SHELL))).mk |
|
51 |
|
52 # Raptor includes the drive letter on paths - this makefile can't handle the drive letter |
|
53 # If we don't do this we get "multiple target patterns" errors in sbsv2 |
|
54 TMPROOT:=$(strip $(foreach let,$(LETTERS),$(if $(findstring $(let):,$(EPOCROOT)),$(subst $(let):,,$(EPOCROOT))))) |
|
55 ifneq ($(TMPROOT),) |
|
56 EPOCROOT:=$(TMPROOT) |
|
57 endif |
|
58 TMPROOT:=$(strip $(foreach let,$(LETTERS),$(if $(findstring $(let):,$(EXTENSION_ROOT)),$(subst $(let):,,$(EXTENSION_ROOT))))) |
|
59 ifneq ($(TMPROOT),) |
|
60 EXTENSION_ROOT:=$(TMPROOT) |
|
61 endif |
|
62 |
|
63 # Make up for raptor not defining TO_ROOT properly |
|
64 # This might get broken if they change the current directory (which should really be in /epoc32/build) |
|
65 # We're using TO_ROOT to handle the fact that the msys shell doesn't seem to handle absolute paths |
|
66 ifdef WIN32 |
|
67 ifeq ($(TO_ROOT),) |
|
68 TMPROOT:=$(strip $(foreach let,$(LETTERS),$(if $(findstring $(let):,$(TO_BLDINF)),$(subst $(let):,,$(TO_BLDINF))))) |
|
69 TO_ROOT:=.$(subst $(space),,$(foreach word,$(subst /,$(space),$(TMPROOT)),/..)) |
|
70 endif |
|
71 endif |
|
72 |
|
73 # Handle inconsistent case for build variant |
|
74 CFG_PATH:=$(CFG) |
|
75 ifeq ($(CFG_PATH),DEB) |
|
76 CFG_PATH:=deb |
|
77 endif |
|
78 ifeq ($(CFG_PATH),REL) |
|
79 CFG_PATH:=rel |
|
80 endif |
|
81 |
|
82 # Set the following to enable code coverage stats |
|
83 CODE_COVERAGE:= |
|
84 |
|
85 # Build |
|
86 ifdef WIN32 |
|
87 TARGET_DIR_REL:=$(EPOCROOT)epoc32/release/tools2/rel/ |
|
88 TARGET_DIR_DEB:=$(EPOCROOT)epoc32/release/tools2/deb/ |
|
89 GCOVDIR:=$(if $(CODE_COVERAGE),$(EPOCROOT)epoc32/gcc_mingw/libgcc/mingw32/3.4.5/) |
|
90 else |
|
91 TARGET_DIR_REL:=$(EPOCROOT)epoc32/release/tools2/linux-i386/rel/ |
|
92 TARGET_DIR_DEB:=$(EPOCROOT)epoc32/release/tools2/linux-i386/deb/ |
|
93 endif |
|
94 |
|
95 # The root to the source code - paths are relative to bld.inf if NOT specified |
|
96 # If SOURCE_ROOT specified then it's relative to EPOCROOT |
|
97 ifndef SOURCE_ROOT |
|
98 ROOT:=$(subst \,/,$(EXTENSION_ROOT)) |
|
99 OBJSUBST:=/ |
|
100 else |
|
101 ROOT:=$(EPOCROOT)$(subst $(space)/,/,$(SOURCE_ROOT)) |
|
102 OBJSUBST:=$(EPOCROOT) |
|
103 endif |
|
104 |
|
105 # *** |
|
106 # STATIC LIBRARY |
|
107 # |
|
108 ifeq ($(TARGET_TYPE),lib) |
|
109 TARGET_FULLNAME_REL:=$(TARGET_DIR_REL)lib$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,.a) |
|
110 TARGET_FULLNAME_DEB:=$(TARGET_DIR_DEB)lib$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,.a) |
|
111 |
|
112 ifeq ($(CFG_PATH),deb) |
|
113 TARGET_LIB:=$(TARGET_FULLNAME_DEB) |
|
114 endif |
|
115 ifeq ($(CFG_PATH),rel) |
|
116 TARGET_LIB:=$(TARGET_FULLNAME_REL) |
|
117 endif |
|
118 TARGET_LIB?=$(TARGET_FULLNAME_REL) $(TARGET_FULLNAME_DEB) |
|
119 endif |
|
120 |
|
121 # *** |
|
122 # EXE |
|
123 # |
|
124 ifeq ($(TARGET_TYPE),exe) |
|
125 TARGET_FULLNAME_REL:=$(TARGET_DIR_REL)$(TARGET_SUB_DIR)$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,$(if $(WIN32),.exe)) |
|
126 TARGET_FULLNAME_DEB:=$(TARGET_DIR_DEB)$(TARGET_SUB_DIR)$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,$(if $(WIN32),.exe)) |
|
127 |
|
128 ifeq ($(CFG_PATH),deb) |
|
129 TARGET_BLD:=$(TARGET_FULLNAME_DEB) |
|
130 endif |
|
131 ifeq ($(CFG_PATH),rel) |
|
132 TARGET_BLD:=$(TARGET_FULLNAME_REL) |
|
133 endif |
|
134 TARGET_BLD?=$(TARGET_FULLNAME_REL) $(TARGET_FULLNAME_DEB) |
|
135 |
|
136 LIBS+=symexestub |
|
137 ifdef STLPORT |
|
138 LIBS+=-lstlport.5.1 |
|
139 endif |
|
140 endif |
|
141 |
|
142 # *** |
|
143 # DLL/SO |
|
144 # |
|
145 ifeq ($(TARGET_TYPE),dll) |
|
146 |
|
147 TARGET_FULLNAME_REL:=$(TARGET_DIR_REL)$(TARGET_SUB_DIR)lib$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,$(if $(WIN32),.dll,.so)) |
|
148 TARGET_FULLNAME_DEB:=$(TARGET_DIR_DEB)$(TARGET_SUB_DIR)lib$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,$(if $(WIN32),.dll,.so)) |
|
149 |
|
150 ifeq ($(CFG_PATH),deb) |
|
151 TARGET_BLD:=$(TARGET_FULLNAME_DEB) |
|
152 endif |
|
153 ifeq ($(CFG_PATH),rel) |
|
154 TARGET_BLD:=$(TARGET_FULLNAME_REL) |
|
155 endif |
|
156 TARGET_BLD?=$(TARGET_FULLNAME_REL) $(TARGET_FULLNAME_DEB) |
|
157 |
|
158 ifdef STLPORT |
|
159 LIBS+=-lstlport.5.1 |
|
160 endif |
|
161 endif |
|
162 |
|
163 # Pick up MINGW compiler from epoc32 on Windows |
|
164 ifdef WIN32 |
|
165 AR:=$(EPOCROOT)epoc32/gcc_mingw/bin/ar |
|
166 CXX:=$(EPOCROOT)epoc32/gcc_mingw/bin/g++ |
|
167 endif |
|
168 |
|
169 # Product include files are different for S60 |
|
170 ifdef S60_BUILD |
|
171 PRODUCT_INCLUDE:=$(EPOCROOT)epoc32/include/oem/bldvariant.hrh |
|
172 else |
|
173 PRODUCT_INCLUDE:=$(EPOCROOT)epoc32/include/variant/Symbian_OS.hrh |
|
174 endif |
|
175 |
|
176 # Define macros we need |
|
177 CXXDEFS_COMMON:=$(foreach def,$(MACROS),-D$(def)) -D__SYMBIAN32__ -D__GCC32__ -D__EPOC32__ -D__X86__ -D_UNICODE -D__SUPPORT_CPP_EXCEPTIONS__ -D__TOOLS2__ -D'__PRODUCT_INCLUDE__="$(PRODUCT_INCLUDE)"' |
|
178 CXXDEFS_DEB:=$(CXXDEFS_COMMON) -D_DEBUG |
|
179 CXXDEFS_REL:=$(CXXDEFS_COMMON) |
|
180 |
|
181 # Setup the command line options for the compiler |
|
182 PREINC=$(EPOCROOT)epoc32/include/x86tool/x86tool.h |
|
183 CXXOPT_DEB:=-fshort-wchar -x c++ -O0 -g3 -Wall -c -fmessage-length=0 -include $(PREINC) -masm=intel |
|
184 OPTIMISE:=-fdefer-pop -fmerge-constants -fthread-jumps -floop-optimize -fif-conversion -fif-conversion2 -fguess-branch-probability -fcprop-registers -fforce-mem -foptimize-sibling-calls -fstrength-reduce -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -frerun-loop-opt -fgcse -fgcse-lm -fgcse-sm -fgcse-las -fdelete-null-pointer-checks -fexpensive-optimizations -fregmove -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec -fcaller-saves -fpeephole2 -freorder-blocks -freorder-functions -fstrict-aliasing -funit-at-a-time -falign-functions -falign-jumps -falign-loops -falign-labels -fcrossjumping |
|
185 CXXOPT_REL:=-fshort-wchar -x c++ -Wall -c -fmessage-length=0 -include $(PREINC) $(if $(CODE_COVERAGE),-O0,$(OPTIMISE)) -masm=intel |
|
186 |
|
187 # Allow specification of additional build include file |
|
188 ifdef BUILDINC |
|
189 CXXOPT_DEB+= -include $(BUILDINC) |
|
190 CXXOPT_REL+= -include $(BUILDINC) |
|
191 endif |
|
192 |
|
193 # Extra options needed for cia files |
|
194 ASMOPT:=-fomit-frame-pointer |
|
195 |
|
196 # Linker options for DLL |
|
197 ifndef DLL_WIN_LINKER_OPTS |
|
198 DLL_WIN_LINKER_OPTS:= $(if $(CODE_COVERAGE),-lgcov) -Wl,-export-all-symbols |
|
199 endif |
|
200 ifndef DLL_LIN_LINKER_OPTS |
|
201 DLL_LIN_LINKER_OPTS:= -Wl,-export-all-symbols $(if $(CODE_COVERAGE),-lgcov) -ldl |
|
202 endif |
|
203 |
|
204 # Source files to scan for in a directory |
|
205 # Note that CPP and cpp will match on the same files - so a sort is necessary on wildcard results |
|
206 SOURCE_EXT:=CPP cpp c cia |
|
207 |
|
208 # Source code assumed to be all cpp/cia files in supplied directories |
|
209 SOURCE_FILES:=$(foreach dir,$(SOURCE_DIRS),$(sort $(foreach ext,$(SOURCE_EXT),$(wildcard $(ROOT)/$(dir)/*.$(ext))))) \ |
|
210 $(foreach src,$(SOURCE),$(ROOT)/$(if $(SOURCE_FOLDER),$(SOURCE_FOLDER)/)$(src)) \ |
|
211 $(foreach src,$(SOURCE_MOD),$(subst \,/,$(EXTENSION_ROOT))/$(src)) \ |
|
212 $(foreach id,$(SOURCE_IDS),$(foreach src,$($(id)_SOURCE),$(subst $(space)/,/,$(if $($(id)_SOURCE_ROOT),$(EPOCROOT)$($(id)_SOURCE_ROOT),$(ROOT))/$(src)))) |
|
213 |
|
214 # Include folders |
|
215 CXXINC:=$(foreach inc,$(INCLUDES) $(SOURCE_DIRS),-I$(ROOT)/$(inc)) \ |
|
216 $(foreach inc,$(SYS_INCLUDES),-I$(EPOCROOT)$(inc)) -I$(ROOT) \ |
|
217 $(foreach id,$(SOURCE_IDS),$(foreach inc,$($(id)_SOURCE_INC),-I$(subst $(space)/,/,$(if $($(id)_SOURCE_ROOT),$(EPOCROOT)$($(id)_SOURCE_ROOT),$(ROOT)))/$(inc))) |
|
218 |
|
219 # Add standard include paths? |
|
220 ifndef NO_STD_INCLUDE |
|
221 CXXINC+= -I$(EPOCROOT)epoc32/include/x86tool -I$(EPOCROOT)epoc32/include |
|
222 ifdef S60_BUILD |
|
223 CXXINC+= -I$(EPOCROOT)epoc32/include/oem |
|
224 endif |
|
225 endif |
|
226 |
|
227 # Support for building JNI |
|
228 ifdef JAVA_JNI |
|
229 CXXINC+= -I"$(JAVA_HOME)/include" |
|
230 ifdef WIN32 |
|
231 CXXINC+= -I"$(JAVA_HOME)/include/win32" |
|
232 else |
|
233 CXXINC+= -I"$(JAVA_HOME)/include/linux" |
|
234 endif |
|
235 endif |
|
236 |
|
237 |
|
238 # STL Port support needed? Note STL and Symbian won't mix! |
|
239 ifdef STLPORT |
|
240 CXXINC+= -I$(EPOCROOT)epoc32/include/tools/stlport |
|
241 endif |
|
242 |
|
243 # *** |
|
244 # DEBUG |
|
245 # |
|
246 |
|
247 # Object files are the same name as the source files with a .o extension |
|
248 OBJECTFILES_DEB:=$(foreach src,$(SOURCE_FILES),deb$(src).o) |
|
249 |
|
250 # Compile |
|
251 $(OBJECTFILES_DEB) : $(PREINC) $(SOURCE_FILES) |
|
252 @echo *** |
|
253 @echo Making: $@ |
|
254 $(call createdir,$(dir $@)) |
|
255 $(CXX) $(CXXDEFS_DEB) $(CXXINC) -I$(subst deb$(OBJSUBST),$(OBJSUBST),$(dir $@)) $(CXXOPT_DEB) $(if $(findstring .cia,$@),$(ASMOPT),$(if $(CODE_COVERAGE),-fprofile-arcs -ftest-coverage)) -o$@ $(subst deb$(OBJSUBST),$(OBJSUBST),$(basename $@)) |
|
256 |
|
257 # Link |
|
258 $(TARGET_FULLNAME_DEB) : $(OBJECTFILES_DEB) $(foreach lib,$(LIBS),$(TARGET_DIR_DEB)lib$(lib).a) $(foreach lib,$(SHARED_LIBS),$(TARGET_DIR_DEB)lib$(lib)$(if $(WIN32),.a,.so)) |
|
259 ifeq ($(TARGET_TYPE),lib) |
|
260 @echo *** |
|
261 @echo Creating lib: $@ |
|
262 $(AR) -r $(TARGET_FULLNAME_DEB) $(OBJECTFILES_DEB) |
|
263 endif |
|
264 ifeq ($(TARGET_TYPE),exe) |
|
265 @echo *** |
|
266 @echo Creating exe: $@ |
|
267 $(CXX) -L$(TARGET_DIR_DEB) $(if $(GCOVDIR),-L$(GCOVDIR)) \ |
|
268 -o$(TARGET_FULLNAME_DEB) $(OBJECTFILES_DEB) \ |
|
269 $(foreach lib,$(LIBS) $(SHARED_LIBS), -l$(lib)) \ |
|
270 $(if $(CODE_COVERAGE),-lgcov) $(if $(WIN32),,-ldl) |
|
271 endif |
|
272 ifeq ($(TARGET_TYPE),dll) |
|
273 ifdef WIN32 |
|
274 @echo *** |
|
275 @echo Creating Windows dll: $@ |
|
276 $(CXX) -L$(TARGET_DIR_DEB) $(if $(GCOVDIR),-L$(GCOVDIR)) \ |
|
277 -shared -o$(TARGET_FULLNAME_DEB) $(OBJECTFILES_DEB) \ |
|
278 $(foreach lib,$(LIBS) $(SHARED_LIBS), -l$(lib)) \ |
|
279 -Wl,-out-implib,$(@D)/$(basename $(@F)).a \ |
|
280 $(DLL_WIN_LINKER_OPTS) |
|
281 else |
|
282 @echo *** |
|
283 @echo Creating Linux shared object: $@ |
|
284 $(CXX) -L$(TARGET_DIR_DEB) \ |
|
285 -shared -o$(TARGET_FULLNAME_DEB) $(OBJECTFILES_DEB) \ |
|
286 $(foreach lib,$(LIBS) $(SHARED_LIBS), -l$(lib)) \ |
|
287 $(DLL_LIN_LINKER_OPTS) |
|
288 endif |
|
289 endif |
|
290 |
|
291 # *** |
|
292 # RELEASE |
|
293 # |
|
294 |
|
295 # Object files are the same name as the source files with a .o extension |
|
296 OBJECTFILES_REL:=$(foreach src,$(SOURCE_FILES),rel$(src).o) |
|
297 |
|
298 # Compile |
|
299 $(OBJECTFILES_REL) : $(PREINC) $(SOURCE_FILES) |
|
300 @echo *** |
|
301 @echo Making: $@ |
|
302 $(call createdir,$(dir $@)) |
|
303 $(CXX) $(CXXDEFS_REL) $(CXXINC) -I$(subst rel$(OBJSUBST),$(OBJSUBST),$(dir $@)) $(CXXOPT_REL) $(if $(findstring .cia,$@),$(ASMOPT),$(if $(CODE_COVERAGE),-fprofile-arcs -ftest-coverage)) -o$@ $(subst rel$(OBJSUBST),$(OBJSUBST),$(basename $@)) |
|
304 |
|
305 # Link |
|
306 $(TARGET_FULLNAME_REL) : $(OBJECTFILES_REL) $(foreach lib,$(LIBS),$(TARGET_DIR_REL)lib$(lib).a) $(foreach lib,$(SHARED_LIBS),$(TARGET_DIR_REL)lib$(lib)$(if $(WIN32),.a,.so)) |
|
307 ifeq ($(TARGET_TYPE),lib) |
|
308 @echo *** |
|
309 @echo Creating lib: $@ |
|
310 $(AR) -r $(TARGET_FULLNAME_REL) $(OBJECTFILES_REL) |
|
311 endif |
|
312 ifeq ($(TARGET_TYPE),exe) |
|
313 @echo *** |
|
314 @echo Creating exe: $@ |
|
315 $(CXX) -L$(TARGET_DIR_REL) $(if $(GCOVDIR),-L$(GCOVDIR)) \ |
|
316 -o$(TARGET_FULLNAME_REL) $(OBJECTFILES_REL) \ |
|
317 $(foreach lib,$(LIBS) $(SHARED_LIBS), -l$(lib)) \ |
|
318 $(if $(CODE_COVERAGE),-lgcov) $(if $(WIN32),,-ldl) |
|
319 endif |
|
320 ifeq ($(TARGET_TYPE),dll) |
|
321 ifdef WIN32 |
|
322 @echo *** |
|
323 @echo Creating Windows dll: $@ |
|
324 $(CXX) -L$(TARGET_DIR_REL) $(if $(GCOVDIR),-L$(GCOVDIR)) \ |
|
325 -shared -o$(TARGET_FULLNAME_REL) $(OBJECTFILES_REL) \ |
|
326 $(foreach lib,$(LIBS) $(SHARED_LIBS), -l$(lib)) \ |
|
327 -Wl,-out-implib,$(@D)/$(basename $(@F)).a \ |
|
328 $(DLL_WIN_LINKER_OPTS) |
|
329 else |
|
330 @echo *** |
|
331 @echo Creating Linux shared object: $@ |
|
332 $(CXX) -L$(TARGET_DIR_REL) \ |
|
333 -shared -o$(TARGET_FULLNAME_REL) $(OBJECTFILES_REL) \ |
|
334 $(foreach lib,$(LIBS) $(SHARED_LIBS), -l$(lib)) \ |
|
335 $(DLL_LIN_LINKER_OPTS) |
|
336 endif |
|
337 endif |
|
338 |
|
339 do_nothing: |
|
340 |
|
341 # |
|
342 # The targets invoked by abld... |
|
343 # |
|
344 |
|
345 MAKMAKE : do_nothing |
|
346 FREEZE : do_nothing |
|
347 RESOURCE : do_nothing |
|
348 CLEANLIB : do_nothing |
|
349 FINAL : do_nothing |
|
350 |
|
351 SAVESPACE : |
|
352 ifeq ($(CFG_PATH),deb) |
|
353 $(call remove,$(OBJECTFILES_DEB)) |
|
354 endif |
|
355 ifeq ($(CFG_PATH),rel) |
|
356 $(call remove,$(OBJECTFILES_REL)) |
|
357 endif |
|
358 |
|
359 LIB : $(TARGET_LIB) |
|
360 |
|
361 BLD : $(TARGET_BLD) |
|
362 |
|
363 CLEAN : |
|
364 $(call remove,$(foreach file,$(TARGET_LIB) $(TARGET_BLD),$(TO_ROOT)$(file))) |
|
365 ifeq ($(CFG_PATH),deb) |
|
366 $(call remove,$(OBJECTFILES_DEB)) |
|
367 endif |
|
368 ifeq ($(CFG_PATH),rel) |
|
369 $(call remove,$(OBJECTFILES_REL)) |
|
370 endif |
|
371 |
|
372 RELEASABLES : |
|
373 @echo $(TARGET_LIB) $(TARGET_BLD) |