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