kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 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 |
| 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. |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame^] | 30 | CXX ?= g++ |
| 31 | LINK ?= g++ |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 32 | OUTDIR ?= out |
| 33 | TESTJOBS ?= -j16 |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 34 | GYPFLAGS ?= |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 35 | TESTFLAGS ?= |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 36 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 37 | # Special build flags. Use them like this: "make library=shared" |
| 38 | |
| 39 | # library=shared || component=shared_library |
| 40 | ifeq ($(library), shared) |
| 41 | GYPFLAGS += -Dcomponent=shared_library |
| 42 | endif |
| 43 | ifdef component |
| 44 | GYPFLAGS += -Dcomponent=$(component) |
| 45 | endif |
| 46 | # console=readline |
| 47 | ifdef console |
| 48 | GYPFLAGS += -Dconsole=$(console) |
| 49 | endif |
| 50 | # disassembler=on |
| 51 | ifeq ($(disassembler), on) |
| 52 | GYPFLAGS += -Dv8_enable_disassembler=1 |
| 53 | endif |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 54 | # objectprint=on |
| 55 | ifeq ($(objectprint), on) |
| 56 | GYPFLAGS += -Dv8_object_print=1 |
| 57 | endif |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 58 | # snapshot=off |
| 59 | ifeq ($(snapshot), off) |
| 60 | GYPFLAGS += -Dv8_use_snapshot='false' |
| 61 | endif |
| 62 | # gdbjit=on |
| 63 | ifeq ($(gdbjit), on) |
| 64 | GYPFLAGS += -Dv8_enable_gdbjit=1 |
| 65 | endif |
| 66 | # liveobjectlist=on |
| 67 | ifeq ($(liveobjectlist), on) |
| 68 | GYPFLAGS += -Dv8_use_liveobjectlist=true |
| 69 | endif |
| 70 | # vfp3=off |
| 71 | ifeq ($(vfp3), off) |
| 72 | GYPFLAGS += -Dv8_can_use_vfp_instructions=false |
| 73 | else |
| 74 | GYPFLAGS += -Dv8_can_use_vfp_instructions=true |
| 75 | endif |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 76 | # soname_version=1.2.3 |
| 77 | ifdef soname_version |
| 78 | GYPFLAGS += -Dsoname_version=$(soname_version) |
| 79 | endif |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 80 | # werror=no |
| 81 | ifeq ($(werror), no) |
| 82 | GYPFLAGS += -Dwerror='' |
| 83 | endif |
| 84 | # presubmit=no |
| 85 | ifeq ($(presubmit), no) |
| 86 | TESTFLAGS += --no-presubmit |
| 87 | endif |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 88 | |
| 89 | # ----------------- available targets: -------------------- |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 90 | # - "dependencies": pulls in external dependencies (currently: GYP) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 91 | # - any arch listed in ARCHES (see below) |
| 92 | # - any mode listed in MODES |
| 93 | # - every combination <arch>.<mode>, e.g. "ia32.release" |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 94 | # - "native": current host's architecture, release mode |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 95 | # - any of the above with .check appended, e.g. "ia32.release.check" |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame^] | 96 | # - default (no target specified): build all DEFAULT_ARCHES and MODES |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 97 | # - "check": build all targets and run all tests |
| 98 | # - "<arch>.clean" for any <arch> in ARCHES |
| 99 | # - "clean": clean all ARCHES |
| 100 | |
| 101 | # ----------------- internal stuff ------------------------ |
| 102 | |
| 103 | # Architectures and modes to be compiled. Consider these to be internal |
| 104 | # variables, don't override them (use the targets instead). |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame^] | 105 | ARCHES = ia32 x64 arm mips |
| 106 | DEFAULT_ARCHES = ia32 x64 arm |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 107 | MODES = release debug |
| 108 | |
| 109 | # List of files that trigger Makefile regeneration: |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 110 | GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \ |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 111 | preparser/preparser.gyp samples/samples.gyp src/d8.gyp \ |
| 112 | test/cctest/cctest.gyp tools/gyp/v8.gyp |
| 113 | |
| 114 | # Generates all combinations of ARCHES and MODES, e.g. "ia32.release". |
| 115 | BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES))) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 116 | # Generates corresponding test targets, e.g. "ia32.release.check". |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 117 | CHECKS = $(addsuffix .check,$(BUILDS)) |
| 118 | # File where previously used GYPFLAGS are stored. |
| 119 | ENVFILE = $(OUTDIR)/environment |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 120 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 121 | .PHONY: all check clean dependencies $(ENVFILE).new native \ |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 122 | $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \ |
| 123 | $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 124 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 125 | # Target definitions. "all" is the default. |
| 126 | all: $(MODES) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 127 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 128 | # Compile targets. MODES and ARCHES are convenience targets. |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 129 | .SECONDEXPANSION: |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame^] | 130 | $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES)) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 131 | |
| 132 | $(ARCHES): $(addprefix $$@.,$(MODES)) |
| 133 | |
| 134 | # Defines how to build a particular target (e.g. ia32.release). |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 135 | $(BUILDS): $(OUTDIR)/Makefile-$$(basename $$@) |
| 136 | @$(MAKE) -C "$(OUTDIR)" -f Makefile-$(basename $@) \ |
| 137 | CXX="$(CXX)" LINK="$(LINK)" \ |
| 138 | BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \ |
| 139 | python -c "print raw_input().capitalize()") \ |
| 140 | builddir="$(shell pwd)/$(OUTDIR)/$@" |
| 141 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 142 | native: $(OUTDIR)/Makefile-native |
| 143 | @$(MAKE) -C "$(OUTDIR)" -f Makefile-native \ |
| 144 | CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \ |
| 145 | builddir="$(shell pwd)/$(OUTDIR)/$@" |
| 146 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 147 | # Test targets. |
| 148 | check: all |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 149 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame^] | 150 | --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 151 | $(TESTFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 152 | |
| 153 | $(addsuffix .check,$(MODES)): $$(basename $$@) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 154 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 155 | --mode=$(basename $@) $(TESTFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 156 | |
| 157 | $(addsuffix .check,$(ARCHES)): $$(basename $$@) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 158 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 159 | --arch=$(basename $@) $(TESTFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 160 | |
| 161 | $(CHECKS): $$(basename $$@) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 162 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 163 | --arch-and-mode=$(basename $@) $(TESTFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 164 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 165 | native.check: native |
| 166 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR)/native \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 167 | --arch-and-mode=. $(TESTFLAGS) |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 168 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 169 | # Clean targets. You can clean each architecture individually, or everything. |
| 170 | $(addsuffix .clean,$(ARCHES)): |
| 171 | rm -f $(OUTDIR)/Makefile-$(basename $@) |
| 172 | rm -rf $(OUTDIR)/$(basename $@).release |
| 173 | rm -rf $(OUTDIR)/$(basename $@).debug |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 174 | find $(OUTDIR) -regex '.*\(host\|target\)-$(basename $@)\.mk' -delete |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 175 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 176 | native.clean: |
| 177 | rm -f $(OUTDIR)/Makefile-native |
| 178 | rm -rf $(OUTDIR)/native |
| 179 | find $(OUTDIR) -regex '.*\(host\|target\)-native\.mk' -delete |
| 180 | |
| 181 | clean: $(addsuffix .clean,$(ARCHES)) native.clean |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 182 | |
| 183 | # GYP file generation targets. |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 184 | $(OUTDIR)/Makefile-ia32: $(GYPFILES) $(ENVFILE) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 185 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 186 | -Ibuild/standalone.gypi --depth=. -Dtarget_arch=ia32 \ |
| 187 | -S-ia32 $(GYPFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 188 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 189 | $(OUTDIR)/Makefile-x64: $(GYPFILES) $(ENVFILE) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 190 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 191 | -Ibuild/standalone.gypi --depth=. -Dtarget_arch=x64 \ |
| 192 | -S-x64 $(GYPFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 193 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame^] | 194 | $(OUTDIR)/Makefile-arm: $(GYPFILES) $(ENVFILE) build/armu.gypi |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 195 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 196 | -Ibuild/standalone.gypi --depth=. -Ibuild/armu.gypi \ |
| 197 | -S-arm $(GYPFLAGS) |
| 198 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame^] | 199 | $(OUTDIR)/Makefile-mips: $(GYPFILES) $(ENVFILE) build/mipsu.gypi |
| 200 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
| 201 | -Ibuild/standalone.gypi --depth=. -Ibuild/mipsu.gypi \ |
| 202 | -S-mips $(GYPFLAGS) |
| 203 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 204 | $(OUTDIR)/Makefile-native: $(GYPFILES) $(ENVFILE) |
| 205 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
| 206 | -Ibuild/standalone.gypi --depth=. -S-native $(GYPFLAGS) |
| 207 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 208 | # Replaces the old with the new environment file if they're different, which |
| 209 | # will trigger GYP to regenerate Makefiles. |
| 210 | $(ENVFILE): $(ENVFILE).new |
| 211 | @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \ |
| 212 | then rm $(ENVFILE).new; \ |
| 213 | else mv $(ENVFILE).new $(ENVFILE); fi |
| 214 | |
| 215 | # Stores current GYPFLAGS in a file. |
| 216 | $(ENVFILE).new: |
| 217 | @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 218 | |
| 219 | # Dependencies. |
| 220 | dependencies: |
| 221 | svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \ |
| 222 | --revision 1026 |