1# -*- makefile -*- 2# $Id: latex.subdir.mk.in.in,v 1.4 2006/01/28 04:43:18 dan Exp $ 3# 4# Copyright (c) 2002, 2006 Dan McMahill 5# All rights reserved. 6# 7# This code is derived from software written by Dan McMahill 8# 9# Redistribution and use in source and binary forms, with or without 10# modification, are permitted provided that the following conditions 11# are met: 12# 1. Redistributions of source code must retain the above copyright 13# notice, this list of conditions and the following disclaimer. 14# 2. Redistributions in binary form must reproduce the above copyright 15# notice, this list of conditions and the following disclaimer in the 16# documentation and/or other materials provided with the distribution. 17# 3. All advertising materials mentioning features or use of this software 18# must display the following acknowledgement: 19# This product includes software developed by Dan McMahill 20# 4. The name of the author may not be used to endorse or promote products 21# derived from this software without specific prior written permission. 22# 23# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 30# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33# SUCH DAMAGE. 34# 35 36ECHO?= @ECHO@ 37 38# 39# This Makefile fragment is included at the very end of users custom 40# Makefiles in subdirectories of a top level latex-mk Makefile. This 41# makes sure the standard set of targets exist so a recursive make 42# will not fail due to undefined targets 43 44# An example is: 45# 46# SUBDIR+= document1 47# SUBDIR+= document2 48# SUBDIR+= document3 49BMK:# .include "/path/to/latex.subdir.mk" 50GMK:# include /path/to/latex.subdir.gmk 51# 52 53 54# note: we put "default" first because when we do not specify a target 55# we want to use "default" because thats what latex.mk has for its own 56# default 57_ALL_TARGETS= default all clean dist distclean dvi html pdf print print-all \ 58 ps rtf show-var view viewall viewpdf viewps 59 60BMK:.for __target in ${_ALL_TARGETS} 61BMK:.if !target(${__target}) 62BMK:.PHONY: ${__target} 63BMK:${__target}: _SUBDIRUSE 64BMK:.endif 65BMK:.endfor 66BMK: 67BMK:# 68BMK:# Derived from NetBSD Id: bsd.pkg.subdir.mk,v 1.60 2005/11/14 04:44:25 rillig Exp 69BMK:# Which in turn says: 70BMK:# Derived from: FreeBSD Id: bsd.port.subdir.mk,v 1.19 1997/03/09 23:10:56 wosch Exp 71BMK:# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 72 73BMK:.if !target(_SUBDIRUSE) 74BMK:_SUBDIRUSE: .USE 75BMK: @for entry in "" ${SUBDIR} ; do \ 76BMK: if [ "$$entry" != "" ] ; then \ 77BMK: OK=""; \ 78BMK: if [ -d ${.CURDIR}/$${entry} ]; then \ 79BMK: edir=$${entry}; \ 80BMK: else \ 81BMK: OK="false"; \ 82BMK: ${ECHO} "===> ${_THISDIR_}$${entry} non-existent"; \ 83BMK: fi; \ 84BMK: if [ "$$OK" = "" ]; then \ 85BMK: cd ${.CURDIR}/$${edir}; \ 86BMK: ${ECHO} "===> ${_THISDIR_}$${edir}"; \ 87BMK: ${MAKE} ${MAKEFLAGS} "_THISDIR_=${_THISDIR_}$${edir}/" \ 88BMK: ${.TARGET} || true; \ 89BMK: fi; \ 90BMK: fi ; \ 91BMK: done 92BMK:.endif 93 94 95GMK:define _SUBDIRUSE_TEMPLATE 96GMK:.PHONY: $(1) 97GMK:$(1): 98GMK: @for entry in "" ${SUBDIR} ; do \ 99GMK: if [ "$$$$entry" != "" ] ; then \ 100GMK: OK=""; \ 101GMK: if [ -d $$$${entry} ]; then \ 102GMK: edir=$$$${entry}; \ 103GMK: else \ 104GMK: OK="false"; \ 105GMK: ${ECHO} "===> ${_THISDIR_}$$$${entry} non-existent"; \ 106GMK: fi; \ 107GMK: if [ "$$$$OK" = "" ]; then \ 108GMK: (cd $$$${edir}; \ 109GMK: ${ECHO} "===> ${_THISDIR_}$$$${edir}"; \ 110GMK: ${MAKE} ${MAKEFLAGS:%=-%} "_THISDIR_=${_THISDIR_}$$$${edir}/" \ 111GMK: $(1) || true;) \ 112GMK: fi; \ 113GMK: fi ; \ 114GMK: done 115GMK:endef 116GMK:$(foreach __tmp__,$(_ALL_TARGETS),$(eval $(call _SUBDIRUSE_TEMPLATE,$(__tmp__)))) 117 118 119 120 121 122 123