Synchronize with FreeType.
[ttfautohint.git] / configure.ac
blob88fd7d3374264ac2351aed5457f5735586e99f16
1 # configure.ac
3 # Copyright (C) 2011-2015 by Werner Lemberg.
5 # This file is part of the ttfautohint library, and may only be used,
6 # modified, and distributed under the terms given in `COPYING'.  By
7 # continuing to use, modify, or distribute this file you indicate that you
8 # have read `COPYING' and understand and accept it fully.
10 # The file `COPYING' mentioned in the previous paragraph is distributed
11 # with the ttfautohint library.
13 AC_INIT([ttfautohint],
14         m4_esyscmd([gnulib/git-version-gen VERSION]),
15         [freetype-devel@nongnu.org])
16 AC_CONFIG_AUX_DIR([gnulib])
18 AM_INIT_AUTOMAKE([-Wall -Werror tar-ustar]
19                  m4_bmatch(m4_defn([AC_PACKAGE_VERSION]),
20                            [-], [gnu],
21                            [gnits]))
23 AC_CONFIG_MACRO_DIRS([gnulib/m4
24                       m4])
26 AM_SILENT_RULES([yes])
28 AC_USE_SYSTEM_EXTENSIONS
30 AC_PROG_CPP
31 AC_PROG_CC
32 AC_PROG_CXX
33 AC_C_INLINE
35 gl_EARLY
37 PKG_PROG_PKG_CONFIG([0.24])
39 # AM_PROG_AR is new in automake 1.11.2;
40 # however, MinGW doesn't have it yet (May 2012)
41 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
43 AC_PATH_PROG([BISON], [bison])
44 AC_PATH_PROG([FLEX], [flex])
46 gl_INIT
48 PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz >= 0.9.19])
50 AT_WITH_QT
51 AT_REQUIRE_QT_VERSION([4.6])
53 if test x"$with_qt" != x"no"; then
54   AC_MSG_CHECKING([for QLocale::quoteString])
55   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
56     [AC_MSG_RESULT(no)],
57     [AC_MSG_RESULT(no)],
58     [AC_MSG_RESULT(yes)
59      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
60        [Define if Qt function QLocale::quoteString is available.])])
63 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
65 LT_INIT
66 LT_LTLIZE_LANG([C])
69 # We use libtool's convenient check for the math library.
70 LT_LIB_M
71 AC_SUBST(LIBM)
74 AC_ARG_WITH([doc],
75             [AS_HELP_STRING([--with-doc],
76                             [install documentation @<:@default=yes@:>@])],
77             [],
78             [with_doc=yes])
80 AC_ARG_WITH([freetype-config],
81             [AS_HELP_STRING([--with-freetype-config=PROG],
82                             [use FreeType configuration program PROG])],
83             [freetype_config=$withval],
84             [freetype_config=yes])
86 if test "$freetype_config" = "yes"; then
87   AC_PATH_TOOL(ft_config,
88                freetype-config,
89                no)
90   if test "$ft_config" = "no"; then
91     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
92   fi
93 else
94   ft_config="$freetype_config"
97 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
98 FREETYPE_LIBS="`$ft_config --libtool`"
100 # many platforms no longer install .la files for system libraries
101 if test ! -f $FREETYPE_LIBS; then
102   FREETYPE_LIBS="`$ft_config --libs`"
105 AC_SUBST(FREETYPE_CPPFLAGS)
106 AC_SUBST(FREETYPE_LIBS)
109 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
110 old_CPPFLAGS="$CPPFLAGS"
111 CPPFLAGS=$FREETYPE_CPPFLAGS
112 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
114 #include <ft2build.h>
115 #include FT_FREETYPE_H
116 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
117 #error Freetype version too low.
118 #endif
120 ]])],
121 [AC_MSG_RESULT(yes)
122  CPPFLAGS="$old_CPPFLAGS"],
123 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
126 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
127 old_CPPFLAGS="$CPPFLAGS"
128 CPPFLAGS=$FREETYPE_CPPFLAGS
129 old_LIBS="$LIBS"
130 LIBS=$FREETYPE_LIBS
131 AC_LANG_PUSH([LTLIZED C])
132 AC_RUN_IFELSE([AC_LANG_SOURCE([[
134 #include <stdlib.h>
135 #include <ft2build.h>
136 #include FT_FREETYPE_H
139 main()
141   FT_Error error;
142   FT_Library library;
143   FT_Int major, minor, patch;
145   error = FT_Init_FreeType(&library);
146   if (error)
147   {
148     printf("(test program reports error code %d)... ", error);
149     exit(EXIT_FAILURE);
150   }
152   FT_Library_Version(library, &major, &minor, &patch);
154   printf("(found %d.%d.%d)... ", major, minor, patch);
156   if (((major*1000 + minor)*1000 + patch) >= 2004005)
157     exit(EXIT_SUCCESS);
158   exit(EXIT_FAILURE);
161 ]])],
162 [AC_MSG_RESULT(yes)
163  CPPFLAGS="$old_CPPFLAGS"
164  LIBS="$old_LIBS"],
165 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
166 [AC_MSG_RESULT([skipped due to cross-compilation])])
167 AC_LANG_POP
170 if test $cross_compiling = no; then
171   AM_MISSING_PROG(HELP2MAN, help2man)
172 else
173   HELP2MAN=:
176 # The documentation is part of the distributed bundle.  In the following,
177 # tests for the documentation building tools are made fatal in case those
178 # files are missing (which can happen during bootstrap).
180 AC_DEFUN([TA_DOC],
181   [if test -f "$1"; then
182      AC_MSG_WARN([$2])
183      with_doc=no
184    else
185      AC_MSG_ERROR([$2])
186    fi])
188 image_file=$srcdir/doc/img/ttfautohintGUI.png
189 html_file=$srcdir/doc/ttfautohint.html
190 pdf_file=$srcdir/doc/ttfautohint.pdf
192 if test x"$with_doc" != x"no"; then
193   # snapshot image creation
194   if test x"$DISPLAY" == x; then
195     TA_DOC([$image_file],
196            [Need X11 to create snapshot image of ttfautohintGUI])
197   else
198     AC_CHECK_PROG([IMPORT], [import], [import], [no])
199     if test x"$IMPORT" == x"no"; then
200       TA_DOC([$image_file],
201              [Need ImageMagick to create snapshot image of ttfautohintGUI])
202     fi
203   fi
205   # conversion of SVG to PDF
206   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
207   if test x"$INKSCAPE" == x"no"; then
208     TA_DOC([$pdf_file],
209            [Need inkscape to convert SVG image files to PDF])
210   fi
212   # documentation creation
213   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
214   if test x"$PANDOC" == x"no"; then
215     TA_DOC([$html_file],
216            [Need pandoc to create PDF and HTML documentation files])
217   fi
219   # PDF documentation
220   # To support Devanagari and other Indic scripts properly,
221   # we currently can use XeTeX only.
222   AC_CHECK_PROGS([LATEX], [xelatex], [no])
223   if test x"$PDFLATEX" == x"no"; then
224     TA_DOC([$pdf_file],
225            [Need xelatex to create documentation in PDF format])
226   fi
229 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
231 AC_CONFIG_HEADERS([config.h])
232 AC_CONFIG_FILES([Makefile
233                  gnulib/src/Makefile
234                  lib/Makefile
235                  frontend/Makefile
236                  doc/Makefile])
237 AC_OUTPUT
239 # end of configure.ac