xref: /aosp_15_r20/external/ltp/include/mk/generic_trunk_target.inc (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker#
2*49cdfc7eSAndroid Build Coastguard Worker#    Generic trunk rules include Makefile.
3*49cdfc7eSAndroid Build Coastguard Worker#
4*49cdfc7eSAndroid Build Coastguard Worker#    Copyright (C) 2009, Cisco Systems Inc.
5*49cdfc7eSAndroid Build Coastguard Worker#
6*49cdfc7eSAndroid Build Coastguard Worker#    This program is free software; you can redistribute it and/or modify
7*49cdfc7eSAndroid Build Coastguard Worker#    it under the terms of the GNU General Public License as published by
8*49cdfc7eSAndroid Build Coastguard Worker#    the Free Software Foundation; either version 2 of the License, or
9*49cdfc7eSAndroid Build Coastguard Worker#    (at your option) any later version.
10*49cdfc7eSAndroid Build Coastguard Worker#
11*49cdfc7eSAndroid Build Coastguard Worker#    This program is distributed in the hope that it will be useful,
12*49cdfc7eSAndroid Build Coastguard Worker#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*49cdfc7eSAndroid Build Coastguard Worker#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*49cdfc7eSAndroid Build Coastguard Worker#    GNU General Public License for more details.
15*49cdfc7eSAndroid Build Coastguard Worker#
16*49cdfc7eSAndroid Build Coastguard Worker#    You should have received a copy of the GNU General Public License along
17*49cdfc7eSAndroid Build Coastguard Worker#    with this program; if not, write to the Free Software Foundation, Inc.,
18*49cdfc7eSAndroid Build Coastguard Worker#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*49cdfc7eSAndroid Build Coastguard Worker#
20*49cdfc7eSAndroid Build Coastguard Worker# Ngie Cooper, July 2009
21*49cdfc7eSAndroid Build Coastguard Worker#
22*49cdfc7eSAndroid Build Coastguard Worker
23*49cdfc7eSAndroid Build Coastguard Worker#
24*49cdfc7eSAndroid Build Coastguard Worker# generic_trunk_target
25*49cdfc7eSAndroid Build Coastguard Worker#
26*49cdfc7eSAndroid Build Coastguard Worker# Generate a set of recursive targets to apply over a trunk directory (has
27*49cdfc7eSAndroid Build Coastguard Worker# directories) -- optionally with a set of trunk-based files.
28*49cdfc7eSAndroid Build Coastguard Worker#
29*49cdfc7eSAndroid Build Coastguard Worker# All variables in this canned define are essentially the same as
30*49cdfc7eSAndroid Build Coastguard Worker# generic_leaf_target, with the exception that the install flow for local
31*49cdfc7eSAndroid Build Coastguard Worker# targets is:
32*49cdfc7eSAndroid Build Coastguard Worker#
33*49cdfc7eSAndroid Build Coastguard Worker# $(INSTALL_FILES) -> trunk-install -> install (recursive)
34*49cdfc7eSAndroid Build Coastguard Worker#
35*49cdfc7eSAndroid Build Coastguard Worker# All recursive targets are traverse SUBDIRS as defined by the user, or if
36*49cdfc7eSAndroid Build Coastguard Worker# undefined, defaults to any subdirectories where Makefile's are contained
37*49cdfc7eSAndroid Build Coastguard Worker# within.
38*49cdfc7eSAndroid Build Coastguard Worker#
39*49cdfc7eSAndroid Build Coastguard Worker# generic_trunk_target specific variables are:
40*49cdfc7eSAndroid Build Coastguard Worker#
41*49cdfc7eSAndroid Build Coastguard Worker# RECURSIVE_TARGETS		: a list of targets to apply over an entire
42*49cdfc7eSAndroid Build Coastguard Worker# 				  directory tree. This defaults to
43*49cdfc7eSAndroid Build Coastguard Worker# 				  `all install'.
44*49cdfc7eSAndroid Build Coastguard Worker#
45*49cdfc7eSAndroid Build Coastguard Worker# See generic_leaf_target, generic_target_env_setup, and get_make_dirs for
46*49cdfc7eSAndroid Build Coastguard Worker# more details and design notes.
47*49cdfc7eSAndroid Build Coastguard Worker#
48*49cdfc7eSAndroid Build Coastguard Worker
49*49cdfc7eSAndroid Build Coastguard Workerinclude $(top_srcdir)/include/mk/functions.mk
50*49cdfc7eSAndroid Build Coastguard Worker
51*49cdfc7eSAndroid Build Coastguard WorkerRECURSIVE_TARGETS		?= all install check
52*49cdfc7eSAndroid Build Coastguard Worker
53*49cdfc7eSAndroid Build Coastguard Worker$(eval $(get_make_dirs))
54*49cdfc7eSAndroid Build Coastguard Worker
55*49cdfc7eSAndroid Build Coastguard Worker.PHONY: $(RECURSIVE_TARGETS) $(addprefix trunk-,$(RECURSIVE_TARGETS))
56*49cdfc7eSAndroid Build Coastguard Worker
57*49cdfc7eSAndroid Build Coastguard Worker$(SUBDIRS): %:
58*49cdfc7eSAndroid Build Coastguard Worker	mkdir -m 00755 -p "$@"
59*49cdfc7eSAndroid Build Coastguard Worker
60*49cdfc7eSAndroid Build Coastguard Worker$(MAKE_TARGETS): | $(MAKE_DEPS)
61*49cdfc7eSAndroid Build Coastguard Worker
62*49cdfc7eSAndroid Build Coastguard Workertrunk-all: $(MAKE_TARGETS)
63*49cdfc7eSAndroid Build Coastguard Worker
64*49cdfc7eSAndroid Build Coastguard Workertrunk-clean:: | $(SUBDIRS)
65*49cdfc7eSAndroid Build Coastguard Worker	$(if $(strip $(CLEAN_TARGETS)),$(RM) -f $(CLEAN_TARGETS))
66*49cdfc7eSAndroid Build Coastguard Worker
67*49cdfc7eSAndroid Build Coastguard Worker$(INSTALL_FILES): | $(INSTALL_DEPS)
68*49cdfc7eSAndroid Build Coastguard Worker
69*49cdfc7eSAndroid Build Coastguard Workertrunk-install: $(INSTALL_FILES)
70*49cdfc7eSAndroid Build Coastguard Worker
71*49cdfc7eSAndroid Build Coastguard Worker$(CHECK_TARGETS): | $(CHECK_DEPS)
72*49cdfc7eSAndroid Build Coastguard Workertrunk-check: $(CHECK_TARGETS) $(SHELL_CHECK_TARGETS)
73*49cdfc7eSAndroid Build Coastguard Worker
74*49cdfc7eSAndroid Build Coastguard Worker# Avoid creating duplicate .PHONY references to all, clean, and install. IIRC,
75*49cdfc7eSAndroid Build Coastguard Worker# I've seen some indeterministic behavior when one does this in the past with
76*49cdfc7eSAndroid Build Coastguard Worker# GNU Make...
77*49cdfc7eSAndroid Build Coastguard Worker.PHONY: $(filter-out $(RECURSIVE_TARGETS),all clean install)
78*49cdfc7eSAndroid Build Coastguard Workerall: trunk-all
79*49cdfc7eSAndroid Build Coastguard Worker
80*49cdfc7eSAndroid Build Coastguard Workerclean:: trunk-clean
81*49cdfc7eSAndroid Build Coastguard Workerifdef VERBOSE
82*49cdfc7eSAndroid Build Coastguard Worker	@set -e; for dir in $(SUBDIRS); do \
83*49cdfc7eSAndroid Build Coastguard Worker	    $(MAKE) -C "$$dir" -f "$(abs_srcdir)/$$dir/Makefile" $@; \
84*49cdfc7eSAndroid Build Coastguard Worker	done
85*49cdfc7eSAndroid Build Coastguard Workerelse
86*49cdfc7eSAndroid Build Coastguard Worker	@set -e; for dir in $(SUBDIRS); do \
87*49cdfc7eSAndroid Build Coastguard Worker	    echo "DIR $$dir"; \
88*49cdfc7eSAndroid Build Coastguard Worker	    $(MAKE) --no-print-directory -C "$$dir" -f "$(abs_srcdir)/$$dir/Makefile" $@; \
89*49cdfc7eSAndroid Build Coastguard Worker	done
90*49cdfc7eSAndroid Build Coastguard Workerendif
91*49cdfc7eSAndroid Build Coastguard Workerifneq ($(abs_builddir),$(abs_srcdir))
92*49cdfc7eSAndroid Build Coastguard Worker	$(RM) -Rf $(SUBDIRS)
93*49cdfc7eSAndroid Build Coastguard Workerendif
94*49cdfc7eSAndroid Build Coastguard Worker
95*49cdfc7eSAndroid Build Coastguard Workerinstall: trunk-install
96*49cdfc7eSAndroid Build Coastguard Worker
97*49cdfc7eSAndroid Build Coastguard Worker# Print out CURDIR to check for a recursion issue.
98*49cdfc7eSAndroid Build Coastguard Workerifeq ($(strip $(SUBDIRS)),)
99*49cdfc7eSAndroid Build Coastguard Worker	$(warning CURDIR is: $(CURDIR))
100*49cdfc7eSAndroid Build Coastguard Worker	$(error SUBDIRS empty -- did you want generic_leaf_target instead?)
101*49cdfc7eSAndroid Build Coastguard Workerelse
102*49cdfc7eSAndroid Build Coastguard Worker$(RECURSIVE_TARGETS): %: | $(SUBDIRS)
103*49cdfc7eSAndroid Build Coastguard Workerifdef VERBOSE
104*49cdfc7eSAndroid Build Coastguard Worker	@set -e; for dir in $(SUBDIRS); do \
105*49cdfc7eSAndroid Build Coastguard Worker	    $(MAKE) -C $$dir -f "$(abs_srcdir)/$$dir/Makefile" $@; \
106*49cdfc7eSAndroid Build Coastguard Worker	done
107*49cdfc7eSAndroid Build Coastguard Workerelse
108*49cdfc7eSAndroid Build Coastguard Worker	@set -e; for dir in $(SUBDIRS); do \
109*49cdfc7eSAndroid Build Coastguard Worker	    $(MAKE) --no-print-directory -C $$dir -f "$(abs_srcdir)/$$dir/Makefile" $@; \
110*49cdfc7eSAndroid Build Coastguard Worker	done
111*49cdfc7eSAndroid Build Coastguard Workerendif
112*49cdfc7eSAndroid Build Coastguard Workerendif
113*49cdfc7eSAndroid Build Coastguard Worker
114*49cdfc7eSAndroid Build Coastguard Workercheck: trunk-check
115*49cdfc7eSAndroid Build Coastguard Worker
116*49cdfc7eSAndroid Build Coastguard Worker# vim: syntax=make
117