1 # Copyright 2011 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.
30 CXX ?= "g++" # For distcc: export CXX="distcc g++"
37 # Special build flags. Use them like this: "make library=shared"
39 # library=shared || component=shared_library
40 ifeq ($(library), shared)
41 GYPFLAGS += -Dcomponent=shared_library
44 GYPFLAGS += -Dcomponent=$(component)
48 GYPFLAGS += -Dconsole=$(console)
51 ifeq ($(disassembler), on)
52 GYPFLAGS += -Dv8_enable_disassembler=1
55 ifeq ($(objectprint), on)
56 GYPFLAGS += -Dv8_object_print=1
59 ifeq ($(snapshot), off)
60 GYPFLAGS += -Dv8_use_snapshot='false'
64 GYPFLAGS += -Dv8_enable_gdbjit=1
67 ifeq ($(liveobjectlist), on)
68 GYPFLAGS += -Dv8_use_liveobjectlist=true
72 GYPFLAGS += -Dv8_can_use_vfp_instructions=false
74 GYPFLAGS += -Dv8_can_use_vfp_instructions=true
76 # soname_version=1.2.3
78 GYPFLAGS += -Dsoname_version=$(soname_version)
82 GYPFLAGS += -Dwerror=''
85 ifeq ($(presubmit), no)
86 TESTFLAGS += --no-presubmit
89 # ----------------- available targets: --------------------
90 # - "dependencies": pulls in external dependencies (currently: GYP)
91 # - any arch listed in ARCHES (see below)
92 # - any mode listed in MODES
93 # - every combination <arch>.<mode>, e.g. "ia32.release"
94 # - "native": current host's architecture, release mode
95 # - any of the above with .check appended, e.g. "ia32.release.check"
96 # - default (no target specified): build all ARCHES and MODES
97 # - "check": build all targets and run all tests
98 # - "<arch>.clean" for any <arch> in ARCHES
99 # - "clean": clean all ARCHES
101 # ----------------- internal stuff ------------------------
103 # Architectures and modes to be compiled. Consider these to be internal
104 # variables, don't override them (use the targets instead).
105 ARCHES = ia32 x64 arm
106 MODES = release debug
108 # List of files that trigger Makefile regeneration:
109 GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \
110 preparser/preparser.gyp samples/samples.gyp src/d8.gyp \
111 test/cctest/cctest.gyp tools/gyp/v8.gyp
113 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
114 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
115 # Generates corresponding test targets, e.g. "ia32.release.check".
116 CHECKS = $(addsuffix .check,$(BUILDS))
117 # File where previously used GYPFLAGS are stored.
118 ENVFILE = $(OUTDIR)/environment
120 .PHONY: all check clean dependencies $(ENVFILE).new native \
121 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
122 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES))
124 # Target definitions. "all" is the default.
127 # Compile targets. MODES and ARCHES are convenience targets.
129 $(MODES): $(addsuffix .$$@,$(ARCHES))
131 $(ARCHES): $(addprefix $$@.,$(MODES))
133 # Defines how to build a particular target (e.g. ia32.release).
134 $(BUILDS): $(OUTDIR)/Makefile-$$(basename $$@)
135 @$(MAKE) -C "$(OUTDIR)" -f Makefile-$(basename $@) \
136 CXX="$(CXX)" LINK="$(LINK)" \
137 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
138 python -c "print raw_input().capitalize()") \
139 builddir="$(shell pwd)/$(OUTDIR)/$@"
141 native: $(OUTDIR)/Makefile-native
142 @$(MAKE) -C "$(OUTDIR)" -f Makefile-native \
143 CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
144 builddir="$(shell pwd)/$(OUTDIR)/$@"
148 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
151 $(addsuffix .check,$(MODES)): $$(basename $$@)
152 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
153 --mode=$(basename $@) $(TESTFLAGS)
155 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
156 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
157 --arch=$(basename $@) $(TESTFLAGS)
159 $(CHECKS): $$(basename $$@)
160 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
161 --arch-and-mode=$(basename $@) $(TESTFLAGS)
164 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
165 --arch-and-mode=. $(TESTFLAGS)
167 # Clean targets. You can clean each architecture individually, or everything.
168 $(addsuffix .clean,$(ARCHES)):
169 rm -f $(OUTDIR)/Makefile-$(basename $@)
170 rm -rf $(OUTDIR)/$(basename $@).release
171 rm -rf $(OUTDIR)/$(basename $@).debug
172 find $(OUTDIR) -regex '.*\(host\|target\)-$(basename $@)\.mk' -delete
175 rm -f $(OUTDIR)/Makefile-native
176 rm -rf $(OUTDIR)/native
177 find $(OUTDIR) -regex '.*\(host\|target\)-native\.mk' -delete
179 clean: $(addsuffix .clean,$(ARCHES)) native.clean
181 # GYP file generation targets.
182 $(OUTDIR)/Makefile-ia32: $(GYPFILES) $(ENVFILE)
183 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
184 -Ibuild/standalone.gypi --depth=. -Dtarget_arch=ia32 \
187 $(OUTDIR)/Makefile-x64: $(GYPFILES) $(ENVFILE)
188 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
189 -Ibuild/standalone.gypi --depth=. -Dtarget_arch=x64 \
192 $(OUTDIR)/Makefile-arm: $(GYPFILES) $(ENVFILE)
193 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
194 -Ibuild/standalone.gypi --depth=. -Ibuild/armu.gypi \
197 $(OUTDIR)/Makefile-native: $(GYPFILES) $(ENVFILE)
198 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
199 -Ibuild/standalone.gypi --depth=. -S-native $(GYPFLAGS)
201 # Replaces the old with the new environment file if they're different, which
202 # will trigger GYP to regenerate Makefiles.
203 $(ENVFILE): $(ENVFILE).new
204 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \
205 then rm $(ENVFILE).new; \
206 else mv $(ENVFILE).new $(ENVFILE); fi
208 # Stores current GYPFLAGS in a file.
210 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new;
214 svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \