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