OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # | 5 # |
6 # GNU Make based build file. For details on GNU Make see: | 6 # GNU Make based build file. For details on GNU Make see: |
7 # http://www.gnu.org/software/make/manual/make.html | 7 # http://www.gnu.org/software/make/manual/make.html |
8 # | 8 # |
9 # | 9 # |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 # | 121 # |
122 # We use the C++ compiler for everything and then use the -Wl,-as-needed flag | 122 # We use the C++ compiler for everything and then use the -Wl,-as-needed flag |
123 # in the linker to drop libc++ unless it's actually needed. | 123 # in the linker to drop libc++ unless it's actually needed. |
124 # | 124 # |
125 X86_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++ | 125 X86_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++ |
126 X86_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++ -Wl,-as-needed | 126 X86_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/bin/i686-nacl-g++ -Wl,-as-needed |
127 | 127 |
128 ARM_CXX?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++ | 128 ARM_CXX?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++ |
129 ARM_LINK?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++ -Wl,-as-needed | 129 ARM_LINK?=$(TC_PATH)/$(OSNAME)_arm_$(TOOLCHAIN)/bin/arm-nacl-g++ -Wl,-as-needed |
130 | 130 |
131 PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++ -c | |
132 PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_$(TOOLCHAIN)/newlib/bin/pnacl-clang++ | |
133 | |
131 | 134 |
132 # | 135 # |
133 # Rules for output directories. | 136 # Rules for output directories. |
134 # | 137 # |
135 # Output will be places in a directory name based on Toolchain and configuration | 138 # Output will be places in a directory name based on Toolchain and configuration |
136 # be default this will be "newlib/Debug". We use a python wrapped MKDIR to | 139 # be default this will be "newlib/Debug". We use a python wrapped MKDIR to |
137 # proivde a cross platform solution. The use of '|' checks for existance instead | 140 # proivde a cross platform solution. The use of '|' checks for existance instead |
138 # of timestamp, since the directory can update when files change. | 141 # of timestamp, since the directory can update when files change. |
139 # | 142 # |
140 $(TOOLCHAIN): | 143 $(TOOLCHAIN): |
141 $(MKDIR) $(TOOLCHAIN) | 144 $(MKDIR) $(TOOLCHAIN) |
142 | 145 |
143 $(TOOLCHAIN)/$(CONFIG): | $(TOOLCHAIN) | 146 $(TOOLCHAIN)/$(CONFIG): | $(TOOLCHAIN) |
144 $(MKDIR) $(TOOLCHAIN)/$(CONFIG) | 147 $(MKDIR) $(TOOLCHAIN)/$(CONFIG) |
145 | 148 |
146 OUTDIR:=$(TOOLCHAIN)/$(CONFIG) | 149 OUTDIR:=$(TOOLCHAIN)/$(CONFIG) |
147 | 150 |
148 | 151 |
149 # | 152 # |
153 # Dependency Macro | |
154 # | |
155 # $1 = Name of dependency | |
156 # | |
157 define DEPEND_RULE | |
158 .PHONY: $(1) | |
159 $(1): | |
160 +$(MAKE) -C $(NACL_SDK_ROOT)/src/$(1) | |
161 DEPS_LIST+=$(1) | |
162 endef | |
163 | |
164 # | |
150 # Compile Macro | 165 # Compile Macro |
151 # | 166 # |
152 # $1 = Source Name | 167 # $1 = Source Name |
153 # | 168 # |
154 # By default, if $(1) = source.c, this rule expands to: | 169 # By default, if $(1) = source.c, this rule expands to: |
155 # newlib/Debug/source_x86_32.o : souce.c Makefile | newlib/Debug | 170 # newlib/Debug/source_x86_32.o : souce.c Makefile | newlib/Debug |
156 # | 171 # |
157 # Which means if 'source.c' or Makefile are newer than the object | 172 # Which means if 'source.c' or Makefile are newer than the object |
158 # newlib/Debug/source_x86_32.o, then run the step: | 173 # newlib/Debug/source_x86_32.o, then run the step: |
159 # $(X86_CC) -o newlib/Debug/source_x86_32.o -c source.c .... | 174 # $(X86_CC) -o newlib/Debug/source_x86_32.o -c source.c .... |
160 # | 175 # |
161 # We repeat this expansion for 64 bit X86 and conditionally for ARM if | 176 # We repeat this expansion for 64 bit X86 and conditionally for ARM if |
162 # TOOLCHAIN=newlib | 177 # TOOLCHAIN=newlib |
163 # | 178 # |
164 define COMPILE_RULE | 179 define COMPILE_RULE |
165 $(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(THIS_MAKE) | $(OUTDIR) | 180 $(OUTDIR)/$(basename $(1))_x86_32.o : $(1) $(THIS_MAKE) | $(OUTDIR) |
166 $(X86_CXX) -o $$@ -c $$< -m32 $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS) | 181 $(X86_CXX) -o $$@ -c $$< -m32 $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS) |
167 | 182 |
168 $(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(THIS_MAKE) | $(OUTDIR) | 183 $(OUTDIR)/$(basename $(1))_x86_64.o : $(1) $(THIS_MAKE) | $(OUTDIR) |
169 $(X86_CXX) -o $$@ -c $$< -m64 $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS) | 184 $(X86_CXX) -o $$@ -c $$< -m64 $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS) |
170 | 185 |
171 $(OUTDIR)/$(basename $(1))_arm.o : $(1) $(THIS_MAKE) | $(OUTDIR) | 186 $(OUTDIR)/$(basename $(1))_arm.o : $(1) $(THIS_MAKE) | $(OUTDIR) |
172 $(ARM_CXX) -o $$@ -c $$< $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS) | 187 $(ARM_CXX) -o $$@ -c $$< $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS) |
188 | |
189 $(OUTDIR)/$(basename $(1))_pnacl.o : $(1) $(THIS_MAKE) | $(OUTDIR) | |
190 $(PNACL_CXX) -o $$@ -c $$< $(OPT_FLAGS) $(CXX_FLAGS) $(NACL_WARNINGS) | |
173 endef | 191 endef |
174 | 192 |
175 | 193 |
176 # | 194 # |
177 # Link Macro | 195 # Link Macro |
178 # | 196 # |
179 # $1 = Target Name | 197 # $1 = Target Name |
180 # $2 = List of Sources | 198 # $2 = List of Sources |
181 # | 199 # |
182 # By default, if $(1) = foo $(2) = A.c B.cc, this rule expands to: | 200 # By default, if $(1) = foo $(2) = A.c B.cc, this rule expands to: |
(...skipping 15 matching lines...) Expand all Loading... | |
198 $(OUTDIR)/$(1)_x86_32.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86 _32.o) | 216 $(OUTDIR)/$(1)_x86_32.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86 _32.o) |
199 $(X86_LINK) -o $$@ $$^ -m32 $(LD_X86_32) $(LD_FLAGS) $(foreach lib,$(LIB S),-l$(lib)) | 217 $(X86_LINK) -o $$@ $$^ -m32 $(LD_X86_32) $(LD_FLAGS) $(foreach lib,$(LIB S),-l$(lib)) |
200 | 218 |
201 NMF_TARGETS+=$(OUTDIR)/$(1)_x86_64.nexe | 219 NMF_TARGETS+=$(OUTDIR)/$(1)_x86_64.nexe |
202 $(OUTDIR)/$(1)_x86_64.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86 _64.o) | 220 $(OUTDIR)/$(1)_x86_64.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_x86 _64.o) |
203 $(X86_LINK) -o $$@ $$^ -m64 $(LD_X86_64) $(LD_FLAGS) $(foreach lib,$(LIB S),-l$(lib)) | 221 $(X86_LINK) -o $$@ $$^ -m64 $(LD_X86_64) $(LD_FLAGS) $(foreach lib,$(LIB S),-l$(lib)) |
204 | 222 |
205 NMF_TARGETS+=$(OUTDIR)/$(1)_arm.nexe | 223 NMF_TARGETS+=$(OUTDIR)/$(1)_arm.nexe |
206 $(OUTDIR)/$(1)_arm.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_arm.o) | 224 $(OUTDIR)/$(1)_arm.nexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_arm.o) |
207 $(ARM_LINK) -o $$@ $$^ $(LD_ARM) $(LD_FLAGS) $(foreach lib,$(LIBS),-l$(l ib)) | 225 $(ARM_LINK) -o $$@ $$^ $(LD_ARM) $(LD_FLAGS) $(foreach lib,$(LIBS),-l$(l ib)) |
226 | |
227 NMF_TARGETS+=$(OUTDIR)/$(1).pexe | |
228 $(OUTDIR)/$(1).pexe : $(foreach src,$(2),$(OUTDIR)/$(basename $(src))_pnacl.o) | |
229 $(PNACL_LINK) -o $$@ $$^ $(LD_PNACL) $(LD_FLAGS) $(foreach lib,$(LIBS),- l$(lib)) | |
208 endef | 230 endef |
209 | 231 |
210 | 232 |
233 | |
211 # | 234 # |
212 # Generate NMF_TARGETS | 235 # Generate NMF_TARGETS |
213 # | 236 # |
214 ARCHES=x86_32 x86_64 | 237 ARCHES=x86_32 x86_64 |
215 ifeq "newlib" "$(TOOLCHAIN)" | 238 ifeq "newlib" "$(TOOLCHAIN)" |
216 ARCHES+=arm | 239 ARCHES+=arm |
217 endif | 240 endif |
241 NMF_ARCHES:=$(foreach arch,$(ARCHES),_$(arch).nexe) | |
242 | |
243 ifeq "pnacl" "$(TOOLCHAIN)" | |
244 NMF_ARCHES:=.pexe | |
245 endif | |
218 | 246 |
219 | 247 |
220 # | 248 # |
221 # NMF Manifiest generation | 249 # NMF Manifiest generation |
222 # | 250 # |
223 # Use the python script create_nmf to scan the binaries for dependencies using | 251 # Use the python script create_nmf to scan the binaries for dependencies using |
224 # objdump. Pass in the (-L) paths to the default library toolchains so that we | 252 # objdump. Pass in the (-L) paths to the default library toolchains so that we |
225 # can find those libraries and have it automatically copy the files (-s) to | 253 # can find those libraries and have it automatically copy the files (-s) to |
226 # the target directory for us. | 254 # the target directory for us. |
227 # | 255 # |
228 # $1 = Target Name (the basename of the nmf | 256 # $1 = Target Name (the basename of the nmf |
229 # $2 = Additional create_nmf.py arguments | 257 # $2 = Additional create_nmf.py arguments |
230 # | 258 # |
231 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py | 259 NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py |
232 GLIBC_DUMP:=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump | 260 GLIBC_DUMP:=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump |
233 GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32 | 261 GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32 |
234 GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib | 262 GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib |
235 | 263 |
236 define NMF_RULE | 264 define NMF_RULE |
237 $(OUTDIR)/$(1).nmf : $(foreach arch,$(ARCHES),$(OUTDIR)/$(1)_$(arch).nexe) | 265 $(OUTDIR)/$(1).nmf : $(foreach arch,$(NMF_ARCHES),$(OUTDIR)/$(1)$(arch)) |
238 » $(NMF) -o $$@ $$^ -D $(GLIBC_DUMP) $(GLIBC_PATHS) $(2) | 266 » $(NMF) -o $$@ $$^ -D $(GLIBC_DUMP) $(GLIBC_PATHS) -s $(OUTDIR) $(2) |
239 | 267 |
240 all : $(OUTDIR)/$(1).nmf | 268 all : $(DEPS_LIST) $(OUTDIR)/$(1).nmf |
241 endef | 269 endef |
242 | 270 |
271 | |
272 # | |
273 # Verify we can find the Chrome executable if we need to launch it. | |
274 # | |
275 .PHONY: CHECK_FOR_CHROME RUN LAUNCH | |
276 CHECK_FOR_CHROME: | |
277 ifeq (,$(wildcard $(CHROME_PATH))) | |
278 $(warning No valid Chrome found at CHROME_PATH=$(CHROME_PATH)) | |
binji
2013/01/02 21:02:26
tabs...? Actually, most of this seems to be untabb
noelallen1
2013/01/07 20:01:30
Strange, should be tabs. It's a tab in my source.
| |
279 $(error Set CHROME_PATH via an environment variable, or command-line.) | |
280 else | |
281 $(warning Using chrome at: $(CHROME_PATH)) | |
282 endif | |
283 | |
284 | |
285 # | |
286 # Variables for running examples with Chrome. | |
287 # | |
288 RUN_PY:=python $(NACL_SDK_ROOT)/tools/run.py | |
289 | |
290 # Add this to launch Chrome with additional environment variables defined. | |
291 # Each element should be specified as KEY=VALUE, with whitespace separating | |
292 # key-value pairs. e.g. | |
293 # CHROME_ENV=FOO=1 BAR=2 BAZ=3 | |
294 CHROME_ENV?= | |
295 | |
296 # Additional arguments to pass to Chrome. | |
297 CHROME_ARGS+=--enable-nacl --enable-pnacl --incognito --ppapi-out-of-process | |
binji
2013/01/02 21:02:26
I'm starting to wonder about --incognito, actually
noelallen1
2013/01/07 20:01:30
Good question. A "temp" user-data-dir might work
| |
298 | |
299 | |
300 CONFIG?=Debug | |
301 PAGE?=index_$(TOOLCHAIN)_$(CONFIG).html | |
302 | |
303 RUN: LAUNCH | |
304 LAUNCH: CHECK_FOR_CHROME all | |
305 ifeq (,$(wildcard $(PAGE))) | |
306 $(warning No valid HTML page found at $(PAGE)) | |
307 $(error Make sure TOOLCHAIN and CONFIG are properly set) | |
308 endif | |
309 $(RUN_PY) -C $(THIS_DIR) -P $(PAGE) $(addprefix -E ,$(CHROME_ENV)) -- \ | |
310 $(CHROME_PATH) $(CHROME_ARGS) \ | |
311 --register-pepper-plugins="$(PPAPI_DEBUG),$(PPAPI_RELEASE)" | |
312 | |
OLD | NEW |