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.
|
|
|
|
#
|
|
|
|
# For library images this file ensures that they are copied in to the
|
|
|
|
# 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
|
|
|
|
2001-10-29 10:21:53 +01:00
|
|
|
_IMAGES_PNG= ${IMAGES:M*.png}
|
|
|
|
_IMAGES_EPS= ${IMAGES:M*.eps}
|
|
|
|
_IMAGES_SCR= ${IMAGES:M*.scr}
|
|
|
|
|
|
|
|
IMAGES_GEN_PNG= ${_IMAGES_EPS:S/.eps$/.png/}
|
|
|
|
IMAGES_GEN_EPS= ${_IMAGES_PNG:S/.png$/.eps/}
|
|
|
|
IMAGES_GEN_PDF= ${_IMAGES_EPS:S/.eps$/.pdf/}
|
|
|
|
IMAGES_SCR_PNG= ${_IMAGES_SCR:S/.scr$/.png/}
|
|
|
|
IMAGES_SCR_EPS= ${_IMAGES_SCR:S/.scr$/.eps/}
|
2000-10-08 21:17:42 +02:00
|
|
|
|
2000-10-29 03:39:10 +01:00
|
|
|
CLEANFILES+= ${IMAGES_GEN_PNG} ${IMAGES_GEN_EPS} ${IMAGES_GEN_PDF}
|
2001-10-29 10:21:53 +01:00
|
|
|
CLEANFILES+= ${IMAGES_SCR_PNG} ${IMAGES_SCR_EPS}
|
|
|
|
|
|
|
|
IMAGES_PNG= ${_IMAGES_PNG} ${IMAGES_GEN_PNG} ${IMAGES_SCR_PNG}
|
|
|
|
IMAGES_EPS= ${_IMAGES_EPS} ${IMAGES_GEN_EPS} ${IMAGES_SCR_EPS}
|
|
|
|
|
|
|
|
.if ${.OBJDIR} != ${.CURDIR}
|
|
|
|
LOCAL_IMAGES= ${IMAGES:S|^|${.OBJDIR}/|}
|
|
|
|
CLEANFILES+= ${LOCAL_IMAGES}
|
|
|
|
|
|
|
|
.if !empty(_IMAGES_PNG)
|
|
|
|
LOCAL_IMAGES_PNG= ${_IMAGES_PNG:S|^|${.OBJDIR}/|}
|
|
|
|
.endif
|
2000-10-08 21:17:42 +02:00
|
|
|
|
2001-10-29 10:21:53 +01:00
|
|
|
.if !empty(_IMAGES_EPS)
|
|
|
|
LOCAL_IMAGES_EPS= ${_IMAGES_EPS:S|^|${.OBJDIR}/|}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.else
|
|
|
|
LOCAL_IMAGES= ${IMAGES}
|
|
|
|
LOCAL_IMAGES_PNG= ${_IMAGES_PNG}
|
|
|
|
LOCAL_IMAGES_EPS= ${_IMAGES_EPS}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
LOCAL_IMAGES_PNG+= ${IMAGES_GEN_PNG} ${IMAGES_SCR_PNG}
|
|
|
|
LOCAL_IMAGES_EPS+= ${IMAGES_GEN_EPS} ${IMAGES_SCR_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.
|
|
|
|
EPS2PNG_RES?= 100
|
|
|
|
|
2000-10-29 03:39:10 +01:00
|
|
|
# We only need to list ${IMAGES_GEN_PDF} here. If all the source files are
|
|
|
|
# EPS then they'll be in this variable; if any of the source files are PNG
|
|
|
|
# then we can use them directly, and don't need to list them.
|
|
|
|
IMAGES_PDF=${IMAGES_GEN_PDF}
|
|
|
|
|
2001-10-29 10:21:53 +01:00
|
|
|
SCR2PNG?= ${PREFIX}/bin/scr2png
|
2001-11-05 11:33:38 +01:00
|
|
|
SCR2PNGOPTS?= ${SCR2PNGFLAGS}
|
2001-10-29 10:21:53 +01:00
|
|
|
EPS2PNG?= ${PREFIX}/bin/peps
|
2001-11-05 11:33:38 +01:00
|
|
|
EPS2PNGOPTS?= -p -r ${EPS2PNG_RES} ${EPS2PNGFLAGS}
|
2001-10-29 10:21:53 +01:00
|
|
|
PNGTOPNM?= ${PREFIX}/bin/pngtopnm
|
2001-11-05 11:33:38 +01:00
|
|
|
PNGTOPNMOPTS?= ${PNGTOPNMFLAGS}
|
2001-10-29 10:21:53 +01:00
|
|
|
PNMTOPS?= ${PREFIX}/bin/pnmtops
|
2001-11-05 11:33:38 +01:00
|
|
|
PNMTOPSOPTS?= -noturn ${PNMTOPSFLAGS}
|
2001-10-29 10:21:53 +01:00
|
|
|
EPSTOPDF?= ${PREFIX}/bin/epstopdf
|
2001-11-05 11:33:38 +01:00
|
|
|
EPSTOPDFOPTS?= ${EPSTOPDFFLAGS}
|
2001-10-29 10:21:53 +01:00
|
|
|
|
2001-06-22 12:12:23 +02:00
|
|
|
# Use suffix rules to convert .scr files to .png files
|
2001-08-14 23:51:25 +02:00
|
|
|
.SUFFIXES: .scr .png .eps
|
2001-06-22 12:12:23 +02:00
|
|
|
|
|
|
|
.scr.png:
|
2001-11-05 11:33:38 +01:00
|
|
|
${SCR2PNG} ${SCR2PNGOPTS} < ${.IMPSRC} > ${.TARGET}
|
2001-08-14 23:51:25 +02:00
|
|
|
.scr.eps:
|
2001-11-05 11:33:38 +01:00
|
|
|
${SCR2PNG} ${SCR2PNGOPTS} < ${.ALLSRC} | \
|
|
|
|
${PNGTOPNM} ${PNGTOPNMOPTS} | \
|
|
|
|
${PNMTOPS} ${PNMTOPSOPTS} > ${.TARGET}
|
2001-06-22 12:12:23 +02: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.
|
|
|
|
|
|
|
|
.for _curimage in ${IMAGES_GEN_PNG}
|
|
|
|
${_curimage}: ${_curimage:S/.png$/.eps/}
|
2001-11-05 11:33:38 +01:00
|
|
|
${EPS2PNG} ${EPS2PNGOPTS} -o ${.TARGET} ${.ALLSRC}
|
2000-10-08 21:17:42 +02:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
.for _curimage in ${IMAGES_GEN_EPS}
|
|
|
|
${_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
|
|
|
|
|
2000-10-29 03:39:10 +01:00
|
|
|
.for _curimage in ${IMAGES_GEN_PDF}
|
|
|
|
${_curimage}: ${_curimage:S/.pdf$/.eps/}
|
2001-11-05 11:33:38 +01:00
|
|
|
${EPSTOPDF} ${EPSTOPDFOPTS} --outfile=${.TARGET} \
|
|
|
|
${.CURDIR}/${_curimage:S/.pdf$/.eps/}
|
2000-10-29 03:39:10 +01:00
|
|
|
.endfor
|
2000-07-16 18:27:30 +02:00
|
|
|
|
2001-10-29 10:21:53 +01:00
|
|
|
.if ${.OBJDIR} != ${.CURDIR}
|
|
|
|
.for _curimage in ${IMAGES}
|
|
|
|
${.OBJDIR}/${_curimage}: ${_curimage}
|
|
|
|
${CP} -p ${.ALLSRC} ${.TARGET}
|
|
|
|
.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
|
2000-10-29 03:39:10 +01: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
|
|
|
|
#
|
2000-10-29 03:39:10 +01: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
|
|
|
|
# might clash with local document images, so use "imagelib" by default
|
|
|
|
# instead. If you redefine this then you must also update the
|
|
|
|
# %callout-graphics-path% variable in the .dsl file.
|
|
|
|
#
|
2000-10-29 03:39:10 +01:00
|
|
|
LOCAL_IMAGES_LIB_DIR?= imagelib
|
2000-07-16 18:27:30 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create a target for each image used from the library. This target just
|
|
|
|
# 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} ] || \
|
|
|
|
${MKDIR} ${LOCAL_IMAGES_LIB_DIR}/${_curimage:H}
|
|
|
|
${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
|