Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | # -*- makefile -*- |
michael@0 | 2 | # vim:set ts=8 sw=8 sts=8 noet: |
michael@0 | 3 | # |
michael@0 | 4 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 7 | |
michael@0 | 8 | # The purpose of this file is to pull in non-recursive targets when performing |
michael@0 | 9 | # a partial tree (not top-level) build. This will allow people to continue to |
michael@0 | 10 | # build individual directories while some of the targets may not be normally |
michael@0 | 11 | # defined in that make file. |
michael@0 | 12 | # |
michael@0 | 13 | # Non-recursive targets are attached to existing make targets. The |
michael@0 | 14 | # NONRECURSIVE_TARGETS variable lists the make targets that modified. For |
michael@0 | 15 | # each target in this list, the NONRECURSIVE_TARGET_<target> variable will |
michael@0 | 16 | # contain a list of partial variable names. We will then look in variables |
michael@0 | 17 | # named NONRECURSIVE_TARGETS_<target>_<fragment>_* for information describing |
michael@0 | 18 | # how to evaluate non-recursive make targets. |
michael@0 | 19 | # |
michael@0 | 20 | # Targets are defined by the following variables: |
michael@0 | 21 | # |
michael@0 | 22 | # FILE - The make file to evaluate. This is equivalent to |
michael@0 | 23 | # |make -f <FILE>| |
michael@0 | 24 | # DIRECTORY - The directory whose Makefile to evaluate. This is |
michael@0 | 25 | # equivalent to |make -C <DIRECTORY>|. |
michael@0 | 26 | # TARGETS - Targets to evaluate in that make file. |
michael@0 | 27 | # |
michael@0 | 28 | # Only 1 of FILE or DIRECTORY may be defined. |
michael@0 | 29 | # |
michael@0 | 30 | # For example: |
michael@0 | 31 | # |
michael@0 | 32 | # NONRECURSIVE_TARGETS = export libs |
michael@0 | 33 | # NONRECURSIVE_TARGETS_export = headers |
michael@0 | 34 | # NONRECURSIVE_TARGETS_export_headers_FILE = /path/to/exports.mk |
michael@0 | 35 | # NONRECURSIVE_TARGETS_export_headers_TARGETS = $(DIST)/include/foo.h $(DIST)/include/bar.h |
michael@0 | 36 | # NONRECURSIVE_TARGETS_libs = cppsrcs |
michael@0 | 37 | # NONRECURSIVE_TARGETS_libs_cppsrcs_DIRECTORY = $(DEPTH)/foo |
michael@0 | 38 | # NONRECURSIVE_TARGETS_libs_cppsrcs_TARGETS = /path/to/foo.o /path/to/bar.o |
michael@0 | 39 | # |
michael@0 | 40 | # Will get turned into the following: |
michael@0 | 41 | # |
michael@0 | 42 | # exports:: |
michael@0 | 43 | # $(MAKE) -C $(DEPTH) -f /path/to/exports.mk $(DIST)/include/foo.h $(DIST)/include/bar.h |
michael@0 | 44 | # |
michael@0 | 45 | # libs:: |
michael@0 | 46 | # $(MAKE) -C $(DEPTH)/foo /path/to/foo.o /path/to/bar.o |
michael@0 | 47 | |
michael@0 | 48 | ifndef INCLUDED_NONRECURSIVE_MK |
michael@0 | 49 | |
michael@0 | 50 | define define_nonrecursive_target |
michael@0 | 51 | $(1):: |
michael@0 | 52 | $$(MAKE) -C $(or $(4),$$(DEPTH)) $(addprefix -f ,$(3)) $(2) |
michael@0 | 53 | endef |
michael@0 | 54 | |
michael@0 | 55 | $(foreach target,$(NONRECURSIVE_TARGETS), \ |
michael@0 | 56 | $(foreach entry,$(NONRECURSIVE_TARGETS_$(target)), \ |
michael@0 | 57 | $(eval $(call define_nonrecursive_target, \ |
michael@0 | 58 | $(target), \ |
michael@0 | 59 | $(NONRECURSIVE_TARGETS_$(target)_$(entry)_TARGETS), \ |
michael@0 | 60 | $(NONRECURSIVE_TARGETS_$(target)_$(entry)_FILE), \ |
michael@0 | 61 | $(NONRECURSIVE_TARGETS_$(target)_$(entry)_DIRECTORY), \ |
michael@0 | 62 | )) \ |
michael@0 | 63 | ) \ |
michael@0 | 64 | ) |
michael@0 | 65 | |
michael@0 | 66 | INCLUDED_NONRECURSIVE_MK := 1 |
michael@0 | 67 | endif |
michael@0 | 68 |