diff options
Diffstat (limited to 'm4/freetype2.m4')
-rw-r--r-- | m4/freetype2.m4 | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/m4/freetype2.m4 b/m4/freetype2.m4 new file mode 100644 index 000000000..7424a32ab --- /dev/null +++ b/m4/freetype2.m4 | |||
@@ -0,0 +1,178 @@ | |||
1 | # Configure paths for FreeType2 | ||
2 | # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor | ||
3 | # | ||
4 | # serial 2 | ||
5 | |||
6 | # AC_CHECK_FT2([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
7 | # Test for FreeType 2, and define FT2_CFLAGS and FT2_LIBS. | ||
8 | # MINIMUM-VERSION is what libtool reports; the default is `7.0.1' (this is | ||
9 | # FreeType 2.0.4). | ||
10 | # | ||
11 | AC_DEFUN([AC_CHECK_FT2], | ||
12 | [# Get the cflags and libraries from the freetype-config script | ||
13 | # | ||
14 | AC_ARG_WITH([ft-prefix], | ||
15 | dnl don't quote AS_HELP_STRING! | ||
16 | AS_HELP_STRING([--with-ft-prefix=PREFIX], | ||
17 | [Prefix where FreeType is installed (optional)]), | ||
18 | [ft_config_prefix="$withval"], | ||
19 | [ft_config_prefix=""]) | ||
20 | |||
21 | AC_ARG_WITH([ft-exec-prefix], | ||
22 | dnl don't quote AS_HELP_STRING! | ||
23 | AS_HELP_STRING([--with-ft-exec-prefix=PREFIX], | ||
24 | [Exec prefix where FreeType is installed (optional)]), | ||
25 | [ft_config_exec_prefix="$withval"], | ||
26 | [ft_config_exec_prefix=""]) | ||
27 | |||
28 | AC_ARG_ENABLE([freetypetest], | ||
29 | dnl don't quote AS_HELP_STRING! | ||
30 | AS_HELP_STRING([--disable-freetypetest], | ||
31 | [Do not try to compile and run a test FreeType program]), | ||
32 | [], | ||
33 | [enable_fttest=yes]) | ||
34 | |||
35 | if test x$ft_config_exec_prefix != x ; then | ||
36 | ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix" | ||
37 | if test x${FT2_CONFIG+set} != xset ; then | ||
38 | FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config | ||
39 | fi | ||
40 | fi | ||
41 | |||
42 | if test x$ft_config_prefix != x ; then | ||
43 | ft_config_args="$ft_config_args --prefix=$ft_config_prefix" | ||
44 | if test x${FT2_CONFIG+set} != xset ; then | ||
45 | FT2_CONFIG=$ft_config_prefix/bin/freetype-config | ||
46 | fi | ||
47 | fi | ||
48 | |||
49 | AC_PATH_PROG([FT2_CONFIG], [freetype-config], [no]) | ||
50 | |||
51 | min_ft_version=m4_if([$1], [], [7.0.1], [$1]) | ||
52 | AC_MSG_CHECKING([for FreeType -- version >= $min_ft_version]) | ||
53 | no_ft="" | ||
54 | if test "$FT2_CONFIG" = "no" ; then | ||
55 | no_ft=yes | ||
56 | else | ||
57 | FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags` | ||
58 | FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs` | ||
59 | ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \ | ||
60 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | ||
61 | ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \ | ||
62 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | ||
63 | ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \ | ||
64 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | ||
65 | ft_min_major_version=`echo $min_ft_version | \ | ||
66 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | ||
67 | ft_min_minor_version=`echo $min_ft_version | \ | ||
68 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | ||
69 | ft_min_micro_version=`echo $min_ft_version | \ | ||
70 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | ||
71 | if test x$enable_fttest = xyes ; then | ||
72 | ft_config_is_lt="" | ||
73 | if test $ft_config_major_version -lt $ft_min_major_version ; then | ||
74 | ft_config_is_lt=yes | ||
75 | else | ||
76 | if test $ft_config_major_version -eq $ft_min_major_version ; then | ||
77 | if test $ft_config_minor_version -lt $ft_min_minor_version ; then | ||
78 | ft_config_is_lt=yes | ||
79 | else | ||
80 | if test $ft_config_minor_version -eq $ft_min_minor_version ; then | ||
81 | if test $ft_config_micro_version -lt $ft_min_micro_version ; then | ||
82 | ft_config_is_lt=yes | ||
83 | fi | ||
84 | fi | ||
85 | fi | ||
86 | fi | ||
87 | fi | ||
88 | if test x$ft_config_is_lt = xyes ; then | ||
89 | no_ft=yes | ||
90 | else | ||
91 | ac_save_CFLAGS="$CFLAGS" | ||
92 | ac_save_LIBS="$LIBS" | ||
93 | CFLAGS="$CFLAGS $FT2_CFLAGS" | ||
94 | LIBS="$FT2_LIBS $LIBS" | ||
95 | |||
96 | # | ||
97 | # Sanity checks for the results of freetype-config to some extent. | ||
98 | # | ||
99 | AC_RUN_IFELSE([ | ||
100 | AC_LANG_SOURCE([[ | ||
101 | |||
102 | #include <ft2build.h> | ||
103 | #include FT_FREETYPE_H | ||
104 | #include <stdio.h> | ||
105 | #include <stdlib.h> | ||
106 | |||
107 | int | ||
108 | main() | ||
109 | { | ||
110 | FT_Library library; | ||
111 | FT_Error error; | ||
112 | |||
113 | error = FT_Init_FreeType(&library); | ||
114 | |||
115 | if (error) | ||
116 | return 1; | ||
117 | else | ||
118 | { | ||
119 | FT_Done_FreeType(library); | ||
120 | return 0; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | ]]) | ||
125 | ], | ||
126 | [], | ||
127 | [no_ft=yes], | ||
128 | [echo $ECHO_N "cross compiling; assuming OK... $ECHO_C"]) | ||
129 | |||
130 | CFLAGS="$ac_save_CFLAGS" | ||
131 | LIBS="$ac_save_LIBS" | ||
132 | fi # test $ft_config_version -lt $ft_min_version | ||
133 | fi # test x$enable_fttest = xyes | ||
134 | fi # test "$FT2_CONFIG" = "no" | ||
135 | |||
136 | if test x$no_ft = x ; then | ||
137 | AC_MSG_RESULT([yes]) | ||
138 | m4_if([$2], [], [:], [$2]) | ||
139 | else | ||
140 | AC_MSG_RESULT([no]) | ||
141 | if test "$FT2_CONFIG" = "no" ; then | ||
142 | AC_MSG_WARN([ | ||
143 | |||
144 | The freetype-config script installed by FreeType 2 could not be found. | ||
145 | If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in | ||
146 | your path, or set the FT2_CONFIG environment variable to the | ||
147 | full path to freetype-config. | ||
148 | ]) | ||
149 | else | ||
150 | if test x$ft_config_is_lt = xyes ; then | ||
151 | AC_MSG_WARN([ | ||
152 | |||
153 | Your installed version of the FreeType 2 library is too old. | ||
154 | If you have different versions of FreeType 2, make sure that | ||
155 | correct values for --with-ft-prefix or --with-ft-exec-prefix | ||
156 | are used, or set the FT2_CONFIG environment variable to the | ||
157 | full path to freetype-config. | ||
158 | ]) | ||
159 | else | ||
160 | AC_MSG_WARN([ | ||
161 | |||
162 | The FreeType test program failed to run. If your system uses | ||
163 | shared libraries and they are installed outside the normal | ||
164 | system library path, make sure the variable LD_LIBRARY_PATH | ||
165 | (or whatever is appropiate for your system) is correctly set. | ||
166 | ]) | ||
167 | fi | ||
168 | fi | ||
169 | |||
170 | FT2_CFLAGS="" | ||
171 | FT2_LIBS="" | ||
172 | m4_if([$3], [], [:], [$3]) | ||
173 | fi | ||
174 | |||
175 | AC_SUBST([FT2_CFLAGS]) | ||
176 | AC_SUBST([FT2_LIBS])]) | ||
177 | |||
178 | # end of freetype2.m4 | ||