|
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 "Symbian Foundation License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # FLM to build x86 exes, libs and dlls |
|
15 # |
|
16 |
|
17 include $(FLMHOME)/flmtools.mk |
|
18 include $(FLMHOME)/metaflm.mk |
|
19 |
|
20 CREATABLEPATHS:= |
|
21 CLEANTARGETS:= |
|
22 |
|
23 # Handle Window/Linux differences |
|
24 ifeq ($(OSTYPE),cygwin) |
|
25 DOTDLL:=.dll |
|
26 WIN32:=1 |
|
27 GCOVDIR:=$(if $(CODE_COVERAGE),$(EPOCROOT)/epoc32/gcc_mingw/libgcc/mingw32/3.4.5/) |
|
28 else |
|
29 DOTDLL:=.so |
|
30 endif |
|
31 |
|
32 # Product include files are different for S60 |
|
33 ifdef S60_BUILD |
|
34 PRODUCT_INCLUDE:=$(EPOCROOT)/epoc32/include/oem/bldvariant.hrh |
|
35 else |
|
36 PRODUCT_INCLUDE:=$(EPOCROOT)/epoc32/include/variant/Symbian_OS.hrh |
|
37 endif |
|
38 |
|
39 # Define macros we need |
|
40 CXXDEFS:=$(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)"' |
|
41 ifeq ($(CFG_PATH),deb) |
|
42 CXXDEFS+= -D_DEBUG |
|
43 endif |
|
44 |
|
45 # Setup the command line options for the compiler |
|
46 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 |
|
47 |
|
48 PREINC=$(EPOCROOT)/epoc32/include/x86tool/x86tool.h |
|
49 ifeq ($(CFG_PATH),deb) |
|
50 CXXOPT:=-fshort-wchar -x c++ -O0 -g3 -Wall -c -fmessage-length=0 -include $(PREINC) |
|
51 else |
|
52 CXXOPT:=-fshort-wchar -x c++ -Wall -c -fmessage-length=0 -include $(PREINC) $(if $(CODE_COVERAGE),-O0,$(OPTIMISE)) |
|
53 endif |
|
54 |
|
55 # Allow specification of additional build include file |
|
56 ifdef BUILDINC |
|
57 CXXOPT+= -include $(BUILDINC) |
|
58 endif |
|
59 |
|
60 # Extra options needed for cia files |
|
61 ASMOPT:=-fomit-frame-pointer -masm=intel |
|
62 |
|
63 # Linker options for DLL |
|
64 ifndef DLL_WIN_LINKER_OPTS |
|
65 DLL_WIN_LINKER_OPTS:=$(if $(CODE_COVERAGE),-lgcov) -Wl,-export-all-symbols -Wl,--enable-auto-import |
|
66 endif |
|
67 ifndef DLL_LIN_LINKER_OPTS |
|
68 DLL_LIN_LINKER_OPTS:=$(if $(CODE_COVERAGE),-lgcov) -Wl,-export-all-symbols -ldl |
|
69 endif |
|
70 |
|
71 # Source files to scan for in a directory |
|
72 # Note that CPP and cpp will match on the same files - so a sort is necessary on wildcard results |
|
73 SOURCE_EXT:=CPP cpp c cia |
|
74 |
|
75 # Source code assumed to be all cpp/cia files in supplied directories |
|
76 SOURCE_FILES:=$(foreach dir,$(SOURCE_DIRS),$(sort $(foreach ext,$(SOURCE_EXT),$(wildcard $(EXTENSION_ROOT)/$(dir)/*.$(ext))))) \ |
|
77 $(foreach src,$(SOURCE),$(EXTENSION_ROOT)/$(if $(SOURCE_FOLDER),$(SOURCE_FOLDER)/)$(src)) |
|
78 |
|
79 # Include folders |
|
80 CXXINC:=$(foreach inc,$(INCLUDES) $(SOURCE_DIRS),-I$(EXTENSION_ROOT)/$(inc)) \ |
|
81 $(foreach inc,$(SYS_INCLUDES),-I$(EPOCROOT)/$(inc)) -I$(EXTENSION_ROOT) |
|
82 |
|
83 # Add standard include paths? |
|
84 ifndef NO_STD_INCLUDE |
|
85 CXXINC+= -I$(EPOCROOT)/epoc32/include/x86tool -I$(EPOCROOT)/epoc32/include |
|
86 ifdef S60_BUILD |
|
87 CXXINC+= -I$(EPOCROOT)/epoc32/include/oem |
|
88 endif |
|
89 endif |
|
90 |
|
91 # Generate target folder names |
|
92 TARGET_DIR:=$(EPOCROOT)/epoc32/release/tools2$(TOOLPLATFORMDIR)/$(CFG_PATH)/ |
|
93 OUTPUTPATH:=$(EPOCROOT)/epoc32/build/x86tools/$(CFG_PATH)/$(TARGET_NAME)/ |
|
94 |
|
95 # Target names differ depending on what we're building |
|
96 ifeq ($(TARGET_TYPE),lib) |
|
97 TARGET_FULLNAME:=$(TARGET_DIR)lib$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,.a) |
|
98 endif |
|
99 ifeq ($(TARGET_TYPE),exe) |
|
100 TARGET_FULLNAME:=$(TARGET_DIR)$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,$(DOTEXE)) |
|
101 LIBS+=symexestub |
|
102 endif |
|
103 ifeq ($(TARGET_TYPE),dll) |
|
104 TARGET_FULLNAME:=$(TARGET_DIR)lib$(TARGET_NAME)$(if $(findstring .,$(TARGET_NAME)),,$(DOTDLL)) |
|
105 endif |
|
106 |
|
107 # Object files are the same name as the source files with a .o extension |
|
108 OBJECTFILES:=$(foreach src,$(SOURCE_FILES),$(OUTPUTPATH)$(subst $(EPOCROOT),,$(src)).o) |
|
109 |
|
110 # Remember what we're going to create for later |
|
111 CLEANTARGETS:=$(TARGET_FULLNAME) $(OBJECTFILES) |
|
112 RELEASEABLES:=$(TARGET_FULLNAME) |
|
113 CREATABLEPATHS:=$(dir $(OBJECTFILES)) |
|
114 |
|
115 # Standard targets |
|
116 $(ALLTARGET):: $(RELEASEABLES) |
|
117 TARGET:: $(RELEASEABLES) |
|
118 |
|
119 # *** |
|
120 # x86targets |
|
121 # |
|
122 define x86targets |
|
123 # Compile |
|
124 $(OBJECTFILES) : $(PREINC) $(SOURCE_FILES) |
|
125 $(call startrule,compile) \ |
|
126 $(CXX) $(CXXDEFS) $(CXXINC) -I$(EPOCROOT)$$(subst $(OUTPUTPATH),,$$(dir $$@)) $(CXXOPT) $$(if $$(findstring .cia,$$@),$(ASMOPT),$(if $(CODE_COVERAGE),-fprofile-arcs -ftest-coverage)) $(COMPILE_OPTIONS) -o$$@ $(EPOCROOT)$$(subst $(OUTPUTPATH),,$$(basename $$@)) \ |
|
127 $(call endrule,compile) |
|
128 |
|
129 # Link |
|
130 $(TARGET_FULLNAME) : $(OBJECTFILES) $(foreach lib,$(LIBS),$(TARGET_DIR)lib$(lib).a) $(foreach lib,$(SHARED_LIBS),$(TARGET_DIR)lib$(lib)$(DOTDLL)) |
|
131 ifeq ($(TARGET_TYPE),lib) |
|
132 $(call startrule,linklib) \ |
|
133 $(AR) -r $$@ $(OBJECTFILES) \ |
|
134 $(call endrule,linklib) |
|
135 endif |
|
136 ifeq ($(TARGET_TYPE),exe) |
|
137 $(call startrule,linkexe) \ |
|
138 $(CXX) -L$(TARGET_DIR) $(if $(GCOVDIR),-L$(GCOVDIR)) -o$$@ $(OBJECTFILES) $(foreach lib,$(LIBS) $(SHARED_LIBS),-l$(lib)) $(if $(CODE_COVERAGE),-lgcov) $(if $(WIN32),-Wl$(CHAR_COMMA)--enable-auto-import,-ldl) \ |
|
139 $(call endrule,linkexe) |
|
140 endif |
|
141 ifeq ($(TARGET_TYPE),dll) |
|
142 $(call startrule,linkdll) \ |
|
143 $(CXX) -L$(TARGET_DIR) $(if $(GCOVDIR),-L$(GCOVDIR)) -shared -o$$@ $(OBJECTFILES) $(foreach lib,$(LIBS) $(SHARED_LIBS), -l$(lib)) $(if $(WIN32),$(DLL_WIN_LINKER_OPTS),$(DLL_LIN_LINKER_OPTS)) \ |
|
144 $(call endrule,linkdll) |
|
145 endif |
|
146 endef |
|
147 |
|
148 # Generate the rules |
|
149 $(eval $(x86targets)) |
|
150 |
|
151 # Create folders we need |
|
152 $(call makepath,$(CREATABLEPATHS)) |
|
153 |
|
154 # Cleanup after ourselves |
|
155 $(eval $(call GenerateStandardCleanTarget,$(CLEANTARGETS),$(CREATABLEPATHS))) |
|
156 |
|
157 # Tell SBS what we're building |
|
158 $(eval $(call whatmacro,$(RELEASEABLES),WHATTOOLS2)) |