1f08c3bdfSopenharmony_ci#
2f08c3bdfSopenharmony_ci#    Generic leaf 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_leaf_target
25f08c3bdfSopenharmony_ci#
26f08c3bdfSopenharmony_ci# Generate a set of basic targets (all, clean, install) for a leaf directory
27f08c3bdfSopenharmony_ci# (no subdirectories).
28f08c3bdfSopenharmony_ci#
29f08c3bdfSopenharmony_ci# $(MAKE_DEPS)			: What should we execute beforehand as a
30f08c3bdfSopenharmony_ci#				  dependency of $(MAKE_TARGETS)?
31f08c3bdfSopenharmony_ci#
32f08c3bdfSopenharmony_ci# $(INSTALL_FILES) -> install
33f08c3bdfSopenharmony_ci#
34f08c3bdfSopenharmony_ci# Helpful variables are:
35f08c3bdfSopenharmony_ci#
36f08c3bdfSopenharmony_ci# $(MAKE_TARGETS)		: What to execute as direct dependencies of
37f08c3bdfSopenharmony_ci# 				  all.
38f08c3bdfSopenharmony_ci# 				  1. Defaults to the basename of the targets
39f08c3bdfSopenharmony_ci# 				     produced by the %.c -> % implicit pattern
40f08c3bdfSopenharmony_ci# 				     rules, e.g. the MAKE_TARGET in a directory
41f08c3bdfSopenharmony_ci# 				     like the following:
42f08c3bdfSopenharmony_ci#
43f08c3bdfSopenharmony_ci#				  $$ ls /bar
44f08c3bdfSopenharmony_ci# 				  foo.c
45f08c3bdfSopenharmony_ci#
46f08c3bdfSopenharmony_ci#				     Would be `foo'. Similarly, the following
47f08c3bdfSopenharmony_ci#				     dir structure:
48f08c3bdfSopenharmony_ci#
49f08c3bdfSopenharmony_ci#				  $$ ls /bar
50f08c3bdfSopenharmony_ci# 				  foo.c zanzibar.c
51f08c3bdfSopenharmony_ci#
52f08c3bdfSopenharmony_ci#				     Would be `foo zanzibar'.
53f08c3bdfSopenharmony_ci#
54f08c3bdfSopenharmony_ci#				  2. If you define MAKE_TARGETS as an empty
55f08c3bdfSopenharmony_ci#				     string, this will override the defaults.
56f08c3bdfSopenharmony_ci#				     I did this to avoid providing too much
57f08c3bdfSopenharmony_ci#				     rope to hang one's self in the event of
58f08c3bdfSopenharmony_ci#				     unwanted behavior.
59f08c3bdfSopenharmony_ci#
60f08c3bdfSopenharmony_ci# $(HOST_MAKE_TARGETS)	: Host tools which use $HOSTCC.
61f08c3bdfSopenharmony_ci#
62f08c3bdfSopenharmony_ci# $(CLEAN_TARGETS)		: What targets should be cleaned (must be
63f08c3bdfSopenharmony_ci#				  real files or directories). This will automatically append
64f08c3bdfSopenharmony_ci#				  adds the .o suffix to all files referenced by
65f08c3bdfSopenharmony_ci#				  $(MAKE_TARGETS)) to CLEAN_TARGETS, if MAKE_TARGETS wasn't
66f08c3bdfSopenharmony_ci#				  defined (see
67f08c3bdfSopenharmony_ci#				  $(MAKE_TARGETS)).
68f08c3bdfSopenharmony_ci# $(INSTALL_MODE)		: What mode should we using when calling
69f08c3bdfSopenharmony_ci# 				  install(1)?
70f08c3bdfSopenharmony_ci#
71f08c3bdfSopenharmony_ci# Also, if you wish to change the installation directory, from the set default
72f08c3bdfSopenharmony_ci# (testcases/bin) you must do something like either one of the following items:
73f08c3bdfSopenharmony_ci#
74f08c3bdfSopenharmony_ci# Method A:
75f08c3bdfSopenharmony_ci#
76f08c3bdfSopenharmony_ci# INSTALL_DIR			:= /path/to/installdir/from/$(DESTDIR)/$(prefix)
77f08c3bdfSopenharmony_ci#
78f08c3bdfSopenharmony_ci# e.g. if I wanted to install my binaries in testcases/bin, I would do:
79f08c3bdfSopenharmony_ci#
80f08c3bdfSopenharmony_ci# INSTALL_DIR			:= testcases/bin
81f08c3bdfSopenharmony_ci#
82f08c3bdfSopenharmony_ci# in my calling Makefile.
83f08c3bdfSopenharmony_ci#
84f08c3bdfSopenharmony_ci# Or Method B:
85f08c3bdfSopenharmony_ci#
86f08c3bdfSopenharmony_ci# INSTALL_DIR			:= /path/to/installdir/from/$(DESTDIR)
87f08c3bdfSopenharmony_ci#
88f08c3bdfSopenharmony_ci# e.g. if I wanted to install my binaries in $(libdir) (which may not exist
89f08c3bdfSopenharmony_ci# outside of $(prefix) right now, but could in the future), I could do the
90f08c3bdfSopenharmony_ci# following:
91f08c3bdfSopenharmony_ci#
92f08c3bdfSopenharmony_ci# INSTALL_DIR			:= $(libdir)
93f08c3bdfSopenharmony_ci#
94f08c3bdfSopenharmony_ci
95f08c3bdfSopenharmony_ci.PHONY: all clean install check
96f08c3bdfSopenharmony_ci
97f08c3bdfSopenharmony_ciifneq ($(strip $(MAKE_TARGETS)),)
98f08c3bdfSopenharmony_ci$(MAKE_TARGETS) += $(HOST_MAKE_TARGETS)
99f08c3bdfSopenharmony_ciendif
100f08c3bdfSopenharmony_ci
101f08c3bdfSopenharmony_ci$(MAKE_TARGETS): | $(MAKE_DEPS)
102f08c3bdfSopenharmony_ci
103f08c3bdfSopenharmony_ciall: $(MAKE_TARGETS)
104f08c3bdfSopenharmony_ci
105f08c3bdfSopenharmony_ciclean:: $(CLEAN_DEPS)
106f08c3bdfSopenharmony_ci	-$(RM) -f -r $(CLEAN_TARGETS)
107f08c3bdfSopenharmony_ci
108f08c3bdfSopenharmony_ci$(INSTALL_FILES): | $(INSTALL_DEPS)
109f08c3bdfSopenharmony_ci
110f08c3bdfSopenharmony_ciinstall: $(INSTALL_FILES)
111f08c3bdfSopenharmony_ci
112f08c3bdfSopenharmony_ci$(CHECK_TARGETS): | $(CHECK_DEPS)
113f08c3bdfSopenharmony_cicheck: $(CHECK_HEADER_TARGETS) $(CHECK_TARGETS) $(SHELL_CHECK_TARGETS)
114f08c3bdfSopenharmony_ci
115f08c3bdfSopenharmony_ci# vim: syntax=make
116