1# Copyright © 2003 Keith Packard 2# 3# Permission to use, copy, modify, distribute, and sell this software and its 4# documentation for any purpose is hereby granted without fee, provided that 5# the above copyright notice appear in all copies and that both that 6# copyright notice and this permission notice appear in supporting 7# documentation, and that the name of Keith Packard not be used in 8# advertising or publicity pertaining to distribution of the software without 9# specific, written prior permission. Keith Packard makes no 10# representations about the suitability of this software for any purpose. It 11# is provided "as is" without express or implied warranty. 12# 13# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 14# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 15# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 16# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 17# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19# PERFORMANCE OF THIS SOFTWARE. 20# 21 22# Initialize Autoconf 23AC_PREREQ([2.70]) 24AC_INIT([libXfont2], [2.0.7], 25 [https://gitlab.freedesktop.org/xorg/lib/libxfont/-/issues], [libXfont2]) 26AC_CONFIG_SRCDIR([Makefile.am]) 27AC_CONFIG_HEADERS([config.h]) 28AC_CONFIG_MACRO_DIRS([m4]) 29 30# Initialize Automake 31AM_INIT_AUTOMAKE([foreign dist-xz subdir-objects]) 32 33# Set common system defines for POSIX extensions, such as _GNU_SOURCE 34# Must be called before any macros that run the compiler (like 35# LT_INIT) to avoid autoconf errors. 36AC_USE_SYSTEM_EXTENSIONS 37 38# Initialize libtool 39LT_INIT 40 41# Require xorg-macros minimum of 1.10 for DocBook XML documentation 42m4_ifndef([XORG_MACROS_VERSION], 43 [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])]) 44XORG_MACROS_VERSION(1.10) 45XORG_DEFAULT_OPTIONS 46XORG_ENABLE_DEVEL_DOCS 47XORG_WITH_XMLTO(0.0.22) 48XORG_WITH_FOP 49XORG_CHECK_SGML_DOCTOOLS(1.7) 50 51# Checks for header files. 52AC_CHECK_HEADERS([endian.h poll.h sys/poll.h]) 53 54# Checks for non-standard functions and fallback to libbsd if we can 55AC_LINK_IFELSE([AC_LANG_CALL([], [reallocarray])], 56 [TRY_LIBBSD="no"], [TRY_LIBBSD="yes"]) 57AC_LINK_IFELSE([AC_LANG_CALL([], [strlcat])], 58 [TRY_LIBBSD="no"], [TRY_LIBBSD="yes"]) 59AS_IF([test "x$TRY_LIBBSD" = "xyes"], 60 [PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay], [ 61 CFLAGS="$CFLAGS $LIBBSD_CFLAGS" 62 LIBS="$LIBS $LIBBSD_LIBS" 63], [:])]) 64 65# Checks for library functions. 66AC_CHECK_FUNCS([poll readlink strlcat]) 67AC_CONFIG_LIBOBJ_DIR([src/util]) 68AC_REPLACE_FUNCS([reallocarray realpath strlcat strlcpy]) 69 70# Checks for header files. 71AC_CHECK_HEADERS([err.h float.h]) 72 73# Checks for typedefs, structures, and compiler characteristics. 74AC_SYS_LARGEFILE 75 76# 77# select libraries to include 78# 79 80XFONT_FONTFILE=no 81 82# 83# FreeType for all scalable (OpenType, TrueType, PostScript) and 84# some bitmap formats (BDF & PCF) 85# 86AC_ARG_ENABLE(freetype, 87 AS_HELP_STRING([--disable-freetype], 88 [Build freetype backend (default: enabled)]), 89 [XFONT_FREETYPE=$enableval],[XFONT_FREETYPE=yes]) 90AM_CONDITIONAL(XFONT_FREETYPE, [test x$XFONT_FREETYPE = xyes]) 91if test x$XFONT_FREETYPE = xyes; then 92 AC_DEFINE(XFONT_FREETYPE,1,[Support FreeType rasterizer for nearly all font file formats]) 93 AC_ARG_WITH(freetype-config, 94 AS_HELP_STRING([--with-freetype-config=PROG], 95 [Use FreeType configuration program PROG]), 96 [freetype_config=$withval], [freetype_config=auto]) 97 98 if test "$freetype_config" = "auto" ; then 99 PKG_CHECK_MODULES(FREETYPE, freetype2, 100 freetype_config=no, freetype_config=yes) 101 fi 102 103 if test "$freetype_config" = "yes"; then 104 AC_PATH_PROG(ft_config,freetype-config,no) 105 if test "$ft_config" = "no"; then 106 AC_MSG_ERROR([You must have freetype installed; see http://www.freetype.org/]) 107 fi 108 else 109 ft_config="$freetype_config" 110 fi 111 112 if test "$freetype_config" != "no"; then 113 FREETYPE_CFLAGS="`$ft_config --cflags`" 114 FREETYPE_LIBS="`$ft_config --libs`" 115 fi 116 FREETYPE_REQUIRES="freetype2" 117 XFONT_FONTFILE=yes 118else 119 FREETYPE_CFLAGS="" 120 FREETYPE_LIBS="" 121 FREETYPE_REQUIRES="" 122fi 123AC_SUBST(FREETYPE_LIBS) 124AC_SUBST(FREETYPE_CFLAGS) 125AC_SUBST(FREETYPE_REQUIRES) 126 127# 128# Bitmap fonts in files: 129# Builtins (gzipped pcf format in .text segment) 130# PCF 131# BDF 132# SNF 133# 134 135AC_DEFINE(X_GZIP_FONT_COMPRESSION,1,[Support gzip for bitmap fonts]) 136X_GZIP_FONT_COMPRESSION=1 137AC_SUBST(X_GZIP_FONT_COMPRESSION) 138PKG_CHECK_MODULES(ZLIB, [zlib], [Z_REQUIRES=zlib], [Z_REQUIRES=""]) 139if test "x$Z_REQUIRES" = "x"; then 140 AC_CHECK_LIB(z, gzopen, [Z_LIBS=-lz], 141 AC_MSG_ERROR([*** zlib is required])) 142fi 143AC_SUBST(Z_REQUIRES) 144 145AC_ARG_WITH(bzip2, 146 AS_HELP_STRING([--with-bzip2], 147 [Use libbz2 to support bzip2 compressed bitmap fonts (default: no)]), 148 [], [with_bzip2=no]) 149if test "x$with_bzip2" = xyes; then 150 AC_CHECK_LIB(bz2, BZ2_bzopen, [Z_LIBS="$Z_LIBS -lbz2"], 151 AC_MSG_ERROR([*** libbz2 is required for bzip2 support])) 152 AC_DEFINE(X_BZIP2_FONT_COMPRESSION,1,[Support bzip2 for bitmap fonts]) 153fi 154AM_CONDITIONAL(X_BZIP2_FONT_COMPRESSION, [test "x$with_bzip2" = xyes ]) 155AC_SUBST(Z_LIBS) 156 157AC_ARG_ENABLE(builtins, 158 AS_HELP_STRING([--disable-builtins], 159 [Support builtin fonts (default: enabled)]), 160 [XFONT_BUILTINS=$enableval], [XFONT_BUILTINS=yes]) 161AM_CONDITIONAL(XFONT_BUILTINS, [test "x$XFONT_BUILTINS" = xyes ]) 162if test "x$XFONT_BUILTINS" = xyes; then 163 AC_DEFINE(XFONT_BUILTINS,1,[Support built-in fonts]) 164 XFONT_BITMAP=yes 165fi 166 167AC_ARG_ENABLE(pcfformat, 168 AS_HELP_STRING([--disable-pcfformat], 169 [Support PCF format bitmap fonts (default: enabled)]), 170 [XFONT_PCFFORMAT=$enableval], [XFONT_PCFFORMAT=yes]) 171AM_CONDITIONAL(XFONT_PCFFORMAT, [test "x$XFONT_PCFFORMAT" = xyes]) 172if test "x$XFONT_PCFFORMAT" = xyes; then 173 AC_DEFINE(XFONT_PCFFORMAT,1,[Support pcf format bitmap font files]) 174 XFONT_BITMAP=yes 175fi 176 177AM_CONDITIONAL(XFONT_PCF_OR_BUILTIN, 178 [test "x$XFONT_PCFFORMAT" = xyes -o "x$XFONT_BUILTINS" = xyes]) 179 180AC_ARG_ENABLE(bdfformat, 181 AS_HELP_STRING([--disable-bdfformat], 182 [Support BDF format bitmap fonts (default: enabled)]), 183 [XFONT_BDFFORMAT=$enableval], [XFONT_BDFFORMAT=yes]) 184AM_CONDITIONAL(XFONT_BDFFORMAT, [test "x$XFONT_BDFFORMAT" = xyes]) 185if test "x$XFONT_BDFFORMAT" = xyes; then 186 AC_DEFINE(XFONT_BDFFORMAT,1,[Support bdf format bitmap font files]) 187 XFONT_BITMAP=yes 188fi 189 190AC_ARG_ENABLE(snfformat, 191 AS_HELP_STRING([--enable-snfformat], 192 [Support SNF format bitmap fonts (default: disabled)]), 193 [XFONT_SNFFORMAT=$enableval], [XFONT_SNFFORMAT=no]) 194AM_CONDITIONAL(XFONT_SNFFORMAT, [test "x$XFONT_SNFFORMAT" = xyes]) 195if test "x$XFONT_SNFFORMAT" = xyes; then 196 AC_DEFINE(XFONT_SNFFORMAT,1,[Support snf format bitmap font files]) 197 XFONT_BITMAP=yes 198fi 199 200AM_CONDITIONAL(XFONT_BITMAP, [test "x$XFONT_BITMAP" = xyes ]) 201if test "x$XFONT_BITMAP" = xyes; then 202 AC_DEFINE(XFONT_BITMAP,1,[Support bitmap font files]) 203 XFONT_FONTFILE=yes 204fi 205 206AM_CONDITIONAL(XFONT_FONTFILE, [test "x$XFONT_FONTFILE" = xyes]) 207if test "x$XFONT_FONTFILE" = xyes; then 208 AC_DEFINE(XFONT_FONTFILE,1,[Support fonts in files]) 209fi 210 211# 212# Support connection to font servers? 213# 214 215AC_ARG_ENABLE(fc, 216 AS_HELP_STRING([--disable-fc], 217 [Support connections to xfs servers (default: enabled)]), 218 [XFONT_FC=$enableval],[XFONT_FC=yes]) 219AM_CONDITIONAL(XFONT_FC, [test "x$XFONT_FC" = xyes]) 220if test "x$XFONT_FC" = xyes; then 221 AC_DEFINE(XFONT_FC,1,[Support the X Font Services Protocol]) 222fi 223 224 225AC_CHECK_LIB(m, hypot, [MATH_LIBS=-lm 226AC_SUBST(MATH_LIBS)], AC_MSG_ERROR([*** libm is required])) 227 228PKG_CHECK_MODULES(XFONT, [xproto xtrans fontsproto >= 2.1.3 fontenc]) 229 230# Transport selection macro from xtrans.m4 231XTRANS_CONNECTION_FLAGS 232 233case $host_os in 234 linux*) 235 OS_CFLAGS="-D_XOPEN_SOURCE" 236 ;; 237 *) 238 OS_CFLAGS= 239 ;; 240esac 241 242save_CFLAGS="$CFLAGS" 243CFLAGS="$CFLAGS -fvisibility=hidden" 244CFLAGS_VISIBILITY= 245AC_COMPILE_IFELSE( 246 [AC_LANG_SOURCE([[ 247 #if defined(__CYGWIN__) || defined(__MINGW32__) 248 #error No visibility support 249 #endif 250 extern __attribute__((__visibility__("default"))) int x; 251 ]])], 252 [CFLAGS_VISIBILITY=-fvisibility=hidden], 253 [] 254) 255CFLAGS="$save_CFLAGS" 256OS_CFLAGS="$OS_CFLAGS $CFLAGS_VISIBILITY" 257 258AC_SUBST([OS_CFLAGS]) 259 260AC_CONFIG_FILES([Makefile 261 doc/Makefile 262 xfont2.pc]) 263AC_OUTPUT 264