2 # -*- Mode: Python; indent-tabs-mode: nil -*-
3 # vi: set ts=4 sw=4 expandtab:
4 # ***** BEGIN LICENSE BLOCK *****
5 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 # The contents of this file are subject to the Mozilla Public License Version
8 # 1.1 (the "License"); you may not use this file except in compliance with
9 # the License. You may obtain a copy of the License at
10 # http://www.mozilla.org/MPL/
12 # Software distributed under the License is distributed on an "AS IS" basis,
13 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 # for the specific language governing rights and limitations under the
17 # The Original Code is [Open Source Virtual Machine].
19 # The Initial Developer of the Original Code is
20 # Adobe System Incorporated.
21 # Portions created by the Initial Developer are Copyright (C) 2005-2006
22 # the Initial Developer. All Rights Reserved.
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
41 # This script runs just like a traditional configure script, to do configuration
42 # testing and makefile generation.
50 thisdir
= os
.path
.dirname(os
.path
.abspath(__file__
))
52 # Look for additional modules in our build/ directory.
53 sys
.path
.append(thisdir
)
55 from build
.configuration
import *
57 import build
.avmfeatures
59 o
= build
.getopt
.Options()
61 config
= Configuration(thisdir
, options
= o
,
62 sourcefile
= 'core/avmplus.h')
64 buildTamarin
= o
.getBoolArg('tamarin', True)
66 config
.subst("ENABLE_TAMARIN", 1)
68 buildShell
= o
.getBoolArg("shell", False)
70 config
.subst("ENABLE_SHELL", 1)
73 APP_CPPFLAGS
= "-DAVMSHELL_BUILD "
78 DEBUG_CPPFLAGS
= "-DDEBUG -D_DEBUG "
84 MMGC_CPPFLAGS
= "-DAVMSHELL_BUILD "
85 AVMSHELL_CPPFLAGS
= ""
87 MMGC_DEFINES
= {'SOFT_ASSERTS': None}
91 # See build/avmfeatures.py for the code that processes switches for
92 # standard feature names.
93 APP_CPPFLAGS
+= build
.avmfeatures
.featureSettings(o
)
95 if not o
.getBoolArg("methodenv-impl32", True):
96 APP_CPPFLAGS
+= "-DVMCFG_METHODENV_IMPL32=0 "
98 memoryProfiler
= o
.getBoolArg("memory-profiler", False)
100 APP_CPPFLAGS
+= "-DMMGC_MEMORY_PROFILER "
102 MMGC_INTERIOR_PTRS
= o
.getBoolArg('mmgc-interior-pointers', False)
103 if MMGC_INTERIOR_PTRS
:
104 MMGC_DEFINES
['MMGC_INTERIOR_PTRS'] = None
106 MMGC_DYNAMIC
= o
.getBoolArg('mmgc-shared', False)
108 MMGC_DEFINES
['MMGC_DLL'] = None
109 MMGC_CPPFLAGS
+= "-DMMGC_IMPL "
111 arm_fpu
= o
.getBoolArg("arm-fpu",False)
112 arm_neon
= o
.getBoolArg("arm-neon",False)
114 the_os
, cpu
= config
.getTarget()
116 # For -Wreorder, see https://bugzilla.mozilla.org/show_bug.cgi?id=475750
117 if config
.getCompiler() == 'GCC':
118 if 'CXX' in os
.environ
:
119 rawver
= build
.process
.run_for_output(['$CXX', '--version'])
121 rawver
= build
.process
.run_for_output(['gcc', '--version'])
122 vre
= re
.compile(".* ([3-9]\.[0-9]+\.[0-9]+)[ \n]")
123 ver
= vre
.match(rawver
).group(1)
124 ver_arr
= ver
.split('.')
125 GCC_MAJOR_VERSION
= int(ver_arr
[0])
126 GCC_MINOR_VERSION
= int(ver_arr
[1])
127 # can't enable -Werror for gcc prior to 4.3 due to unavoidable "clobbered" warnings in Interpreter.cpp
128 # warnings have been updated to try to include all those enabled by current Flash/AIR builds -- disable with caution, or risk integration pain
129 APP_CXXFLAGS
= "-Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wno-invalid-offsetof -Wno-switch -Wparentheses -Wpointer-arith -Wreorder -Wsign-compare -Wunused-parameter -Wwrite-strings -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wsign-promo -Wno-char-subscripts -fmessage-length=0 -fno-exceptions -fno-rtti -fno-check-new -fstrict-aliasing -fsigned-char "
130 if GCC_MAJOR_VERSION
>= 4:
131 APP_CXXFLAGS
+= "-Wstrict-null-sentinel "
132 if (GCC_MAJOR_VERSION
== 4 and GCC_MINOR_VERSION
<= 2) or cpu
== 'mips': # 4.0 - 4.2
133 APP_CXXFLAGS
+= "-Wstrict-aliasing=0 "
134 else: # gcc 4.3 or later
135 APP_CXXFLAGS
+= "-Werror -Wempty-body -Wno-logical-op -Wmissing-field-initializers -Wstrict-aliasing=3 -Wno-array-bounds -Wno-clobbered -Wstrict-overflow=0 -funit-at-a-time "
137 OPT_CXXFLAGS
+= "-mfloat-abi=softfp -mfpu=vfp -march=armv6 -Wno-cast-align " # compile to use hardware fpu and armv6
138 DEBUG_CXXFLAGS
+= OPT_CXXFLAGS
140 OPT_CXXFLAGS
+= "-mfloat-abi=softfp -mfpu=neon -march=armv7-a -Wno-cast-align " # compile to use neon vfp and armv7
141 DEBUG_CXXFLAGS
+= OPT_CXXFLAGS
142 if config
.getDebug():
145 APP_CXXFLAGS
+= "-Wuninitialized "
146 DEBUG_CXXFLAGS
+= "-g "
147 elif config
.getCompiler() == 'VS':
149 APP_CXXFLAGS
= "-W4 -WX -wd4291 -wd4201 -wd4189 -wd4740 -wd4127 -fp:fast -GF -GS- -Zc:wchar_t- "
150 OS_LDFLAGS
+= "-MAP "
151 if config
.getDebug():
152 DEBUG_CXXFLAGS
= "-Od "
153 DEBUG_CFLAGS
= "-Od "
154 APP_CXXFLAGS
+= "-GR- -fp:fast -GS- -Zc:wchar_t- -Zc:forScope "
156 OPT_CXXFLAGS
= "-O2 -GR- "
159 OPT_CXXFLAGS
+= "-QRfpe- -QRarch6" # compile to use hardware fpu and armv6
161 APP_CXXFLAGS
= "-W4 -WX -wd4291 -GF -GS- -Zc:wchar_t- "
162 APP_CFLAGS
= "-W4 -WX -wd4291 -GF -GS- -Zc:wchar_t- "
164 pass # 64 bit VC does NaN comparisons incorrectly with fp:fast
166 APP_CXXFLAGS
+= "-fp:fast "
167 APP_CFLAGS
+= "-fp:fast "
168 OS_LDFLAGS
+= "-SAFESEH:NO -MAP "
169 if config
.getDebug():
170 DEBUG_CXXFLAGS
= "-Od "
171 DEBUG_CFLAGS
= "-Od "
173 OPT_CXXFLAGS
= "-O2 -Ob1 -GR- "
174 OPT_CFLAGS
= "-O2 -Ob1 -GR- "
176 OPT_CXXFLAGS
+= "-Oy- -Zi "
177 DEBUG_CXXFLAGS
+= "-Zi "
178 DEBUG_CFLAGS
+= "-Zi "
179 DEBUG_LDFLAGS
+= "-DEBUG "
180 elif config
.getCompiler() == 'SunStudio':
181 APP_CXXFLAGS
= "-template=no%extdef -erroff=wvarhidemem"
182 OPT_CXXFLAGS
= "-xO5 "
183 DEBUG_CXXFLAGS
+= "-g "
185 raise Exception('Unrecognized compiler: ' + config
.getCompiler())
187 zlib_include_dir
= o
.getStringArg('zlib-include-dir')
188 if zlib_include_dir
is not None:
189 AVMSHELL_CPPFLAGS
+= "-I%s " % zlib_include_dir
191 zlib_lib
= o
.getStringArg('zlib-lib')
192 if zlib_lib
is not None:
193 AVMSHELL_LDFLAGS
= zlib_lib
195 AVMSHELL_LDFLAGS
= '$(call EXPAND_LIBNAME,zlib)'
197 sys_root_dir
= o
.getStringArg('sys-root-dir')
198 if sys_root_dir
is not None:
199 OS_LDFLAGS
+= " --sysroot=%s " % sys_root_dir
200 OPT_CXXFLAGS
+= " --sysroot=%s " % sys_root_dir
202 if the_os
== "darwin":
203 AVMSHELL_LDFLAGS
+= " -exported_symbols_list " + thisdir
+ "/platform/mac/avmshell/exports.exp"
204 MMGC_DEFINES
.update({'TARGET_API_MAC_CARBON': 1,
208 'TARGET_RT_MAC_MACHO': 1})
209 APP_CXXFLAGS
+= "-fpascal-strings -faltivec -fasm-blocks "
210 if cpu
== 'x86_64' or cpu
== 'ppc64':
211 # 64-bit mac targets require the 10.5 sdk.
212 # Note that we don't override CC/CXX here; the calling script is expected to do that if desired
213 # (thus we can support 10.5sdk with either 4.0 or 4.2)
214 APP_CXXFLAGS
+= "-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk "
215 config
.subst("MACOSX_DEPLOYMENT_TARGET",10.5)
217 APP_CXXFLAGS
+= "-arch x86_64 "
218 APP_CFLAGS
+= "-arch x86_64 "
219 OS_LDFLAGS
+= "-arch x86_64 "
221 APP_CXXFLAGS
+= "-arch ppc64 "
222 APP_CFLAGS
+= "-arch ppc64 "
223 OS_LDFLAGS
+= "-arch ppc64 "
225 APP_CXXFLAGS
+= "-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk "
226 config
.subst("MACOSX_DEPLOYMENT_TARGET",10.4)
227 elif the_os
== "windows" or the_os
== "cygwin":
228 MMGC_DEFINES
.update({'WIN32': None,
229 '_CRT_SECURE_NO_DEPRECATE': None})
230 OS_LDFLAGS
+= "-MAP "
232 APP_CPPFLAGS
+= "-DARM -D_ARM_ -DUNICODE -DUNDER_CE=1 -DMMGC_ARM "
234 APP_CPPFLAGS
+= "-DARMV6 -QRarch6 "
236 APP_CPPFLAGS
+= "-DARMV5 -QRarch5t "
237 OS_LIBS
.append('mmtimer corelibc coredll')
239 APP_CPPFLAGS
+= "-DWIN32_LEAN_AND_MEAN -D_CONSOLE "
240 OS_LIBS
.append('winmm')
241 OS_LIBS
.append('shlwapi')
242 OS_LIBS
.append('AdvAPI32')
243 elif the_os
== "linux":
244 MMGC_DEFINES
.update({'UNIX': None,
245 'AVMPLUS_UNIX': None})
246 OS_LIBS
.append('pthread')
247 # if cpu == "x86_64":
248 # # workaround https://bugzilla.mozilla.org/show_bug.cgi?id=467776
249 # OPT_CXXFLAGS += '-fno-schedule-insns2 '
250 if config
.getDebug():
252 elif the_os
== "sunos":
253 if config
.getCompiler() != 'GCC':
254 APP_CXXFLAGS
= "-template=no%extdef -erroff=wvarhidemem"
255 OPT_CXXFLAGS
= "-xO5 "
256 DEBUG_CXXFLAGS
= "-g "
257 MMGC_DEFINES
.update({'UNIX': None,
258 'AVMPLUS_UNIX': None,
260 OS_LIBS
.append('pthread')
261 APP_CPPFLAGS
+= '-DAVMPLUS_CDECL '
262 if config
.getDebug():
265 raise Exception("Unsupported OS")
268 if config
.getCompiler() == 'GCC' and the_os
== 'darwin':
269 #only mactel always has sse2
270 APP_CPPFLAGS
+= "-msse2 "
271 elif cpu
== "powerpc":
272 # we detect this in core/avmbuild.h and MMgc/*build.h
275 # we detect this in core/avmbuild.h and MMgc/*build.h
278 APP_CPPFLAGS
+= "-DAVMPLUS_SPARC "
279 elif cpu
== "x86_64":
280 # we detect this in core/avmbuild.h and MMgc/*build.h
283 # we detect this in core/avmbuild.h and MMgc/*build.h
286 # we detect this in core/avmbuild.h and MMgc/*build.h
289 raise Exception("Unsupported CPU")
291 if o
.getBoolArg('perfm'):
292 APP_CPPFLAGS
+= "-DPERFM "
295 sys
.stdout
.write(o
.getHelp())
299 # We do two things with MMGC_DEFINES: we append it to APP_CPPFLAGS and we also write MMgc-config.h
300 APP_CPPFLAGS
+= ''.join(val
is None and ('-D%s ' % var
) or ('-D%s=%s ' % (var
, val
))
301 for (var
, val
) in MMGC_DEFINES
.iteritems())
305 #define %(var)s %(val)s
309 outpath
= "%s/MMgc-config.h" % config
.getObjDir()
310 contents
= ''.join(definePattern
% {'var': var
,
311 'val': val
is not None and val
or ''}
312 for (var
, val
) in MMGC_DEFINES
.iteritems())
313 writeFileIfChanged(outpath
, contents
)
315 config
.subst("APP_CPPFLAGS", APP_CPPFLAGS
)
316 config
.subst("APP_CXXFLAGS", APP_CXXFLAGS
)
317 config
.subst("OPT_CPPFLAGS", OPT_CPPFLAGS
)
318 config
.subst("OPT_CXXFLAGS", OPT_CXXFLAGS
)
319 config
.subst("DEBUG_CPPFLAGS", DEBUG_CPPFLAGS
)
320 config
.subst("DEBUG_CXXFLAGS", DEBUG_CXXFLAGS
)
321 config
.subst("DEBUG_LDFLAGS", DEBUG_LDFLAGS
)
322 config
.subst("OS_LIBS", " ".join(OS_LIBS
))
323 config
.subst("OS_LDFLAGS", OS_LDFLAGS
)
324 config
.subst("MMGC_CPPFLAGS", MMGC_CPPFLAGS
)
325 config
.subst("AVMSHELL_CPPFLAGS", AVMSHELL_CPPFLAGS
)
326 config
.subst("AVMSHELL_LDFLAGS", AVMSHELL_LDFLAGS
)
327 config
.subst("MMGC_DYNAMIC", MMGC_DYNAMIC
and 1 or '')
328 config
.generate("Makefile")