fontutil.m4.in revision a9274bcd
1dnl @configure_input@
2dnl
3dnl This file comes from X.Org's @PACKAGE_STRING@
4dnl
5dnl Copyright 2005 Red Hat, Inc
6dnl
7dnl Permission to use, copy, modify, distribute, and sell this software and its
8dnl documentation for any purpose is hereby granted without fee, provided that
9dnl the above copyright notice appear in all copies and that both that
10dnl copyright notice and this permission notice appear in supporting
11dnl documentation.
12dnl
13dnl The above copyright notice and this permission notice shall be included
14dnl in all copies or substantial portions of the Software.
15dnl
16dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
20dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22dnl OTHER DEALINGS IN THE SOFTWARE.
23dnl
24dnl Except as contained in this notice, the name of the copyright holders shall
25dnl not be used in advertising or otherwise to promote the sale, use or
26dnl other dealings in this Software without prior written authorization
27dnl from the copyright holders.
28dnl
29dnl --------------------------------------------------------------------
30dnl
31dnl Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
32dnl
33dnl Permission is hereby granted, free of charge, to any person obtaining a
34dnl copy of this software and associated documentation files (the
35dnl "Software"), to deal in the Software without restriction, including
36dnl without limitation the rights to use, copy, modify, merge, publish,
37dnl distribute, and/or sell copies of the Software, and to permit persons
38dnl to whom the Software is furnished to do so, provided that the above
39dnl copyright notice(s) and this permission notice appear in all copies of
40dnl the Software and that both the above copyright notice(s) and this
41dnl permission notice appear in supporting documentation.
42dnl
43dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
44dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
46dnl OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
47dnl HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
48dnl INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
49dnl FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
50dnl NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
51dnl WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52dnl
53dnl Except as contained in this notice, the name of a copyright holder
54dnl shall not be used in advertising or otherwise to promote the sale, use
55dnl or other dealings in this Software without prior written authorization
56dnl of the copyright holder.
57
58# XORG_FONT_MACROS_VERSION(required-version)
59# ------------------------------------------
60# Minimum version: 1.1.0
61#
62# If you're using a macro added in Version 1.1 or newer, include this in
63# your configure.ac with the minimum required version, such as:
64# XORG_FONT_MACROS_VERSION(1.1)
65#
66# To ensure that this macro is defined, also add:
67# m4_ifndef([XORG_FONT_MACROS_VERSION],
68#     [m4_fatal([must install X.Org font-util 1.1 or later before running autoconf/autogen])])
69#
70#
71# See the "minimum version" comment for each macro you use to see what
72# version you require.
73m4_defun([XORG_FONT_MACROS_VERSION],[
74m4_define([vers_have], [@VERSION@])
75m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
76m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
77m4_if(m4_cmp(maj_have, maj_needed), 0,,
78    [m4_fatal([font-util major version ]maj_needed[ is required but ]vers_have[ found])])
79m4_if(m4_version_compare(vers_have, [$1]), -1,
80    [m4_fatal([font-util version $1 or higher is required but ]vers_have[ found])])
81m4_undefine([vers_have])
82m4_undefine([maj_have])
83m4_undefine([maj_needed])
84]) # XORG_FONT_MACROS_VERSION
85
86# XORG_FONT_CHECK_{maps}()
87# ------------------------
88# Minimum version: 1.0.0
89# These macros add --enable/disable-{maps} where {maps} are ISO8859-*,
90# JISX0201 or KOI8_R.  By default, they are all enabled.
91
92AC_DEFUN([XORG_FONT_CHECK_ISO8859_1], [XORG_FONT_CHECK_ENCODING(ISO8859-1)])
93AC_DEFUN([XORG_FONT_CHECK_ISO8859_2], [XORG_FONT_CHECK_ENCODING(ISO8859-2)])
94AC_DEFUN([XORG_FONT_CHECK_ISO8859_3], [XORG_FONT_CHECK_ENCODING(ISO8859-3)])
95AC_DEFUN([XORG_FONT_CHECK_ISO8859_4], [XORG_FONT_CHECK_ENCODING(ISO8859-4)])
96AC_DEFUN([XORG_FONT_CHECK_ISO8859_5], [XORG_FONT_CHECK_ENCODING(ISO8859-5)])
97AC_DEFUN([XORG_FONT_CHECK_ISO8859_6], [XORG_FONT_CHECK_ENCODING(ISO8859-6)])
98AC_DEFUN([XORG_FONT_CHECK_ISO8859_7], [XORG_FONT_CHECK_ENCODING(ISO8859-7)])
99AC_DEFUN([XORG_FONT_CHECK_ISO8859_8], [XORG_FONT_CHECK_ENCODING(ISO8859-8)])
100AC_DEFUN([XORG_FONT_CHECK_ISO8859_9], [XORG_FONT_CHECK_ENCODING(ISO8859-9)])
101AC_DEFUN([XORG_FONT_CHECK_ISO8859_10],[XORG_FONT_CHECK_ENCODING(ISO8859-10)])
102AC_DEFUN([XORG_FONT_CHECK_ISO8859_11],[XORG_FONT_CHECK_ENCODING(ISO8859-11)])
103AC_DEFUN([XORG_FONT_CHECK_ISO8859_12],[XORG_FONT_CHECK_ENCODING(ISO8859-12)])
104AC_DEFUN([XORG_FONT_CHECK_ISO8859_13],[XORG_FONT_CHECK_ENCODING(ISO8859-13)])
105AC_DEFUN([XORG_FONT_CHECK_ISO8859_14],[XORG_FONT_CHECK_ENCODING(ISO8859-14)])
106AC_DEFUN([XORG_FONT_CHECK_ISO8859_15],[XORG_FONT_CHECK_ENCODING(ISO8859-15)])
107AC_DEFUN([XORG_FONT_CHECK_ISO8859_16],[XORG_FONT_CHECK_ENCODING(ISO8859-16)])
108AC_DEFUN([XORG_FONT_CHECK_JISX0201],  [XORG_FONT_CHECK_ENCODING(JISX0201)])
109AC_DEFUN([XORG_FONT_CHECK_KOI8_R],    [XORG_FONT_CHECK_ENCODING(KOI8-R)])
110
111# XORG_FONT_CHECK_ENCODING(encoding)
112# ----------------------------------
113# Minimum version: 1.1.0
114# This macro adds --enable/disable-<encoding>, enabled by default.
115# It replaced individual copies of this code in the above macros in 1.1.
116# Currently assumes encoding names will be all upper-case - add m4_toupper
117# calls if this is not true in the future.
118
119AC_DEFUN([XORG_FONT_CHECK_ENCODING],[
120	AC_ARG_ENABLE(m4_tolower($1),
121		AS_HELP_STRING(m4_join([-], [--disable], m4_tolower($1)),
122				[Build $1 fonts (default: yes)]),
123		[AS_TR_SH($1)=$enableval], [AS_TR_SH($1)=yes])
124	AC_MSG_CHECKING([whether to build $1 fonts])
125	AC_MSG_RESULT($[AS_TR_SH($1)])
126	AM_CONDITIONAL(AS_TR_SH($1), [test "x$AS_TR_SH($1)" = xyes])
127]) # XORG_FONT_CHECK_ENCODING
128
129# XORG_FONT_CHECK_ENCODING_LIST(encoding1 encoding2....)
130# -----------------------------------------------------
131# Minimum version: 1.1.0
132# Call XORG_FONT_CHECK_ENCODING for multiple encodings at once
133
134AC_DEFUN([XORG_FONT_CHECK_ENCODING_LIST],[
135	m4_foreach_w([enc], [$1], [XORG_FONT_CHECK_ENCODING(enc)])
136]) # XORG_FONT_CHECK_ENCODING_LIST
137
138# XORG_FONT_REQUIRED_PROG(VARNAME, progname)
139# ------------------------------------------
140# Minimum version: 1.1.0
141#
142# Simple wrapper around AC_PATH_PROG that errors if not found
143#
144
145AC_DEFUN([XORG_FONT_REQUIRED_PROG],[
146	AC_PATH_PROG($1, $2)
147	if test x"$1" = x; then
148		AC_MSG_ERROR([$2 is required to build $PACKAGE_NAME.])
149	fi
150])
151
152
153# XORG_FONT_FCCACHE()
154# -------------------
155# Minimum version: 1.1.0
156#
157# Set FCCACHE to path to fc-cache (fontconfig cache builder) if found
158# Set RUN_FCCACHE to a rule suitable for substituting into a makefile
159# to run fc-cache if found and not installing to $DESTDIR
160#
161# fc-cache is optional, not required, and should be skipped when making
162# packages (installing to $DESTDIR).
163#
164AC_DEFUN([XORG_FONT_FCCACHE],[
165	AC_PATH_PROG(FCCACHE, fc-cache)
166	FCCACHE_WARN='echo "** Warning: fonts.cache not built" ; echo "** Generate this file manually on host system using fc-cache"'
167	if test x"$FCCACHE" = x ; then
168		RUN_FCCACHE="${FCCACHE_WARN}"
169	else
170		RUN_FCCACHE='@(if test -z "$(DESTDIR)"; then echo $(FCCACHE) $(fontdir); $(FCCACHE) $(fontdir); else'
171		RUN_FCCACHE="${RUN_FCCACHE} ${FCCACHE_WARN} ; fi)"
172	fi
173	AC_SUBST([RUN_FCCACHE])
174])
175
176
177# XORG_FONT_COMMON_UTILS()
178# ------------------------
179# Minimum version: 1.1.0
180#
181# Call XORG_FONT_REQUIRED_PROG for programs needed for all font types
182
183AC_DEFUN([XORG_FONT_COMMON_UTILS],[
184	XORG_FONT_FCCACHE
185	XORG_FONT_REQUIRED_PROG(MKFONTDIR, mkfontdir)
186])
187
188# XORG_FONT_SCALED_UTILS()
189# ------------------------
190# Minimum version: 1.1.0
191#
192# Call XORG_FONT_REQUIRED_PROG for programs needed for scalable fonts
193# (TrueType, OpenType, Type1)
194
195AC_DEFUN([XORG_FONT_SCALED_UTILS],[
196	XORG_FONT_COMMON_UTILS
197	XORG_FONT_REQUIRED_PROG(MKFONTSCALE, mkfontscale)
198])
199
200# XORG_FONT_BDF_UTILS()
201# ---------------------
202# Minimum version: 1.1.0
203#
204# Call XORG_FONT_REQUIRED_PROG for programs needed for BDF format bitmap fonts
205# Also call XORG_FONT_CHECK_COMPRESSION to determine how to compress the
206# PCF output files created by bdftopcf
207
208AC_DEFUN([XORG_FONT_BDF_UTILS],[
209	XORG_FONT_COMMON_UTILS
210	XORG_FONT_REQUIRED_PROG(BDFTOPCF, bdftopcf)
211	XORG_FONT_CHECK_COMPRESSION
212])
213
214# XORG_FONT_CHECK_COMPRESSION()
215# -----------------------------
216# Minimum version: 1.1.0
217#
218# Offer a --with-compression flag to control what compression method is
219# used for pcf font files.   Offers all the methods currently supported
220# by libXfont, including no compression.
221
222AC_DEFUN([XORG_FONT_CHECK_COMPRESSION],[
223	AC_MSG_CHECKING([font compression method])
224	AC_ARG_WITH(compression,
225	 [AS_HELP_STRING([--with-compression=<no|compress|gzip|bzip2>],
226			 [compression method to use on pcf fonts])],
227         [compression="$withval"], [compression="yes"])
228	if test x"$compression" = "xyes" ; then
229		compression="gzip"
230	fi
231	AC_MSG_RESULT([${compression}])
232	case ${compression} in
233	 *compress)	COMPRESS_SUFFIX=".Z" ;;
234	 *gzip)		COMPRESS_SUFFIX=".gz" ;;
235	 *bzip2)	COMPRESS_SUFFIX=".bz2" ;;
236	 no|none)	COMPRESS_SUFFIX="" ; COMPRESS="cat" ;;
237	 *) AC_MSG_ERROR([${compression} is not a supported compression method]) ;;
238	esac
239	if test x"$COMPRESS_SUFFIX" != "x" ; then
240	   XORG_FONT_REQUIRED_PROG(COMPRESS, ${compression})
241	fi
242	AC_SUBST([COMPRESS_SUFFIX])
243])
244
245# XORG_FONT_UCS2ANY()
246# -------------------
247# Minimum version: 1.1.0
248#
249# Call XORG_FONT_REQUIRED_PROG for ucs2any program needed for splitting
250# Unicode-encoded BDF format bitmap fonts into subsets for older encodings.
251# Also call pkg-config to find the directory with the encoding files needed
252# by ucs2any, and export it as MAPFILES_PATH to the Makefiles
253
254AC_DEFUN([XORG_FONT_UCS2ANY],[
255	XORG_FONT_REQUIRED_PROG(UCS2ANY, ucs2any)
256	PKG_CHECK_MODULES(MAPS, [fontutil])
257	AC_MSG_CHECKING([for ucs2any encoding data files])
258	MAPFILES_PATH=`pkg-config --variable=mapdir fontutil`
259	AC_SUBST(MAPFILES_PATH)
260	AC_MSG_RESULT([${MAPFILES_PATH}])
261])
262
263
264
265# XORG_FONTROOTDIR()
266# --------------------
267# Minimum version: 1.1.0
268#
269# Sets FONTROOTDIR to the root directory for font files.  Uses the first
270# found from:
271#	--with-fontrootdir
272#	pkg-config --variable=fontrootdir fontutil
273#	${datadir}/fonts/X11
274
275AC_DEFUN([XORG_FONTROOTDIR],[
276	dnl Ensure $PKG_CONFIG is set first
277	AC_REQUIRE([PKG_PROG_PKG_CONFIG])
278
279	AC_MSG_CHECKING([for root directory for font files])
280	AC_ARG_WITH(fontrootdir,
281		    AS_HELP_STRING([--with-fontrootdir=DIR],
282			   [Path to root directory for font files]),
283		    [FONTROOTDIR="$withval"])
284	# if --with-fontrootdir not specified...
285	if test "x${FONTROOTDIR}" = "x"; then
286		FONTROOTDIR=`$PKG_CONFIG --variable=fontrootdir fontutil`
287	fi
288	# ...and if pkg-config didn't find fontdir in fontutil.pc...
289	if test "x${FONTROOTDIR}" = "x"; then
290		FONTROOTDIR="${datadir}/fonts/X11"
291	fi
292	AC_SUBST(FONTROOTDIR)
293	AC_MSG_RESULT([${FONTROOTDIR}])
294])
295
296# XORG_FONTSUBDIR(variable, flag, subdir)
297# ---------------------------------------
298# Minimum version: 1.1.0
299#
300# Offer a --with-<flag> flag to control directory for font installation
301# Default is the specified <subdir> of the font root directory.
302# Sets <variable> to the selected directory
303
304AC_DEFUN([XORG_FONTSUBDIR],[
305	AC_REQUIRE([XORG_FONTROOTDIR])
306
307	AC_MSG_CHECKING([for directory for $3 files])
308	AC_ARG_WITH($2,
309		    [AS_HELP_STRING([--with-$2=DIR],
310				    [Path to $3 files [FONTROOTDIR/$3]])],
311		    [$1="${withval}"], [$1='${FONTROOTDIR}/$3'])
312	AC_SUBST($1)
313	AC_MSG_RESULT([${$1}])
314]) # XORG_FONTSUBDIR
315
316# XORG_FONTDIR(subdir)
317# --------------------
318# Minimum version: 1.1.0
319#
320# Offer a --with-fontdir flag to control directory for font installation
321# Default is the specified subdir of the font root directory.
322# Sets FONTDIR to the selected directory
323
324AC_DEFUN([XORG_FONTDIR],[XORG_FONTSUBDIR([FONTDIR], [fontdir], [$1])])
325