2000-07-16 18:27:30 +02:00
|
|
|
#
|
2001-10-29 10:21:53 +01:00
|
|
|
# $FreeBSD$
|
2000-07-16 18:27:30 +02:00
|
|
|
#
|
|
|
|
# This include file <doc.images.mk> handles image processing.
|
|
|
|
#
|
|
|
|
# There are two types of images that must be handled:
|
|
|
|
#
|
|
|
|
# 1. Images from the library directory, that are shared across multiple
|
|
|
|
# documents.
|
|
|
|
#
|
|
|
|
# 2. Images that are document specific.
|
|
|
|
#
|
2004-07-23 20:58:56 +02:00
|
|
|
# For library images this file ensures that they are copied in to the
|
2000-07-16 18:27:30 +02:00
|
|
|
# documents directory so that they can be reference properly.
|
|
|
|
#
|
|
|
|
# For library images *and* document specific images, this file ensures
|
|
|
|
# that the images are converted from their repository format to the
|
|
|
|
# correct output format.
|
|
|
|
#
|
2000-10-08 21:17:42 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Using document specific images
|
|
|
|
# ------------------------------
|
|
|
|
#
|
|
|
|
# The images that each document provides *from the repository* are listed in
|
|
|
|
# the IMAGES variable.
|
|
|
|
#
|
|
|
|
# We then need to build a list of images that must be generated from these.
|
|
|
|
# This is to handle the case where a document might include some images as
|
|
|
|
# bitmaps and some as vector images in the repository, but where, depending
|
|
|
|
# on the output format, you want all the images in one format or another.
|
2000-07-16 18:27:30 +02:00
|
|
|
#
|
2000-10-08 21:17:42 +02:00
|
|
|
# This list of generated images can then be cleaned in the clean target
|
|
|
|
# later
|
|
|
|
#
|
|
|
|
# This is the same for each format. To use IMAGES_GEN_PNG as an example,
|
|
|
|
# the substitution means "First match, using M, all the components of
|
|
|
|
# ${IMAGES} that match the '*.eps' regexp. Then, search/replace the .eps
|
|
|
|
# in the matching filenames with .png. Finally, stick the results in the
|
|
|
|
# ${IMAGES_GEN_PNG} variable." ${IMAGES_GEN_PNG} then contains the names
|
|
|
|
# of all the .eps images listed, but with a .png extension. This is the
|
|
|
|
# list of files we need to generate if we need PNG format images.
|
|
|
|
#
|
2000-10-29 03:39:10 +01:00
|
|
|
# The PDF generation, when it's looking for file 'foo', will first try
|
|
|
|
# foo.pdf, and it will try foo.png. There's no point converting PNG files
|
|
|
|
# to PDF, as they'll be used directly. However, we can convert the EPS files
|
|
|
|
# to PDF, and hopefully get better quality.
|
|
|
|
#
|
2000-10-08 21:17:42 +02:00
|
|
|
|
2003-04-11 11:21:15 +02:00
|
|
|
IMAGES_EN?=
|
|
|
|
LOCAL_IMAGES_EN?=
|
|
|
|
|
|
|
|
#
|
|
|
|
# The name of the directory that contains all the library images for this
|
|
|
|
# language and encoding
|
|
|
|
#
|
|
|
|
IMAGES_EN_DIR?= ${.CURDIR}/../../../share/images
|
|
|
|
|
|
|
|
.for _curimage in ${IMAGES_EN}
|
|
|
|
LOCAL_IMAGES_EN += ${IMAGES_EN_DIR}/${DOC}s/${.CURDIR:T}/${_curimage}
|
|
|
|
.endfor
|
|
|
|
|
2001-10-29 10:21:53 +01:00
|
|
|
_IMAGES_PNG= ${IMAGES:M*.png}
|
2003-04-11 11:21:15 +02:00
|
|
|
_IMAGES_PNG+= ${LOCAL_IMAGES_EN:M*.png}
|
2001-10-29 10:21:53 +01:00
|
|
|
_IMAGES_EPS= ${IMAGES:M*.eps}
|
2003-04-11 11:21:15 +02:00
|
|
|
_IMAGES_EPS+= ${LOCAL_IMAGES_EN:M*.eps}
|
2001-10-29 10:21:53 +01:00
|
|
|
_IMAGES_SCR= ${IMAGES:M*.scr}
|
2003-04-11 11:21:15 +02:00
|
|
|
_IMAGES_SCR+= ${LOCAL_IMAGES_EN:M*.scr}
|
2002-10-28 20:41:55 +01:00
|
|
|
_IMAGES_TXT= ${IMAGES:M*.txt}
|
2003-04-11 11:21:15 +02:00
|
|
|
_IMAGES_TXT+= ${LOCAL_IMAGES_EN:M*.txt}
|
2002-02-02 21:30:55 +01:00
|
|
|
_IMAGES_PIC= ${IMAGES:M*.pic}
|
2003-04-11 11:21:15 +02:00
|
|
|
_IMAGES_PIC+= ${LOCAL_IMAGES_EN:M*.pic}
|
2001-10-29 10:21:53 +01:00
|
|
|
|
2013-03-31 23:35:32 +02:00
|
|
|
IMAGES_GEN_PNG= ${_IMAGES_EPS:S/.eps$/.png/} ${_IMAGES_SCR:S/.scr$/.png/} ${_IMAGES_PIC:S/.pic$/.png/}
|
|
|
|
IMAGES_GEN_EPS= ${_IMAGES_PNG:S/.png$/.eps/} ${_IMAGES_SCR:S/.scr$/.eps/} ${_IMAGES_PIC:S/.pic$/.eps/}
|
|
|
|
|
2017-09-19 11:54:21 +02:00
|
|
|
CLEANFILES+= ${IMAGES_GEN_PNG} ${IMAGES_GEN_EPS} ${_IMAGES_PIC:S/.pic$/.ps/}
|
2013-03-31 23:35:32 +02:00
|
|
|
|
|
|
|
IMAGES_PNG= ${_IMAGES_PNG} ${IMAGES_GEN_PNG}
|
|
|
|
IMAGES_EPS= ${_IMAGES_EPS} ${IMAGES_GEN_EPS}
|
2001-10-29 10:21:53 +01:00
|
|
|
|
|
|
|
LOCAL_IMAGES= ${IMAGES}
|
|
|
|
LOCAL_IMAGES_PNG= ${_IMAGES_PNG}
|
|
|
|
LOCAL_IMAGES_EPS= ${_IMAGES_EPS}
|
2002-10-28 20:41:55 +01:00
|
|
|
LOCAL_IMAGES_TXT= ${_IMAGES_TXT}
|
2013-03-31 23:35:32 +02:00
|
|
|
LOCAL_IMAGES_PNG+= ${IMAGES_GEN_PNG}
|
|
|
|
LOCAL_IMAGES_EPS+= ${IMAGES_GEN_EPS}
|
2000-10-08 21:17:42 +02:00
|
|
|
|
2001-06-22 12:12:23 +02:00
|
|
|
# The default resolution eps2png (82) assumes a 640x480 monitor, and is too
|
|
|
|
# low for the typical monitor in use today. The resolution of 100 looks
|
|
|
|
# much better on these monitors without making the image too large for
|
|
|
|
# a 640x480 monitor.
|
2004-07-23 20:53:34 +02:00
|
|
|
EPS2PNM_RES?= 100
|
2001-06-22 12:12:23 +02:00
|
|
|
|
2003-12-30 22:41:17 +01:00
|
|
|
#
|
2002-10-28 20:41:55 +01:00
|
|
|
# Use suffix rules to convert .scr files to other formats
|
2003-12-30 22:41:17 +01:00
|
|
|
.SUFFIXES: .scr .pic .png .ps .eps .txt
|
2001-06-22 12:12:23 +02:00
|
|
|
|
|
|
|
.scr.png:
|
2001-11-05 11:33:38 +01:00
|
|
|
${SCR2PNG} ${SCR2PNGOPTS} < ${.IMPSRC} > ${.TARGET}
|
2002-11-02 22:45:53 +01:00
|
|
|
|
2003-12-08 03:37:02 +01:00
|
|
|
## If we want grayscale, convert with ppmtopgm before running through pnmtops
|
|
|
|
.if defined(GREYSCALE_IMAGES)
|
2001-08-14 23:51:25 +02:00
|
|
|
.scr.eps:
|
2017-09-19 11:57:15 +02:00
|
|
|
tmpfile=$$(mktemp ${.TARGET}.XXXXXXXX); \
|
2001-11-05 11:33:38 +01:00
|
|
|
${SCR2PNG} ${SCR2PNGOPTS} < ${.ALLSRC} | \
|
|
|
|
${PNGTOPNM} ${PNGTOPNMOPTS} | \
|
2003-12-08 03:37:02 +01:00
|
|
|
${PPMTOPGM} ${PPMTOPGMOPTS} | \
|
2017-09-19 11:57:15 +02:00
|
|
|
${PNMTOPS} ${PNMTOPSOPTS} > $$tmpfile && \
|
|
|
|
${MV} -f $$tmpfile ${.TARGET}
|
2003-12-08 03:37:02 +01:00
|
|
|
.else
|
|
|
|
.scr.eps:
|
2017-09-19 11:57:15 +02:00
|
|
|
tmpfile=$$(mktemp ${.TARGET}.XXXXXXXX); \
|
2003-12-08 03:37:02 +01:00
|
|
|
${SCR2PNG} ${SCR2PNGOPTS} < ${.ALLSRC} | \
|
|
|
|
${PNGTOPNM} ${PNGTOPNMOPTS} | \
|
2017-09-19 11:57:15 +02:00
|
|
|
${PNMTOPS} ${PNMTOPSOPTS} > $$tmpfile && \
|
|
|
|
${MV} -f $$tmpfile ${.TARGET}
|
2003-12-08 03:37:02 +01:00
|
|
|
.endif
|
2001-06-22 12:12:23 +02:00
|
|
|
|
2002-11-02 22:45:53 +01:00
|
|
|
# The .txt files need to have any trailing spaces trimmed from
|
|
|
|
# each line, which is why the output from ${SCR2TXT} is run
|
|
|
|
# through ${SED}
|
|
|
|
.scr.txt:
|
|
|
|
${SCR2TXT} ${SCR2TXTOPTS} < ${.IMPSRC} | ${SED} -E -e 's/ +$$//' > ${.TARGET}
|
|
|
|
|
2002-02-02 21:30:55 +01:00
|
|
|
.pic.png: ${.TARGET:S/.png$/.eps/}
|
2004-07-23 20:53:34 +02:00
|
|
|
${EPSGEOM} -offset ${EPSGEOMOPTS} ${.TARGET:S/.png$/.eps/} \
|
|
|
|
| ${EPS2PNM} ${EPS2PNMOPTS} \
|
|
|
|
-g`${EPSGEOM} -geom ${EPSGEOMOPTS} ${.TARGET:S/.png$/.eps/}` - \
|
|
|
|
| ${PNMTOPNG} > ${.TARGET}
|
2002-02-02 21:30:55 +01:00
|
|
|
|
2013-04-01 10:16:09 +02:00
|
|
|
.pic.ps:
|
2017-09-19 11:57:15 +02:00
|
|
|
tmpfile=$$(mktemp ${.TARGET}.XXXXXXXX); \
|
|
|
|
${PIC2PS} ${.ALLSRC} > $$tmpfile && ${MV} -f $$tmpfile ${.TARGET}
|
2013-04-01 10:16:09 +02:00
|
|
|
|
2003-12-30 22:41:17 +01:00
|
|
|
# When ghostscript built with A4=yes is used, ps2epsi's paper size also
|
|
|
|
# becomes the A4 size. However, the ps2epsi fails to convert grops(1)
|
|
|
|
# outputs, which is the letter size, and we cannot change ps2epsi's paper size
|
|
|
|
# from the command line. So ps->eps suffix rule is defined. In the rule,
|
|
|
|
# gs(1) is used to generate the bitmap preview and the size of the
|
|
|
|
# bounding box.
|
2009-12-25 19:12:00 +01:00
|
|
|
#
|
|
|
|
# ps2epsi.ps in GS 8.70 requires $outfile before the conversion and it
|
|
|
|
# must contain %%BoundingBox line which the "gs -sDEVICE=bbox" outputs
|
|
|
|
# (the older versions calculated BBox directly in ps2epsi.ps).
|
2003-12-30 22:41:17 +01:00
|
|
|
.ps.eps:
|
2017-09-19 11:57:15 +02:00
|
|
|
tmpfile=$$(mktemp ${.TARGET}.XXXXXXXX); \
|
|
|
|
${PS2BBOX} ${PS2BBOXOPTS} ${.ALLSRC} > $$tmpfile 2>&1; \
|
|
|
|
${SETENV} outfile=$$tmpfile ${PS2EPS} ${PS2EPSOPTS} < ${.ALLSRC} 1>&2; \
|
2004-07-23 20:53:34 +02:00
|
|
|
(echo "save countdictstack mark newpath /showpage {} def /setpagedevice {pop} def";\
|
|
|
|
echo "%%EndProlog";\
|
|
|
|
echo "%%Page: 1 1";\
|
|
|
|
echo "%%BeginDocument: ${.ALLSRC}";\
|
2017-09-19 11:57:15 +02:00
|
|
|
) >> $$tmpfile; \
|
2003-12-30 22:41:17 +01:00
|
|
|
${SED} -e '/^%%BeginPreview:/,/^%%EndPreview[^!-~]*$$/d' \
|
|
|
|
-e '/^%!PS-Adobe/d' \
|
|
|
|
-e '/^%%[A-Za-z][A-Za-z]*[^!-~]*$$/d'\
|
2017-09-19 11:57:15 +02:00
|
|
|
-e '/^%%[A-Za-z][A-Za-z]*: /d' < ${.ALLSRC} >> $$tmpfile; \
|
2004-07-23 20:53:34 +02:00
|
|
|
(echo "%%EndDocument";\
|
|
|
|
echo "%%Trailer";\
|
|
|
|
echo "cleartomark countdictstack exch sub { end } repeat restore";\
|
|
|
|
echo "%%EOF";\
|
2017-09-19 11:57:15 +02:00
|
|
|
) >> $$tmpfile; \
|
|
|
|
${MV} -f $$tmpfile ${.TARGET}
|
2002-02-02 21:30:55 +01:00
|
|
|
|
2000-10-08 21:17:42 +02:00
|
|
|
# We can't use suffix rules to generate the rules to convert EPS to PNG and
|
|
|
|
# PNG to EPS. This is because a .png file can depend on a .eps file, and
|
|
|
|
# vice versa, leading to a loop in the dependency graph. Instead, build
|
|
|
|
# the targets on the fly.
|
|
|
|
|
2013-03-31 23:35:32 +02:00
|
|
|
.for _curimage in ${_IMAGES_EPS:S/.eps$/.png/}
|
|
|
|
${_curimage}: ${_curimage:S/.png/.eps/}
|
2004-07-23 20:53:34 +02:00
|
|
|
${EPSGEOM} -offset ${EPSGEOMOPTS} ${.ALLSRC} \
|
|
|
|
| ${EPS2PNM} ${EPS2PNMOPTS} \
|
|
|
|
-g`${EPSGEOM} -geom ${EPSGEOMOPTS} ${.ALLSRC}` - \
|
|
|
|
| ${PNMTOPNG} > ${.TARGET}
|
2000-10-08 21:17:42 +02:00
|
|
|
.endfor
|
|
|
|
|
2013-04-01 10:16:09 +02:00
|
|
|
.for _curimage in ${_IMAGES_PNG:S/.png$/.eps/}
|
2000-10-08 21:17:42 +02:00
|
|
|
${_curimage}: ${_curimage:S/.eps$/.png/}
|
2001-11-05 11:33:38 +01:00
|
|
|
${PNGTOPNM} ${PNGTOPNMOPTS} ${.ALLSRC} | \
|
|
|
|
${PNMTOPS} ${PNMTOPSOPTS} > ${.TARGET}
|
2000-10-08 21:17:42 +02:00
|
|
|
.endfor
|
|
|
|
|
2001-10-29 10:21:53 +01:00
|
|
|
.if ${.OBJDIR} != ${.CURDIR}
|
|
|
|
.for _curimage in ${IMAGES}
|
|
|
|
${.OBJDIR}/${_curimage}: ${_curimage}
|
2003-04-11 11:21:15 +02:00
|
|
|
@${CP} -p ${.ALLSRC} ${.TARGET}
|
2001-10-29 10:21:53 +01:00
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
2000-07-16 18:27:30 +02:00
|
|
|
#
|
|
|
|
# Using library images
|
|
|
|
# --------------------
|
|
|
|
#
|
2000-10-08 21:17:42 +02:00
|
|
|
# Each document that wants to use one or more library images has to
|
2004-07-23 20:58:56 +02:00
|
|
|
# list them in the IMAGES_LIB variable. For example, a document that wants
|
2000-07-16 18:27:30 +02:00
|
|
|
# to use callouts 1 thru 4 has to list
|
|
|
|
#
|
2000-10-29 03:39:10 +01:00
|
|
|
# IMAGES_LIB= callouts/1.png callouts/2.png callouts/3.png callouts/4.png
|
2000-07-16 18:27:30 +02:00
|
|
|
#
|
|
|
|
# in the controlling Makefile.
|
|
|
|
#
|
|
|
|
# This code ensures they exist in the current directory, and copies them in
|
|
|
|
# as necessary.
|
|
|
|
#
|
|
|
|
|
2001-10-29 10:21:53 +01:00
|
|
|
IMAGES_LIB?=
|
|
|
|
LOCAL_IMAGES_LIB ?=
|
|
|
|
|
2000-07-16 18:27:30 +02:00
|
|
|
#
|
|
|
|
# The name of the directory that contains all the library images for this
|
|
|
|
# language and encoding
|
|
|
|
#
|
2003-04-11 11:21:15 +02:00
|
|
|
IMAGES_LIB_DIR?= ${.CURDIR}/../../../share/images
|
2000-07-16 18:27:30 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# The name of the directory *in* the document directory where files and
|
|
|
|
# directory hierarchies should be copied to. "images" is too generic, and
|
2004-07-23 20:58:56 +02:00
|
|
|
# might clash with local document images, so use "imagelib" by default
|
2013-05-29 21:21:25 +02:00
|
|
|
# instead.
|
2000-07-16 18:27:30 +02:00
|
|
|
#
|
2000-10-29 03:39:10 +01:00
|
|
|
LOCAL_IMAGES_LIB_DIR?= imagelib
|
2003-01-31 18:26:53 +01:00
|
|
|
CLEANDIRS+= ${LOCAL_IMAGES_LIB_DIR}
|
2000-07-16 18:27:30 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create a target for each image used from the library. This target just
|
2004-07-23 20:58:56 +02:00
|
|
|
# ensures that each image required is copied from its location in
|
2000-10-29 03:39:10 +01:00
|
|
|
# ${IMAGES_LIB_DIR} to the same place in ${LOCAL_IMAGES_LIB_DIR}.
|
2000-07-16 18:27:30 +02:00
|
|
|
#
|
2001-10-29 10:21:53 +01:00
|
|
|
|
2000-10-29 03:39:10 +01:00
|
|
|
.for _curimage in ${IMAGES_LIB}
|
2001-10-29 10:21:53 +01:00
|
|
|
LOCAL_IMAGES_LIB += ${LOCAL_IMAGES_LIB_DIR}/${_curimage}
|
2000-10-29 03:39:10 +01:00
|
|
|
${LOCAL_IMAGES_LIB_DIR}/${_curimage}: ${IMAGES_LIB_DIR}/${_curimage}
|
2001-10-29 10:21:53 +01:00
|
|
|
@[ -d ${LOCAL_IMAGES_LIB_DIR}/${_curimage:H} ] || \
|
2003-08-01 22:28:55 +02:00
|
|
|
${MKDIR} -p ${LOCAL_IMAGES_LIB_DIR}/${_curimage:H}
|
2001-10-29 10:21:53 +01:00
|
|
|
${CP} -p ${IMAGES_LIB_DIR}/${_curimage} \
|
|
|
|
${LOCAL_IMAGES_LIB_DIR}/${_curimage}
|
2000-07-16 18:27:30 +02:00
|
|
|
.endfor
|
2001-10-29 10:21:53 +01:00
|
|
|
|
|
|
|
.if !empty(IMAGES_LIB)
|
|
|
|
CLEANFILES+= ${IMAGES_LIB:S|^|${LOCAL_IMAGES_LIB_DIR}/|}
|
|
|
|
.endif
|