- add third_party src.
[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=1
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 # soname_version=1.2.3
108 ifdef soname_version
109   GYPFLAGS += -Dsoname_version=$(soname_version)
110 endif
111 # werror=no
112 ifeq ($(werror), no)
113   GYPFLAGS += -Dwerror=''
114 endif
115 # presubmit=no
116 ifeq ($(presubmit), no)
117   TESTFLAGS += --no-presubmit
118 endif
119 # strictaliasing=off (workaround for GCC-4.5)
120 ifeq ($(strictaliasing), off)
121   GYPFLAGS += -Dv8_no_strict_aliasing=1
122 endif
123 # regexp=interpreted
124 ifeq ($(regexp), interpreted)
125   GYPFLAGS += -Dv8_interpreted_regexp=1
126 endif
127 # i18nsupport=off
128 ifeq ($(i18nsupport), off)
129   GYPFLAGS += -Dv8_enable_i18n_support=0
130   TESTFLAGS += --noi18n
131 endif
132 # deprecation_warnings=on
133 ifeq ($(deprecationwarnings), on)
134   GYPFLAGS += -Dv8_deprecation_warnings=1
135 endif 
136 # arm specific flags.
137 # armv7=false/true
138 ifeq ($(armv7), false)
139   GYPFLAGS += -Darmv7=0
140 else
141 ifeq ($(armv7), true)
142   GYPFLAGS += -Darmv7=1
143 endif
144 endif
145 # vfp2=off. Deprecated, use armfpu=
146 # vfp3=off. Deprecated, use armfpu=
147 ifeq ($(vfp3), off)
148   GYPFLAGS += -Darm_fpu=vfp
149 endif
150 # hardfp=on/off. Deprecated, use armfloatabi
151 ifeq ($(hardfp),on)
152   GYPFLAGS += -Darm_float_abi=hard
153 else
154 ifeq ($(hardfp),off)
155   GYPFLAGS += -Darm_float_abi=softfp
156 endif
157 endif
158 # armneon=on/off
159 ifeq ($(armneon), on)
160   GYPFLAGS += -Darm_neon=1
161 endif
162 # fpu: armfpu=xxx
163 # xxx: vfp, vfpv3-d16, vfpv3, neon.
164 ifeq ($(armfpu),)
165 ifneq ($(vfp3), off)
166   GYPFLAGS += -Darm_fpu=default
167 endif
168 else
169   GYPFLAGS += -Darm_fpu=$(armfpu)
170 endif
171 # float abi: armfloatabi=softfp/hard
172 ifeq ($(armfloatabi),)
173 ifeq ($(hardfp),)
174   GYPFLAGS += -Darm_float_abi=default
175 endif
176 else
177   GYPFLAGS += -Darm_float_abi=$(armfloatabi)
178 endif
179 # armthumb=on/off
180 ifeq ($(armthumb), off)
181   GYPFLAGS += -Darm_thumb=0
182 else
183 ifeq ($(armthumb), on)
184   GYPFLAGS += -Darm_thumb=1
185 endif
186 endif
187 # armtest=on
188 # With this flag set, by default v8 will only use features implied
189 # by the compiler (no probe). This is done by modifying the default
190 # values of enable_armv7, enable_vfp2, enable_vfp3 and enable_32dregs.
191 # Modifying these flags when launching v8 will enable the probing for
192 # the specified values.
193 # When using the simulator, this flag is implied.
194 ifeq ($(armtest), on)
195   GYPFLAGS += -Darm_test=on
196 endif
197
198 # ----------------- available targets: --------------------
199 # - "dependencies": pulls in external dependencies (currently: GYP)
200 # - "grokdump": rebuilds heap constants lists used by grokdump
201 # - any arch listed in ARCHES (see below)
202 # - any mode listed in MODES
203 # - every combination <arch>.<mode>, e.g. "ia32.release"
204 # - "native": current host's architecture, release mode
205 # - any of the above with .check appended, e.g. "ia32.release.check"
206 # - "android": cross-compile for Android/ARM
207 # - "nacl" : cross-compile for Native Client (ia32 and x64)
208 # - default (no target specified): build all DEFAULT_ARCHES and MODES
209 # - "check": build all targets and run all tests
210 # - "<arch>.clean" for any <arch> in ARCHES
211 # - "clean": clean all ARCHES
212
213 # ----------------- internal stuff ------------------------
214
215 # Architectures and modes to be compiled. Consider these to be internal
216 # variables, don't override them (use the targets instead).
217 ARCHES = ia32 x64 arm mipsel
218 DEFAULT_ARCHES = ia32 x64 arm
219 MODES = release debug
220 ANDROID_ARCHES = android_ia32 android_arm android_mipsel
221 NACL_ARCHES = nacl_ia32 nacl_x64
222
223 # List of files that trigger Makefile regeneration:
224 GYPFILES = build/all.gyp build/features.gypi build/standalone.gypi \
225            build/toolchain.gypi samples/samples.gyp src/d8.gyp \
226            test/cctest/cctest.gyp tools/gyp/v8.gyp
227
228 # If vtunejit=on, the v8vtune.gyp will be appended.
229 ifeq ($(vtunejit), on)
230   GYPFILES += src/third_party/vtune/v8vtune.gyp
231 endif
232 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
233 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
234 ANDROID_BUILDS = $(foreach mode,$(MODES), \
235                    $(addsuffix .$(mode),$(ANDROID_ARCHES)))
236 NACL_BUILDS = $(foreach mode,$(MODES), \
237                    $(addsuffix .$(mode),$(NACL_ARCHES)))
238 # Generates corresponding test targets, e.g. "ia32.release.check".
239 CHECKS = $(addsuffix .check,$(BUILDS))
240 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
241 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
242 # File where previously used GYPFLAGS are stored.
243 ENVFILE = $(OUTDIR)/environment
244
245 .PHONY: all check clean dependencies $(ENVFILE).new native \
246         $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
247         $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
248         $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
249         must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \
250         $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
251         must-set-NACL_SDK_ROOT
252
253 # Target definitions. "all" is the default.
254 all: $(MODES)
255
256 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
257 # having been created before.
258 buildbot:
259         $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
260                 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
261
262 mips mips.release mips.debug:
263         @echo "V8 does not support big-endian MIPS builds at the moment," \
264               "please use little-endian builds (mipsel)."
265
266 # Compile targets. MODES and ARCHES are convenience targets.
267 .SECONDEXPANSION:
268 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
269
270 $(ARCHES): $(addprefix $$@.,$(MODES))
271
272 # Defines how to build a particular target (e.g. ia32.release).
273 $(BUILDS): $(OUTDIR)/Makefile.$$(basename $$@)
274         @$(MAKE) -C "$(OUTDIR)" -f Makefile.$(basename $@) \
275                  CXX="$(CXX)" LINK="$(LINK)" \
276                  BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
277                              python -c "print raw_input().capitalize()") \
278                  builddir="$(shell pwd)/$(OUTDIR)/$@"
279
280 native: $(OUTDIR)/Makefile.native
281         @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
282                  CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
283                  builddir="$(shell pwd)/$(OUTDIR)/$@"
284
285 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
286
287 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \
288                    must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android
289         @$(MAKE) -f Makefile.android $@ \
290                 ARCH="$(basename $@)" \
291                 MODE="$(subst .,,$(suffix $@))" \
292                 OUTDIR="$(OUTDIR)" \
293                 GYPFLAGS="$(GYPFLAGS)"
294
295 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
296
297 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
298                    Makefile.nacl must-set-NACL_SDK_ROOT
299         @$(MAKE) -f Makefile.nacl $@ \
300                 ARCH="$(basename $@)" \
301                 MODE="$(subst .,,$(suffix $@))" \
302                 OUTDIR="$(OUTDIR)" \
303                 GYPFLAGS="$(GYPFLAGS)"
304
305 # Test targets.
306 check: all
307         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
308             --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
309             $(TESTFLAGS)
310
311 $(addsuffix .check,$(MODES)): $$(basename $$@)
312         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
313             --mode=$(basename $@) $(TESTFLAGS)
314
315 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
316         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
317             --arch=$(basename $@) $(TESTFLAGS)
318
319 $(CHECKS): $$(basename $$@)
320         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
321             --arch-and-mode=$(basename $@) $(TESTFLAGS)
322
323 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
324         @tools/android-sync.sh $(basename $@) $(OUTDIR) \
325                                $(shell pwd) $(ANDROID_V8)
326
327 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
328         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
329              --arch-and-mode=$(basename $@) \
330              --timeout=600 \
331              --command-prefix="tools/android-run.py" $(TESTFLAGS)
332
333 $(addsuffix .check, $(ANDROID_ARCHES)): \
334                 $(addprefix $$(basename $$@).,$(MODES)).check
335
336 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
337         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
338              --arch-and-mode=$(basename $@) \
339              --timeout=600 --nopresubmit --noi18n \
340              --command-prefix="tools/nacl-run.py"
341
342 $(addsuffix .check, $(NACL_ARCHES)): \
343                 $(addprefix $$(basename $$@).,$(MODES)).check
344
345 native.check: native
346         @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
347             --arch-and-mode=. $(TESTFLAGS)
348
349 # Clean targets. You can clean each architecture individually, or everything.
350 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
351         rm -f $(OUTDIR)/Makefile.$(basename $@)
352         rm -rf $(OUTDIR)/$(basename $@).release
353         rm -rf $(OUTDIR)/$(basename $@).debug
354         find $(OUTDIR) -regex '.*\(host\|target\).$(basename $@)\.mk' -delete
355
356 native.clean:
357         rm -f $(OUTDIR)/Makefile.native
358         rm -rf $(OUTDIR)/native
359         find $(OUTDIR) -regex '.*\(host\|target\).native\.mk' -delete
360
361 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean
362
363 # GYP file generation targets.
364 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ARCHES))
365 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
366         PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
367         GYP_GENERATORS=make \
368         build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
369                       -Ibuild/standalone.gypi --depth=. \
370                       -Dv8_target_arch=$(subst .,,$(suffix $@)) \
371                       -S.$(subst .,,$(suffix $@)) $(GYPFLAGS)
372
373 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
374         PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
375         GYP_GENERATORS=make \
376         build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
377                       -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
378
379 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
380 ifndef ANDROID_NDK_ROOT
381 ifndef ANDROID_TOOLCHAIN
382           $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
383 endif
384 endif
385
386 # Note that NACL_SDK_ROOT must be set to point to an appropriate
387 # Native Client SDK before using this makefile. You can download
388 # an SDK here:
389 #   https://developers.google.com/native-client/sdk/download
390 # The path indicated by NACL_SDK_ROOT will typically end with
391 # a folder for a pepper version such as "pepper_25" that should
392 # have "tools" and "toolchain" subdirectories.
393 must-set-NACL_SDK_ROOT:
394 ifndef NACL_SDK_ROOT
395           $(error NACL_SDK_ROOT must be set)
396 endif
397
398 # Replaces the old with the new environment file if they're different, which
399 # will trigger GYP to regenerate Makefiles.
400 $(ENVFILE): $(ENVFILE).new
401         @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
402             then rm $(ENVFILE).new; \
403             else mv $(ENVFILE).new $(ENVFILE); fi
404
405 # Stores current GYPFLAGS in a file.
406 $(ENVFILE).new:
407         @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
408             echo "CXX=$(CXX)" >> $(ENVFILE).new
409
410 # Heap constants for grokdump.
411 DUMP_FILE = tools/v8heapconst.py
412 grokdump: ia32.release
413         @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
414         @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
415
416 # Dependencies.
417 # Remember to keep these in sync with the DEPS file.
418 dependencies:
419         svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
420             --revision 1685
421         svn checkout --force \
422             https://src.chromium.org/chrome/trunk/deps/third_party/icu46 \
423             third_party/icu --revision 214189