1 # Configure paths for FreeType2
2 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
4 dnl AC_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
5 dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS
7 AC_DEFUN([AC_CHECK_FT2],
9 dnl Get the cflags and libraries from the freetype-config script
11 AC_ARG_WITH(ft-prefix,
12 [ --with-ft-prefix=PREFIX
13 Prefix where FreeType is installed (optional)],
14 ft_config_prefix="$withval", ft_config_prefix="")
15 AC_ARG_WITH(ft-exec-prefix,
16 [ --with-ft-exec-prefix=PREFIX
17 Exec prefix where FreeType is installed (optional)],
18 ft_config_exec_prefix="$withval", ft_config_exec_prefix="")
19 AC_ARG_ENABLE(freetypetest,
20 [ --disable-freetypetest Do not try to compile and run
21 a test FreeType program],
22 [], enable_fttest=yes)
24 if test x$ft_config_exec_prefix != x ; then
25 ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
26 if test x${FT2_CONFIG+set} != xset ; then
27 FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
30 if test x$ft_config_prefix != x ; then
31 ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
32 if test x${FT2_CONFIG+set} != xset ; then
33 FT2_CONFIG=$ft_config_prefix/bin/freetype-config
36 AC_PATH_PROG(FT2_CONFIG, freetype-config, no)
38 min_ft_version=ifelse([$1], ,6.1.0,$1)
39 AC_MSG_CHECKING(for FreeType - version >= $min_ft_version)
41 if test "$FT2_CONFIG" = "no" ; then
44 FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
45 FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
46 ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
47 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
48 ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
49 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
50 ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
51 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
52 ft_min_major_version=`echo $min_ft_version | \
53 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
54 ft_min_minor_version=`echo $min_ft_version | \
55 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
56 ft_min_micro_version=`echo $min_ft_version | \
57 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
58 if test x$enable_fttest = xyes ; then
60 if test $ft_config_major_version -lt $ft_min_major_version ; then
63 if test $ft_config_major_version -eq $ft_min_major_version ; then
64 if test $ft_config_minor_version -lt $ft_min_minor_version ; then
67 if test $ft_config_minor_version -eq $ft_min_minor_version ; then
68 if test $ft_config_micro_version -lt $ft_min_micro_version ; then
75 if test x$ft_config_is_lt = xyes ; then
78 ac_save_CFLAGS="$CFLAGS"
79 ac_save_CXXFLAGS="$CFLAGS"
81 CFLAGS="$CFLAGS $FT2_CFLAGS"
82 CXXFLAGS="$CXXFLAGS $FT2_CFLAGS"
83 LIBS="$FT2_LIBS $LIBS"
85 dnl Sanity checks for the results of freetype-config to some extent
89 #include FT_FREETYPE_H
99 error = FT_Init_FreeType(&library);
105 FT_Done_FreeType(library);
109 ],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
110 CFLAGS="$ac_save_CFLAGS"
111 CXXFLAGS="$ac_save_CXXFLAGS"
113 fi # test $ft_config_version -lt $ft_min_version
114 fi # test x$enable_fttest = xyes
115 fi # test "$FT2_CONFIG" = "no"
116 if test x$no_ft = x ; then
118 ifelse([$2], , :, [$2])
121 if test "$FT2_CONFIG" = "no" ; then
122 echo "*** The freetype-config script installed by FreeType 2 could not be found."
123 echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in"
124 echo "*** your path, or set the FT2_CONFIG environment variable to the"
125 echo "*** full path to freetype-config."
127 if test x$ft_config_is_lt = xyes ; then
128 echo "*** Your installed version of the FreeType 2 library is too old."
129 echo "*** If you have different versions of FreeType 2, make sure that"
130 echo "*** correct values for --with-ft-prefix or --with-ft-exec-prefix"
131 echo "*** are used, or set the FT2_CONFIG environment variable to the"
132 echo "*** full path to freetype-config."
134 echo "*** The FreeType test program failed to run. If your system uses"
135 echo "*** shared libraries and they are installed outside the normal"
136 echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
137 echo "*** (or whatever is appropiate for your system) is correctly set."
142 ifelse([$3], , :, [$3])