Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / v8 / Makefile
1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are
4 # met:
5 #
6 #     * Redistributions of source code must retain the above copyright
7 #       notice, this list of conditions and the following disclaimer.
8 #     * Redistributions in binary form must reproduce the above
9 #       copyright notice, this list of conditions and the following
10 #       disclaimer in the documentation and/or other materials provided
11 #       with the distribution.
12 #     * Neither the name of Google Inc. nor the names of its
13 #       contributors may be used to endorse or promote products derived
14 #       from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29 # Variable default definitions. Override them by exporting them in your shell.
30 CXX ?= g++
31 LINK ?= g++
32 OUTDIR ?= out
33 TESTJOBS ?=
34 GYPFLAGS ?=
35 TESTFLAGS ?=
36 ANDROID_NDK_ROOT ?=
37 ANDROID_NDK_HOST_ARCH ?=
38 ANDROID_TOOLCHAIN ?=
39 ANDROID_V8 ?= /data/local/tmp/v8
40 NACL_SDK_ROOT ?=
41
42 # Special build flags. Use them like this: "make library=shared"
43
44 # library=shared || component=shared_library
45 ifeq ($(library), shared)
46   GYPFLAGS += -Dcomponent=shared_library
47 endif
48 ifdef component
49   GYPFLAGS += -Dcomponent=$(component)
50 endif
51 # console=readline
52 ifdef console
53   GYPFLAGS += -Dconsole=$(console)
54 endif
55 # disassembler=on
56 ifeq ($(disassembler), on)
57   GYPFLAGS += -Dv8_enable_disassembler=1
58 endif
59 # objectprint=on
60 ifeq ($(objectprint), on)
61   GYPFLAGS += -Dv8_object_print=1
62 endif
63 # verifyheap=on
64 ifeq ($(verifyheap), on)
65   GYPFLAGS += -Dv8_enable_verify_heap=1
66 endif
67 # backtrace=off
68 ifeq ($(backtrace), off)
69   GYPFLAGS += -Dv8_enable_backtrace=0
70 else
71   GYPFLAGS += -Dv8_enable_backtrace=1
72 endif
73 # snapshot=off
74 ifeq ($(snapshot), off)
75   GYPFLAGS += -Dv8_use_snapshot='false'
76 endif
77 # extrachecks=on/off
78 ifeq ($(extrachecks), on)
79   GYPFLAGS += -Dv8_enable_extra_checks=1 -Dv8_enable_handle_zapping=1
80 endif
81 ifeq ($(extrachecks), off)
82   GYPFLAGS += -Dv8_enable_extra_checks=0 -Dv8_enable_handle_zapping=0
83 endif
84 # gdbjit=on/off
85 ifeq ($(gdbjit), on)
86   GYPFLAGS += -Dv8_enable_gdbjit=1
87 endif
88 ifeq ($(gdbjit), off)
89   GYPFLAGS += -Dv8_enable_gdbjit=0
90 endif
91 # vtunejit=on
92 ifeq ($(vtunejit), on)
93   GYPFLAGS += -Dv8_enable_vtunejit=1
94 endif
95 # optdebug=on
96 ifeq ($(optdebug), on)
97   GYPFLAGS += -Dv8_optimized_debug=2
98 endif
99 # debuggersupport=off
100 ifeq ($(debuggersupport), off)
101   GYPFLAGS += -Dv8_enable_debugger_support=0
102 endif
103 # unalignedaccess=on
104 ifeq ($(unalignedaccess), on)
105   GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
106 endif
107 # randomseed=12345, disable random seed via randomseed=0
108 ifdef randomseed
109   GYPFLAGS += -Dv8_random_seed=$(randomseed)
110 endif
111 # soname_version=1.2.3
112 ifdef soname_version
113   GYPFLAGS += -Dsoname_version=$(soname_version)
114 endif
115 # werror=no
116 ifeq ($(werror), no)
117   GYPFLAGS += -Dwerror=''
118 endif
119 # presubmit=no
120 ifeq ($(presubmit), no)
121   TESTFLAGS += --no-presubmit
122 endif
123 # strictaliasing=off (workaround for GCC-4.5)
124 ifeq ($(strictaliasing), off)
125   GYPFLAGS += -Dv8_no_strict_aliasing=1
126 endif
127 # regexp=interpreted
128 ifeq ($(regexp), interpreted)
129   GYPFLAGS += -Dv8_interpreted_regexp=1
130 endif
131 # i18nsupport=off
132 ifeq ($(i18nsupport), off)
133   GYPFLAGS += -Dv8_enable_i18n_support=0
134   TESTFLAGS += --noi18n
135 endif
136 # deprecation_warnings=on
137 ifeq ($(deprecationwarnings), on)
138   GYPFLAGS += -Dv8_deprecation_warnings=1
139 endif 
140 # arm specific flags.
141 # arm_version=<number | "default">
142 ifneq ($(strip $(arm_version)),)
143   GYPFLAGS += -Darm_version=$(arm_version)
144 else
145 # Deprecated (use arm_version instead): armv7=false/true
146 ifeq ($(armv7), false)
147   GYPFLAGS += -Darm_version=6
148 else
149 ifeq ($(armv7), true)
150   GYPFLAGS += -Darm_version=7
151 endif
152 endif
153 endif
154 # vfp2=off. Deprecated, use armfpu=
155 # vfp3=off. Deprecated, use armfpu=
156 ifeq ($(vfp3), off)
157   GYPFLAGS += -Darm_fpu=vfp
158 endif
159 # hardfp=on/off. Deprecated, use armfloatabi
160 ifeq ($(hardfp),on)
161   GYPFLAGS += -Darm_float_abi=hard
162 else
163 ifeq ($(hardfp),off)
164   GYPFLAGS += -Darm_float_abi=softfp
165 endif
166 endif
167 # armneon=on/off
168 ifeq ($(armneon), on)
169   GYPFLAGS += -Darm_neon=1
170 endif
171 # fpu: armfpu=xxx
172 # xxx: vfp, vfpv3-d16, vfpv3, neon.
173 ifeq ($(armfpu),)
174 ifneq ($(vfp3), off)
175   GYPFLAGS += -Darm_fpu=default
176 endif
177 else
178   GYPFLAGS += -Darm_fpu=$(armfpu)
179 endif
180 # float abi: armfloatabi=softfp/hard
181 ifeq ($(armfloatabi),)
182 ifeq ($(hardfp),)
183   GYPFLAGS += -Darm_float_abi=default
184 endif
185 else
186   GYPFLAGS += -Darm_float_abi=$(armfloatabi)
187 endif
188 # armthumb=on/off
189 ifeq ($(armthumb), off)
190   GYPFLAGS += -Darm_thumb=0
191 else
192 ifeq ($(armthumb), on)
193   GYPFLAGS += -Darm_thumb=1
194 endif
195 endif
196 # armtest=on
197 # With this flag set, by default v8 will only use features implied
198 # by the compiler (no probe). This is done by modifying the default
199 # values of enable_armv7, enable_vfp2, enable_vfp3 and enable_32dregs.
200 # Modifying these flags when launching v8 will enable the probing for
201 # the specified values.
202 # When using the simulator, this flag is implied.
203 ifeq ($(armtest), on)
204   GYPFLAGS += -Darm_test=on
205 endif
206
207 # ----------------- available targets: --------------------
208 # - "dependencies": pulls in external dependencies (currently: GYP)
209 # - "grokdump": rebuilds heap constants lists used by grokdump
210 # - any arch listed in ARCHES (see below)
211 # - any mode listed in MODES
212 # - every combination <arch>.<mode>, e.g. "ia32.release"
213 # - "native": current host's architecture, release mode
214 # - any of the above with .check appended, e.g. "ia32.release.check"
215 # - "android": cross-compile for Android/ARM
216 # - "nacl" : cross-compile for Native Client (ia32 and x64)
217 # - default (no target specified): build all DEFAULT_ARCHES and MODES
218 # - "check": build all targets and run all tests
219 # - "<arch>.clean" for any <arch> in ARCHES
220 # - "clean": clean all ARCHES
221
222 # ----------------- internal stuff ------------------------
223
224 # Architectures and modes to be compiled. Consider these to be internal
225 # variables, don't override them (use the targets instead).
226 ARCHES = ia32 x64 arm mipsel
227 DEFAULT_ARCHES = ia32 x64 arm
228 MODES = release debug optdebug
229 DEFAULT_MODES = release debug
230 ANDROID_ARCHES = android_ia32 android_arm android_mipsel
231 NACL_ARCHES = nacl_ia32 nacl_x64
232
233 # List of files that trigger Makefile regeneration:
234 GYPFILES = build/all.gyp build/features.gypi build/standalone.gypi \
235            build/toolchain.gypi samples/samples.gyp src/d8.gyp \
236            test/cctest/cctest.gyp tools/gyp/v8.gyp
237
238 # If vtunejit=on, the v8vtune.gyp will be appended.
239 ifeq ($(vtunejit), on)
240   GYPFILES += src/third_party/vtune/v8vtune.gyp
241 endif
242 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
243 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
244 ANDROID_BUILDS = $(foreach mode,$(MODES), \
245                    $(addsuffix .$(mode),$(ANDROID_ARCHES)))
246 NACL_BUILDS = $(foreach mode,$(MODES), \
247                    $(addsuffix .$(mode),$(NACL_ARCHES)))
248 # Generates corresponding test targets, e.g. "ia32.release.check".
249 CHECKS = $(addsuffix .check,$(BUILDS))
250 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
251 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
252 # File where previously used GYPFLAGS are stored.
253 ENVFILE = $(OUTDIR)/environment
254
255 .PHONY: all check clean dependencies $(ENVFILE).new native \
256         qc quickcheck \
257         $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
258         $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
259         $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
260         must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \
261         $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
262         must-set-NACL_SDK_ROOT
263
264 # Target definitions. "all" is the default.
265 all: $(DEFAULT_MODES)
266
267 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
268 # having been created before.
269 buildbot:
270         $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
271                 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
272
273 mips mips.release mips.debug:
274         @echo "V8 does not support big-endian MIPS builds at the moment," \
275               "please use little-endian builds (mipsel)."
276
277 # Compile targets. MODES and ARCHES are convenience targets.
278 .SECONDEXPANSION:
279 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
280
281 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
282
283 # Defines how to build a particular target (e.g. ia32.release).
284 $(BUILDS): $(OUTDIR)/Makefile.$$@
285         @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
286                  CXX="$(CXX)" LINK="$(LINK)" \
287                  BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
288                              python -c "print \
289                              raw_input().replace('opt', '').capitalize()") \
290                  builddir="$(shell pwd)/$(OUTDIR)/$@"
291
292 native: $(OUTDIR)/Makefile.native
293         @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
294                  CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
295                  builddir="$(shell pwd)/$(OUTDIR)/$@"
296
297 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
298
299 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \
300                    must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android
301         @$(MAKE) -f Makefile.android $@ \
302                 ARCH="$(basename $@)" \
303                 MODE="$(subst .,,$(suffix $@))" \
304                 OUTDIR="$(OUTDIR)" \
305                 GYPFLAGS="$(GYPFLAGS)"
306
307 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
308
309 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
310                    Makefile.nacl must-set-NACL_SDK_ROOT
311         @$(MAKE) -f Makefile.nacl $@ \
312                 ARCH="$(basename $@)" \
313                 MODE="$(subst .,,$(suffix $@))" \
314                 OUTDIR="$(OUTDIR)" \
315                 GYPFLAGS="$(GYPFLAGS)"
316
317 # Test targets.
318 check: all
319         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
320             --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
321             $(TESTFLAGS)
322
323 $(addsuffix .check,$(MODES)): $$(basename $$@)
324         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
325             --mode=$(basename $@) $(TESTFLAGS)
326
327 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
328         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
329             --arch=$(basename $@) $(TESTFLAGS)
330
331 $(CHECKS): $$(basename $$@)
332         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
333             --arch-and-mode=$(basename $@) $(TESTFLAGS)
334
335 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
336         @tools/android-sync.sh $(basename $@) $(OUTDIR) \
337                                $(shell pwd) $(ANDROID_V8)
338
339 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
340         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
341              --arch-and-mode=$(basename $@) \
342              --timeout=600 \
343              --command-prefix="tools/android-run.py" $(TESTFLAGS)
344
345 $(addsuffix .check, $(ANDROID_ARCHES)): \
346                 $(addprefix $$(basename $$@).,$(MODES)).check
347
348 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
349         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
350              --arch-and-mode=$(basename $@) \
351              --timeout=600 --nopresubmit --noi18n \
352              --command-prefix="tools/nacl-run.py"
353
354 $(addsuffix .check, $(NACL_ARCHES)): \
355                 $(addprefix $$(basename $$@).,$(MODES)).check
356
357 native.check: native
358         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
359             --arch-and-mode=. $(TESTFLAGS)
360
361 FASTTESTMODES = ia32.release,x64.release,ia32.optdebug,x64.optdebug,arm.optdebug
362
363 COMMA = ,
364 EMPTY =
365 SPACE = $(EMPTY) $(EMPTY)
366 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTTESTMODES))
367         tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
368             --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
369 qc: quickcheck
370
371 # Clean targets. You can clean each architecture individually, or everything.
372 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
373         rm -f $(OUTDIR)/Makefile.$(basename $@)*
374         rm -rf $(OUTDIR)/$(basename $@).release
375         rm -rf $(OUTDIR)/$(basename $@).debug
376         rm -rf $(OUTDIR)/$(basename $@).optdebug
377         find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
378
379 native.clean:
380         rm -f $(OUTDIR)/Makefile.native
381         rm -rf $(OUTDIR)/native
382         find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
383
384 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean
385
386 # GYP file generation targets.
387 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
388 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
389         PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
390         GYP_GENERATORS=make \
391         build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
392                       -Ibuild/standalone.gypi --depth=. \
393                       -Dv8_target_arch=$(subst .,,$(suffix $(basename $@))) \
394                       -Dv8_optimized_debug=$(if $(findstring optdebug,$@),2,0) \
395                       -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
396
397 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
398         PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
399         GYP_GENERATORS=make \
400         build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
401                       -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
402
403 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
404 ifndef ANDROID_NDK_ROOT
405 ifndef ANDROID_TOOLCHAIN
406           $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
407 endif
408 endif
409
410 # Note that NACL_SDK_ROOT must be set to point to an appropriate
411 # Native Client SDK before using this makefile. You can download
412 # an SDK here:
413 #   https://developers.google.com/native-client/sdk/download
414 # The path indicated by NACL_SDK_ROOT will typically end with
415 # a folder for a pepper version such as "pepper_25" that should
416 # have "tools" and "toolchain" subdirectories.
417 must-set-NACL_SDK_ROOT:
418 ifndef NACL_SDK_ROOT
419           $(error NACL_SDK_ROOT must be set)
420 endif
421
422 # Replaces the old with the new environment file if they're different, which
423 # will trigger GYP to regenerate Makefiles.
424 $(ENVFILE): $(ENVFILE).new
425         @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
426             then rm $(ENVFILE).new; \
427             else mv $(ENVFILE).new $(ENVFILE); fi
428
429 # Stores current GYPFLAGS in a file.
430 $(ENVFILE).new:
431         @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
432             echo "CXX=$(CXX)" >> $(ENVFILE).new
433
434 # Heap constants for grokdump.
435 DUMP_FILE = tools/v8heapconst.py
436 grokdump: ia32.release
437         @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
438         @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
439
440 # Dependencies.
441 # Remember to keep these in sync with the DEPS file.
442 dependencies:
443         svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
444             --revision 1831
445         svn checkout --force \
446             https://src.chromium.org/chrome/trunk/deps/third_party/icu46 \
447             third_party/icu --revision 239289