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