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