Synchronize with FreeType.
[ttfautohint.git] / configure.ac
blob9f8c7f9eb2961f4db246a4c33549b0cb49e2317c
1 # configure.ac
3 # Copyright (C) 2011-2014 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]
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 PKG_PROG_PKG_CONFIG([0.24])
37 # AM_PROG_AR is new in automake 1.11.2;
38 # however, MinGW doesn't have it yet (May 2012)
39 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
41 gl_EARLY
42 gl_INIT
44 PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz >= 0.9.19])
46 AT_WITH_QT
47 AT_REQUIRE_QT_VERSION([4.6])
49 if test x"$with_qt" != x"no"; then
50   AC_MSG_CHECKING([for QLocale::quoteString])
51   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
52     [AC_MSG_RESULT(no)],
53     [AC_MSG_RESULT(no)],
54     [AC_MSG_RESULT(yes)
55      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
56        [Define if Qt function QLocale::quoteString is available.])])
59 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
61 LT_INIT
62 LT_LTLIZE_LANG([C])
65 AC_ARG_WITH([doc],
66             [AS_HELP_STRING([--with-doc],
67                             [install documentation @<:@default=yes@:>@])],
68             [],
69             [with_doc=yes])
71 AC_ARG_WITH([freetype-config],
72             [AS_HELP_STRING([--with-freetype-config=PROG],
73                             [use FreeType configuration program PROG])],
74             [freetype_config=$withval],
75             [freetype_config=yes])
77 if test "$freetype_config" = "yes"; then
78   AC_PATH_PROG(ft_config,
79                freetype-config,
80                no)
81   if test "$ft_config" = "no"; then
82     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
83   fi
84 else
85   ft_config="$freetype_config"
88 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
89 FREETYPE_LIBS="`$ft_config --libtool`"
91 # many platforms no longer install .la files for system libraries
92 if test ! -f $FREETYPE_LIBS; then
93   FREETYPE_LIBS="`$ft_config --libs`"
96 AC_SUBST(FREETYPE_CPPFLAGS)
97 AC_SUBST(FREETYPE_LIBS)
100 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
101 old_CPPFLAGS="$CPPFLAGS"
102 CPPFLAGS=$FREETYPE_CPPFLAGS
103 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
105 #include <ft2build.h>
106 #include FT_FREETYPE_H
107 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
108 #error Freetype version too low.
109 #endif
111 ]])],
112 [AC_MSG_RESULT(yes)
113  CPPFLAGS="$old_CPPFLAGS"],
114 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
117 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
118 old_CPPFLAGS="$CPPFLAGS"
119 CPPFLAGS=$FREETYPE_CPPFLAGS
120 old_LIBS="$LIBS"
121 LIBS=$FREETYPE_LIBS
122 AC_LANG_PUSH([LTLIZED C])
123 AC_RUN_IFELSE([AC_LANG_SOURCE([[
125 #include <stdlib.h>
126 #include <ft2build.h>
127 #include FT_FREETYPE_H
130 main()
132   FT_Error error;
133   FT_Library library;
134   FT_Int major, minor, patch;
136   error = FT_Init_FreeType(&library);
137   if (error)
138   {
139     printf("(test program reports error code %d)... ", error);
140     exit(EXIT_FAILURE);
141   }
143   FT_Library_Version(library, &major, &minor, &patch);
145   printf("(found %d.%d.%d)... ", major, minor, patch);
147   if (((major*1000 + minor)*1000 + patch) >= 2004005)
148     exit(EXIT_SUCCESS);
149   exit(EXIT_FAILURE);
152 ]])],
153 [AC_MSG_RESULT(yes)
154  CPPFLAGS="$old_CPPFLAGS"
155  LIBS="$old_LIBS"],
156 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
157 [AC_MSG_RESULT([skipped due to cross-compilation])])
158 AC_LANG_POP
161 if test $cross_compiling = no; then
162   AM_MISSING_PROG(HELP2MAN, help2man)
163 else
164   HELP2MAN=:
167 # The documentation is part of the distributed bundle.  In the following,
168 # tests for the documentation building tools are made fatal in case those
169 # files are missing (which can happen during bootstrap).
171 AC_DEFUN([TA_DOC],
172   [if test -f "$1"; then
173      AC_MSG_WARN([$2])
174      with_doc=no
175    else
176      AC_MSG_ERROR([$2])
177    fi])
179 image_file=$srcdir/doc/img/ttfautohintGUI.png
180 html_file=$srcdir/doc/ttfautohint.html
181 pdf_file=$srcdir/doc/ttfautohint.pdf
183 if test x"$with_doc" != x"no"; then
184   # snapshot image creation
185   if test x"$DISPLAY" == x; then
186     TA_DOC([$image_file],
187            [Need X11 to create snapshot image of ttfautohintGUI])
188   else
189     AC_CHECK_PROG([IMPORT], [import], [import], [no])
190     if test x"$IMPORT" == x"no"; then
191       TA_DOC([$image_file],
192              [Need ImageMagick to create snapshot image of ttfautohintGUI])
193     fi
194   fi
196   # conversion of SVG to PDF
197   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
198   if test x"$INKSCAPE" == x"no"; then
199     TA_DOC([$pdf_file],
200            [Need inkscape to convert SVG image files to PDF])
201   fi
203   # documentation creation
204   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
205   if test x"$PANDOC" == x"no"; then
206     TA_DOC([$html_file],
207            [Need pandoc to create PDF and HTML documentation files])
208   fi
210   # PDF documentation
211   AC_CHECK_PROGS([LATEX], [lualatex xelatex], [no])
212   if test x"$PDFLATEX" == x"no"; then
213     TA_DOC([$pdf_file],
214            [Need lualatex or xelatex to create documentation in PDF format])
215   fi
218 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
220 AC_CONFIG_HEADERS([config.h])
221 AC_CONFIG_FILES([Makefile
222                  gnulib/src/Makefile
223                  lib/Makefile
224                  frontend/Makefile
225                  doc/Makefile])
226 AC_OUTPUT
228 # end of configure.ac