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

Last change on this file since 2803 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
RevLine 
[72]1# $Id: footer-passes.kmk 2726 2014-02-26 23:23:54Z bird $
2## @file
[2521]3# kBuild - Footer - Target lists - Pass 2 - Passes.
[72]4#
[1547]5
6#
[2726]7# Copyright (c) 2004-2014 knut st. osmundsen <bird-kBuild-spam-xiv@anduin.net>
[72]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
[106]13# the Free Software Foundation; either version source of the License, or
[72]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
[353]23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[72]24#
25#
[1547]26# As a special exception you are granted permission to include this file, via
[1599]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.
[1547]29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
[72]33
34#
[353]35# PASSES (including directory and makefile walking)
36#
[221]37
[1667]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)
[2389]51 SUBDIRS_$(PASS) := $(SUBDIRS) $(SUBDIRS.$(KBUILD_TARGET)) $(SUBDIRS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
[1667]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
[1936]75$(eval-opt-var def_pass_setup_and_optimize)
[1667]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
[2058]84ifeq ($(_KBUILD_STRICT_PASS_ORDER),strict)
[2059]85 if !defined(KBUILD_SAFE_PARALLEL) || "$(KMK_OPT_JOBS)" == "1"
[2058]86_KBUILD_STRICT_PASS_ORDER := strict_unsafe
87 endif
88endif
[1667]89
[2058]90
[75]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
[219]97pass_$(pass)$(tag):: $(dep)
[696]98 + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
[75]99endef
[72]100
[75]101## Submakefile
102# @param $(pass) Lowercase pass name.
103# @param $(PASS) Uppercase pass name.
[1667]104# @param $(makefile) Makefile.
[75]105# @param $(tag) tag to attach to the rule name.
106define def_pass_makefile
[219]107pass_$(pass)$(tag):: $(dep)
[696]108 + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
[75]109endef
[73]110
[1667]111## Execute a pass, strict order.
[75]112# @param $(pass) Lowercase pass name.
113# @param $(PASS) Uppercase pass name.
[1667]114define def_pass_strict
[75]115$(eval tag:=_before)
[2058]116$(eval dep:= )
[1667]117$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
[1504]118$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
[75]119
[353]120$(eval tag:=_after)
121$(eval dep:=pass_$(pass)_doit)
[1667]122$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
[1504]123$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
[75]124
[353]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
[2058]127pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
[353]128pass_$(pass)_this: pass_$(pass)_before
[696]129 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
[353]130pass_$(pass)_after:: pass_$(pass)_this
131pass_$(pass): pass_$(pass)_after
[2058]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
[1667]150.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
[388]151.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
[353]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 \
[1667]157 pass_$(pass)_after
[353]158#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
[2058]159endef # def_pass_strict_unsafe
160$(eval-opt-var def_pass_strict_unsafe)
[75]161
[1667]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
[1919]167pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$$$$($(var)))
[1667]168pass_$(pass): pass_$(pass)_doit
169endef # def_pass_nonstrict
170
171## PASS: rules
172# Generate the rules for the defined passes.
[353]173$(foreach PASS, $(PASSES), \
174 $(eval pass := $(PASS_$(PASS)_pass)) \
[1667]175 $(eval $(def_pass_$(_KBUILD_STRICT_PASS_ORDER))))
[75]176
[1667]177
178## Pass order, strict.
[219]179# @param $(pass) Current pass name.
180# @param $(prev_pass) The previous pass name.
[1667]181define def_pass_order_strict
182.PHONY: pass_$(pass)_order
[353]183.NOTPARALLEL: pass_$(pass)_order
[219]184pass_$(pass)_order: $(pass_prev)
[1496]185 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
[696]186 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
[2058]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
[353]195.NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
[388]196.PHONY: pass_$(pass)_order pass_$(pass)_banner
[2058]197pass_$(pass)_banner: $(pass_prev)
[1496]198 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
[2058]199pass_$(pass)_order: $(pass_prev) \
[353]200 pass_$(pass)_banner \
201 pass_$(pass)
[219]202$(eval pass_prev := pass_$(pass)_order)
[2058]203endef # def_pass_order_strict_unsafe
204$(eval-opt-var def_pass_order_strict_unsafe)
[183]205
[1667]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
[1936]219$(eval-opt-var def_pass_order_nonstrict)
[1667]220
[219]221## PASS: order
222# Use dependencies to ensure correct pass order.
223pass_prev :=
[353]224$(foreach PASS,$(DEFAULT_PASSES),\
225 $(eval pass := $(PASS_$(PASS)_pass)) \
[1667]226 $(eval $(def_pass_order_$(_KBUILD_STRICT_PASS_ORDER))))
[219]227
[988]228ifdef KBUILD_PROFILE_SELF
[2008]229 $(evalcall def_profile_self, done passes)
[988]230endif
[272]231
[2107]232# Some common pass aliases
233ifndef KBUILD_NO_PASS_ALIASES
234.PHONY: clean
235clean: pass_clean
[897]236
[2107]237.PHONY: nothing
238nothing: pass_nothing
239
[2475]240.PHONY: staging
241staging: pass_staging
242
[2107]243.PHONY: packing
244packing: pass_packing
245
[2222]246 ifndef KBUILD_NO_TESTING_PASS_ALIASES
[2107]247.PHONY: check
248check:: pass_testing
249
250.PHONY: test
251test:: pass_testing
[2222]252 endif # KBUILD_NO_TESTING_PASS_ALIASES
253endif # KBUILD_NO_PASS_ALIASES
[2107]254
255
Note: See TracBrowser for help on using the repository browser.