Fix a incompatible pointer warning on NetBSD
[platform/upstream/fontconfig.git] / configure.ac
1 dnl 
2 dnl  fontconfig/configure.in
3 dnl 
4 dnl  Copyright © 2003 Keith Packard
5 dnl 
6 dnl  Permission to use, copy, modify, distribute, and sell this software and its
7 dnl  documentation for any purpose is hereby granted without fee, provided that
8 dnl  the above copyright notice appear in all copies and that both that
9 dnl  copyright notice and this permission notice appear in supporting
10 dnl  documentation, and that the name of the author(s) not be used in
11 dnl  advertising or publicity pertaining to distribution of the software without
12 dnl  specific, written prior permission.  The authors make no
13 dnl  representations about the suitability of this software for any purpose.  It
14 dnl  is provided "as is" without express or implied warranty.
15 dnl 
16 dnl  THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 dnl  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 dnl  EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 dnl  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 dnl  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 dnl  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 dnl  PERFORMANCE OF THIS SOFTWARE.
23 dnl
24 dnl Process this file with autoconf to create configure.
25
26 AC_PREREQ(2.61)
27
28 dnl ==========================================================================
29 dnl                               Versioning              
30 dnl ==========================================================================
31
32 dnl This is the package version number, not the shared library
33 dnl version.  This same version number must appear in fontconfig/fontconfig.h
34 dnl Yes, it is a pain to synchronize version numbers.  Unfortunately, it's
35 dnl not possible to extract the version number here from fontconfig.h
36 AC_INIT([fontconfig], [2.10.93], [https://bugs.freedesktop.org/enger_bug.cgi?product=fontconfig])
37 AM_INIT_AUTOMAKE([1.11 parallel-tests dist-bzip2])
38 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
39
40 dnl libtool versioning
41
42 dnl bump revision when fixing bugs
43 dnl bump current and age, reset revision to zero when adding APIs
44 dnl bump current, leave age, reset revision to zero when changing/removing APIS
45 LIBT_CURRENT=8
46 LIBT_REVISION=0
47 AC_SUBST(LIBT_CURRENT)
48 AC_SUBST(LIBT_REVISION)
49 LIBT_AGE=7
50
51 LIBT_VERSION_INFO="$LIBT_CURRENT:$LIBT_REVISION:$LIBT_AGE"
52 AC_SUBST(LIBT_VERSION_INFO)
53
54 LIBT_CURRENT_MINUS_AGE=`expr $LIBT_CURRENT - $LIBT_AGE`
55 AC_SUBST(LIBT_CURRENT_MINUS_AGE)
56
57 dnl ==========================================================================
58
59 AC_CONFIG_HEADERS(config.h)
60 AC_CONFIG_MACRO_DIR([m4])
61
62 AC_PROG_CC
63 AC_USE_SYSTEM_EXTENSIONS
64 AC_SYS_LARGEFILE
65 AC_PROG_INSTALL
66 AC_PROG_LN_S
67 AC_LIBTOOL_WIN32_DLL
68 AM_PROG_LIBTOOL
69 AC_PROG_MAKE_SET
70 PKG_PROG_PKG_CONFIG
71 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig))
72
73 AM_MISSING_PROG([GIT], [git])
74 AM_MISSING_PROG([GPERF], [gperf])
75
76 AC_MSG_CHECKING([for RM macro])
77 _predefined_rm=`make -p -f /dev/null 2>/dev/null|grep '^RM ='|sed -e 's/^RM = //'`
78 if test "x$_predefined_rm" = "x"; then
79         AC_MSG_RESULT([no predefined RM])
80         AC_CHECK_PROG(RM, rm, [rm -f])
81 else
82         AC_MSG_RESULT($_predefined_rm)
83 fi
84
85 dnl ==========================================================================
86
87 case "$host" in
88   *-*-mingw*)
89     os_win32=yes
90     ;;
91   *)
92     os_win32=no
93 esac
94 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
95
96 if test "$os_win32" = "yes"; then
97   AC_CHECK_PROG(ms_librarian, lib.exe, yes, no)
98 fi
99 AM_CONDITIONAL(MS_LIB_AVAILABLE, test x$ms_librarian = xyes)
100
101 WARN_CFLAGS=""
102 if test "x$GCC" = "xyes"; then
103         WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \
104         -Wmissing-prototypes -Wmissing-declarations \
105         -Wnested-externs -fno-strict-aliasing"
106         AC_DEFINE_UNQUOTED(HAVE_WARNING_CPP_DIRECTIVE,1,
107         [Can use #warning in C files])
108 fi
109 AC_SUBST(WARN_CFLAGS)
110
111
112 dnl ==========================================================================
113
114 AX_CC_FOR_BUILD()
115 AC_ARG_VAR(CC_FOR_BUILD, [build system C compiler])
116 AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
117 AM_CONDITIONAL(ENABLE_SHARED, test "$enable_shared" = "yes")
118
119 dnl ==========================================================================
120
121 AC_ARG_WITH(arch,
122         [AC_HELP_STRING([--with-arch=ARCH],
123                         [Force architecture to ARCH])],
124         arch="$withval", arch=auto)
125
126 if test "x$arch" != xauto; then
127         AC_DEFINE_UNQUOTED([FC_ARCHITECTURE], "$arch", [Architecture prefix to use for cache file names])
128 fi
129
130
131 dnl ==========================================================================
132
133 # Checks for header files.
134 AC_HEADER_DIRENT
135 AC_HEADER_STDC
136 AC_CHECK_HEADERS([fcntl.h regex.h stdlib.h string.h unistd.h sys/vfs.h sys/statfs.h sys/param.h sys/mount.h])
137 AX_CREATE_STDINT_H([src/fcstdint.h])
138
139 # Checks for typedefs, structures, and compiler characteristics.
140 AC_C_CONST
141 AC_C_INLINE
142 AC_C_FLEXIBLE_ARRAY_MEMBER
143 AC_TYPE_PID_T
144
145 # Checks for library functions.
146 AC_FUNC_VPRINTF
147 AC_FUNC_MMAP
148 AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r regcomp regerror regexec regfree fstatvfs fstatfs lstat])
149
150 dnl AC_CHECK_FUNCS doesn't check for header files.
151 dnl posix_fadvise() may be not available in older libc.
152 fc_saved_CFLAGS="$CFLAGS"
153 CFLAGS="$CFLAGS $WARN_CFLAGS -Werror"
154 AC_MSG_CHECKING([for posix_fadvise])
155 AC_LINK_IFELSE([AC_LANG_SOURCE([[
156         #include <fcntl.h>
157         int main(void) {
158             return posix_fadvise(0, 0, 0, 0);
159         }
160         ]])],[
161                 AC_MSG_RESULT([yes])
162                 AC_DEFINE([HAVE_POSIX_FADVISE], [1], [Define to 1 if you have the 'posix_fadvise' function.])
163         ],[AC_MSG_RESULT([no])])
164 AC_MSG_CHECKING([for scandir])
165 AC_LINK_IFELSE([AC_LANG_SOURCE([[
166         #include <dirent.h>
167         int comp(const struct dirent **, const struct dirent **);
168         int comp(const struct dirent **a, const struct dirent **b) { return 0; }
169         int main(void) {
170             struct dirent **d;
171             return scandir(".", &d, 0, &comp) >= 0;
172         }
173         ]])],[
174                 AC_MSG_RESULT([yes])
175                 AC_DEFINE([HAVE_SCANDIR], [1], [Define to 1 if you have the 'scandir' function.])
176         ],[
177                 AC_LINK_IFELSE([AC_LANG_SOURCE([[
178                         #include <dirent.h>
179                         int comp(const void *, const void *);
180                         int comp(const void *a, const void *b) { return 0; }
181                         int main(void) {
182                             struct dirent **d;
183                             return scandir(".", &d, 0, &comp) >= 0;
184                         }
185                 ]])],[
186                         AC_MSG_RESULT([yes])
187                         AC_DEFINE([HAVE_SCANDIR_VOID_P], [1], [Define to 1 if you have the 'scandir' function with int (* compar)(const void *, const void *)])
188                 ],[
189                         AC_MSG_ERROR([
190 *** No scandir function available.])
191                 ])
192         ])
193 CFLAGS="$fc_saved_CFLAGS"
194
195 #
196 if test "x$ac_cv_func_fstatvfs" = "xyes"; then
197         AC_CHECK_MEMBERS([struct statvfs.f_basetype, struct statvfs.f_fstypename],,,
198                 [#include <sys/statvfs.h>])
199 fi
200 if test "x$ac_cv_func_fstatfs" = "xyes"; then
201         AC_CHECK_MEMBERS([struct statfs.f_flags, struct statfs.f_fstypename],,, [
202 #ifdef HAVE_SYS_VFS_H
203 #include <sys/vfs.h>
204 #endif
205 #ifdef HAVE_SYS_STATFS_H
206 #include <sys/statfs.h>
207 #endif
208 #ifdef HAVE_SYS_PARAM_H
209 #include <sys/param.h>
210 #endif
211 #ifdef HAVE_SYS_MOUNT_H
212 #include <sys/mount.h>
213 #endif])
214 fi
215 AC_CHECK_MEMBERS([struct dirent.d_type],,,
216         [#include <dirent.h>])
217 #
218 # regex
219 #
220 if test "x$ac_cv_func_regcomp" = "xyes" -a "x$ac_cv_func_regerror" = "xyes" -a "x$ac_cv_func_regexec" = "xyes" -a "x$ac_cv_func_regfree"; then
221         AC_DEFINE(USE_REGEX,,[Use regex])
222 fi
223
224 #
225 # Checks for iconv
226 #
227 AC_ARG_ENABLE(iconv,
228         [AC_HELP_STRING([--enable-iconv],
229                         [Use iconv to support non-Unicode SFNT name])],
230         ,enable_iconv=no)
231 AC_ARG_WITH(libiconv,
232         [AC_HELP_STRING([--with-libiconv=DIR],
233                         [Use libiconv in DIR])],
234         [if test "x$withval" = "xyes"; then
235                 libiconv_prefix=$prefix
236          else
237                 libiconv_prefix=$withval
238          fi],
239         [libiconv_prefix=auto])
240 AC_ARG_WITH(libiconv-includes,
241         [AC_HELP_STRING([--with-libiconv-includes=DIR],
242                         [Use libiconv includes in DIR])],
243         [libiconv_includes=$withval],
244         [libiconv_includes=auto])
245 AC_ARG_WITH(libiconv-lib,
246         [AC_HELP_STRING([--with-libiconv-lib=DIR],
247                         [Use libiconv library in DIR])],
248         [libiconv_lib=$withval],
249         [libiconv_lib=auto])
250
251 # if no libiconv,libiconv-includes,libiconv-lib are specified,
252 # libc's iconv has a priority.
253 if test "$libiconv_includes" != "auto" -a -r ${libiconv_includes}/iconv.h; then
254         libiconv_cflags="-I${libiconv_includes}"
255 elif test "$libiconv_prefix" != "auto" -a -r ${libiconv_prefix}/include/iconv.h; then
256         libiconv_cflags="-I${libiconv_prefix}/include"
257 else
258         libiconv_cflags=""
259 fi
260 libiconv_libs=""
261 if test "x$libiconv_cflags" != "x"; then
262         if test "$libiconv_lib" != "auto" -a -d ${libiconv_lib}; then
263                 libiconv_libs="-L${libiconv_lib} -liconv"
264         elif test "$libiconv_prefix" != "auto" -a -d ${libiconv_prefix}/lib; then
265                 libiconv_libs="-L${libiconv_prefix}/lib -liconv"
266         else
267                 libiconv_libs="-liconv"
268         fi
269 fi
270
271 use_iconv=0
272 if test "x$enable_iconv" != "xno"; then
273         AC_MSG_CHECKING([for a usable iconv])
274         if test "x$libiconv_cflags" != "x" -o "x$libiconv_libs" != "x"; then
275                 iconvsaved_CFLAGS="$CFLAGS"
276                 iconvsaved_LIBS="$LIBS"
277                 CFLAGS="$CFLAGS $libiconv_cflags"
278                 LIBS="$LIBS $libiconv_libs"
279
280                 AC_TRY_LINK([#include <iconv.h>],
281                         [iconv_open ("from", "to");],
282                         [iconv_type="libiconv"
283                          use_iconv=1],
284                         [use_iconv=0])
285
286                 CFLAGS="$iconvsaved_CFLAGS"
287                 LIBS="$iconvsaved_LIBS"
288                 ICONV_CFLAGS="$libiconv_cflags"
289                 ICONV_LIBS="$libiconv_libs"
290         fi
291         if test "x$use_iconv" = "x0"; then
292                 AC_TRY_LINK([#include <iconv.h>],
293                         [iconv_open ("from", "to");],
294                         [iconv_type="libc"
295                          use_iconv=1],
296                         [iconv_type="not found"
297                          use_iconv=0])
298         fi
299
300         AC_MSG_RESULT([$iconv_type])
301         AC_SUBST(ICONV_CFLAGS)
302         AC_SUBST(ICONV_LIBS)
303 fi
304 AC_DEFINE_UNQUOTED(USE_ICONV,$use_iconv,[Use iconv.])
305 #
306 # Checks for FreeType
307 #
308 PKG_CHECK_MODULES(FREETYPE, freetype2)
309
310 AC_SUBST(FREETYPE_LIBS)
311 AC_SUBST(FREETYPE_CFLAGS)
312
313 fontconfig_save_libs="$LIBS"
314 fontconfig_save_cflags="$CFLAGS"
315 LIBS="$LIBS $FREETYPE_LIBS"
316 CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
317 AC_CHECK_FUNCS(FT_Get_Next_Char FT_Get_BDF_Property FT_Get_PS_Font_Info FT_Has_PS_Glyph_Names FT_Get_X11_Font_Format FT_Select_Size)
318 AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem,
319                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1,
320                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0,
321 [#include <ft2build.h>
322 #include FT_FREETYPE_H])
323 AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM,
324                    [FT_Bitmap_Size structure includes y_ppem field])
325 CFLAGS="$fontconfig_save_cflags"
326 LIBS="$fontconfig_save_libs"
327
328 #
329 # Check expat configuration
330 #
331 AC_ARG_WITH(expat,
332         [AC_HELP_STRING([--with-expat=DIR],
333                         [Use Expat in DIR])],
334         [expat_prefix=$withval],
335         [expat_prefix=auto])
336 AC_ARG_WITH(expat-includes,
337         [AC_HELP_STRING([--with-expat-includes=DIR],
338                         [Use Expat includes in DIR])],
339         [expat_includes=$withval],
340         [expat_includes=auto])
341 AC_ARG_WITH(expat-lib,
342         [AC_HELP_STRING([--with-expat-lib=DIR])],
343         [expat_lib=$withval],
344         [expat_lib=auto])
345
346 if test "$enable_libxml2" != "yes"; then
347         use_pkgconfig_for_expat=yes
348         if test "$expat_prefix" = "auto" -a "$expat_includes" = "auto" -a "$expat_lib" = "auto"; then
349                 PKG_CHECK_MODULES(EXPAT, expat,,use_pkgconfig_for_expat=no)
350         else
351                 use_pkgconfig_for_expat=no
352         fi
353         if test "x$use_pkgconfig_for_expat" = "xno"; then
354                 if test "$expat_includes" != "auto" -a -r ${expat_includes}/expat.h; then
355                         EXPAT_CFLAGS="-I${expat_includes}"
356                 elif test "$expat_prefix" != "auto" -a -r ${expat_prefix}/include/expat.h; then
357                         EXPAT_CFLAGS="-I${expat_prefix}/include"
358                 else
359                         EXPAT_CFLAGS=""
360                 fi
361                 if test "$expat_lib" != "auto"; then
362                         EXPAT_LIBS="-L${expat_lib} -lexpat"
363                 elif test "$expat_prefix" != "auto"; then
364                         EXPAT_LIBS="-L${expat_prefix}/lib -lexpat"
365                 else
366                         EXPAT_LIBS="-lexpat"
367                 fi
368         fi
369
370         expatsaved_CPPFLAGS="$CPPFLAGS"
371         expatsaved_LIBS="$LIBS"
372         CPPFLAGS="$CPPFLAGS $EXPAT_CFLAGS"
373         LIBS="$LIBS $EXPAT_LIBS"
374
375         AC_CHECK_HEADER(expat.h)
376         if test "$ac_cv_header_expat_h" = "no"; then
377                 AC_CHECK_HEADER(xmlparse.h)
378                 if test "$ac_cv_header_xmlparse_h" = "yes"; then
379                         HAVE_XMLPARSE_H=1
380                         AC_SUBST(HAVE_XMLPARSE_H)
381                         AC_DEFINE_UNQUOTED(HAVE_XMLPARSE_H,$HAVE_XMLPARSE_H,
382                                 [Use xmlparse.h instead of expat.h])
383                 else
384                         AC_MSG_ERROR([
385 *** expat is required. or try to use --enable-libxml2])
386                 fi
387         fi
388         AC_CHECK_FUNCS(XML_SetDoctypeDeclHandler)
389         if test "$ac_cv_func_XML_SetDoctypeDeclHandler" = "no"; then
390                 AC_MSG_ERROR([
391 *** expat is required. or try to use --enable-libxml2])
392         fi
393         CPPFLAGS="$expatsaved_CPPFLAGS"
394         LIBS="$expatsaved_LIBS"
395
396         AC_SUBST(EXPAT_CFLAGS)
397         AC_SUBST(EXPAT_LIBS)
398 fi
399
400 #
401 # Check libxml2 configuration
402 #
403 AC_ARG_ENABLE(libxml2,
404         [AC_HELP_STRING([--enable-libxml2],
405                         [Use libxml2 instead of Expat])])
406
407 if test "$enable_libxml2" = "yes"; then
408     PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6])
409     AC_DEFINE_UNQUOTED(ENABLE_LIBXML2,1,[Use libxml2 instead of Expat])
410
411     AC_SUBST(LIBXML2_CFLAGS)
412     AC_SUBST(LIBXML2_LIBS)
413
414     fc_saved_CFLAGS="$CFLAGS"
415     CFLAGS="$CFLAGS $LIBXML2_CFLAGS"
416     AC_MSG_CHECKING([SAX1 support in libxml2])
417     AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
418         #include <libxml/xmlversion.h>
419         #if !defined(LIBXML_SAX1_ENABLED)
420         #  include "error: No SAX1 support in libxml2"
421         #endif
422         ]])], [AC_MSG_RESULT([found])], [AC_MSG_ERROR([
423 *** SAX1 support in libxml2 is required. enable it or use expat instead.])])
424     CFLAGS="$fc_saved_CFLAGS"
425 fi
426
427 #
428 # Set default font directory
429 #
430
431 AC_ARG_WITH(default-fonts,
432         [AC_HELP_STRING([--with-default-fonts=DIR],
433                         [Use fonts from DIR when config is busted])],
434         default_fonts="$withval", default_fonts=yes)
435
436 case "$default_fonts" in
437 yes)
438         if test "$os_win32" = "yes"; then
439                 FC_DEFAULT_FONTS="WINDOWSFONTDIR"
440                 AC_DEFINE_UNQUOTED(FC_DEFAULT_FONTS, "WINDOWSFONTDIR", 
441                                    [Windows font directory])
442         else
443                 FC_DEFAULT_FONTS="/usr/share/fonts"
444                 AC_DEFINE_UNQUOTED(FC_DEFAULT_FONTS, "/usr/share/fonts", 
445                                    [System font directory])
446         fi
447         ;;
448 *)
449         FC_DEFAULT_FONTS="$default_fonts"
450         AC_DEFINE_UNQUOTED(FC_DEFAULT_FONTS, "$default_fonts",
451                            [System font directory])
452         ;;
453 esac
454
455 AC_SUBST(FC_DEFAULT_FONTS)
456
457 #
458 # Add more fonts if available.  By default, add only the directories
459 # with outline fonts; those with bitmaps can be added as desired in
460 # local.conf or ~/.fonts.conf
461 #
462 AC_ARG_WITH(add-fonts,
463         [AC_HELP_STRING([--with-add-fonts=DIR1,DIR2,...],
464                         [Find additional fonts in DIR1,DIR2,... ])],
465         add_fonts="$withval", add_fonts=yes)
466
467 case "$add_fonts" in
468 yes)
469         FC_ADD_FONTS=""
470         for dir in /usr/X11R6/lib/X11 /usr/X11/lib/X11 /usr/lib/X11; do
471                 case x"$FC_ADD_FONTS" in
472                 x)
473                         sub="$dir/fonts"
474                         if test -d "$sub"; then
475                                 case x$FC_ADD_FONTS in
476                                 x)
477                                         FC_ADD_FONTS="$sub"
478                                         ;;
479                                 *)
480                                         FC_ADD_FONTS="$FC_ADD_FONTS,$sub"
481                                         ;;
482                                 esac
483                         fi
484                         ;;
485                 esac
486         done
487         AC_DEFINE_UNQUOTED(FC_ADD_FONTS,"$add_fonts",[Additional font directories])
488         ;;
489 no)
490         FC_ADD_FONTS=""
491         ;;
492 *)
493         FC_ADD_FONTS="$add_fonts"
494         AC_DEFINE_UNQUOTED(FC_ADD_FONTS,"$add_fonts",[Additional font directories])
495         ;;
496 esac
497
498 AC_SUBST(FC_ADD_FONTS)
499
500 FC_FONTPATH=""
501
502 case "$FC_ADD_FONTS" in
503 "")
504         ;;
505 *)
506         FC_FONTPATH=`echo $FC_ADD_FONTS | 
507                         sed -e 's/^/<dir>/' -e 's/$/<\/dir>/' -e 's/,/<\/dir> <dir>/g'`
508         ;;
509 esac
510
511 AC_SUBST(FC_FONTPATH)
512
513 #
514 # Set default cache directory path
515 #
516 AC_ARG_WITH(cache-dir,
517         [AC_HELP_STRING([--with-cache-dir=DIR],
518                         [Use DIR to store cache files [default=LOCALSTATEDIR/cache/fontconfig]])],
519         fc_cachedir="$withval", fc_cachedir=yes)
520
521 case $fc_cachedir in
522 no|yes)
523         if test "$os_win32" = "yes"; then
524                 fc_cachedir="WINDOWSTEMPDIR_FONTCONFIG_CACHE"
525         else
526                 fc_cachedir='${localstatedir}/cache/${PACKAGE}'
527         fi
528         ;;
529 *)
530         ;;
531 esac
532 AC_SUBST(fc_cachedir)
533 FC_CACHEDIR=${fc_cachedir}
534 AC_SUBST(FC_CACHEDIR)
535
536 FC_FONTDATE=`LC_ALL=C date`
537
538 AC_SUBST(FC_FONTDATE)
539
540 #
541 # Set configuration paths
542 #
543
544 AC_ARG_WITH(templatedir,
545         [AC_HELP_STRING([--with-templatedir=DIR],
546                         [Use DIR to store the configuration template files [default=DATADIR/fontconfig/conf.avail]])],
547         [templatedir="$withval"],
548         [templatedir=yes])
549 AC_ARG_WITH(baseconfigdir,
550         [AC_HELP_STRING([--with-baseconfigdir=DIR],
551                         [Use DIR to store the base configuration files [default=SYSCONFDIR/fonts]])],
552         [baseconfigdir="$withval"],
553         [baseconfigdir=yes])
554 AC_ARG_WITH(configdir,
555         [AC_HELP_STRING([--with-configdir=DIR],
556                         [Use DIR to store active configuration files [default=BASECONFIGDIR/conf.d]])],
557         [configdir="$withval"],
558         [configdir=yes])
559 AC_ARG_WITH(xmldir,
560         [AC_HELP_STRING([--with-xmldir=DIR],
561                         [Use DIR to store XML schema files [default=DATADIR/xml/fontconfig]])],
562         [xmldir="$withval"],
563         [xmldir=yes])
564
565 case "$templatedir" in
566 no|yes)
567         templatedir='${datadir}'/fontconfig/conf.avail
568         ;;
569 *)
570         ;;
571 esac
572 case "$baseconfigdir" in
573 no|yes)
574         baseconfigdir='${sysconfdir}'/fonts
575         ;;
576 *)
577         ;;
578 esac
579 case "$configdir" in
580 no|yes)
581         configdir='${baseconfigdir}'/conf.d
582         ;;
583 *)
584         ;;
585 esac
586 case "$xmldir" in
587 no|yes)
588         xmldir='${datadir}'/xml/fontconfig
589         ;;
590 *)
591         ;;
592 esac
593
594 TEMPLATEDIR=${templatedir}
595 BASECONFIGDIR=${baseconfigdir}
596 CONFIGDIR=${configdir}
597 XMLDIR=${xmldir}
598 AC_SUBST(templatedir)
599 AC_SUBST(TEMPLATEDIR)
600 AC_SUBST(baseconfigdir)
601 AC_SUBST(BASECONFIGDIR)
602 AC_SUBST(configdir)
603 AC_SUBST(CONFIGDIR)
604 AC_SUBST(xmldir)
605 AC_SUBST(XMLDIR)
606
607
608 dnl ===========================================================================
609
610 #
611 # Thread-safety primitives
612 #
613
614 AC_CACHE_CHECK([for Intel atomic primitives], fc_cv_have_intel_atomic_primitives, [
615         fc_cv_have_intel_atomic_primitives=false
616         AC_TRY_LINK([
617                 void memory_barrier (void) { __sync_synchronize (); }
618                 int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
619                 int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
620                 void mutex_unlock (int *m) { __sync_lock_release (m); }
621                 ], [], fc_cv_have_intel_atomic_primitives=true
622         )
623 ])
624 if $fc_cv_have_intel_atomic_primitives; then
625         AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1, [Have Intel __sync_* atomic primitives])
626 fi
627
628 AC_CACHE_CHECK([for Solaris atomic operations], fc_cv_have_solaris_atomic_ops, [
629         fc_cv_have_solaris_atomic_ops=false
630         AC_TRY_LINK([
631                 #include <atomic.h>
632                 /* This requires Solaris Studio 12.2 or newer: */
633                 #include <mbarrier.h>
634                 void memory_barrier (void) { __machine_rw_barrier (); }
635                 int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
636                 void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }
637                 ], [], fc_cv_have_solaris_atomic_ops=true
638         )
639 ])
640 if $fc_cv_have_solaris_atomic_ops; then
641         AC_DEFINE(HAVE_SOLARIS_ATOMIC_OPS, 1, [Have Solaris __machine_*_barrier and atomic_* operations])
642 fi
643
644 if test "$os_win32" = no && ! $have_pthread; then
645         AC_CHECK_HEADERS(sched.h)
646         AC_SEARCH_LIBS(sched_yield,rt,AC_DEFINE(HAVE_SCHED_YIELD, 1, [Have sched_yield]))
647 fi
648
649 have_pthread=false
650 if test "$os_win32" = no; then
651         AX_PTHREAD([have_pthread=true])
652 fi
653 if $have_pthread; then
654         LIBS="$PTHREAD_LIBS $LIBS"
655         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
656         CC="$PTHREAD_CC"
657         AC_DEFINE(HAVE_PTHREAD, 1, [Have POSIX threads])
658 fi
659 AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread)
660
661
662 dnl ===========================================================================
663
664 #
665 # Let people not build/install docs if they don't have docbook
666 #
667
668 AC_CHECK_PROG(HASDOCBOOK, docbook2html, yes, no)
669
670 AM_CONDITIONAL(USEDOCBOOK, test "x$HASDOCBOOK" = xyes)
671
672 default_docs="yes"
673 #
674 # Check if docs exist or can be created
675 #
676 if test x$HASDOCBOOK = xno; then
677         if test -f $srcdir/doc/fonts-conf.5; then
678                 :
679         else
680                 default_docs="no"
681         fi
682 fi
683
684 AC_ARG_ENABLE(docs,
685         [AC_HELP_STRING([--disable-docs],
686                         [Don't build and install documentation])],
687         ,
688         enable_docs=$default_docs)
689
690 AM_CONDITIONAL(ENABLE_DOCS, test "x$enable_docs" = xyes)
691
692 if test "x$enable_docs" = xyes; then
693         tmp=funcs.$$
694         cat $srcdir/doc/*.fncs | awk '
695         /^@TITLE@/      { if (!done) { printf ("%s\n", $2); done = 1; } }
696         /^@FUNC@/       { if (!done) { printf ("%s\n", $2); done = 1; } }
697         /^@@/           { done = 0; }' > $tmp
698         DOCMAN3=`cat $tmp | awk '{ printf ("%s.3 ", $1); }'`
699         echo DOCMAN3 $DOCMAN3
700         rm -f $tmp
701 else
702         DOCMAN3=""
703 fi
704 AC_SUBST(DOCMAN3)
705
706
707 dnl Figure out what cache format suffix to use for this architecture
708 AC_C_BIGENDIAN
709 AC_CHECK_SIZEOF([void *])
710 AC_CHECK_ALIGNOF([double])
711
712 dnl include the header file for workaround of miscalculating size on autoconf
713 dnl particularly for fat binaries
714 AH_BOTTOM([#include "config-fixups.h"])
715
716 AC_CONFIG_FILES([
717 Makefile
718 fontconfig/Makefile
719 fc-lang/Makefile
720 fc-glyphname/Makefile
721 fc-case/Makefile
722 src/Makefile
723 conf.d/Makefile
724 fc-cache/Makefile
725 fc-cat/Makefile
726 fc-list/Makefile
727 fc-match/Makefile
728 fc-pattern/Makefile
729 fc-query/Makefile
730 fc-scan/Makefile
731 fc-validate/Makefile
732 doc/Makefile
733 doc/version.sgml
734 test/Makefile
735 fontconfig.spec
736 fontconfig.pc
737 fontconfig-zip
738 ])
739 AC_OUTPUT