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# $(CLEAN_TARGETS) : What targets should be cleaned (must be 61# real files). This will automatically append 62# adds the .o suffix to all files referenced 63# by $(MAKE_TARGETS)) to CLEAN_TARGETS, if 64# MAKE_TARGETS wasn't defined (see 65# $(MAKE_TARGETS)). 66# $(INSTALL_MODE) : What mode should we using when calling 67# install(1)? 68# 69# Also, if you wish to change the installation directory, from the set default 70# (testcases/bin) you must do something like either one of the following items: 71# 72# Method A: 73# 74# INSTALL_DIR := /path/to/installdir/from/$(DESTDIR)/$(prefix) 75# 76# e.g. if I wanted to install my binaries in testcases/bin, I would do: 77# 78# INSTALL_DIR := testcases/bin 79# 80# in my calling Makefile. 81# 82# Or Method B: 83# 84# INSTALL_DIR := /path/to/installdir/from/$(DESTDIR) 85# 86# e.g. if I wanted to install my binaries in $(libdir) (which may not exist 87# outside of $(prefix) right now, but could in the future), I could do the 88# following: 89# 90# INSTALL_DIR := $(libdir) 91# 92 93.PHONY: all clean install 94 95$(MAKE_TARGETS): | $(MAKE_DEPS) 96 97all: $(MAKE_TARGETS) 98 99clean:: $(CLEAN_DEPS) 100 -$(RM) -f $(CLEAN_TARGETS) 101 102$(INSTALL_FILES): | $(INSTALL_DEPS) 103 104install: $(INSTALL_FILES) 105 106# vim: syntax=make 107