Do not log an error for missing Video info in DefineVideo, as that's fine when Vide...
[gnash.git] / macros / freetype.m4
blobe8fe45cf4a9a6b0b9c3cc7e1ceee8e62e83b608f
1 dnl  
2 dnl    Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
3 dnl  
4 dnl  This program is free software; you can redistribute it and/or modify
5 dnl  it under the terms of the GNU General Public License as published by
6 dnl  the Free Software Foundation; either version 3 of the License, or
7 dnl  (at your option) any later version.
8 dnl  
9 dnl  This program is distributed in the hope that it will be useful,
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl  GNU General Public License for more details.
13 dnl  You should have received a copy of the GNU General Public License
14 dnl  along with this program; if not, write to the Free Software
15 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 AC_DEFUN([GNASH_PATH_FREETYPE2],
19   dnl Look for the header
20   AC_ARG_WITH(freetype_incl, AC_HELP_STRING([--with-freetype-incl], [directory where libfreetype header is (w/out the freetype/ prefix)]), with_freetype_incl=${withval})
21     AC_CACHE_VAL(ac_cv_path_freetype_incl,[
22     if test x"${with_freetype_incl}" != x ; then
23       if test -f ${with_freetype_incl}/freetype/freetype.h ; then
24               ac_cv_path_freetype_incl="-I`(cd ${with_freetype_incl}; pwd)`"
25       else
26               AC_MSG_ERROR([${with_freetype_incl} directory doesn't contain freetype/freetype.h])
27       fi
28     fi
29   ])
31   if test x$cross_compiling = xno; then
32     if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_freetype_incl}" = x; then
33       $PKG_CONFIG --exists freetype2 && ac_cv_path_freetype_incl="`$PKG_CONFIG --cflags freetype2`"
34     fi
35   fi
37   dnl If the path hasn't been specified, go look for it.
38   if test x"${ac_cv_path_freetype_incl}" = x; then
39     for i in $incllist; do
40       if test -f $i/freetype2/freetype/freetype.h; then
41         ac_cv_path_freetype_incl="-I$i/freetype2"
42               break
43       fi
44       dnl Haiku uses only freetype as the directory, not freetype2
45       if test x"${haiku}" = xyes; then
46         if test -f $i/freetype/freetype/freetype.h; then
47           ac_cv_path_freetype_incl="-I$i/freetype"
48                 break
49         fi
50       fi
51     done
53     if test x"${ac_cv_path_freetype_incl}" = x ; then
54       AC_CHECK_HEADERS(freetype2/freetype/freetype.h)
55     fi
57     AC_MSG_CHECKING([for libfreetype header])
58     if test x"${ac_cv_path_freetype_incl}" != x ; then
59       AC_MSG_RESULT(yes)
60     else
61       AC_MSG_RESULT(no)
62     fi
63   fi
66   dnl This check is bogus, ac_cv_path_freetype_incl will have -I too, and possibly multiple things too
67   dnl so at most we can try to *strip* any -I/usr/include
68   if test x"${ac_cv_path_freetype_incl}" != x"/usr/include"; then
69     ac_cv_path_freetype_incl="${ac_cv_path_freetype_incl}"
70   else
71     ac_cv_path_freetype_incl=""
72   fi
74 dnl   if test x"${darwin}" = xyes; then
75      libname=freetype
76 dnl   else
77 dnl     libname=freetype2
78 dnl   fi
79   AC_ARG_WITH(freetype_lib, AC_HELP_STRING([--with-freetype-lib], [directory where freetype library is]), with_freetype_lib=${withval})
80     AC_CACHE_VAL(ac_cv_path_freetype_lib,[
81     if test x"${with_freetype_lib}" != x ; then
82       if test -f ${with_freetype_lib}/lib${libname}.a -o -f ${with_freetype_lib}/lib${libname}.${shlibext}; then
83         ac_cv_path_freetype_lib="-L`(cd ${with_freetype_lib}; pwd)` -l${libname}"
84       else
85         AC_MSG_ERROR([${with_freetype_lib} directory doesn't contain libfreetype.])
86       fi
87     fi
88   ])
90   dnl Look for the library
91   if test x$cross_compiling = xno; then
92     if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_freetype_lib}" = x; then
93       $PKG_CONFIG --exists freetype2 && ac_cv_path_freetype_lib="`$PKG_CONFIG --libs freetype2`"
94     fi
95   fi
97   dnl If the path hasn't been specified, go look for it.
98   if test x"${ac_cv_path_freetype_lib}" = x; then
99     dnl freetype-config gives us way too many libraries, which create nasty linking
100     dnl dependancy issues, so we strip them off here. The real dependencies are
101     dnl are taken care of by other config tests.
102     AC_MSG_CHECKING([for ${libname} library])
103     for i in $libslist; do
104       if test -f $i/lib${libname}.a -o -f $i/lib${libname}.${shlibext}; then
105         if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
106           ac_cv_path_freetype_lib="-L$i -l${libname}"
107           AC_MSG_RESULT(${ac_cv_path_freetype_lib})
108           break
109         else
110           ac_cv_path_freetype_lib="-l${libname}"
111           AC_MSG_RESULT(yes)
112           break
113         fi
114       fi
115     done
116   fi
118   if test x"${ac_cv_path_freetype_incl}" != x ; then
119     FREETYPE2_CFLAGS="${ac_cv_path_freetype_incl}"
120   else
121     FREETYPE2_CFLAGS=""
122   fi
124   if test x"${ac_cv_path_freetype_lib}" != x ; then
125     FREETYPE2_LIBS="${ac_cv_path_freetype_lib}"
126   else
127     FREETYPE2_LIBS=""
128   fi
130   AM_CONDITIONAL(FREETYPE, [test -n "$FREETYPE_LIBS"])
132   if test -n "$FREETYPE2_LIBS"; then
133     AC_DEFINE(USE_FREETYPE, [1], [Define this if you want to enable freetype usage])
134   fi
136   dnl Look for fontconfig's fc-match to set a hard-coded font path.
137   dnl If fontconfig is available, gnash should always manage to find a
138   dnl suitable system font in run time, so will never need this hard-coded
139   dnl default (unless fontconfig is removed after building gnash, for instance).
140   AC_PATH_PROG(FC_MATCH, fc-match, ,[${pathlist}])
141   if test x"$FC_MATCH" != x; then
142     DEFAULT_FONT="`$FC_MATCH -v 'Sans' | grep '^.file:' | sed 's/\(.*\"\)\(.*\)\(\".*\)/\2/g'`"
143   fi
145   dnl Hard-coded last resort, which is only likely to work
146   dnl on UNIX-like systems.
147   if test -z "$DEFAULT_FONT"; then
148     DEFAULT_FONT="/usr/share/fonts/truetype/freefont/FreeSans.ttf"
149   fi
150   
151   AC_DEFINE_UNQUOTED(DEFAULT_FONTFILE, ["$DEFAULT_FONT"], [Path to default font])
153   AC_SUBST(FREETYPE2_CFLAGS)
154   AC_SUBST(FREETYPE2_LIBS)
157 # Local Variables:
158 # c-basic-offset: 2
159 # tab-width: 2
160 # indent-tabs-mode: nil
161 # End: