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