Git init
[framework/graphics/fontconfig.git] / configure.in
1 dnl 
2 dnl  $Id$
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 Keith Packard not be used in
11 dnl  advertising or publicity pertaining to distribution of the software without
12 dnl  specific, written prior permission.  Keith Packard makes 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  KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 dnl  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 dnl  EVENT SHALL KEITH PACKARD 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_INIT(fonts.dtd)
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 AM_INIT_AUTOMAKE(fontconfig, 2.6.0)
37 AM_MAINTAINER_MODE
38
39 dnl libtool versioning
40
41 dnl bump revision when fixing bugs
42 dnl bump current and age, reset revision to zero when adding APIs
43 dnl bump current, leave age, reset revision to zero when changing/removing APIS
44 LIBT_CURRENT=4
45 LIBT_REVISION=0
46 AC_SUBST(LIBT_CURRENT)
47 AC_SUBST(LIBT_REVISION)
48 LIBT_AGE=3
49
50 LIBT_VERSION_INFO="$LIBT_CURRENT:$LIBT_REVISION:$LIBT_AGE"
51 AC_SUBST(LIBT_VERSION_INFO)
52
53 LIBT_CURRENT_MINUS_AGE=`expr $LIBT_CURRENT - $LIBT_AGE`
54 AC_SUBST(LIBT_CURRENT_MINUS_AGE)
55
56 dnl ==========================================================================
57
58 AM_CONFIG_HEADER(config.h)
59
60 AC_PROG_CC
61 AC_PROG_INSTALL
62 AC_PROG_LN_S
63 AC_LIBTOOL_WIN32_DLL
64 AM_PROG_LIBTOOL
65 DOLT
66 AC_PROG_MAKE_SET
67
68 dnl ==========================================================================
69
70 case "$host" in
71   *-*-mingw*)
72     os_win32=yes
73     ;;
74   *)
75     os_win32=no
76 esac
77 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
78
79 if test "$os_win32" = "yes"; then
80   AC_CHECK_PROG(ms_librarian, lib.exe, yes, no)
81 fi
82 AM_CONDITIONAL(MS_LIB_AVAILABLE, test x$ms_librarian = xyes)
83
84 WARN_CFLAGS=""
85 if test "x$GCC" = "xyes"; then
86         WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \
87         -Wmissing-prototypes -Wmissing-declarations \
88         -Wnested-externs -fno-strict-aliasing"
89         AC_DEFINE_UNQUOTED(HAVE_WARNING_CPP_DIRECTIVE,1,
90         [Can use #warning in C files])
91 fi
92 AC_SUBST(WARN_CFLAGS)
93
94
95 dnl ==========================================================================
96
97 AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
98
99 dnl ==========================================================================
100
101 # Setup for compiling build tools (fc-glyphname, etc)
102 AC_MSG_CHECKING([for a C compiler for build tools])
103 if test $cross_compiling = yes; then
104   AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
105 else
106   CC_FOR_BUILD=$CC
107 fi
108 AC_MSG_RESULT([$CC_FOR_BUILD])
109 AC_SUBST(CC_FOR_BUILD)
110
111 AC_MSG_CHECKING([for suffix of executable build tools])
112 if test $cross_compiling = yes; then
113   cat >conftest.c <<\_______EOF
114 int
115 main ()
116 {
117   exit (0);
118 }
119 _______EOF
120   for i in .exe ""; do
121     compile="$CC_FOR_BUILD conftest.c -o conftest$i"
122     if AC_TRY_EVAL(compile); then
123       if (./conftest) 2>&AC_FD_CC; then
124         EXEEXT_FOR_BUILD=$i
125         break
126       fi
127     fi
128   done
129   rm -f conftest*
130   if test "${EXEEXT_FOR_BUILD+set}" != set; then
131     AC_MSG_ERROR([Cannot determine suffix of executable build tools])
132   fi
133 else
134   EXEEXT_FOR_BUILD=$EXEEXT
135 fi
136 AC_MSG_RESULT([$EXEEXT_FOR_BUILD])
137 AC_SUBST(EXEEXT_FOR_BUILD)
138
139 dnl ==========================================================================
140
141 AC_ARG_WITH(arch,      [  --with-arch=ARCH      Force architecture to ARCH], arch="$withval", arch=auto)
142
143 if test $cross_compiling = yes; then
144         case "$arch" in
145         auto)
146                 AC_MSG_ERROR([Cannot autodetect architecture in cross compile environment]
147                              [Use --with-arch=ARCH to specify architecture])
148                 ;;
149         esac
150 fi
151
152 ARCHITECTURE=$arch
153 AC_SUBST(ARCHITECTURE)
154
155 dnl ==========================================================================
156
157 # Checks for header files.
158 AC_HEADER_DIRENT
159 AC_HEADER_STDC
160 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
161
162 # Checks for typedefs, structures, and compiler characteristics.
163 AC_C_CONST
164 AC_C_INLINE
165 AC_TYPE_PID_T
166
167 # Checks for library functions.
168 AC_FUNC_VPRINTF
169 AC_FUNC_MMAP
170 AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long sysconf ftruncate chsize rand random lrand48])
171
172 #
173 # Checks for iconv
174 #
175 AC_MSG_CHECKING([for a usable iconv])
176 ICONV_LIBS=""
177 AC_TRY_LINK([#include <iconv.h>],
178             [iconv_open ("from", "to");],
179             [use_iconv=1],
180             [use_iconv=0])
181 if test x$use_iconv = x1; then
182         AC_MSG_RESULT([libc])
183 else
184         # try using libiconv
185         fontconfig_save_libs="$LIBS"
186         LIBS="$LIBS -liconv"
187
188         AC_TRY_LINK([#include <iconv.h>],
189                     [iconv_open ("from", "to");],
190                     [use_iconv=1],
191                     [use_iconv=0])
192         
193         if test x$use_iconv = x1; then
194                 ICONV_LIBS="-liconv"
195                 AC_MSG_RESULT([libiconv])
196         else
197                 AC_MSG_RESULT([no])
198         fi
199
200         LIBS="$fontconfig_save_libs"
201 fi
202 AC_SUBST(ICONV_LIBS)
203 AC_DEFINE_UNQUOTED(USE_ICONV,$use_iconv,[Use iconv.])
204
205 #
206 # Checks for FreeType
207 #
208
209 AC_ARG_WITH(freetype-config, [  --with-freetype-config=PROG   Use FreeType configuration program PROG], freetype_config=$withval, freetype_config=yes)
210
211 if test "$freetype_config" = "yes"; then 
212         AC_PATH_PROG(ft_config,freetype-config,no)
213         if test "$ft_config" = "no"; then
214                 AC_MSG_ERROR([You must have freetype installed; see http://www.freetype.org/])
215         fi
216 else
217         ft_config="$freetype_config"
218 fi
219
220 FREETYPE_CFLAGS="`$ft_config --cflags`"
221 FREETYPE_LIBS="`$ft_config --libs`"
222
223 AC_SUBST(FREETYPE_LIBS)
224 AC_SUBST(FREETYPE_CFLAGS)
225
226 #
227 # Check to see whether we have:
228 #  FT_Get_Next_Char
229 #  FT_Get_BDF_Property
230 #  FT_Get_PS_Font_Info
231 #  FT_Has_PS_Glyph_Names
232 #
233
234 fontconfig_save_libs="$LIBS"
235 fontconfig_save_cflags="$CFLAGS"
236 LIBS="$LIBS $FREETYPE_LIBS"
237 CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
238 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)
239 AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem,
240                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1,
241                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0,
242 [#include <ft2build.h>
243 #include FT_FREETYPE_H])
244 AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM,
245                    [FT_Bitmap_Size structure includes y_ppem field])
246 # Should perform a check here I guess..
247 #CFLAGS="$fontconfig_save_cflags"
248 #LIBS="$fontconfig_save_libs"
249
250 #
251 # Check expat configuration
252 #
253
254 AC_ARG_WITH(expat,             [  --with-expat=DIR              Use Expat in DIR], expat=$withval, expat=yes)
255 AC_ARG_WITH(expat-includes,    [  --with-expat-includes=DIR     Use Expat includes in DIR], expat_includes=$withval, expat_includes=yes)
256 AC_ARG_WITH(expat-lib,         [  --with-expat-lib=DIR          Use Expat library in DIR], expat_lib=$withval, expat_lib=yes)
257
258 if test "$enable_libxml2" != "yes"; then
259         case "$expat" in
260         no)
261         ;;
262         *)
263                 case "$expat_includes" in
264                 yes)
265                         case "$expat" in
266                         yes)
267                                 ;;
268                         *)
269                                 EXPAT_CFLAGS="-I$expat/include"
270                                 ;;
271                         esac
272                         ;;
273                 no)
274                         EXPAT_CFLAGS=""
275                         ;;
276                 *)
277                         EXPAT_CFLAGS="-I$expat_includes"
278                         ;;
279                 esac
280                 case "$expat_lib" in
281                 yes)
282                         case "$expat" in
283                         yes)
284                                 EXPAT_LIBS="-lexpat"
285                                 ;;
286                         *)
287                                 EXPAT_LIBS="-L$expat/lib -lexpat"
288                                 ;;
289                         esac
290                         ;;
291                 no)
292                         ;;
293                 *)
294                         EXPAT_LIBS="-L$expat_lib -lexpat"
295                         ;;
296                 esac
297
298                 expatsaved_CPPFLAGS="$CPPFLAGS"
299                 CPPFLAGS="$CPPFLAGS $EXPAT_CFLAGS"
300                 expatsaved_LIBS="$LIBS"
301                 LIBS="$LIBS $EXPAT_LIBS"
302
303                 AC_CHECK_HEADER(expat.h)
304                 case "$ac_cv_header_expat_h" in
305                 no)
306                         AC_CHECK_HEADER(xmlparse.h)
307                         case "$ac_cv_header_xmlparse_h" in
308                         no)
309                                 have_expat_header=no;
310                                 ;;
311                         yes)
312                                 HAVE_XMLPARSE_H=1
313                                 AC_SUBST(HAVE_XMLPARSE_H)
314                                 AC_DEFINE_UNQUOTED(HAVE_XMLPARSE_H,$HAVE_XMLPARSE_H,
315                                 [Use xmlparse.h instead of expat.h])
316                                 have_expat_header=yes
317                                 ;;
318                         esac
319                         ;;
320                 yes)
321                         have_expat_header=yes
322                         ;;
323                 esac
324                 case "$have_expat_header" in
325                 no)
326                         expat=no
327                         ;;
328                 yes)
329                         AC_CHECK_FUNCS(XML_SetDoctypeDeclHandler)
330                         case "$ac_cv_func_XML_SetDoctypeDeclHandler" in
331                         yes)
332                                 HAVE_EXPAT=1
333                                 AC_SUBST(HAVE_EXPAT)
334                                 AC_DEFINE_UNQUOTED(HAVE_EXPAT,$HAVE_EXPAT,
335                                 [Found a useable expat library])
336                                 ;;
337                         *)
338                                 expat=no
339                                 ;;
340                         esac
341                         ;;
342                 esac
343                 CPPFLAGS="$expatsaved_CPPFLAGS"
344                 LIBS="$expatsaved_LIBS"
345                 ;;
346         esac
347         
348         AC_SUBST(EXPAT_CFLAGS)
349         AC_SUBST(EXPAT_LIBS)
350
351         case "$expat" in
352         no)
353                 EXPAT_CFLAGS=""
354                 EXPAT_LIBS=""
355
356                 AC_MSG_WARN([Cannot find usable expat library. Trying to use libxml2 as fallback.])
357                 ;;
358        *)
359                CPPFLAGS="$CPPFLAGS $EXPAT_CFLAGS"
360                LIBS="$LIBS $EXPAT_LIBS"
361                ;;
362         esac
363 fi
364
365 #
366 # Check libxml2 configuration
367 #
368
369 AC_ARG_ENABLE(libxml2,         [  --enable-libxml2              Use libxml2 instead of Expat])
370
371 PKG_PROG_PKG_CONFIG
372
373 if test "$enable_libxml2" = "yes" -o "$expat" = "no"; then
374     PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6])
375     AC_DEFINE_UNQUOTED(ENABLE_LIBXML2,1,[Use libxml2 instead of Expat])
376
377     AC_SUBST(LIBXML2_CFLAGS)
378     AC_SUBST(LIBXML2_LIBS)
379 fi
380
381 #
382 # Set default font directory
383 #
384
385 AC_ARG_WITH(default-fonts,     [  --with-default-fonts=DIR      Use fonts from DIR when config is busted], default_fonts="$withval", default_fonts=yes)
386
387 case "$default_fonts" in
388 yes)
389         if test "$os_win32" = "yes"; then
390                 FC_DEFAULT_FONTS="WINDOWSFONTDIR"
391                 AC_DEFINE_UNQUOTED(FC_DEFAULT_FONTS, "WINDOWSFONTDIR", 
392                                    [Windows font directory])
393         else
394                 FC_DEFAULT_FONTS="/usr/share/fonts"
395                 AC_DEFINE_UNQUOTED(FC_DEFAULT_FONTS, "/usr/share/fonts", 
396                                    [System font directory])
397         fi
398         ;;
399 *)
400         FC_DEFAULT_FONTS="$default_fonts"
401         AC_DEFINE_UNQUOTED(FC_DEFAULT_FONTS, "$default_fonts",
402                            [System font directory])
403         ;;
404 esac
405
406 AC_SUBST(FC_DEFAULT_FONTS)
407
408 #
409 # Add more fonts if available.  By default, add only the directories
410 # with outline fonts; those with bitmaps can be added as desired in
411 # local.conf or ~/.fonts.conf
412 #
413 AC_ARG_WITH(add-fonts,        [  --with-add-fonts=DIR1,DIR2,...Find additional fonts in DIR1,DIR2,... ], add_fonts="$withval", add_fonts=yes)
414
415 case "$add_fonts" in
416 yes)
417         FC_ADD_FONTS=""
418         for dir in /usr/X11R6/lib/X11 /usr/X11/lib/X11 /usr/lib/X11; do
419                 case x"$FC_ADD_FONTS" in
420                 x)
421                         sub="$dir/fonts"
422                         if test -d "$sub"; then
423                                 case x$FC_ADD_FONTS in
424                                 x)
425                                         FC_ADD_FONTS="$sub"
426                                         ;;
427                                 *)
428                                         FC_ADD_FONTS="$FC_ADD_FONTS,$sub"
429                                         ;;
430                                 esac
431                         fi
432                         ;;
433                 esac
434         done
435         AC_DEFINE_UNQUOTED(FC_ADD_FONTS,"$add_fonts",[Additional font directories])
436         ;;
437 no)
438         FC_ADD_FONTS=""
439         ;;
440 *)
441         FC_ADD_FONTS="$add_fonts"
442         AC_DEFINE_UNQUOTED(FC_ADD_FONTS,"$add_fonts",[Additional font directories])
443         ;;
444 esac
445
446 AC_SUBST(FC_ADD_FONTS)
447
448 FC_FONTPATH=""
449
450 case "$FC_ADD_FONTS" in
451 "")
452         ;;
453 *)
454         FC_FONTPATH=`echo $FC_ADD_FONTS | 
455                         sed -e 's/^/<dir>/' -e 's/$/<\/dir>/' -e 's/,/<\/dir> <dir>/g'`
456         ;;
457 esac
458
459 AC_SUBST(FC_FONTPATH)
460
461 #
462 # Set default cache directory path
463 #
464 AC_ARG_WITH(cache-dir,         [ --with-cache-dir=DIR           Use DIR to store cache files (default /var/cache/fontconfig)], fc_cachedir="$withval", fc_cachedir=yes)
465
466 case $fc_cachedir in
467 no|yes)
468         if test "$os_win32" = "yes"; then
469                 fc_cachedir="WINDOWSTEMPDIR_FONTCONFIG_CACHE"
470         else
471                 fc_cachedir=`eval echo "${localstatedir}/cache/"${PACKAGE}`
472         fi
473         ;;
474 *)
475         ;;
476 esac
477 AC_SUBST(fc_cachedir)
478 FC_CACHEDIR=${fc_cachedir}
479 AC_SUBST(FC_CACHEDIR)
480
481 FC_FONTDATE=`LC_ALL=C date`
482
483 AC_SUBST(FC_FONTDATE)
484
485 AC_ARG_WITH(confdir,           [  --with-confdir=DIR            Use DIR to store configuration files (default /etc/fonts)], confdir="$withval", confdir=yes)
486
487 #
488 # Set CONFDIR and FONTCONFIG_PATH
489 #
490
491 case "$confdir" in
492 no|yes)
493         confdir='${sysconfdir}'/fonts
494         ;;
495 *)
496         ;;
497 esac
498 AC_SUBST(confdir)
499 CONFDIR=${confdir}
500 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR",[Font configuration directory])
501 AC_SUBST(CONFDIR)
502
503 #
504 # Find out what language orthographies are included
505 #
506
507 ORTH_FILES=`cd ${srcdir}/fc-lang && echo *.orth`
508 AC_SUBST(ORTH_FILES)
509
510 #
511 # Let people not build/install docs if they don't have docbook
512 #
513
514 AC_CHECK_PROG(HASDOCBOOK, docbook2html, yes, no)
515
516 AM_CONDITIONAL(USEDOCBOOK, test "x$HASDOCBOOK" = xyes)
517
518 default_docs="yes"
519 #
520 # Check if docs exist or can be created
521 #
522 if test x$HASDOCBOOK = xno; then
523         if test -f $srcdir/doc/fonts-conf.5; then
524                 :
525         else
526                 default_docs="no"
527         fi
528 fi
529
530 AC_ARG_ENABLE(docs,           [  --disable-docs                Don't build and install documentation],,enable_docs=$default_docs)
531
532 AM_CONDITIONAL(ENABLE_DOCS, test "x$enable_docs" = xyes)
533
534 if test "x$enable_docs" = xyes; then
535         DOCSRC="doc"
536         tmp=funcs.$$
537         cat $srcdir/doc/*.fncs | awk '
538         /^@TITLE@/      { if (!done) { printf ("%s\n", $2); done = 1; } }
539         /^@FUNC@/       { if (!done) { printf ("%s\n", $2); done = 1; } }
540         /^@@/           { done = 0; }' > $tmp
541         DOCMAN3=`cat $tmp | awk '{ printf ("%s.3 ", $1); }'`
542         echo DOCMAN3 $DOCMAN3
543         rm -f $tmp
544 else
545         DOCSRC=""
546         DOCMAN3=""
547 fi
548
549 AC_SUBST(DOCSRC)
550 AC_SUBST(DOCMAN3)
551
552 #
553 # Figure out where to install documentation
554 #
555
556 AC_ARG_WITH(docdir,           [  --with-docdir=DIR             Use DIR to store documentation files (default ${datadir}/doc/fontconfig)], confdir="$withval")
557
558 if test "x$with_docdir" = "x" ; then
559   DOCDIR='${datadir}/doc/fontconfig'
560 else
561   DOCDIR=$with_docdir
562 fi
563
564 AC_SUBST(DOCDIR)
565
566
567 AC_OUTPUT([
568 Makefile 
569 fontconfig/Makefile
570 fc-lang/Makefile
571 fc-glyphname/Makefile
572 fc-case/Makefile
573 fc-arch/Makefile
574 src/Makefile
575 conf.d/Makefile
576 fc-cache/Makefile
577 fc-cat/Makefile
578 fc-list/Makefile
579 fc-match/Makefile
580 doc/Makefile
581 doc/version.sgml
582 test/Makefile
583 fontconfig.spec
584 fontconfig.pc
585 fonts.conf
586 fontconfig-zip
587 ])