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