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 3 # found in the LICENSE file. 4 5 # 6 # GNU Make based build file. For details on GNU Make see: 7 # http://www.gnu.org/software/make/manual/make.html 8 # 9 10 PROJECTS := \ 11 [[for project in projects:]] 12 {{project}} \ 13 [[]] 14 15 [[for dep,vals in deps.iteritems():]] 16 {{dep}}_DEPS:={{'_ALL_TARGET '.join(vals) + '_ALL_TARGET'}} 17 [[]] 18 19 HTTPD_PY := python {{rel_sdk}}/tools/httpd.py 20 21 ifeq ($(TOOLCHAIN),all) 22 TOOLCHAIN_ARG:=TOOLCHAIN=all 23 endif 24 25 # Define the default target 26 all: 27 28 # 29 # Target Macro 30 # 31 # Macro defines a phony target for each example, and adds it to a list of 32 # targets. 33 # 34 # Note: We use targets for each project (instead of an explicit recipe) so 35 # each project can be built in parallel. 36 # 37 define TARGET 38 ALL_TARGET_LIST+=$(1)_ALL_TARGET 39 .PHONY: $(1)_ALL_TARGET 40 $(1)_ALL_TARGET: $$($(1)_DEPS) 41 +$(MAKE) -C $(1) $(TOOLCHAIN_ARG) all 42 43 CLEAN_TARGET_LIST+=$(1)_CLEAN_TARGET 44 .PHONY: $(1)_CLEAN_TARGET 45 $(1)_CLEAN_TARGET: 46 +$(MAKE) -C $(1) $(TOOLCHAIN_ARG) clean 47 endef 48 49 50 # Define the various targets via the Macro 51 $(foreach proj,$(PROJECTS),$(eval $(call TARGET,$(proj)))) 52 53 .PHONY: all 54 all: $(ALL_TARGET_LIST) 55 @echo Done building targets. 56 57 .PHONY: clean 58 clean: $(CLEAN_TARGET_LIST) 59 @echo Done cleaning targets. 60 61 .PHONY: serve 62 serve: all 63 @echo Starting up python webserver. 64 @$(HTTPD_PY) 65 66 # Phony aliases for backward compatibility 67 RUN: run 68 run: serve 69 70 all_versions: 71 +$(MAKE) TOOLCHAIN=all 72 73 .PHONY: RUN all_versions 74