1# This file is part of the FreeType project.
2#
3# Process this file with autoconf to produce a configure script.
4#
5# Copyright 2001-2016 by
6# David Turner, Robert Wilhelm, and Werner Lemberg.
7#
8# This file is part of the FreeType project, and may only be used, modified,
9# and distributed under the terms of the FreeType project license,
10# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
11# indicate that you have read the license and understand and accept it
12# fully.
13
14AC_INIT([FreeType], [2.7.1], [freetype@nongnu.org], [freetype])
15AC_CONFIG_SRCDIR([ftconfig.in])
16
17
18# Don't forget to update `docs/VERSIONS.TXT'!
19
20version_info='19:0:13'
21AC_SUBST([version_info])
22ft_version=`echo $version_info | tr : .`
23AC_SUBST([ft_version])
24
25
26# checks for system type
27
28AC_CANONICAL_HOST
29
30
31# checks for programs
32
33AC_PROG_CC
34AC_PROG_CPP
35AC_SUBST(EXEEXT)
36
37PKG_PROG_PKG_CONFIG([0.24])
38
39LT_INIT(win32-dll)
40
41
42# checks for native programs to generate building tool
43
44if test ${cross_compiling} = yes; then
45  AC_CHECK_PROG(CC_BUILD, ${build}-gcc, ${build}-gcc)
46  test -z "${CC_BUILD}" && AC_CHECK_PROG(CC_BUILD, gcc, gcc)
47  test -z "${CC_BUILD}" && AC_CHECK_PROG(CC_BUILD, cc, cc, , , /usr/ucb/cc)
48  test -z "${CC_BUILD}" && AC_MSG_ERROR([cannot find native C compiler])
49
50  AC_MSG_CHECKING([for suffix of native executables])
51  rm -f a.* b.* a_out.exe conftest.*
52  echo > conftest.c "int main() { return 0;}"
53  ${CC_BUILD} conftest.c || AC_MSG_ERROR([native C compiler is not working])
54  rm -f conftest.c
55  if test -x a.out -o -x b.out -o -x conftest; then
56    EXEEXT_BUILD=""
57  elif test -x a_out.exe -o -x conftest.exe; then
58    EXEEXT_BUILD=".exe"
59  elif test -x conftest.*; then
60    EXEEXT_BUILD=`echo conftest.* | sed -n '1s/^.*\././'`
61  fi
62  rm -f a.* b.* a_out.exe conftest.*
63  AC_MSG_RESULT($EXEEXT_BUILD)
64else
65  CC_BUILD=${CC}
66  EXEEXT_BUILD=${EXEEXT}
67fi
68
69AC_SUBST(CC_BUILD)
70AC_SUBST(EXEEXT_BUILD)
71
72
73# Since these files will be eventually called from another directory (namely
74# from the top level) we make the path of the scripts absolute.
75#
76# This small code snippet has been taken from automake's `ylwrap' script.
77
78AC_PROG_INSTALL
79case "$INSTALL" in
80[[\\/]]* | ?:[[\\/]]*)
81  ;;
82*[[\\/]]*)
83  INSTALL="`pwd`/$INSTALL"
84  ;;
85esac
86
87AC_PROG_MKDIR_P
88case "$MKDIR_P" in
89[[\\/]]* | ?:[[\\/]]*)
90  ;;
91*[[\\/]]*)
92  MKDIR_P="`pwd`/$MKDIR_P"
93  ;;
94esac
95
96
97# checks for header files
98
99AC_HEADER_STDC
100AC_CHECK_HEADERS([fcntl.h unistd.h])
101
102
103# checks for typedefs, structures, and compiler characteristics
104
105AC_C_CONST
106AC_CHECK_SIZEOF([int])
107AC_CHECK_SIZEOF([long])
108AC_TYPE_LONG_LONG_INT
109
110
111# check whether cpp computation of size of int and long in ftconfig.in works
112
113AC_MSG_CHECKING([whether cpp computation of bit length in ftconfig.in works])
114orig_CPPFLAGS="${CPPFLAGS}"
115CPPFLAGS="-I${srcdir} -I. ${CPPFLAGS}"
116
117ac_clean_files=
118for f in ft2build.h ftoption.h ftstdlib.h; do
119  if test ! -f $f; then
120    ac_clean_files="$ac_clean_files $f"
121    touch $f
122  fi
123done
124
125cat > conftest.c <<\_ACEOF
126#include <limits.h>
127#define FT_CONFIG_OPTIONS_H "ftoption.h"
128#define FT_CONFIG_STANDARD_LIBRARY_H "ftstdlib.h"
129#define FT_UINT_MAX  UINT_MAX
130#define FT_ULONG_MAX ULONG_MAX
131#include "ftconfig.in"
132_ACEOF
133echo >> conftest.c "#if FT_SIZEOF_INT == "${ac_cv_sizeof_int}
134echo >> conftest.c "ac_cpp_ft_sizeof_int="${ac_cv_sizeof_int}
135echo >> conftest.c "#endif"
136echo >> conftest.c "#if FT_SIZEOF_LONG == "${ac_cv_sizeof_long}
137echo >> conftest.c "ac_cpp_ft_sizeof_long="${ac_cv_sizeof_long}
138echo >> conftest.c "#endif"
139
140${CPP} ${CPPFLAGS} conftest.c | ${GREP} ac_cpp_ft > conftest.sh
141eval `cat conftest.sh`
142rm -f conftest.* $ac_clean_files
143
144if test x != "x${ac_cpp_ft_sizeof_int}" \
145   -a x != x"${ac_cpp_ft_sizeof_long}"; then
146  unset ft_use_autoconf_sizeof_types
147else
148  ft_use_autoconf_sizeof_types=yes
149fi
150
151AC_ARG_ENABLE(biarch-config,
152[  --enable-biarch-config  install biarch ftconfig.h to support multiple
153                          architectures by single file], [], [])
154
155case :${ft_use_autoconf_sizeof_types}:${enable_biarch_config}: in
156  :yes:yes:)
157    AC_MSG_RESULT([broken but use it])
158    unset ft_use_autoconf_sizeof_types
159    ;;
160  ::no:)
161    AC_MSG_RESULT([works but ignore it])
162    ft_use_autoconf_sizeof_types=yes
163    ;;
164  ::yes: | :::)
165    AC_MSG_RESULT([yes])
166    unset ft_use_autoconf_sizeof_types
167    ;;
168  *)
169    AC_MSG_RESULT([no])
170    ft_use_autoconf_sizeof_types=yes
171    ;;
172esac
173
174if test x"${ft_use_autoconf_sizeof_types}" = xyes; then
175  AC_DEFINE([FT_USE_AUTOCONF_SIZEOF_TYPES], [],
176            [Define if autoconf sizeof types should be used.])
177fi
178
179CPPFLAGS="${orig_CPPFLAGS}"
180
181
182# checks for library functions
183
184AC_SYS_LARGEFILE
185
186# Here we check whether we can use our mmap file component.
187
188AC_ARG_ENABLE([mmap],
189  AS_HELP_STRING([--disable-mmap],
190                 [do not check mmap() and do not use]),
191  [enable_mmap="no"],[enable_mmap="yes"])
192if test "x${enable_mmap}" != "xno"; then
193  AC_FUNC_MMAP
194fi
195if test "x${enable_mmap}" = "xno" \
196   -o "$ac_cv_func_mmap_fixed_mapped" != "yes"; then
197  FTSYS_SRC='$(BASE_DIR)/ftsystem.c'
198else
199  FTSYS_SRC='$(BUILD_DIR)/ftsystem.c'
200
201  AC_CHECK_DECLS([munmap],
202    [],
203    [],
204    [
205
206#ifdef HAVE_UNISTD_H
207#include <unistd.h>
208#endif
209#include <sys/mman.h>
210
211    ])
212
213  FT_MUNMAP_PARAM
214fi
215AC_SUBST([FTSYS_SRC])
216
217AC_CHECK_FUNCS([memcpy memmove])
218
219
220# get compiler flags right
221#
222#   We try to make the compiler work for C89-strict source.  Even if the
223#   C compiler is gcc and C89 flags are available, some system headers
224#   (e.g., Android Bionic libc) are broken in C89 mode.  We have to check
225#   whether the compilation finishes successfully.
226#
227#   Due to bugs in mingwrt 4.0.3 we don't use `-ansi' for MinGW.
228#
229#   To avoid zillions of
230#
231#     ISO C90 does not support 'long long'
232#
233#   warnings, we disable `-pedantic' for gcc version < 4.6.
234#
235if test "x$GCC" = xyes; then
236  XX_CFLAGS="-Wall"
237  case "$host" in
238  *-*-mingw*)
239    XX_ANSIFLAGS="-pedantic"
240    ;;
241  *-*-aix*)
242    XX_ANSIFLAGS="-pedantic"
243    ;;
244  *)
245    GCC_VERSION=`$CC -dumpversion`
246    GCC_MAJOR=`echo "$GCC_VERSION" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
247    GCC_MINOR=`echo "$GCC_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
248
249    XX_PEDANTIC=-pedantic
250    if test $GCC_MAJOR -lt 4; then
251      XX_PEDANTIC=
252    else
253      if test $GCC_MAJOR -eq 4 -a $GCC_MINOR -lt 6; then
254        XX_PEDANTIC=
255      fi
256    fi
257
258    XX_ANSIFLAGS=""
259    for a in $XX_PEDANTIC -ansi
260    do
261      AC_MSG_CHECKING([gcc compiler flag ${a} to assure ANSI C works correctly])
262      orig_CFLAGS="${CFLAGS}"
263      CFLAGS="${CFLAGS} ${XX_ANSIFLAGS} ${a}"
264      AC_COMPILE_IFELSE([
265        AC_LANG_PROGRAM([
266
267#include <stdio.h>
268
269          ],
270          [
271
272            {
273              puts( "" );
274              return 0;
275            }
276
277          ])],
278        [AC_MSG_RESULT([ok, add it to XX_ANSIFLAGS])
279         XX_ANSIFLAGS="${XX_ANSIFLAGS} ${a}"
280        ],
281        [AC_MSG_RESULT([no])])
282      CFLAGS="${orig_CFLAGS}"
283    done
284    ;;
285  esac
286else
287  case "$host" in
288  *-dec-osf*)
289    CFLAGS=
290    XX_CFLAGS="-std1 -g3"
291    XX_ANSIFLAGS=
292    ;;
293  *)
294    XX_CFLAGS=
295    XX_ANSIFLAGS=
296    ;;
297  esac
298fi
299AC_SUBST([XX_CFLAGS])
300AC_SUBST([XX_ANSIFLAGS])
301
302
303# All library tests below try `pkg-config' first.  If that fails, a function
304# from the library is tested in the traditional autoconf way (zlib, bzip2),
305# or a config script is called (libpng).
306#
307# The `xxx_reqpriv' variables are for the `Requires.private' field in
308# `freetype2.pc'.  The `xxx_libspriv' variables are for the `Libs.private'
309# field in `freetype2.pc' if pkg-config doesn't find a proper .pc file.
310#
311# The `xxx_libsstaticconf' variables are for the `freetype-config' script.
312#
313# Note that a call to PKG_CHECK_MODULES(XXX, ...) sets and creates the
314# output variables `XXX_CFLAGS' and `XXX_LIBS'.  In case one or both are set
315# for a library by the user, no entry for this library is added to
316# `Requires.private'.  Instead, it gets added to `Libs.private'
317
318
319# check for system zlib
320
321AC_ARG_WITH([zlib],
322  [AS_HELP_STRING([--with-zlib=@<:@yes|no|auto@:>@],
323                  [use system zlib instead of internal library @<:@default=auto@:>@])],
324  [], [with_zlib=auto])
325
326have_zlib=no
327if test x"$with_zlib" = xyes -o x"$with_zlib" = xauto; then
328  zlib_pkg="zlib"
329  have_zlib_pkg=no
330
331  if test x"$ZLIB_CFLAGS" = x -a x"$ZLIB_LIBS" = x; then
332    PKG_CHECK_EXISTS([$zlib_pkg], [have_zlib_pkg=yes])
333  fi
334  PKG_CHECK_MODULES([ZLIB], [$zlib_pkg],
335                    [have_zlib="yes (pkg-config)"], [:])
336
337  if test $have_zlib_pkg = yes; then
338    # we have zlib.pc
339    zlib_reqpriv="$zlib_pkg"
340    zlib_libspriv=
341    zlib_libsstaticconf=`$PKG_CONFIG --static --libs "$zlib_pkg"`
342  else
343    zlib_reqpriv=
344
345    if test "$have_zlib" != no; then
346      # ZLIB_CFLAGS and ZLIB_LIBS are set by the user
347      zlib_libspriv="$ZLIB_LIBS"
348      zlib_libsstaticconf="$ZLIB_LIBS"
349      have_zlib="yes (ZLIB_CFLAGS and ZLIB_LIBS)"
350    else
351      # fall back to standard autoconf test
352      AC_CHECK_LIB([z],
353                   [gzsetparams],
354                   [AC_CHECK_HEADER([zlib.h],
355                                    [have_zlib="yes (autoconf test)"
356                                     zlib_libspriv="-lz"
357                                     zlib_libsstaticconf="$zlib_libspriv"
358                                     ZLIB_LIBS="$zlib_libspriv"])])
359    fi
360  fi
361fi
362
363if test x"$with_zlib" = xyes -a "$have_zlib" = no; then
364  AC_MSG_ERROR([external zlib support requested but library not found])
365fi
366
367
368# check for system libbz2
369
370AC_ARG_WITH([bzip2],
371  [AS_HELP_STRING([--with-bzip2=@<:@yes|no|auto@:>@],
372                  [support bzip2 compressed fonts @<:@default=auto@:>@])],
373  [], [with_bzip2=auto])
374
375have_bzip2=no
376if test x"$with_bzip2" = xyes -o x"$with_bzip2" = xauto; then
377  bzip2_pkg="bzip2"
378  have_bzip2_pkg=no
379
380  if test x"$BZIP2_CFLAGS" = x -a x"$BZIP2_LIBS" = x; then
381    PKG_CHECK_EXISTS([$bzip2_pkg], [have_bzip2_pkg=yes])
382  fi
383  PKG_CHECK_MODULES([BZIP2], [$bzip2_pkg],
384                    [have_bzip2="yes (pkg-config)"], [:])
385
386  if test $have_bzip2_pkg = yes; then
387    # we have bzip2.pc
388    bzip2_reqpriv="$bzip2_pkg"
389    bzip2_libspriv=
390    bzip2_libsstaticconf=`$PKG_CONFIG --static --libs "$bzip2_pkg"`
391  else
392    bzip2_reqpriv=
393
394    if test "$have_bzip2" != no; then
395      # BZIP2_CFLAGS and BZIP2_LIBS are set by the user
396      bzip2_libspriv="$BZIP2_LIBS"
397      bzip2_libsstaticconf="$BZIP2_LIBS"
398      have_bzip2="yes (BZIP2_CFLAGS and BZIP2_LIBS)"
399    else
400      # fall back to standard autoconf test
401      AC_CHECK_LIB([bz2],
402                   [BZ2_bzDecompress],
403                   [AC_CHECK_HEADER([bzlib.h],
404                                    [have_bzip2="yes (autoconf test)"
405                                     bzip2_libspriv="-lbz2"
406                                     bzip2_libsstaticconf="$bzip2_libspriv"
407                                     BZIP2_LIBS="$bzip2_libspriv"])])
408    fi
409  fi
410fi
411
412if test x"$with_bzip2" = xyes -a "$have_bzip2" = no; then
413  AC_MSG_ERROR([bzip2 support requested but library not found])
414fi
415
416
417# check for system libpng
418
419AC_ARG_WITH([png],
420  [AS_HELP_STRING([--with-png=@<:@yes|no|auto@:>@],
421                  [support png compressed OpenType embedded bitmaps @<:@default=auto@:>@])],
422  [], [with_png=auto])
423
424have_libpng=no
425if test x"$with_png" = xyes -o x"$with_png" = xauto; then
426  libpng_pkg="libpng"
427  have_libpng_pkg=no
428
429  if test x"$LIBPNG_CFLAGS" = x -a x"$LIBPNG_LIBS" = x; then
430    PKG_CHECK_EXISTS([$libpng_pkg], [have_libpng_pkg=yes])
431  fi
432  PKG_CHECK_MODULES([LIBPNG], [$libpng_pkg],
433                    [have_libpng="yes (pkg-config)"], [:])
434
435  if test $have_libpng_pkg = yes; then
436    # we have libpng.pc
437    libpng_reqpriv="$libpng_pkg"
438    libpng_libspriv=
439    libpng_libsstaticconf=`$PKG_CONFIG --static --libs "$libpng_pkg"`
440  else
441    libpng_reqpriv=
442
443    if test "$have_libpng" != no; then
444      # LIBPNG_CFLAGS and LIBPNG_LIBS are set by the user
445      libpng_libspriv="$LIBPNG_LIBS"
446      libpng_libsstaticconf="$LIBPNG_LIBS"
447      have_libpng="yes (LIBPNG_CFLAGS and LIBPNG_LIBS)"
448    else
449      # fall back to config script.
450      AC_MSG_CHECKING([for libpng-config])
451      if which libpng-config > /dev/null 2>&1; then
452        LIBPNG_CFLAGS=`libpng-config --cflags`
453        LIBPNG_LIBS=`libpng-config --ldflags`
454        libpng_libspriv=`libpng-config --static --ldflags`
455        libpng_libsstaticconf="$libpng_libspriv"
456        have_libpng="yes (libpng-config)"
457        AC_MSG_RESULT([yes])
458      else
459        AC_MSG_RESULT([no])
460      fi
461    fi
462  fi
463fi
464
465if test x"$with_png" = xyes -a "$have_libpng" = no; then
466  AC_MSG_ERROR([libpng support requested but library not found])
467fi
468
469
470# check for system libharfbuzz
471
472AC_ARG_WITH([harfbuzz],
473  [AS_HELP_STRING([--with-harfbuzz=@<:@yes|no|auto@:>@],
474                  [improve auto-hinting of OpenType fonts @<:@default=auto@:>@])],
475  [], [with_harfbuzz=auto])
476
477have_harfbuzz=no
478if test x"$with_harfbuzz" = xyes -o x"$with_harfbuzz" = xauto; then
479  harfbuzz_pkg="harfbuzz >= 0.9.21"
480  have_harfbuzz_pkg=no
481
482  if test x"$HARFBUZZ_CFLAGS" = x -a x"$HARFBUZZ_LIBS" = x; then
483    PKG_CHECK_EXISTS([$harfbuzz_pkg], [have_harfbuzz_pkg=yes])
484  fi
485  PKG_CHECK_MODULES([HARFBUZZ], [$harfbuzz_pkg],
486                    [have_harfbuzz="yes (pkg-config)"], [:])
487
488  if test $have_harfbuzz_pkg = yes; then
489    # we have harfbuzz.pc
490    harfbuzz_reqpriv="$harfbuzz_pkg"
491    harfbuzz_libspriv=
492    harfbuzz_libsstaticconf=`$PKG_CONFIG --static --libs "$harfbuzz_pkg"`
493  else
494    harfbuzz_reqpriv=
495
496    if test "$have_harfbuzz" != no; then
497      # HARFBUZZ_CFLAGS and HARFBUZZ_LIBS are set by the user
498      harfbuzz_libspriv="$HARFBUZZ_LIBS"
499      harfbuzz_libsstaticconf="$HARFBUZZ_LIBS"
500      have_harfbuzz="yes (HARFBUZZ_CFLAGS and HARFBUZZ_LIBS)"
501    else
502      # since HarfBuzz is quite a new library we don't fall back to a
503      # different test; additionally, it has too many dependencies
504      :
505    fi
506  fi
507fi
508
509if test x"$with_harfbuzz" = xyes -a "$have_harfbuzz" = no; then
510  AC_MSG_ERROR([harfbuzz support requested but library not found])
511fi
512
513
514# Some options handling SDKs/archs in CFLAGS should be copied
515# to LDFLAGS. Apple TechNote 2137 recommends to include these
516# options in CFLAGS but not in LDFLAGS.
517
518save_config_args=$*
519set dummy ${CFLAGS}
520i=1
521while test $i -le $#
522do
523  c=$1
524
525  case "${c}" in
526  -isysroot|-arch) # options taking 1 argument
527    a=$2
528    AC_MSG_CHECKING([whether CFLAGS and LDFLAGS share ${c} ${a}])
529    if expr " ${LDFLAGS} " : ".* ${c} *${a}.*" > /dev/null
530    then
531      AC_MSG_RESULT([yes])
532    else
533      AC_MSG_RESULT([no, copy to LDFLAGS])
534      LDFLAGS="${LDFLAGS} ${c} ${a}"
535    fi
536    shift 1
537    ;;
538  -m32|-m64|-march=*|-mcpu=*) # options taking no argument
539    AC_MSG_CHECKING([whether CFLAGS and LDFLAGS share ${c}])
540    if expr " ${LDFLAGS} " : ".* ${c} *${a}.*" > /dev/null
541    then
542      AC_MSG_RESULT([yes])
543    else
544      AC_MSG_RESULT([no, copy to LDFLAGS])
545      LDFLAGS="${LDFLAGS} ${c}"
546    fi
547    ;;
548  # *)
549  #   AC_MSG_RESULT([${c} is not copied to LDFLAGS])
550  #   ;;
551  esac
552
553  shift 1
554done
555set ${save_config_args}
556
557
558# Whether to use Mac OS resource-based fonts.
559
560ftmac_c="" # src/base/ftmac.c should not be included in makefiles by default
561
562AC_ARG_WITH([old-mac-fonts],
563  AS_HELP_STRING([--with-old-mac-fonts],
564                 [allow Mac resource-based fonts to be used]))
565if test x$with_old_mac_fonts = xyes; then
566  orig_LDFLAGS="${LDFLAGS}"
567  AC_MSG_CHECKING([CoreServices & ApplicationServices of Mac OS X])
568  ft2_extra_libs="-Wl,-framework,CoreServices -Wl,-framework,ApplicationServices"
569  LDFLAGS="$LDFLAGS $ft2_extra_libs"
570  AC_LINK_IFELSE([
571    AC_LANG_PROGRAM([
572
573#if defined(__GNUC__) && defined(__APPLE_CC__)
574# include <CoreServices/CoreServices.h>
575# include <ApplicationServices/ApplicationServices.h>
576#else
577# include <ConditionalMacros.h>
578# include <Files.h>
579#endif
580
581      ],
582      [
583
584        short res = 0;
585
586
587        UseResFile( res );
588
589      ])],
590    [AC_MSG_RESULT([ok])
591     ftmac_c='ftmac.c'
592     AC_MSG_CHECKING([whether OS_INLINE macro is ANSI compatible])
593     orig_CFLAGS="$CFLAGS -DFT_MACINTOSH"
594     CFLAGS="$CFLAGS $XX_CFLAGS $XX_ANSIFLAGS"
595     AC_COMPILE_IFELSE([
596       AC_LANG_PROGRAM([
597
598#if defined(__GNUC__) && defined(__APPLE_CC__)
599# include <CoreServices/CoreServices.h>
600# include <ApplicationServices/ApplicationServices.h>
601#else
602# include <ConditionalMacros.h>
603# include <Files.h>
604#endif
605
606         ],
607         [
608
609           /* OSHostByteOrder() is typed as OS_INLINE */
610           int32_t  os_byte_order = OSHostByteOrder();
611
612
613           if ( OSBigEndian != os_byte_order )
614             return 1;
615
616         ])],
617       [AC_MSG_RESULT([ok])
618        CFLAGS="$orig_CFLAGS"
619        CFLAGS="$CFLAGS -DHAVE_ANSI_OS_INLINE=1"
620       ],
621       [AC_MSG_RESULT([no, ANSI incompatible])
622        CFLAGS="$orig_CFLAGS"
623       ])
624     AC_MSG_CHECKING([type ResourceIndex])
625     orig_CFLAGS="$CFLAGS"
626     CFLAGS="$CFLAGS $XX_CFLAGS $XX_ANSIFLAGS"
627     AC_COMPILE_IFELSE([
628       AC_LANG_PROGRAM([
629
630#if defined(__GNUC__) && defined(__APPLE_CC__)
631# include <CoreServices/CoreServices.h>
632# include <ApplicationServices/ApplicationServices.h>
633#else
634# include <ConditionalMacros.h>
635# include <Files.h>
636# include <Resources.h>
637#endif
638
639         ],
640         [
641
642           ResourceIndex i = 0;
643           return i;
644
645         ])],
646       [AC_MSG_RESULT([ok])
647        CFLAGS="$orig_CFLAGS"
648        CFLAGS="$CFLAGS -DHAVE_TYPE_RESOURCE_INDEX=1"
649       ],
650       [AC_MSG_RESULT([no])
651        CFLAGS="$orig_CFLAGS"
652        CFLAGS="$CFLAGS -DHAVE_TYPE_RESOURCE_INDEX=0"
653       ])],
654    [AC_MSG_RESULT([not found])
655     ft2_extra_libs=""
656     LDFLAGS="${orig_LDFLAGS}"
657     CFLAGS="$CFLAGS -DDARWIN_NO_CARBON"])
658else
659  case x$host_os in
660  xdarwin*)
661    dnl AC_MSG_WARN([host system is MacOS but configured to build without Carbon])
662    CFLAGS="$CFLAGS -DDARWIN_NO_CARBON"
663    ;;
664  *)
665    ;;
666  esac
667fi
668
669
670# Whether to use FileManager, which is deprecated since Mac OS X 10.4.
671
672AC_ARG_WITH([fsspec],
673  AS_HELP_STRING([--with-fsspec],
674                 [use obsolete FSSpec API of MacOS, if available (default=yes)]))
675if test x$with_fsspec = xno; then
676  CFLAGS="$CFLAGS -DHAVE_FSSPEC=0"
677elif test x$with_old_mac_fonts = xyes -a x$with_fsspec != x; then
678  AC_MSG_CHECKING([FSSpec-based FileManager])
679  AC_LINK_IFELSE([
680    AC_LANG_PROGRAM([
681
682#if defined(__GNUC__) && defined(__APPLE_CC__)
683# include <CoreServices/CoreServices.h>
684# include <ApplicationServices/ApplicationServices.h>
685#else
686# include <ConditionalMacros.h>
687# include <Files.h>
688#endif
689
690      ],
691      [
692
693        FCBPBPtr          paramBlock;
694        short             vRefNum;
695        long              dirID;
696        ConstStr255Param  fileName;
697        FSSpec*           spec;
698
699
700        /* FSSpec functions: deprecated since Mac OS X 10.4 */
701        PBGetFCBInfoSync( paramBlock );
702        FSMakeFSSpec( vRefNum, dirID, fileName, spec );
703
704      ])],
705    [AC_MSG_RESULT([ok])
706     CFLAGS="$CFLAGS -DHAVE_FSSPEC=1"],
707    [AC_MSG_RESULT([not found])
708     CFLAGS="$CFLAGS -DHAVE_FSSPEC=0"])
709fi
710
711
712# Whether to use FileManager in Carbon since MacOS 9.x.
713
714AC_ARG_WITH([fsref],
715  AS_HELP_STRING([--with-fsref],
716                 [use Carbon FSRef API of MacOS, if available (default=yes)]))
717if test x$with_fsref = xno; then
718  AC_MSG_WARN([
719*** WARNING
720    FreeType2 built without FSRef API cannot load
721    data-fork fonts on MacOS, except of XXX.dfont.
722    ])
723  CFLAGS="$CFLAGS -DHAVE_FSREF=0"
724elif test x$with_old_mac_fonts = xyes -a x$with_fsref != x; then
725  AC_MSG_CHECKING([FSRef-based FileManager])
726  AC_LINK_IFELSE([
727    AC_LANG_PROGRAM([
728
729#if defined(__GNUC__) && defined(__APPLE_CC__)
730# include <CoreServices/CoreServices.h>
731# include <ApplicationServices/ApplicationServices.h>
732#else
733# include <ConditionalMacros.h>
734# include <Files.h>
735#endif
736
737      ],
738      [
739
740        short                vRefNum;
741        long                 dirID;
742        ConstStr255Param     fileName;
743
744        Boolean*             isDirectory;
745        UInt8*               path;
746        SInt16               desiredRefNum;
747        SInt16*              iterator;
748        SInt16*              actualRefNum;
749        HFSUniStr255*        outForkName;
750        FSVolumeRefNum       volume;
751        FSCatalogInfoBitmap  whichInfo;
752        FSCatalogInfo*       catalogInfo;
753        FSForkInfo*          forkInfo;
754        FSRef*               ref;
755
756#if HAVE_FSSPEC
757        FSSpec*              spec;
758#endif
759
760        /* FSRef functions: no need to check? */
761        FSGetForkCBInfo( desiredRefNum, volume, iterator,
762                         actualRefNum, forkInfo, ref,
763                         outForkName );
764        FSPathMakeRef( path, ref, isDirectory );
765
766#if HAVE_FSSPEC
767        FSpMakeFSRef ( spec, ref );
768        FSGetCatalogInfo( ref, whichInfo, catalogInfo,
769                          outForkName, spec, ref );
770#endif
771      ])],
772    [AC_MSG_RESULT([ok])
773     CFLAGS="$CFLAGS -DHAVE_FSREF=1"],
774    [AC_MSG_RESULT([not found])
775     CFLAGS="$CFLAGS -DHAVE_FSREF=0"])
776fi
777
778
779# Whether to use QuickDraw API in ToolBox, which is deprecated since
780# Mac OS X 10.4.
781
782AC_ARG_WITH([quickdraw-toolbox],
783  AS_HELP_STRING([--with-quickdraw-toolbox],
784                 [use MacOS QuickDraw in ToolBox, if available (default=yes)]))
785if test x$with_quickdraw_toolbox = xno; then
786  CFLAGS="$CFLAGS -DHAVE_QUICKDRAW_TOOLBOX=0"
787elif test x$with_old_mac_fonts = xyes -a x$with_quickdraw_toolbox != x; then
788  AC_MSG_CHECKING([QuickDraw FontManager functions in ToolBox])
789  AC_LINK_IFELSE([
790    AC_LANG_PROGRAM([
791
792#if defined(__GNUC__) && defined(__APPLE_CC__)
793# include <CoreServices/CoreServices.h>
794# include <ApplicationServices/ApplicationServices.h>
795#else
796# include <ConditionalMacros.h>
797# include <Fonts.h>
798#endif
799
800      ],
801      [
802
803        Str255     familyName;
804        SInt16     familyID   = 0;
805        FMInput*   fmIn       = NULL;
806        FMOutput*  fmOut      = NULL;
807
808
809        GetFontName( familyID, familyName );
810        GetFNum( familyName, &familyID );
811        fmOut = FMSwapFont( fmIn );
812
813      ])],
814    [AC_MSG_RESULT([ok])
815     CFLAGS="$CFLAGS -DHAVE_QUICKDRAW_TOOLBOX=1"],
816    [AC_MSG_RESULT([not found])
817     CFLAGS="$CFLAGS -DHAVE_QUICKDRAW_TOOLBOX=0"])
818fi
819
820
821# Whether to use QuickDraw API in Carbon, which is deprecated since
822# Mac OS X 10.4.
823
824AC_ARG_WITH([quickdraw-carbon],
825  AS_HELP_STRING([--with-quickdraw-carbon],
826                 [use MacOS QuickDraw in Carbon, if available (default=yes)]))
827if test x$with_quickdraw_carbon = xno; then
828  CFLAGS="$CFLAGS -DHAVE_QUICKDRAW_CARBON=0"
829elif test x$with_old_mac_fonts = xyes -a x$with_quickdraw_carbon != x; then
830  AC_MSG_CHECKING([QuickDraw FontManager functions in Carbon])
831  AC_LINK_IFELSE([
832    AC_LANG_PROGRAM([
833
834#if defined(__GNUC__) && defined(__APPLE_CC__)
835# include <CoreServices/CoreServices.h>
836# include <ApplicationServices/ApplicationServices.h>
837#else
838# include <ConditionalMacros.h>
839# include <Fonts.h>
840#endif
841
842      ],
843      [
844
845        FMFontFamilyIterator          famIter;
846        FMFontFamily                  family;
847        Str255                        famNameStr;
848        FMFontFamilyInstanceIterator  instIter;
849        FMFontStyle                   style;
850        FMFontSize                    size;
851        FMFont                        font;
852        FSSpec*                       pathSpec;
853
854
855        FMCreateFontFamilyIterator( NULL, NULL, kFMUseGlobalScopeOption,
856                                    &famIter );
857        FMGetNextFontFamily( &famIter, &family );
858        FMGetFontFamilyName( family, famNameStr );
859        FMCreateFontFamilyInstanceIterator( family, &instIter );
860        FMGetNextFontFamilyInstance( &instIter, &font, &style, &size );
861        FMDisposeFontFamilyInstanceIterator( &instIter );
862        FMDisposeFontFamilyIterator( &famIter );
863        FMGetFontContainer( font, pathSpec );
864
865      ])],
866    [AC_MSG_RESULT([ok])
867     CFLAGS="$CFLAGS -DHAVE_QUICKDRAW_CARBON=1"],
868    [AC_MSG_RESULT([not found])
869     CFLAGS="$CFLAGS -DHAVE_QUICKDRAW_CARBON=0"])
870fi
871
872
873# Whether to use AppleTypeService since Mac OS X.
874
875AC_ARG_WITH([ats],
876  AS_HELP_STRING([--with-ats],
877                 [use AppleTypeService, if available (default=yes)]))
878if test x$with_ats = xno; then
879  CFLAGS="$CFLAGS -DHAVE_ATS=0"
880elif test x$with_old_mac_fonts = xyes -a x$with_ats != x; then
881  AC_MSG_CHECKING([AppleTypeService functions])
882  AC_LINK_IFELSE([
883    AC_LANG_PROGRAM([
884
885#if defined(__GNUC__) && defined(__APPLE_CC__)
886# include <CoreServices/CoreServices.h>
887# include <ApplicationServices/ApplicationServices.h>
888#else
889# include <ConditionalMacros.h>
890# include <Files.h>
891#endif
892
893      ],
894      [
895
896        FSSpec*  pathSpec;
897
898
899        ATSFontFindFromName( NULL, kATSOptionFlagsUnRestrictedScope );
900#if HAVE_FSSPEC
901        ATSFontGetFileSpecification( 0, pathSpec );
902#endif
903
904      ])],
905    [AC_MSG_RESULT([ok])
906     CFLAGS="$CFLAGS -DHAVE_ATS=1"],
907    [AC_MSG_RESULT([not found])
908     CFLAGS="$CFLAGS -DHAVE_ATS=0"])
909fi
910
911case "$CFLAGS" in
912  *HAVE_FSSPEC* | *HAVE_FSREF* | *HAVE_QUICKDRAW* | *HAVE_ATS* )
913    AC_MSG_WARN([
914*** WARNING
915    FSSpec/FSRef/QuickDraw/ATS options are explicitly given,
916    thus it is recommended to replace src/base/ftmac.c by builds/mac/ftmac.c.
917    ])
918    CFLAGS="$CFLAGS "'-I$(TOP_DIR)/builds/mac/'
919    ;;
920  *)
921    ;;
922esac
923
924
925# entries in Requires.private are separated by commas;
926REQUIRES_PRIVATE="$zlib_reqpriv,     \
927                  $bzip2_reqpriv,    \
928                  $libpng_reqpriv,   \
929                  $harfbuzz_reqpriv"
930# beautify
931REQUIRES_PRIVATE=`echo "$REQUIRES_PRIVATE" \
932                  | sed -e 's/^  *//'      \
933                        -e 's/  *$//'      \
934                        -e 's/, */,/g'     \
935                        -e 's/,,*/,/g'     \
936                        -e 's/^,*//'       \
937                        -e 's/,*$//'       \
938                        -e 's/,/, /g'`
939
940LIBS_PRIVATE="$zlib_libspriv     \
941              $bzip2_libspriv    \
942              $libpng_libspriv   \
943              $harfbuzz_libspriv \
944              $ft2_extra_libs"
945# beautify
946LIBS_PRIVATE=`echo "$LIBS_PRIVATE"  \
947              | sed -e 's/^  *//'   \
948                    -e 's/  *$//'   \
949                    -e 's/  */ /g'`
950
951LIBSSTATIC_CONFIG="-lfreetype               \
952                   $zlib_libsstaticconf     \
953                   $bzip2_libsstaticconf    \
954                   $libpng_libsstaticconf   \
955                   $harfbuzz_libsstaticconf \
956                   $ft2_extra_libs"
957# remove -L/usr/lib and -L/usr/lib64 since `freetype-config' adds them later
958# on if necessary; also beautify
959LIBSSTATIC_CONFIG=`echo "$LIBSSTATIC_CONFIG"          \
960                   | sed -e 's|-L */usr/lib64/* | |g' \
961                         -e 's|-L */usr/lib/* | |g'   \
962                         -e 's/^  *//'                \
963                         -e 's/  *$//'                \
964                         -e 's/  */ /g'`
965
966
967AC_SUBST([ftmac_c])
968AC_SUBST([REQUIRES_PRIVATE])
969AC_SUBST([LIBS_PRIVATE])
970AC_SUBST([LIBSSTATIC_CONFIG])
971
972AC_SUBST([hardcode_libdir_flag_spec])
973AC_SUBST([wl])
974AC_SUBST([build_libtool_libs])
975
976
977# changing LDFLAGS value should only be done after
978# lt_cv_prog_compiler_static_works test
979
980if test "$have_zlib" != no; then
981  CFLAGS="$CFLAGS $ZLIB_CFLAGS -DFT_CONFIG_OPTION_SYSTEM_ZLIB"
982  LDFLAGS="$LDFLAGS $ZLIB_LIBS"
983fi
984
985if test "$have_bzip2" != no; then
986  CFLAGS="$CFLAGS $BZIP2_CFLAGS -DFT_CONFIG_OPTION_USE_BZIP2"
987  LDFLAGS="$LDFLAGS $BZIP2_LIBS"
988fi
989if test "$have_libpng" != no; then
990  CFLAGS="$CFLAGS $LIBPNG_CFLAGS -DFT_CONFIG_OPTION_USE_PNG"
991  LDFLAGS="$LDFLAGS $LIBPNG_LIBS"
992fi
993if test "$have_harfbuzz" != no; then
994  CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS -DFT_CONFIG_OPTION_USE_HARFBUZZ"
995  LDFLAGS="$LDFLAGS $HARFBUZZ_LIBS"
996fi
997
998AC_SUBST([CFLAGS])
999AC_SUBST([LDFLAGS])
1000
1001# configuration file -- stay in 8.3 limit
1002#
1003# since #undef doesn't survive in configuration header files we replace
1004# `/undef' with `#undef' after creating the output file
1005
1006AC_CONFIG_HEADERS([ftconfig.h:ftconfig.in],
1007  [mv ftconfig.h ftconfig.tmp
1008   sed 's|/undef|#undef|' < ftconfig.tmp > ftconfig.h
1009   rm ftconfig.tmp])
1010
1011# create the Unix-specific sub-Makefiles `builds/unix/unix-def.mk'
1012# and `builds/unix/unix-cc.mk' that will be used by the build system
1013#
1014AC_CONFIG_FILES([unix-cc.mk:unix-cc.in
1015                 unix-def.mk:unix-def.in])
1016
1017# re-generate the Jamfile to use libtool now
1018#
1019# AC_CONFIG_FILES([../../Jamfile:../../Jamfile.in])
1020
1021AC_OUTPUT
1022
1023AC_MSG_NOTICE([
1024
1025Library configuration:
1026  external zlib: $have_zlib
1027  bzip2:         $have_bzip2
1028  libpng:        $have_libpng
1029  harfbuzz:      $have_harfbuzz
1030])
1031
1032# end of configure.raw
1033