1# -*- Makefile -*- 2# $Id: tgif.mk.in.in,v 1.15 2006/09/21 13:48:13 dan Exp $ 3# 4# Makefile fragment for processing tgif files to produce postscript 5# 6# Copyright (c) 2001, 2002, 2003, 2005, 2006 Dan McMahill 7# All rights reserved. 8# 9# This code is derived from software written by Dan McMahill 10# 11# Redistribution and use in source and binary forms, with or without 12# modification, are permitted provided that the following conditions 13# are met: 14# 1. Redistributions of source code must retain the above copyright 15# notice, this list of conditions and the following disclaimer. 16# 2. Redistributions in binary form must reproduce the above copyright 17# notice, this list of conditions and the following disclaimer in the 18# documentation and/or other materials provided with the distribution. 19# 3. All advertising materials mentioning features or use of this software 20# must display the following acknowledgement: 21# This product includes software developed by Dan McMahill 22# 4. The name of the author may not be used to endorse or promote products 23# derived from this software without specific prior written permission. 24# 25# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 26# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 29# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 32# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35# SUCH DAMAGE. 36# 37 38 39####################################### 40# 41# README: 42# 43# To use this makefile fragment, set the variable: 44# TGIFSRCS = the tgif drawing files (.obj files) 45# in your top level Makefile. You can also specify 46# TGIFDIRS which is a list of directories containing 47# tgif files. All tgif files in the specified directories 48# are added to TGIFSRCS 49# 50# The following variables may be overridden in your top level Makefile 51# 52# TGIF = the tgif executable 53# TGIF_FLAGS = flags passed to tgif for any exporting 54# TGIF_EPS_FLAGS = flags passed to tgif for exporting to eps 55# TGIF_PDF_FLAGS = flags passed to tgif for exporting to pdf 56# 57####################################### 58 59 60# how to call tgif to convert tgif files to postscript 61TGIF?= @TGIF@ 62TGIF_FLAGS?= -color -print 63TGIF_EPS_FLAGS?= -eps 64TGIF_PDF_FLAGS?= -pdf 65 66####################################### 67# 68# Process TGIFDIRS, adding to TGIFSRCS 69# 70####################################### 71 72BMK:.if defined(TGIFDIRS) 73BMK:.for __tmp__ in ${TGIFDIRS} 74BMK:.if exists(${__tmp__}) 75BMK:_TGIF_ADD_${__tmp__}!= ls ${__tmp__}/*.obj 76BMK:TGIFSRCS+= ${_TGIF_ADD_${__tmp__}} 77BMK:.endif 78BMK:.endfor 79BMK:.endif 80 81GMK:ifdef TGIFDIRS 82GMK:TGIFSRCS+= $(foreach __tmp__,$(TGIFDIRS),$(wildcard $(__tmp__)/*.obj)) 83GMK:endif 84 85####################################### 86# 87# Process proj_TGIFDIRS, adding to proj_TGIFSRCS 88# 89####################################### 90 91BMK:.for __name__ in ${NAME} 92BMK:.if defined(${__name__}_TGIFDIRS) 93BMK:.for __tmp__ in ${${__name__}_TGIFDIRS} 94BMK:.if exists(${__tmp__}) 95BMK:_TGIF_ADD2_${__tmp__}!= ls ${__tmp__}/*.obj 96BMK:${__name__}_TGIFSRCS+= ${_TGIF_ADD2_${__tmp__}} 97BMK:.endif 98BMK:.endfor 99BMK:.endif 100BMK:.endfor 101 102GMK:define tgifdirs_template 103GMK:ifdef $(1)_TGIFDIRS 104GMK:$(1)_TGIFSRCS+= $(foreach __tmp2__,$($(1)_TGIFDIRS),$(wildcard $(__tmp2__)/*.obj)) 105GMK:endif 106GMK:endef 107GMK:$(foreach __tmp__,$(NAME),$(eval $(call tgifdirs_template,$(__tmp__)))) 108 109####################################### 110# 111# Process proj_TGIFSRCS to add to 112# proj_OTHER dependencies 113# 114####################################### 115 116# if we are using pdflatex, then don't bother with the .eps files 117# but create .pdf files instead 118 119BMK:.if defined(USE_PDFLATEX) 120GMK:ifdef USE_PDFLATEX 121TGIFOBJS?= $(TGIFSRCS:.obj=.pdf) 122BMK:.else 123GMK:else 124TGIFOBJS?= $(TGIFSRCS:.obj=.eps) 125BMK:.endif 126GMK:endif 127ALLTGIFOBJS+= $(TGIFOBJS) 128 129BMK:.for __tmp__ in ${NAME} 130BMK:.if defined(${__tmp__}_TGIFSRCS) 131BMK:.if defined(USE_PDFLATEX) 132BMK:${__tmp__}_TGIFOBJS?= ${${__tmp__}_TGIFSRCS:.obj=.pdf} 133BMK:.else 134BMK:${__tmp__}_TGIFOBJS?= ${${__tmp__}_TGIFSRCS:.obj=.eps} 135BMK:.endif 136BMK:${__tmp__}_OTHER+= ${${__tmp__}_TGIFOBJS} 137BMK:ALLTGIFOBJS+= ${${__tmp__}_TGIFOBJS} 138BMK:.endif 139BMK:${__tmp__}_DIST+= ${${__tmp__}_TGIFSRCS} ${TGIFSRCS} 140BMK:.endfor 141 142GMK:# note, this had to be done in two steps (create proj_TGIFOBJS, 143GMK:# and then add to proj_OTHER and ALLTGIFOBJS) with GNU make 3.80 144GMK:# don't really know why. 145GMK:define tgifobjs_template 146GMK:ifdef $(1)_TGIFSRCS 147GMK:ifdef USE_PDFLATEX 148GMK:$(1)_TGIFOBJS?= ${$(1)_TGIFSRCS:.obj=.pdf} 149GMK:else 150GMK:$(1)_TGIFOBJS?= ${$(1)_TGIFSRCS:.obj=.eps} 151GMK:endif 152GMK:endif 153GMK:$(1)_DIST+= ${$(1)_TGIFSRCS} ${TGIFSRCS} 154GMK:endef 155GMK:$(foreach __tmp__,$(NAME),$(eval $(call tgifobjs_template,$(__tmp__)))) 156 157GMK:define tgifdeps_template 158GMK:ifdef $(1)_TGIFSRCS 159GMK:$(1)_OTHER+= ${$(1)_TGIFOBJS} 160GMK:ALLTGIFOBJS+= ${$(1)_TGIFOBJS} 161GMK:endif 162GMK:endef 163GMK:$(foreach __tmp__,$(NAME),$(eval $(call tgifdeps_template,$(__tmp__)))) 164 165 166####################################### 167# 168# Add the dependencies 169# 170####################################### 171 172 173OTHER+= $(TGIFOBJS) 174all:: $(ALLTGIFOBJS) 175 176clean:: 177BMK:.for __tmp__ in $(ALLTGIFOBJS) 178BMK: $(RM) -f $(__tmp__:Q) 179BMK:.endfor 180GMK: $(RM) -f $(ALLTGIFOBJS) 181 182####################################### 183# 184# The suffix rules 185# 186####################################### 187 188.SUFFIXES : .obj .eps .pdf 189 190.obj.eps : 191BMK: $(TGIF:Q) $(TGIF_FLAGS) $(TGIF_EPS_FLAGS) $*.obj 192GMK: $(TGIF) $(TGIF_FLAGS) $(TGIF_EPS_FLAGS) $*.obj 193 194.obj.pdf : 195BMK: $(TGIF:Q) $(TGIF_FLAGS) $(TGIF_PDF_FLAGS) $*.obj 196GMK: $(TGIF) $(TGIF_FLAGS) $(TGIF_PDF_FLAGS) $*.obj 197 198