File: mpost.mk.in.in

package info (click to toggle)
latex-mk 2.1-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,988 kB
  • ctags: 243
  • sloc: sh: 4,252; makefile: 165
file content (213 lines) | stat: -rw-r--r-- 6,328 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# -*- Makefile -*-
# $Id: mpost.mk.in.in,v 1.4 2007/08/26 20:38:26 dan Exp $
#
# Makefile fragment for processing METAPOST files to produce postscript
#
# Copyright (c) 2007 Dan McMahill
# All rights reserved.
#
# This code is derived from software written by Dan McMahill
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#        This product includes software developed by Dan McMahill
#  4. The name of the author may not be used to endorse or promote products
#     derived from this software without specific prior written permission.
# 
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
#  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
#  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
#  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
#  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
#  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#  SUCH DAMAGE.
#


#######################################
#
# README:
#
# To use this makefile fragment, set the variable:
#	MPOSTSRCS	= the METAPOST input files (.mp files)
# in your top level Makefile.  You can also specify
# MPOSTDIRS which is a list of directories containing
# METAPOST files.  All mpost files in the specified directories
# are added to MPOSTSRCS
#
# The following variables may be overridden in your top level Makefile
#
#  MPOST	  = the METAPOST executable
#  MPOST_FLAGS	  = flags passed to ${MPOST}
#
#######################################


# how to call METAPOST
MPOST?=		@MPOST@
MPOST_FLAGS?=

#######################################
#
# Process MPOSTDIRS, adding to MPOSTSRCS
#
#######################################

