source: trunk/kBuild/footer-passes.kmk@ 2731

Last change on this file since 2731 was 2726, checked in by bird, 11 years ago

s/PATH_DEVTOOLS/KBUILD_DEVTOOLS/g, (c) & e-mail updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.2 KB
Line 
1# $Id: footer-passes.kmk 2726 2014-02-26 23:23:54Z bird $
2## @file
3# kBuild - Footer - Target lists - Pass 2 - Passes.
4#
5
6#
7# Copyright (c) 2004-2014 knut st. osmundsen <bird-kBuild-spam-xiv@anduin.net>
8#
9# This file is part of kBuild.
10#
11# kBuild is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version source of the License, or
14# (at your option) any later version.
15#
16# kBuild is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with kBuild; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24#
25#
26# As a special exception you are granted permission to include this file, via
27# the kmk include directive, as you wish without this in itself causing the
28# resulting makefile, program or whatever to be covered by the GPL license.
29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
33
34#
35# PASSES (including directory and makefile walking)
36#
37
38#
39# First, check whether we need to order the passes explicitly or not.
40# This depends on whether we're a leaf makefile or not. A leaf will
41# know all its dependencies, while a recursive one relies on the
42# order sub-directories and other makefiles are executed it.
43#
44
45## Setup a pass and check for optimizations.
46# @param $(PASS) Uppercase pass name.
47define def_pass_setup_and_optimize
48
49# The setup. ## @todo This is looks a bit weird...
50ifndef SUBDIRS_$(PASS)
51 SUBDIRS_$(PASS) := $(SUBDIRS) $(SUBDIRS.$(KBUILD_TARGET)) $(SUBDIRS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
52endif
53ifndef SUBDIRS_AFTER_$(PASS)
54 SUBDIRS_AFTER_$(PASS) := $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(KBUILD_TARGET)) $(SUBDIRS_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
55endif
56ifndef MAKEFILES_BEFORE_$(PASS)
57 MAKEFILES_BEFORE_$(PASS) := $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(KBUILD_TARGET)) $(MAKEFILES_BEFORE.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
58endif
59ifndef MAKEFILES_AFTER_$(PASS)
60 MAKEFILES_AFTER_$(PASS) := $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(KBUILD_TARGET)) $(MAKEFILES_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
61endif
62
63# The check.
64ifeq ($(_KBUILD_STRICT_PASS_ORDER),nonstrict)
65 ifneq ($(strip \
66 $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
67 $(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
68 $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
69 $(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
70 ),)
71 _KBUILD_STRICT_PASS_ORDER := strict
72 endif
73endif # _KBUILD_STRICT_PASS_ORDER == nonstrict
74endef # def_pass_setup_and_optimize
75$(eval-opt-var def_pass_setup_and_optimize)
76
77## PASS: Setup & optimization.
78# Check if we can apply the non-strict pass order optimzation (no SUBDIRS_* and MAKEFILES_*),
79# and set up the pass specific variables as we go along.
80_KBUILD_STRICT_PASS_ORDER := nonstrict
81$(foreach PASS, $(PASSES), $(evalval def_pass_setup_and_optimize))
82#$ (error _KBUILD_STRICT_PASS_ORDER=$(_KBUILD_STRICT_PASS_ORDER))
83
84ifeq ($(_KBUILD_STRICT_PASS_ORDER),strict)
85 if !defined(KBUILD_SAFE_PARALLEL) || "$(KMK_OPT_JOBS)" == "1"
86_KBUILD_STRICT_PASS_ORDER := strict_unsafe
87 endif
88endif
89
90
91## Subdir
92# @param $(pass) Lowercase pass name.
93# @param $(PASS) Uppercase pass name.
94# @param $(subdir) Subdirectory
95# @param $(tag) tag to attach to the rule name.
96define def_pass_subdir
97pass_$(pass)$(tag):: $(dep)
98 + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
99endef
100
101## Submakefile
102# @param $(pass) Lowercase pass name.
103# @param $(PASS) Uppercase pass name.
104# @param $(makefile) Makefile.
105# @param $(tag) tag to attach to the rule name.
106define def_pass_makefile
107pass_$(pass)$(tag):: $(dep)
108 + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
109endef
110
111## Execute a pass, strict order.
112# @param $(pass) Lowercase pass name.
113# @param $(PASS) Uppercase pass name.
114define def_pass_strict
115$(eval tag:=_before)
116$(eval dep:= )
117$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
118$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
119
120$(eval tag:=_after)
121$(eval dep:=pass_$(pass)_doit)
122$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
123$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
124
125.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
126.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
127pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
128pass_$(pass)_this: pass_$(pass)_before
129 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
130pass_$(pass)_after:: pass_$(pass)_this
131pass_$(pass): pass_$(pass)_after
132#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
133endef # def_pass_strict
134$(eval-opt-var def_pass_strict)
135
136## Execute a pass, strict order.
137# @param $(pass) Lowercase pass name.
138# @param $(PASS) Uppercase pass name.
139define def_pass_strict_unsafe
140$(eval tag:=_before)
141$(eval dep:= )
142$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
143$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
144
145$(eval tag:=_after)
146$(eval dep:=pass_$(pass)_doit)
147$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
148$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
149
150.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
151.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
152pass_$(pass)_doit: pass_$(pass)_before \
153 $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
154pass_$(pass): \
155 pass_$(pass)_before \
156 pass_$(pass)_doit \
157 pass_$(pass)_after
158#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
159endef # def_pass_strict_unsafe
160$(eval-opt-var def_pass_strict_unsafe)
161
162## Execute a pass, non-strict pass ordering.
163# @param $(pass) Lowercase pass name.
164# @param $(PASS) Uppercase pass name.
165define def_pass_nonstrict
166.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
167pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$$$$($(var)))
168pass_$(pass): pass_$(pass)_doit
169endef # def_pass_nonstrict
170
171## PASS: rules
172# Generate the rules for the defined passes.
173$(foreach PASS, $(PASSES), \
174 $(eval pass := $(PASS_$(PASS)_pass)) \
175 $(eval $(def_pass_$(_KBUILD_STRICT_PASS_ORDER))))
176
177
178## Pass order, strict.
179# @param $(pass) Current pass name.
180# @param $(prev_pass) The previous pass name.
181define def_pass_order_strict
182.PHONY: pass_$(pass)_order
183.NOTPARALLEL: pass_$(pass)_order
184pass_$(pass)_order: $(pass_prev)
185 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
186 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
187$(eval pass_prev := pass_$(pass)_order)
188endef # def_pass_order_strict
189$(eval-opt-var def_pass_order_strict)
190
191## Pass order, strict unsafe.
192# @param $(pass) Current pass name.
193# @param $(prev_pass) The previous pass name.
194define def_pass_order_strict_unsafe
195.NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
196.PHONY: pass_$(pass)_order pass_$(pass)_banner
197pass_$(pass)_banner: $(pass_prev)
198 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
199pass_$(pass)_order: $(pass_prev) \
200 pass_$(pass)_banner \
201 pass_$(pass)
202$(eval pass_prev := pass_$(pass)_order)
203endef # def_pass_order_strict_unsafe
204$(eval-opt-var def_pass_order_strict_unsafe)
205
206## Pass order, non-strict.
207# @param $(pass) Current pass name.
208# @param $(prev_pass) The previous pass name.
209define def_pass_order_nonstrict
210.PHONY: pass_$(pass)_order pass_$(pass)_banner
211pass_$(pass)_banner:
212 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
213pass_$(pass)_order: \
214 $(pass_prev) \
215 pass_$(pass)_banner \
216 pass_$(pass)
217$(eval pass_prev := pass_$(pass)_order)
218endef # def_pass_order_nonstrict
219$(eval-opt-var def_pass_order_nonstrict)
220
221## PASS: order
222# Use dependencies to ensure correct pass order.
223pass_prev :=
224$(foreach PASS,$(DEFAULT_PASSES),\
225 $(eval pass := $(PASS_$(PASS)_pass)) \
226 $(eval $(def_pass_order_$(_KBUILD_STRICT_PASS_ORDER))))
227
228ifdef KBUILD_PROFILE_SELF
229 $(evalcall def_profile_self, done passes)
230endif
231
232# Some common pass aliases
233ifndef KBUILD_NO_PASS_ALIASES
234.PHONY: clean
235clean: pass_clean
236
237.PHONY: nothing
238nothing: pass_nothing
239
240.PHONY: staging
241staging: pass_staging
242
243.PHONY: packing
244packing: pass_packing
245
246 ifndef KBUILD_NO_TESTING_PASS_ALIASES
247.PHONY: check
248check:: pass_testing
249
250.PHONY: test
251test:: pass_testing
252 endif # KBUILD_NO_TESTING_PASS_ALIASES
253endif # KBUILD_NO_PASS_ALIASES
254
255
Note: See TracBrowser for help on using the repository browser.