1# 2# Generic leaf rules include Makefile. 3# 4# Copyright (C) 2009, Cisco Systems Inc. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License along 17# with this program; if not, write to the Free Software Foundation, Inc., 18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19# 20# Ngie Cooper, July 2009 21# 22 23# 24# generic_leaf_target 25# 26# Generate a set of basic targets (all, clean, install) for a leaf directory 27# (no subdirectories). 28# 29# $(MAKE_DEPS) : What should we execute beforehand as a 30# dependency of $(MAKE_TARGETS)? 31# 32# $(INSTALL_FILES) -> install 33# 34# Helpful variables are: 35# 36# $(MAKE_TARGETS) : What to execute as direct dependencies of 37# all. 38# 1. Defaults to the basename of the targets 39# produced by the %.c -> % implicit pattern 40# rules, e.g. the MAKE_TARGET in a directory 41# like the following: 42# 43# $$ ls /bar 44# foo.c 45# 46# Would be `foo'. Similarly, the following 47# dir structure: 48# 49# $$ ls /bar 50# foo.c zanzibar.c 51# 52# Would be `foo zanzibar'. 53# 54# 2. If you define MAKE_TARGETS as an empty 55# string, this will override the defaults. 56# I did this to avoid providing too much 57# rope to hang one's self in the event of 58# unwanted behavior. 59# 60# $(HOST_MAKE_TARGETS) : Host tools which use $HOSTCC. 61# 62# $(CLEAN_TARGETS) : What targets should be cleaned (must be 63# real files or directories). This will automatically append 64# adds the .o suffix to all files referenced by 65# $(MAKE_TARGETS)) to CLEAN_TARGETS, if MAKE_TARGETS wasn't 66# defined (see 67# $(MAKE_TARGETS)). 68# $(INSTALL_MODE) : What mode should we using when calling 69# install(1)? 70# 71# Also, if you wish to change the installation directory, from the set default 72# (testcases/bin) you must do something like either one of the following items: 73# 74# Method A: 75# 76# INSTALL_DIR := /path/to/installdir/from/$(DESTDIR)/$(prefix) 77# 78# e.g. if I wanted to install my binaries in testcases/bin, I would do: 79# 80# INSTALL_DIR := testcases/bin 81# 82# in my calling Makefile. 83# 84# Or Method B: 85# 86# INSTALL_DIR := /path/to/installdir/from/$(DESTDIR) 87# 88# e.g. if I wanted to install my binaries in $(libdir) (which may not exist 89# outside of $(prefix) right now, but could in the future), I could do the 90# following: 91# 92# INSTALL_DIR := $(libdir) 93# 94 95.PHONY: all clean install check 96 97ifneq ($(strip $(MAKE_TARGETS)),) 98$(MAKE_TARGETS) += $(HOST_MAKE_TARGETS) 99endif 100 101$(MAKE_TARGETS): | $(MAKE_DEPS) 102 103all: $(MAKE_TARGETS) 104 105clean:: $(CLEAN_DEPS) 106 -$(RM) -f -r $(CLEAN_TARGETS) 107 108$(INSTALL_FILES): | $(INSTALL_DEPS) 109 110install: $(INSTALL_FILES) 111 112$(CHECK_TARGETS): | $(CHECK_DEPS) 113check: $(CHECK_TARGETS) $(SHELL_CHECK_TARGETS) 114 115# vim: syntax=make 116