BMK:.if defined(MPOSTDIRS)
BMK:.for __tmp__ in ${MPOSTDIRS}
BMK:.if exists(${__tmp__})
BMK:_MPOST_ADD_${__tmp__}!=	ls ${__tmp__}/*.mp
BMK:MPOSTSRCS+=	${_MPOST_ADD_${__tmp__}}
BMK:.endif
BMK:.endfor
BMK:.endif

GMK:ifdef MPOSTDIRS
GMK:MPOSTSRCS+= $(foreach __tmp__,$(MPOSTDIRS),$(wildcard $(__tmp__)/*.mp))
GMK:endif

#######################################
#
# Process proj_MPOSTDIRS, adding to proj_MPOSTSRCS
#
#######################################

BMK:.for __name__ in ${NAME}
BMK:.if defined(${__name__}_MPOSTDIRS)
BMK:.for __tmp__ in ${${__name__}_MPOSTDIRS}
BMK:.if exists(${__tmp__})
BMK:_MPOST_ADD2_${__tmp__}!=	ls ${__tmp__}/*.mp
BMK:${__name__}_MPOSTSRCS+=	${_MPOST_ADD2_${__tmp__}}
BMK:.endif
BMK:.endfor
BMK:.endif
BMK:.endfor

GMK:define mpostdirs_template
GMK:ifdef $(1)_MPOSTDIRS
GMK:$(1)_MPOSTSRCS+= $(foreach __tmp2__,$($(1)_MPOSTDIRS),$(wildcard $(__tmp2__)/*.mp))
GMK:endif
GMK:endef
GMK:$(foreach __tmp__,$(NAME),$(eval $(call mpostdirs_template,$(__tmp__))))

#######################################
# 
# Process proj_MPOSTSRCS to add to
# proj_OTHER dependencies
#
#######################################


MPOSTOBJS?=      $(MPOSTSRCS:.mp=.mpx)
ALLMPOSTOBJS+=	$(MPOSTOBJS)

BMK:.for __tmp__ in ${NAME}
BMK:.if defined(${__tmp__}_MPOSTSRCS)
BMK:${__tmp__}_MPOSTOBJS?=	${${__tmp__}_MPOSTSRCS:.mp=.mpx}
BMK:${__tmp__}_OTHER+=	${${__tmp__}_MPOSTOBJS}
BMK:ALLMPOSTOBJS+=	${${__tmp__}_MPOSTOBJS}
BMK:.endif
BMK:${__tmp__}_DIST+=	${${__tmp__}_MPOSTSRCS} ${MPOSTSRCS}
BMK:.endfor

GMK:# note, this had to be done in two steps (create proj_MPOSTOBJS,
GMK:# and then add to proj_OTHER and ALLMPOSTOBJS) with GNU make 3.80
GMK:# don't really know why.
GMK:define mpostobjs_template
GMK:ifdef $(1)_MPOSTSRCS
GMK:$(1)_MPOSTOBJS?=	${$(1)_MPOSTSRCS:.mp=.mpx}
GMK:endif
GMK:$(1)_DIST+=		${$(1)_MPOSTSRCS}  ${MPOSTSRCS}
GMK:endef
GMK:$(foreach __tmp__,$(NAME),$(eval $(call mpostobjs_template,$(__tmp__))))

GMK:define mpostdeps_template
GMK:ifdef $(1)_MPOSTSRCS
GMK:$(1)_OTHER+=	${$(1)_MPOSTOBJS}
GMK:ALLMPOSTOBJS+=	${$(1)_MPOSTOBJS}
GMK:endif
GMK:endef
GMK:$(foreach __tmp__,$(NAME),$(eval $(call mpostdeps_template,$(__tmp__))))


#######################################
# 
# Add the dependencies
#
#######################################


OTHER+=	$(MPOSTOBJS)
all::		$(ALLMPOSTOBJS)


# we do this funny thing because neither BSD make nor GNU make
# seem to like make conditionals in the middle of shell code
BMK:.if defined(USE_PDFLATEX)
GMK:ifdef USE_PDFLATEX
_MPOST_PDF_REMOVE_=	$$fn
BMK:.endif
GMK:endif

clean::
BMK:.for __tmp__ in $(ALLMPOSTOBJS)
BMK:	$(RM) -f $(__tmp__:Q)
BMK:.endfor
GMK:	$(RM) -f $(ALLMPOSTOBJS)
	for mp in $(ALLMPOSTOBJS) ; do \
		mpb=`basename $${mp} .mpx` ; \
		for f in $${mpb}.ps $${mpb}.[0-9]* "" ; do \
			if test "X$$f" != "X" ; then \
				fn=`basename $$f .ps` ; \
				fn=$${fn}.pdf ; \
				$(RM) -f $$f ${_MPOST_PDF_REMOVE_}; \
			fi ; \
		done ; \
	done

#######################################
# 
# The suffix rules
#
#######################################

.SUFFIXES : .mp .mpx 

# if we are using pdflatex, then we probably need to convert our
# postscript output to PDF

.mp.mpx : 
BMK:	$(MPOST:Q) $(MPOST_FLAGS) $(MPOST_EPS_FLAGS) $*.mp
GMK:	$(MPOST) $(MPOST_FLAGS) $(MPOST_EPS_FLAGS) $*.mp
BMK:.if defined(MPOST_TWICE)
GMK:ifdef MPOST_TWICE
BMK:	$(MPOST:Q) $(MPOST_FLAGS) $(MPOST_EPS_FLAGS) $*.mp
GMK:	$(MPOST) $(MPOST_FLAGS) $(MPOST_EPS_FLAGS) $*.mp
BMK:.endif
GMK:endif
BMK:.if defined(USE_PDFLATEX)
GMK:ifdef USE_PDFLATEX
	for f in $*.ps $*.[0-9]* "" ; do \
		if test "X$$f" != "X" ; then \
			fn=`basename $$f .ps` ; \
			fn=$${fn}.pdf ; \
BMK:			${PS2PDF:Q} ${PS2PDF_FLAGS} $$f $$fn ; \
GMK:			${PS2PDF} ${PS2PDF_FLAGS} $$f $$fn ; \
		fi ; \
	done
BMK:.endif
GMK:endif