Allow using things that were deprecated in gtk+-3.22.
[freeciv.git] / m4 / freetype2.m4
blobe8cf2fdb8355972cca75a8512b3e04351f38b054
1 # Configure paths for FreeType2
2 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
4 # Copyright 2001, 2003, 2007, 2009, 2014 by
5 # David Turner, Robert Wilhelm, and Werner Lemberg.
7 # This file is part of the FreeType project, and may only be used, modified,
8 # and distributed under the terms of the FreeType project license,
9 # LICENSE.TXT.  By continuing to use, modify, or distribute this file you
10 # indicate that you have read the license and understand and accept it
11 # fully.
13 # As a special exception to the FreeType project license, this file may be
14 # distributed as part of a program that contains a configuration script
15 # generated by Autoconf, under the same distribution terms as the rest of
16 # that program.
18 # serial 4
20 # AC_CHECK_FT2([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
21 # Test for FreeType 2, and define FT2_CFLAGS and FT2_LIBS.
22 # MINIMUM-VERSION is what libtool reports; the default is `7.0.1' (this is
23 # FreeType 2.0.4).
25 AC_DEFUN([AC_CHECK_FT2],
26   [# Get the cflags and libraries from the freetype-config script
27    #
28    AC_ARG_WITH([ft-prefix],
29      AS_HELP_STRING([--with-ft-prefix=PREFIX],
30                     [Prefix where FreeType is installed (optional)]),
31      [ft_config_prefix="$withval"],
32      [ft_config_prefix=""])
34    AC_ARG_WITH([ft-exec-prefix],
35      AS_HELP_STRING([--with-ft-exec-prefix=PREFIX],
36                     [Exec prefix where FreeType is installed (optional)]),
37      [ft_config_exec_prefix="$withval"],
38      [ft_config_exec_prefix=""])
40    AC_ARG_ENABLE([freetypetest],
41      AS_HELP_STRING([--disable-freetypetest],
42                     [Do not try to compile and run a test FreeType program]),
43      [],
44      [enable_fttest=yes])
46    if test x$ft_config_exec_prefix != x ; then
47      ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
48      if test x${FT2_CONFIG+set} != xset ; then
49        FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
50      fi
51    fi
53    if test x$ft_config_prefix != x ; then
54      ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
55      if test x${FT2_CONFIG+set} != xset ; then
56        FT2_CONFIG=$ft_config_prefix/bin/freetype-config
57      fi
58    fi
60    if test "x$FT2_CONFIG" = x ; then
61      AC_PATH_TOOL([FT2_CONFIG], [freetype-config], [no])
62    fi
64    min_ft_version=m4_if([$1], [], [7.0.1], [$1])
65    AC_MSG_CHECKING([for FreeType -- version >= $min_ft_version])
66    no_ft=""
67    if test "$FT2_CONFIG" = "no" ; then
68      no_ft=yes
69    else
70      FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
71      FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
72      ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
73        sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
74      ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
75        sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
76      ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
77        sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
78      ft_min_major_version=`echo $min_ft_version | \
79        sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
80      ft_min_minor_version=`echo $min_ft_version | \
81        sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
82      ft_min_micro_version=`echo $min_ft_version | \
83        sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
84      if test x$enable_fttest = xyes ; then
85        ft_config_is_lt=""
86        if test $ft_config_major_version -lt $ft_min_major_version ; then
87          ft_config_is_lt=yes
88        else
89          if test $ft_config_major_version -eq $ft_min_major_version ; then
90            if test $ft_config_minor_version -lt $ft_min_minor_version ; then
91              ft_config_is_lt=yes
92            else
93              if test $ft_config_minor_version -eq $ft_min_minor_version ; then
94                if test $ft_config_micro_version -lt $ft_min_micro_version ; then
95                  ft_config_is_lt=yes
96                fi
97              fi
98            fi
99          fi
100        fi
101        if test x$ft_config_is_lt = xyes ; then
102          no_ft=yes
103        else
104          ac_save_CFLAGS="$CFLAGS"
105          ac_save_LIBS="$LIBS"
106          CFLAGS="$CFLAGS $FT2_CFLAGS"
107          LIBS="$FT2_LIBS $LIBS"
109          #
110          # Sanity checks for the results of freetype-config to some extent.
111          #
112          AC_RUN_IFELSE([
113              AC_LANG_SOURCE([[
115 #include <ft2build.h>
116 #include FT_FREETYPE_H
117 #include <stdio.h>
118 #include <stdlib.h>
121 main()
123   FT_Library library;
124   FT_Error  error;
126   error = FT_Init_FreeType(&library);
128   if (error)
129     return 1;
130   else
131   {
132     FT_Done_FreeType(library);
133     return 0;
134   }
137              ]])
138            ],
139            [],
140            [no_ft=yes],
141            [echo $ECHO_N "cross compiling; assuming OK... $ECHO_C"])
143          CFLAGS="$ac_save_CFLAGS"
144          LIBS="$ac_save_LIBS"
145        fi             # test $ft_config_version -lt $ft_min_version
146      fi               # test x$enable_fttest = xyes
147    fi                 # test "$FT2_CONFIG" = "no"
149    if test x$no_ft = x ; then
150      AC_MSG_RESULT([yes])
151      m4_if([$2], [], [:], [$2])
152    else
153      AC_MSG_RESULT([no])
154      if test "$FT2_CONFIG" = "no" ; then
155        AC_MSG_WARN([
157   The freetype-config script installed by FreeType 2 could not be found.
158   If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in
159   your path, or set the FT2_CONFIG environment variable to the
160   full path to freetype-config.
161        ])
162      else
163        if test x$ft_config_is_lt = xyes ; then
164          AC_MSG_WARN([
166   Your installed version of the FreeType 2 library is too old.
167   If you have different versions of FreeType 2, make sure that
168   correct values for --with-ft-prefix or --with-ft-exec-prefix
169   are used, or set the FT2_CONFIG environment variable to the
170   full path to freetype-config.
171          ])
172        else
173          AC_MSG_WARN([
175   The FreeType test program failed to run.  If your system uses
176   shared libraries and they are installed outside the normal
177   system library path, make sure the variable LD_LIBRARY_PATH
178   (or whatever is appropriate for your system) is correctly set.
179          ])
180        fi
181      fi
183      FT2_CFLAGS=""
184      FT2_LIBS=""
185      m4_if([$3], [], [:], [$3])
186    fi
188    AC_SUBST([FT2_CFLAGS])
189    AC_SUBST([FT2_LIBS])])
191 # end of freetype2.m4