summaryrefslogtreecommitdiff
path: root/ltp_framework/include/mk/generic_trunk_target.inc
diff options
context:
space:
mode:
authorLe Chi Thu <thu2004@yahoo.se>2012-04-03 01:23:00 +0200
committerLe Chi Thu <thu2004@yahoo.se>2012-04-03 01:23:00 +0200
commit01c165cd1b2ac601d5ae73d3cb5e82ccdd94ac94 (patch)
tree777ab4b2289c860cab0b438f08e4f30bd52d9af5 /ltp_framework/include/mk/generic_trunk_target.inc
Initial commit
Diffstat (limited to 'ltp_framework/include/mk/generic_trunk_target.inc')
-rw-r--r--ltp_framework/include/mk/generic_trunk_target.inc97
1 files changed, 97 insertions, 0 deletions
diff --git a/ltp_framework/include/mk/generic_trunk_target.inc b/ltp_framework/include/mk/generic_trunk_target.inc
new file mode 100644
index 0000000..86d654c
--- /dev/null
+++ b/ltp_framework/include/mk/generic_trunk_target.inc
@@ -0,0 +1,97 @@
+#
+# Generic trunk rules include Makefile.
+#
+# Copyright (C) 2009, Cisco Systems Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+#
+# generic_trunk_target
+#
+# Generate a set of recursive targets to apply over a trunk directory (has
+# directories) -- optionally with a set of trunk-based files.
+#
+# All variables in this canned define are essentially the same as
+# generic_leaf_target, with the exception that the install flow for local
+# targets is:
+#
+# $(INSTALL_FILES) -> trunk-install -> install (recursive)
+#
+# All recursive targets are traverse SUBDIRS as defined by the user, or if
+# undefined, defaults to any subdirectories where Makefile's are contained
+# within.
+#
+# generic_trunk_target specific variables are:
+#
+# RECURSIVE_TARGETS : a list of targets to apply over an entire
+# directory tree. This defaults to
+# `all install'.
+#
+# See generic_leaf_target, generic_target_env_setup, and get_make_dirs for
+# more details and design notes.
+#
+
+include $(top_srcdir)/include/mk/functions.mk
+
+RECURSIVE_TARGETS ?= all install
+
+$(eval $(get_make_dirs))
+
+.PHONY: $(RECURSIVE_TARGETS) $(addprefix trunk-,$(RECURSIVE_TARGETS))
+
+$(SUBDIRS): %:
+ mkdir -m 00755 -p "$@"
+
+$(MAKE_TARGETS): | $(MAKE_DEPS)
+
+trunk-all: $(MAKE_TARGETS)
+
+trunk-clean:: | $(SUBDIRS)
+ $(if $(strip $(CLEAN_TARGETS)),$(RM) -f $(CLEAN_TARGETS))
+
+$(INSTALL_FILES): | $(INSTALL_DEPS)
+
+trunk-install: $(INSTALL_FILES)
+
+# Avoid creating duplicate .PHONY references to all, clean, and install. IIRC,
+# I've seen some indeterministic behavior when one does this in the past with
+# GNU Make...
+.PHONY: $(filter-out $(RECURSIVE_TARGETS),all clean install)
+all: trunk-all
+
+clean:: trunk-clean
+ @set -e; for dir in $(SUBDIRS); do \
+ $(MAKE) -C "$$dir" -f "$(abs_srcdir)/$$dir/Makefile" $@; \
+ done
+ifneq ($(abs_builddir),$(abs_srcdir))
+ $(RM) -Rf $(SUBDIRS)
+endif
+
+install: trunk-install
+
+# Print out CURDIR to check for a recursion issue.
+ifeq ($(strip $(SUBDIRS)),)
+ $(warning CURDIR is: $(CURDIR))
+else
+$(RECURSIVE_TARGETS): %: | $(SUBDIRS)
+ @set -e; for dir in $(SUBDIRS); do \
+ $(MAKE) -C $$dir -f "$(abs_srcdir)/$$dir/Makefile" $@; \
+ done
+endif
+
+# vim: syntax=make