Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: native_client_sdk/src/tools/common.mk

Issue 12395032: [NaCl SDK] Handle sources outside root in example build system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 11 matching lines...) Expand all
22 # 22 #
23 # Top Make file, which we want to trigger a rebuild on if it changes 23 # Top Make file, which we want to trigger a rebuild on if it changes
24 # 24 #
25 TOP_MAKE:=$(word 1,$(MAKEFILE_LIST)) 25 TOP_MAKE:=$(word 1,$(MAKEFILE_LIST))
26 26
27 27
28 # 28 #
29 # Verify we selected a valid toolchain for this example 29 # Verify we selected a valid toolchain for this example
30 # 30 #
31 ifeq (,$(findstring $(TOOLCHAIN),$(VALID_TOOLCHAINS))) 31 ifeq (,$(findstring $(TOOLCHAIN),$(VALID_TOOLCHAINS)))
32 $(warning Availbile choices are: $(VALID_TOOLCHAINS)) 32 $(warning Availbile choices are: $(VALID_TOOLCHAINS))
33 $(error Can not use TOOLCHAIN=$(TOOLCHAIN) on this example.) 33 $(error Can not use TOOLCHAIN=$(TOOLCHAIN) on this example.)
34 endif 34 endif
35 35
36 36
37 # 37 #
38 # Build Configuration 38 # Build Configuration
39 # 39 #
40 # The SDK provides two sets of libraries, Debug and Release. Debug libraries 40 # The SDK provides two sets of libraries, Debug and Release. Debug libraries
41 # are compiled without optimizations to make debugging easier. By default 41 # are compiled without optimizations to make debugging easier. By default
42 # this will build a Debug configuration. 42 # this will build a Debug configuration.
43 # 43 #
44 CONFIG?=Debug 44 CONFIG?=Debug
45 45
46 46
47
48 # Note for Windows: 47 # Note for Windows:
49 # Both GCC and LLVM bases tools (include the version of Make.exe that comes 48 # The GCC and LLVM toolchains (include the version of Make.exe that comes
50 # with the SDK) both expect and are capable of dealing with the '/' seperator. 49 # with the SDK) expect and are capable of dealing with the '/' seperator.
51 # For that reason, the tools in the SDK, including build, compilers, scripts 50 # For this reason, the tools in the SDK, including Makefiles and build scripts
52 # all have a preference for POSIX style command-line arguments. 51 # have a preference for POSIX style command-line arguments.
53 # 52 #
54 # Keep in mind however that the shell is responsible for command-line escaping, 53 # Keep in mind however that the shell is responsible for command-line escaping,
55 # globbing, and variable expansion, so those may change based on which shell 54 # globbing, and variable expansion, so those may change based on which shell
56 # is used. For Cygwin shells this can include automatic and incorrect expansion 55 # is used. For Cygwin shells this can include automatic and incorrect expansion
57 # of response files (files starting with '@'). 56 # of response files (files starting with '@').
58 # 57 #
59 # Disable DOS PATH warning when using Cygwin based NaCl tools on Windows. 58 # Disable DOS PATH warning when using Cygwin based NaCl tools on Windows.
60 # 59 #
61 CYGWIN?=nodosfilewarning 60 ifeq ($(OSNAME),win)
62 export CYGWIN 61 CYGWIN?=nodosfilewarning
62 export CYGWIN
63 endif
63 64
64 65
65 # 66 #
66 # If NACL_SDK_ROOT is not already set, then set it relative to this makefile. 67 # If NACL_SDK_ROOT is not already set, then set it relative to this makefile.
67 # 68 #
68 THIS_MAKEFILE:=$(CURDIR)/$(lastword $(MAKEFILE_LIST)) 69 THIS_MAKEFILE:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
69 ifndef NACL_SDK_ROOT 70 NACL_SDK_ROOT?=$(realpath $(dir $(THIS_MAKEFILE))/..)
70 NACL_SDK_ROOT:=$(realpath $(dir $(THIS_MAKEFILE))/..)
71 endif
72 71
73 72
74 # 73 #
75 # Check that NACL_SDK_ROOT is set to a valid location. 74 # Check that NACL_SDK_ROOT is set to a valid location.
76 # We use the existence of tools/oshelpers.py to verify the validity of the SDK 75 # We use the existence of tools/oshelpers.py to verify the validity of the SDK
77 # root. 76 # root.
78 # 77 #
79 ifeq (,$(wildcard $(NACL_SDK_ROOT)/tools/oshelpers.py)) 78 ifeq (,$(wildcard $(NACL_SDK_ROOT)/tools/oshelpers.py))
80 $(error NACL_SDK_ROOT is set to an invalid location: $(NACL_SDK_ROOT)) 79 $(error NACL_SDK_ROOT is set to an invalid location: $(NACL_SDK_ROOT))
81 endif 80 endif
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 +$(MAKE) TOOLCHAIN=$(1) 152 +$(MAKE) TOOLCHAIN=$(1)
154 TOOLCHAIN_LIST+=all_$(1) 153 TOOLCHAIN_LIST+=all_$(1)
155 endef 154 endef
156 155
157 156
158 # 157 #
159 # The target for all versions 158 # The target for all versions
160 # 159 #
161 USABLE_TOOLCHAINS=$(filter $(OSNAME) newlib glibc pnacl,$(VALID_TOOLCHAINS)) 160 USABLE_TOOLCHAINS=$(filter $(OSNAME) newlib glibc pnacl,$(VALID_TOOLCHAINS))
162 161
163 ifeq (1,$(NO_HOST_BUILDS)) 162 ifeq ($(NO_HOST_BUILDS),1)
164 USABLE_TOOLCHAINS:=$(filter-out $(OSNAME),$(USABLE_TOOLCHAINS)) 163 USABLE_TOOLCHAINS:=$(filter-out $(OSNAME),$(USABLE_TOOLCHAINS))
165 endif 164 endif
166 165
167 $(foreach tool,$(USABLE_TOOLCHAINS),$(eval $(call TOOLCHAIN_RULE,$(tool),$(dep)) )) 166 $(foreach tool,$(USABLE_TOOLCHAINS),$(eval $(call TOOLCHAIN_RULE,$(tool),$(dep)) ))
168 167
169 .PHONY: all_versions 168 .PHONY: all_versions
170 all_versions: $(TOOLCHAIN_LIST) 169 all_versions: $(TOOLCHAIN_LIST)
171 170
172 171
173 OUTBASE?=. 172 OUTBASE?=.
(...skipping 24 matching lines...) Expand all
198 197
199 198
200 # 199 #
201 # Dependency Macro 200 # Dependency Macro
202 # 201 #
203 # $1 = Name of stamp 202 # $1 = Name of stamp
204 # $2 = Directory for the sub-make 203 # $2 = Directory for the sub-make
205 # $3 = Extra Settings 204 # $3 = Extra Settings
206 # 205 #
207 define DEPEND_RULE 206 define DEPEND_RULE
208 ifeq (,$(IGNORE_DEPS)) 207 ifndef $(IGNORE_DEPS)
209 .PHONY : rebuild_$(1) 208 .PHONY : rebuild_$(1)
210 209
211 rebuild_$(1) :| $(STAMPDIR)/dir.stamp 210 rebuild_$(1) :| $(STAMPDIR)/dir.stamp
212 ifeq (,$(2)) 211 ifeq (,$(2))
213 +$(MAKE) -C $(NACL_SDK_ROOT)/src/$(1) STAMPDIR=$(abspath $(STAMPDIR)) $( abspath $(STAMPDIR)/$(1).stamp) $(3) 212 +$(MAKE) -C $(NACL_SDK_ROOT)/src/$(1) STAMPDIR=$(abspath $(STAMPDIR)) $( abspath $(STAMPDIR)/$(1).stamp) $(3)
214 else 213 else
215 +$(MAKE) -C $(2) STAMPDIR=$(abspath $(STAMPDIR)) $(abspath $(STAMPDIR)/$ (1).stamp) $(3) 214 +$(MAKE) -C $(2) STAMPDIR=$(abspath $(STAMPDIR)) $(abspath $(STAMPDIR)/$ (1).stamp) $(3)
216 endif 215 endif
217 216
218 all: rebuild_$(1) 217 all: rebuild_$(1)
219 $(STAMPDIR)/$(1).stamp : rebuild_$(1) 218 $(STAMPDIR)/$(1).stamp : rebuild_$(1)
220 219
221 else 220 else
222 221
223 .PHONY : $(STAMPDIR)/$(1).stamp 222 .PHONY : $(STAMPDIR)/$(1).stamp
224 $(STAMPDIR)/$(1).stamp : 223 $(STAMPDIR)/$(1).stamp :
225 @echo Ignore $(1) 224 @echo Ignore $(1)
226 endif 225 endif
227 endef 226 endef
228 227
229 228
230 229 ifeq ($(TOOLCHAIN),win)
231 ifeq ('win','$(TOOLCHAIN)')
232 HOST_EXT=.dll 230 HOST_EXT=.dll
233 else 231 else
234 HOST_EXT=.so 232 HOST_EXT=.so
235 endif 233 endif
236 234
237 235
238 # 236 #
239 # Common Compile Options 237 # Common Compile Options
240 # 238 #
241 ifeq ('Release','$(CONFIG)') 239 ifeq ($(CONFIG),Release)
242 POSIX_FLAGS?=-g -O2 -pthread -MMD 240 POSIX_FLAGS?=-g -O2 -pthread -MMD
243 else 241 else
244 POSIX_FLAGS?=-g -O0 -pthread -MMD 242 POSIX_FLAGS?=-g -O0 -pthread -MMD
245 endif 243 endif
246 244
247 NACL_CFLAGS?=-Wno-long-long -Werror 245 NACL_CFLAGS?=-Wno-long-long -Werror
248 NACL_CXXFLAGS?=-Wno-long-long -Werror 246 NACL_CXXFLAGS?=-Wno-long-long -Werror
249 NACL_LDFLAGS?=-Wl,-as-needed 247 NACL_LDFLAGS?=-Wl,-as-needed
250 248
251 # 249 #
(...skipping 29 matching lines...) Expand all
281 endef 279 endef
282 else 280 else
283 define LOG 281 define LOG
284 @echo " $(1) $(2)" && $(3) 282 @echo " $(1) $(2)" && $(3)
285 endef 283 endef
286 endif 284 endif
287 endif 285 endif
288 286
289 287
290 # 288 #
289 # Convert a source path to a object file path.
290 #
291 # $1 = Source Name
292 # $2 = Arch suffix
293 #
294 define SRC_TO_OBJ
295 $(OUTDIR)/$(basename $(subst ..,__,$(1)))$(2).o
296 endef
297
298
299 #
300 # Convert a source path to a dependency file path.
301 #
302 # $1 = Source Name
303 # $2 = Arch suffix
304 #
305 define SRC_TO_DEP
306 $(patsubst %.o,%.d,$(call SRC_TO_OBJ,$(1),$(2)))
307 endef
308
309
310 #
291 # If the requested toolchain is a NaCl or PNaCl toolchain, the use the 311 # If the requested toolchain is a NaCl or PNaCl toolchain, the use the
292 # macros and targets defined in nacl.mk, otherwise use the host sepecific 312 # macros and targets defined in nacl.mk, otherwise use the host sepecific
293 # macros and targets. 313 # macros and targets.
294 # 314 #
295 ifneq (,$(findstring $(TOOLCHAIN),linux mac)) 315 ifneq (,$(findstring $(TOOLCHAIN),linux mac))
296 include $(NACL_SDK_ROOT)/tools/host_gcc.mk 316 include $(NACL_SDK_ROOT)/tools/host_gcc.mk
297 endif 317 endif
298 318
299 ifneq (,$(findstring $(TOOLCHAIN),win)) 319 ifneq (,$(findstring $(TOOLCHAIN),win))
300 include $(NACL_SDK_ROOT)/tools/host_vc.mk 320 include $(NACL_SDK_ROOT)/tools/host_vc.mk
(...skipping 12 matching lines...) Expand all
313 # 333 #
314 ifeq ($(OSNAME),win) 334 ifeq ($(OSNAME),win)
315 DEV_NULL=nul 335 DEV_NULL=nul
316 else 336 else
317 DEV_NULL=/dev/null 337 DEV_NULL=/dev/null
318 endif 338 endif
319 339
320 # 340 #
321 # Assign a sensible default to CHROME_PATH. 341 # Assign a sensible default to CHROME_PATH.
322 # 342 #
323 ifndef CHROME_PATH 343 CHROME_PATH?=$(shell python $(NACL_SDK_ROOT)/tools/getos.py --chrome 2> $(DEV_NU LL))
324 CHROME_PATH:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py --chrome 2> $(DEV_NU LL))
325 endif
326 344
327 # 345 #
328 # Verify we can find the Chrome executable if we need to launch it. 346 # Verify we can find the Chrome executable if we need to launch it.
329 # 347 #
330 CHECK_FOR_CHROME: 348 CHECK_FOR_CHROME:
331 ifeq (,$(wildcard $(CHROME_PATH))) 349 ifeq (,$(wildcard $(CHROME_PATH)))
332 $(warning No valid Chrome found at CHROME_PATH=$(CHROME_PATH)) 350 $(warning No valid Chrome found at CHROME_PATH=$(CHROME_PATH))
333 $(error Set CHROME_PATH via an environment variable, or command-line.) 351 $(error Set CHROME_PATH via an environment variable, or command-line.)
334 else 352 else
335 $(warning Using chrome at: $(CHROME_PATH)) 353 $(warning Using chrome at: $(CHROME_PATH))
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 GDB_ARGS+=-D $(abspath $(OUTDIR))/$(TARGET)_$(SYSARCH).nexe 392 GDB_ARGS+=-D $(abspath $(OUTDIR))/$(TARGET)_$(SYSARCH).nexe
375 393
376 DEBUG: CHECK_FOR_CHROME all 394 DEBUG: CHECK_FOR_CHROME all
377 $(RUN_PY) $(GDB_ARGS) \ 395 $(RUN_PY) $(GDB_ARGS) \
378 -C $(CURDIR) -P $(PAGE_TC_CONFIG) \ 396 -C $(CURDIR) -P $(PAGE_TC_CONFIG) \
379 $(addprefix -E ,$(CHROME_ENV)) -- $(CHROME_PATH) $(CHROME_ARGS) \ 397 $(addprefix -E ,$(CHROME_ENV)) -- $(CHROME_PATH) $(CHROME_ARGS) \
380 --enable-nacl-debug \ 398 --enable-nacl-debug \
381 --register-pepper-plugins="$(PPAPI_DEBUG),$(PPAPI_RELEASE)" 399 --register-pepper-plugins="$(PPAPI_DEBUG),$(PPAPI_RELEASE)"
382 400
383 .PHONY: CHECK_FOR_CHROME RUN LAUNCH 401 .PHONY: CHECK_FOR_CHROME RUN LAUNCH
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/tools/host_gcc.mk » ('j') | native_client_sdk/src/tools/nacl_gcc.mk » ('J')

Powered by Google App Engine
This is Rietveld 408576698