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
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.
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.
29 # Variable default definitions. Override them by exporting them in your shell.
37 ANDROID_TOOL_PREFIX = $(ANDROID_NDK_ROOT)/toolchain/bin/arm-linux-androideabi
39 # Special build flags. Use them like this: "make library=shared"
41 # library=shared || component=shared_library
42 ifeq ($(library), shared)
43 GYPFLAGS += -Dcomponent=shared_library
46 GYPFLAGS += -Dcomponent=$(component)
50 GYPFLAGS += -Dconsole=$(console)
53 ifeq ($(disassembler), on)
54 GYPFLAGS += -Dv8_enable_disassembler=1
57 ifeq ($(objectprint), on)
58 GYPFLAGS += -Dv8_object_print=1
61 ifeq ($(snapshot), off)
62 GYPFLAGS += -Dv8_use_snapshot='false'
66 GYPFLAGS += -Dv8_enable_gdbjit=1
69 ifeq ($(liveobjectlist), on)
70 GYPFLAGS += -Dv8_use_liveobjectlist=true
74 GYPFLAGS += -Dv8_can_use_vfp_instructions=false
76 GYPFLAGS += -Dv8_can_use_vfp_instructions=true
79 ifeq ($(debuggersupport), off)
80 GYPFLAGS += -Dv8_enable_debugger_support=0
82 # soname_version=1.2.3
84 GYPFLAGS += -Dsoname_version=$(soname_version)
88 GYPFLAGS += -Dwerror=''
91 ifeq ($(presubmit), no)
92 TESTFLAGS += --no-presubmit
94 # strictaliasing=off (workaround for GCC-4.5)
95 ifeq ($(strictaliasing), off)
96 GYPFLAGS += -Dv8_no_strict_aliasing=1
99 # ----------------- available targets: --------------------
100 # - "dependencies": pulls in external dependencies (currently: GYP)
101 # - any arch listed in ARCHES (see below)
102 # - any mode listed in MODES
103 # - every combination <arch>.<mode>, e.g. "ia32.release"
104 # - "native": current host's architecture, release mode
105 # - any of the above with .check appended, e.g. "ia32.release.check"
106 # - "android": cross-compile for Android/ARM (release mode)
107 # - default (no target specified): build all DEFAULT_ARCHES and MODES
108 # - "check": build all targets and run all tests
109 # - "<arch>.clean" for any <arch> in ARCHES
110 # - "clean": clean all ARCHES
112 # ----------------- internal stuff ------------------------
114 # Architectures and modes to be compiled. Consider these to be internal
115 # variables, don't override them (use the targets instead).
116 ARCHES = ia32 x64 arm mips
117 DEFAULT_ARCHES = ia32 x64 arm
118 MODES = release debug
120 # List of files that trigger Makefile regeneration:
121 GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \
122 preparser/preparser.gyp samples/samples.gyp src/d8.gyp \
123 test/cctest/cctest.gyp tools/gyp/v8.gyp
125 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
126 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
127 # Generates corresponding test targets, e.g. "ia32.release.check".
128 CHECKS = $(addsuffix .check,$(BUILDS))
129 # File where previously used GYPFLAGS are stored.
130 ENVFILE = $(OUTDIR)/environment
132 .PHONY: all check clean dependencies $(ENVFILE).new native \
133 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
134 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
135 must-set-ANDROID_NDK_ROOT
137 # Target definitions. "all" is the default.
140 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
141 # having been created before.
143 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
144 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
146 # Compile targets. MODES and ARCHES are convenience targets.
148 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
150 $(ARCHES): $(addprefix $$@.,$(MODES))
152 # Defines how to build a particular target (e.g. ia32.release).
153 $(BUILDS): $(OUTDIR)/Makefile.$$(basename $$@)
154 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$(basename $@) \
155 CXX="$(CXX)" LINK="$(LINK)" \
156 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
157 python -c "print raw_input().capitalize()") \
158 builddir="$(shell pwd)/$(OUTDIR)/$@"
160 native: $(OUTDIR)/Makefile.native
161 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
162 CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
163 builddir="$(shell pwd)/$(OUTDIR)/$@"
165 # TODO(jkummerow): add "android.debug" when we need it.
166 android android.release: $(OUTDIR)/Makefile.android
167 @$(MAKE) -C "$(OUTDIR)" -f Makefile.android \
168 CXX="$(ANDROID_TOOL_PREFIX)-g++" \
169 AR="$(ANDROID_TOOL_PREFIX)-ar" \
170 RANLIB="$(ANDROID_TOOL_PREFIX)-ranlib" \
171 CC="$(ANDROID_TOOL_PREFIX)-gcc" \
172 LD="$(ANDROID_TOOL_PREFIX)-ld" \
173 LINK="$(ANDROID_TOOL_PREFIX)-g++" \
175 builddir="$(shell pwd)/$(OUTDIR)/android.release"
179 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
180 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
183 $(addsuffix .check,$(MODES)): $$(basename $$@)
184 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
185 --mode=$(basename $@) $(TESTFLAGS)
187 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
188 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
189 --arch=$(basename $@) $(TESTFLAGS)
191 $(CHECKS): $$(basename $$@)
192 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
193 --arch-and-mode=$(basename $@) $(TESTFLAGS)
196 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
197 --arch-and-mode=. $(TESTFLAGS)
199 # Clean targets. You can clean each architecture individually, or everything.
200 $(addsuffix .clean,$(ARCHES)) android.clean:
201 rm -f $(OUTDIR)/Makefile.$(basename $@)
202 rm -rf $(OUTDIR)/$(basename $@).release
203 rm -rf $(OUTDIR)/$(basename $@).debug
204 find $(OUTDIR) -regex '.*\(host\|target\).$(basename $@)\.mk' -delete
207 rm -f $(OUTDIR)/Makefile.native
208 rm -rf $(OUTDIR)/native
209 find $(OUTDIR) -regex '.*\(host\|target\).native\.mk' -delete
211 clean: $(addsuffix .clean,$(ARCHES)) native.clean android.clean
213 # GYP file generation targets.
214 MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ARCHES))
215 $(MAKEFILES): $(GYPFILES) $(ENVFILE)
216 GYP_GENERATORS=make \
217 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
218 -Ibuild/standalone.gypi --depth=. \
219 -Dv8_target_arch=$(subst .,,$(suffix $@)) \
220 -S.$(subst .,,$(suffix $@)) $(GYPFLAGS)
222 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
223 GYP_GENERATORS=make \
224 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
225 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
227 $(OUTDIR)/Makefile.android: $(GYPFILES) $(ENVFILE) build/android.gypi \
228 must-set-ANDROID_NDK_ROOT
229 GYP_GENERATORS=make \
230 CC="${ANDROID_TOOL_PREFIX}-gcc" \
231 CXX="${ANDROID_TOOL_PREFIX}-g++" \
232 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
233 -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \
234 -S.android $(GYPFLAGS)
236 must-set-ANDROID_NDK_ROOT:
237 ifndef ANDROID_NDK_ROOT
238 $(error ANDROID_NDK_ROOT is not set)
241 # Replaces the old with the new environment file if they're different, which
242 # will trigger GYP to regenerate Makefiles.
243 $(ENVFILE): $(ENVFILE).new
244 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \
245 then rm $(ENVFILE).new; \
246 else mv $(ENVFILE).new $(ENVFILE); fi
248 # Stores current GYPFLAGS in a file.
250 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
251 echo "CXX=$(CXX)" >> $(ENVFILE).new
255 svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \