From c0e82f1e41c8d0e58307c8eaaaafd66f5dd14920 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Fri, 17 May 2013 10:54:53 -0700 Subject: [PATCH] Bug 860957 - Support for invoking non-recursive targets during partial tree builds; r=glandium --- Makefile.in | 2 + config/makefiles/nonrecursive.mk | 62 +++++++++++++++++++++++++ config/rules.mk | 5 ++ js/src/Makefile.in | 2 + js/src/config/makefiles/nonrecursive.mk | 62 +++++++++++++++++++++++++ js/src/config/rules.mk | 5 ++ 6 files changed, 138 insertions(+) create mode 100644 config/makefiles/nonrecursive.mk create mode 100644 js/src/config/makefiles/nonrecursive.mk diff --git a/Makefile.in b/Makefile.in index 5811cf5a2789..aa7d097d7bd5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,6 +17,8 @@ $(error GNU Make 3.80 or higher is required) endif endif +export TOPLEVEL_BUILD := 1 + include $(DEPTH)/config/autoconf.mk default:: diff --git a/config/makefiles/nonrecursive.mk b/config/makefiles/nonrecursive.mk new file mode 100644 index 000000000000..226c798484c4 --- /dev/null +++ b/config/makefiles/nonrecursive.mk @@ -0,0 +1,62 @@ +# -*- makefile -*- +# vim:set ts=8 sw=8 sts=8 noet: +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# The purpose of this file is to pull in non-recursive targets when performing +# a partial tree (not top-level) build. This will allow people to continue to +# build individual directories while some of the targets may not be normally +# defined in that make file. +# +# Non-recursive targets are attached to existing make targets. The +# NONRECURSIVE_TARGETS variable lists the make targets that modified. For +# each target in this list, the NONRECURSIVE_TARGET_ variable will +# contain a list of partial variable names. We will then look in variables +# named NONRECURSIVE_TARGETS___* for information describing +# how to evaluate non-recursive make targets. +# +# Targets are defined by the following variables: +# +# FILE - The make file to evaluate. +# TARGETS - Targets to evaluate in that make file. +# +# For example: +# +# NONRECURSIVE_TARGETS = export libs +# NONRECURSIVE_TARGETS_export = headers +# NONRECURSIVE_TARGETS_export_headers_FILE = /path/to/exports.mk +# NONRECURSIVE_TARGETS_export_headers_TARGETS = $(DIST)/include/foo.h $(DIST)/include/bar.h +# NONRECURSIVE_TARGETS_libs = cppsrcs +# NONRECURSIVE_TARGETS_libs_cppsrcs_FILE = /path/to/compilation.mk +# NONRECURSIVE_TARGETS_libs_cppsrcs_TARGETS = /path/to/foo.o /path/to/bar.o +# +# Will get turned into the following: +# +# exports:: +# $(MAKE) -f /path/to/exports.mk $(DIST)/include/foo.h $(DIST)/include/bar.h +# +# libs:: +# $(MAKE) -f /path/to/compilation.mk /path/to/foo.o /path/to/bar.o + +ifndef INCLUDED_NONRECURSIVE_MK + +define define_nonrecursive_target +$(1):: + cd $$(DEPTH) && $$(MAKE) -f $(2) $(3) +endef + +$(foreach target,$(NONRECURSIVE_TARGETS), \ + $(foreach entry,$(NONRECURSIVE_TARGETS_$(target)), \ + $(eval $(call define_nonrecursive_target, \ + $(target), \ + $(NONRECURSIVE_TARGETS_$(target)_$(entry)_FILE), \ + $(NONRECURSIVE_TARGETS_$(target)_$(entry)_TARGETS) \ + )) \ + ) \ +) + +INCLUDED_NONRECURSIVE_MK := 1 +endif + diff --git a/config/rules.mk b/config/rules.mk index 9584939fdeaf..a6a91d2de1be 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -1728,6 +1728,11 @@ $(foreach category,$(PP_TARGETS), \ ) \ ) +# Pull in non-recursive targets if this is a partial tree build. +ifndef TOPLEVEL_BUILD +include $(topsrcdir)/config/makefiles/nonrecursive.mk +endif + ################################################################################ # Special gmake rules. ################################################################################ diff --git a/js/src/Makefile.in b/js/src/Makefile.in index 7ef900f1715f..d9d61cafb216 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -8,6 +8,8 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ +TOPLEVEL_BUILD := 1 + run_for_side_effects := $(shell echo "MAKE: $(MAKE)") include $(DEPTH)/config/autoconf.mk diff --git a/js/src/config/makefiles/nonrecursive.mk b/js/src/config/makefiles/nonrecursive.mk new file mode 100644 index 000000000000..226c798484c4 --- /dev/null +++ b/js/src/config/makefiles/nonrecursive.mk @@ -0,0 +1,62 @@ +# -*- makefile -*- +# vim:set ts=8 sw=8 sts=8 noet: +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# The purpose of this file is to pull in non-recursive targets when performing +# a partial tree (not top-level) build. This will allow people to continue to +# build individual directories while some of the targets may not be normally +# defined in that make file. +# +# Non-recursive targets are attached to existing make targets. The +# NONRECURSIVE_TARGETS variable lists the make targets that modified. For +# each target in this list, the NONRECURSIVE_TARGET_ variable will +# contain a list of partial variable names. We will then look in variables +# named NONRECURSIVE_TARGETS___* for information describing +# how to evaluate non-recursive make targets. +# +# Targets are defined by the following variables: +# +# FILE - The make file to evaluate. +# TARGETS - Targets to evaluate in that make file. +# +# For example: +# +# NONRECURSIVE_TARGETS = export libs +# NONRECURSIVE_TARGETS_export = headers +# NONRECURSIVE_TARGETS_export_headers_FILE = /path/to/exports.mk +# NONRECURSIVE_TARGETS_export_headers_TARGETS = $(DIST)/include/foo.h $(DIST)/include/bar.h +# NONRECURSIVE_TARGETS_libs = cppsrcs +# NONRECURSIVE_TARGETS_libs_cppsrcs_FILE = /path/to/compilation.mk +# NONRECURSIVE_TARGETS_libs_cppsrcs_TARGETS = /path/to/foo.o /path/to/bar.o +# +# Will get turned into the following: +# +# exports:: +# $(MAKE) -f /path/to/exports.mk $(DIST)/include/foo.h $(DIST)/include/bar.h +# +# libs:: +# $(MAKE) -f /path/to/compilation.mk /path/to/foo.o /path/to/bar.o + +ifndef INCLUDED_NONRECURSIVE_MK + +define define_nonrecursive_target +$(1):: + cd $$(DEPTH) && $$(MAKE) -f $(2) $(3) +endef + +$(foreach target,$(NONRECURSIVE_TARGETS), \ + $(foreach entry,$(NONRECURSIVE_TARGETS_$(target)), \ + $(eval $(call define_nonrecursive_target, \ + $(target), \ + $(NONRECURSIVE_TARGETS_$(target)_$(entry)_FILE), \ + $(NONRECURSIVE_TARGETS_$(target)_$(entry)_TARGETS) \ + )) \ + ) \ +) + +INCLUDED_NONRECURSIVE_MK := 1 +endif + diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index 9584939fdeaf..a6a91d2de1be 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -1728,6 +1728,11 @@ $(foreach category,$(PP_TARGETS), \ ) \ ) +# Pull in non-recursive targets if this is a partial tree build. +ifndef TOPLEVEL_BUILD +include $(topsrcdir)/config/makefiles/nonrecursive.mk +endif + ################################################################################ # Special gmake rules. ################################################################################