summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 34367961507fcd29f593e48690ec194ad09c0711 (plain)
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#  Copyright © 2003 Keith Packard
#
#  Permission to use, copy, modify, distribute, and sell this software and its
#  documentation for any purpose is hereby granted without fee, provided that
#  the above copyright notice appear in all copies and that both that
#  copyright notice and this permission notice appear in supporting
#  documentation, and that the name of Keith Packard not be used in
#  advertising or publicity pertaining to distribution of the software without
#  specific, written prior permission.  Keith Packard makes no
#  representations about the suitability of this software for any purpose.  It
#  is provided "as is" without express or implied warranty.
#
#  KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
#  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
#  EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
#  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
#  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
#  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
#  PERFORMANCE OF THIS SOFTWARE.
#

# Initialize Autoconf
AC_PREREQ([2.70])
AC_INIT([libXfont2], [2.0.6],
	[https://gitlab.freedesktop.org/xorg/lib/libxfont/-/issues], [libXfont2])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])

# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-xz subdir-objects])

# Set common system defines for POSIX extensions, such as _GNU_SOURCE
# Must be called before any macros that run the compiler (like
# LT_INIT) to avoid autoconf errors.
AC_USE_SYSTEM_EXTENSIONS

# Initialize libtool
LT_INIT

# Require xorg-macros minimum of 1.10 for DocBook XML documentation
m4_ifndef([XORG_MACROS_VERSION],
          [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.10)
XORG_DEFAULT_OPTIONS
XORG_ENABLE_DEVEL_DOCS
XORG_WITH_XMLTO(0.0.22)
XORG_WITH_FOP
XORG_CHECK_SGML_DOCTOOLS(1.7)

# Checks for header files.
AC_CHECK_HEADERS([endian.h poll.h sys/poll.h])

# Checks for non-standard functions and fallback to libbsd if we can
AC_LINK_IFELSE([AC_LANG_CALL([], [reallocarray])],
               [TRY_LIBBSD="no"], [TRY_LIBBSD="yes"])
AC_LINK_IFELSE([AC_LANG_CALL([], [strlcat])],
               [TRY_LIBBSD="no"], [TRY_LIBBSD="yes"])
AS_IF([test "x$TRY_LIBBSD" = "xyes"],
      [PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay], [
	CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
	LIBS="$LIBS $LIBBSD_LIBS"
], [:])])

# Checks for library functions.
AC_CHECK_FUNCS([poll readlink strlcat])
AC_CONFIG_LIBOBJ_DIR([src/util])
AC_REPLACE_FUNCS([reallocarray realpath strlcat strlcpy])

# Checks for header files.
AC_CHECK_HEADERS([err.h float.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_SYS_LARGEFILE

#
# select libraries to include
#

XFONT_FONTFILE=no

#
# FreeType for all scalable (OpenType, TrueType, PostScript) and
# some bitmap formats (BDF & PCF)
#
AC_ARG_ENABLE(freetype,
	AS_HELP_STRING([--disable-freetype],
		[Build freetype backend (default: enabled)]),
	[XFONT_FREETYPE=$enableval],[XFONT_FREETYPE=yes])
AM_CONDITIONAL(XFONT_FREETYPE, [test x$XFONT_FREETYPE = xyes])
if test x$XFONT_FREETYPE = xyes; then
	AC_DEFINE(XFONT_FREETYPE,1,[Support FreeType rasterizer for nearly all font file formats])
	AC_ARG_WITH(freetype-config,
		AS_HELP_STRING([--with-freetype-config=PROG],
			[Use FreeType configuration program PROG]),
		[freetype_config=$withval], [freetype_config=auto])

	if test "$freetype_config" = "auto" ; then
		PKG_CHECK_MODULES(FREETYPE, freetype2,
			freetype_config=no, freetype_config=yes)
	fi

	if test "$freetype_config" = "yes"; then
		AC_PATH_PROG(ft_config,freetype-config,no)
		if test "$ft_config" = "no"; then
			AC_MSG_ERROR([You must have freetype installed; see http://www.freetype.org/])
		fi
	else
		ft_config="$freetype_config"
	fi

	if test "$freetype_config" != "no"; then
		FREETYPE_CFLAGS="`$ft_config --cflags`"
		FREETYPE_LIBS="`$ft_config --libs`"
	fi
	FREETYPE_REQUIRES="freetype2"
	XFONT_FONTFILE=yes
else
	FREETYPE_CFLAGS=""
	FREETYPE_LIBS=""
	FREETYPE_REQUIRES=""
fi
AC_SUBST(FREETYPE_LIBS)
AC_SUBST(FREETYPE_CFLAGS)
AC_SUBST(FREETYPE_REQUIRES)

#
# Bitmap fonts in files:
#	Builtins (gzipped pcf format in .text segment)
#	PCF
#	BDF
#	SNF
#

AC_DEFINE(X_GZIP_FONT_COMPRESSION,1,[Support gzip for bitmap fonts])
X_GZIP_FONT_COMPRESSION=1
AC_SUBST(X_GZIP_FONT_COMPRESSION)
PKG_CHECK_MODULES(ZLIB, [zlib], [Z_REQUIRES=zlib], [Z_REQUIRES=""])
if test "x$Z_REQUIRES" = "x"; then
	AC_CHECK_LIB(z, gzopen, [Z_LIBS=-lz],
		AC_MSG_ERROR([*** zlib is required]))
fi
AC_SUBST(Z_REQUIRES)

AC_ARG_WITH(bzip2,
	AS_HELP_STRING([--with-bzip2],
	  [Use libbz2 to support bzip2 compressed bitmap fonts (default: no)]),
	[], [with_bzip2=no])
if test "x$with_bzip2" = xyes; then
	AC_CHECK_LIB(bz2, BZ2_bzopen, [Z_LIBS="$Z_LIBS -lbz2"],
		AC_MSG_ERROR([*** libbz2 is required for bzip2 support]))
	AC_DEFINE(X_BZIP2_FONT_COMPRESSION,1,[Support bzip2 for bitmap fonts])
fi
AM_CONDITIONAL(X_BZIP2_FONT_COMPRESSION, [test "x$with_bzip2" = xyes ])
AC_SUBST(Z_LIBS)

AC_ARG_ENABLE(builtins,
	AS_HELP_STRING([--disable-builtins],
		[Support builtin fonts (default: enabled)]),
	[XFONT_BUILTINS=$enableval], [XFONT_BUILTINS=yes])
AM_CONDITIONAL(XFONT_BUILTINS, [test "x$XFONT_BUILTINS" = xyes ])
if test "x$XFONT_BUILTINS" = xyes; then
	AC_DEFINE(XFONT_BUILTINS,1,[Support built-in fonts])
	XFONT_BITMAP=yes
fi

AC_ARG_ENABLE(pcfformat,
	AS_HELP_STRING([--disable-pcfformat],
		[Support PCF format bitmap fonts (default: enabled)]),
	[XFONT_PCFFORMAT=$enableval], [XFONT_PCFFORMAT=yes])
AM_CONDITIONAL(XFONT_PCFFORMAT, [test "x$XFONT_PCFFORMAT" = xyes])
if test "x$XFONT_PCFFORMAT" = xyes; then
	AC_DEFINE(XFONT_PCFFORMAT,1,[Support pcf format bitmap font files])
	XFONT_BITMAP=yes
fi

AM_CONDITIONAL(XFONT_PCF_OR_BUILTIN,
	[test "x$XFONT_PCFFORMAT" = xyes -o "x$XFONT_BUILTINS" = xyes])

AC_ARG_ENABLE(bdfformat,
	AS_HELP_STRING([--disable-bdfformat],
		[Support BDF format bitmap fonts (default: enabled)]),
	[XFONT_BDFFORMAT=$enableval], [XFONT_BDFFORMAT=yes])
AM_CONDITIONAL(XFONT_BDFFORMAT, [test "x$XFONT_BDFFORMAT" = xyes])
if test "x$XFONT_BDFFORMAT" = xyes; then
	AC_DEFINE(XFONT_BDFFORMAT,1,[Support bdf format bitmap font files])
	XFONT_BITMAP=yes
fi

AC_ARG_ENABLE(snfformat,
	AS_HELP_STRING([--enable-snfformat],
		[Support SNF format bitmap fonts (default: disabled)]),
	[XFONT_SNFFORMAT=$enableval], [XFONT_SNFFORMAT=no])
AM_CONDITIONAL(XFONT_SNFFORMAT, [test "x$XFONT_SNFFORMAT" = xyes])
if test "x$XFONT_SNFFORMAT" = xyes; then
	AC_DEFINE(XFONT_SNFFORMAT,1,[Support snf format bitmap font files])
	XFONT_BITMAP=yes
fi

AM_CONDITIONAL(XFONT_BITMAP, [test "x$XFONT_BITMAP" = xyes ])
if test "x$XFONT_BITMAP" = xyes; then
	AC_DEFINE(XFONT_BITMAP,1,[Support bitmap font files])
	XFONT_FONTFILE=yes
fi

AM_CONDITIONAL(XFONT_FONTFILE, [test "x$XFONT_FONTFILE" = xyes])
if test "x$XFONT_FONTFILE" = xyes; then
	AC_DEFINE(XFONT_FONTFILE,1,[Support fonts in files])
fi

#
# Support connection to font servers?
#

AC_ARG_ENABLE(fc,
	AS_HELP_STRING([--disable-fc],
		[Support connections to xfs servers (default: enabled)]),
	[XFONT_FC=$enableval],[XFONT_FC=yes])
AM_CONDITIONAL(XFONT_FC, [test "x$XFONT_FC" = xyes])
if test "x$XFONT_FC" = xyes; then
	AC_DEFINE(XFONT_FC,1,[Support the X Font Services Protocol])
fi


AC_CHECK_LIB(m, hypot, [MATH_LIBS=-lm
AC_SUBST(MATH_LIBS)], AC_MSG_ERROR([*** libm is required]))

PKG_CHECK_MODULES(XFONT, [xproto xtrans fontsproto >= 2.1.3 fontenc])

# Transport selection macro from xtrans.m4
XTRANS_CONNECTION_FLAGS

case $host_os in
    linux*)
        OS_CFLAGS="-D_XOPEN_SOURCE"
        ;;
    *)
        OS_CFLAGS=
        ;;
esac

save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fvisibility=hidden"
CFLAGS_VISIBILITY=
AC_COMPILE_IFELSE(
  [AC_LANG_SOURCE([[
    #if defined(__CYGWIN__) || defined(__MINGW32__)
    #error No visibility support
    #endif
    extern __attribute__((__visibility__("default"))) int x;
  ]])],
  [CFLAGS_VISIBILITY=-fvisibility=hidden],
  []
)
CFLAGS="$save_CFLAGS"
OS_CFLAGS="$OS_CFLAGS $CFLAGS_VISIBILITY"

AC_SUBST([OS_CFLAGS])

AC_CONFIG_FILES([Makefile
		doc/Makefile
		xfont2.pc])
AC_OUTPUT