config/makefiles/nonrecursive.mk

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/config/makefiles/nonrecursive.mk	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +# -*- makefile -*-
     1.5 +# vim:set ts=8 sw=8 sts=8 noet:
     1.6 +#
     1.7 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.8 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
    1.10 +
    1.11 +# The purpose of this file is to pull in non-recursive targets when performing
    1.12 +# a partial tree (not top-level) build. This will allow people to continue to
    1.13 +# build individual directories while some of the targets may not be normally
    1.14 +# defined in that make file.
    1.15 +#
    1.16 +# Non-recursive targets are attached to existing make targets. The
    1.17 +# NONRECURSIVE_TARGETS variable lists the make targets that modified. For
    1.18 +# each target in this list, the NONRECURSIVE_TARGET_<target> variable will
    1.19 +# contain a list of partial variable names. We will then look in variables
    1.20 +# named NONRECURSIVE_TARGETS_<target>_<fragment>_* for information describing
    1.21 +# how to evaluate non-recursive make targets.
    1.22 +#
    1.23 +# Targets are defined by the following variables:
    1.24 +#
    1.25 +#   FILE - The make file to evaluate. This is equivalent to
    1.26 +#      |make -f <FILE>|
    1.27 +#   DIRECTORY - The directory whose Makefile to evaluate. This is
    1.28 +#      equivalent to |make -C <DIRECTORY>|.
    1.29 +#   TARGETS - Targets to evaluate in that make file.
    1.30 +#
    1.31 +# Only 1 of FILE or DIRECTORY may be defined.
    1.32 +#
    1.33 +# For example:
    1.34 +#
    1.35 +# NONRECURSIVE_TARGETS = export libs
    1.36 +# NONRECURSIVE_TARGETS_export = headers
    1.37 +# NONRECURSIVE_TARGETS_export_headers_FILE = /path/to/exports.mk
    1.38 +# NONRECURSIVE_TARGETS_export_headers_TARGETS = $(DIST)/include/foo.h $(DIST)/include/bar.h
    1.39 +# NONRECURSIVE_TARGETS_libs = cppsrcs
    1.40 +# NONRECURSIVE_TARGETS_libs_cppsrcs_DIRECTORY = $(DEPTH)/foo
    1.41 +# NONRECURSIVE_TARGETS_libs_cppsrcs_TARGETS = /path/to/foo.o /path/to/bar.o
    1.42 +#
    1.43 +# Will get turned into the following:
    1.44 +#
    1.45 +# exports::
    1.46 +#     $(MAKE) -C $(DEPTH) -f /path/to/exports.mk $(DIST)/include/foo.h $(DIST)/include/bar.h
    1.47 +#
    1.48 +# libs::
    1.49 +#     $(MAKE) -C $(DEPTH)/foo /path/to/foo.o /path/to/bar.o
    1.50 +
    1.51 +ifndef INCLUDED_NONRECURSIVE_MK
    1.52 +
    1.53 +define define_nonrecursive_target
    1.54 +$(1)::
    1.55 +	$$(MAKE) -C $(or $(4),$$(DEPTH)) $(addprefix -f ,$(3)) $(2)
    1.56 +endef
    1.57 +
    1.58 +$(foreach target,$(NONRECURSIVE_TARGETS), \
    1.59 +    $(foreach entry,$(NONRECURSIVE_TARGETS_$(target)), \
    1.60 +        $(eval $(call define_nonrecursive_target, \
    1.61 +            $(target), \
    1.62 +            $(NONRECURSIVE_TARGETS_$(target)_$(entry)_TARGETS), \
    1.63 +            $(NONRECURSIVE_TARGETS_$(target)_$(entry)_FILE), \
    1.64 +            $(NONRECURSIVE_TARGETS_$(target)_$(entry)_DIRECTORY), \
    1.65 +        )) \
    1.66 +    ) \
    1.67 +)
    1.68 +
    1.69 +INCLUDED_NONRECURSIVE_MK := 1
    1.70 +endif
    1.71 +

mercurial