RIP, Vernon...
[ttfautohint.git] / configure.ac
blobd38886bb8599d273f535137c6e53eaf0e2b8c40b
1 # configure.ac
3 # Copyright (C) 2011-2016 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_LN_S
32 AC_PROG_CPP
33 AC_PROG_CC
34 AC_PROG_CC_C99
35 AC_PROG_CXX
36 AX_CXX_COMPILE_STDCXX([11])
37 AC_C_INLINE
39 gl_EARLY
41 PKG_PROG_PKG_CONFIG([0.24])
43 # AM_PROG_AR is new in automake 1.11.2;
44 # however, MinGW doesn't have it yet (May 2012)
45 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
47 AC_PATH_PROG([BISON], [bison])
48 AC_PATH_PROG([FLEX], [flex])
50 gl_INIT
52 PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz >= 0.9.19])
54 AT_WITH_QT
55 AT_REQUIRE_QT_VERSION([4.6])
57 if test x"$with_qt" != x"no"; then
58   AC_MSG_CHECKING([for QLocale::quoteString])
59   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
60     [AC_MSG_RESULT(no)],
61     [AC_MSG_RESULT(no)],
62     [AC_MSG_RESULT(yes)
63      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
64        [Define if Qt function QLocale::quoteString is available.])])
67 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
69 LT_INIT
70 LT_LTLIZE_LANG([C])
73 # We use libtool's convenient check for the math library.
74 LT_LIB_M
75 AC_SUBST(LIBM)
78 AC_ARG_WITH([doc],
79             [AS_HELP_STRING([--with-doc],
80                             [install documentation @<:@default=yes@:>@])],
81             [],
82             [with_doc=yes])
84 AC_ARG_WITH([freetype-config],
85             [AS_HELP_STRING([--with-freetype-config=PROG],
86                             [use FreeType configuration program PROG])],
87             [freetype_config=$withval],
88             [freetype_config=yes])
90 if test "$freetype_config" = "yes"; then
91   AC_PATH_TOOL(ft_config,
92                freetype-config,
93                no)
94   if test "$ft_config" = "no"; then
95     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
96   fi
97 else
98   ft_config="$freetype_config"
101 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
102 FREETYPE_LIBS="`$ft_config --libtool`"
104 # many platforms no longer install .la files for system libraries
105 if test ! -f "$FREETYPE_LIBS"; then
106   FREETYPE_LIBS="`$ft_config --libs`"
109 AC_SUBST(FREETYPE_CPPFLAGS)
110 AC_SUBST(FREETYPE_LIBS)
113 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
114 old_CPPFLAGS="$CPPFLAGS"
115 CPPFLAGS=$FREETYPE_CPPFLAGS
116 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
118 #include <ft2build.h>
119 #include FT_FREETYPE_H
120 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
121 #error Freetype version too low.
122 #endif
124 ]])],
125 [AC_MSG_RESULT(yes)
126  CPPFLAGS="$old_CPPFLAGS"],
127 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
130 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
131 old_CPPFLAGS="$CPPFLAGS"
132 CPPFLAGS=$FREETYPE_CPPFLAGS
133 old_LIBS="$LIBS"
134 LIBS=$FREETYPE_LIBS
135 AC_LANG_PUSH([LTLIZED C])
136 AC_RUN_IFELSE([AC_LANG_SOURCE([[
138 #include <stdlib.h>
139 #include <ft2build.h>
140 #include FT_FREETYPE_H
143 main()
145   FT_Error error;
146   FT_Library library;
147   FT_Int major, minor, patch;
149   error = FT_Init_FreeType(&library);
150   if (error)
151   {
152     printf("(test program reports error code %d)... ", error);
153     exit(EXIT_FAILURE);
154   }
156   FT_Library_Version(library, &major, &minor, &patch);
158   printf("(found %d.%d.%d)... ", major, minor, patch);
160   if (((major*1000 + minor)*1000 + patch) >= 2004005)
161     exit(EXIT_SUCCESS);
162   exit(EXIT_FAILURE);
165 ]])],
166 [AC_MSG_RESULT(yes)
167  CPPFLAGS="$old_CPPFLAGS"
168  LIBS="$old_LIBS"],
169 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
170 [AC_MSG_RESULT([skipped due to cross-compilation])])
171 AC_LANG_POP
174 if test $cross_compiling = no; then
175   AM_MISSING_PROG(HELP2MAN, help2man)
176 else
177   HELP2MAN=:
180 # The documentation is part of the distributed bundle.  In the following,
181 # tests for the documentation building tools are made fatal in case those
182 # files are missing (which can happen during bootstrap).
184 AC_DEFUN([TA_DOC],
185   [if test -f "$1"; then
186      AC_MSG_WARN([$2])
187      with_doc=no
188    else
189      AC_MSG_ERROR([$2])
190    fi])
192 image_file=$srcdir/doc/img/ttfautohintGUI.png
193 html_file=$srcdir/doc/ttfautohint.html
194 pdf_file=$srcdir/doc/ttfautohint.pdf
196 if test x"$with_doc" != x"no"; then
197   # snapshot image creation
198   if test x"$DISPLAY" == x; then
199     TA_DOC([$image_file],
200            [Need X11 to create snapshot image of ttfautohintGUI])
201   else
202     AC_CHECK_PROG([IMPORT], [import], [import], [no])
203     if test x"$IMPORT" == x"no"; then
204       TA_DOC([$image_file],
205              [Need ImageMagick to create snapshot image of ttfautohintGUI])
206     fi
207   fi
209   # conversion of SVG to PDF
210   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
211   if test x"$INKSCAPE" == x"no"; then
212     TA_DOC([$pdf_file],
213            [Need inkscape to convert SVG image files to PDF])
214   fi
216   # documentation creation
217   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
218   if test x"$PANDOC" == x"no"; then
219     TA_DOC([$html_file],
220            [Need pandoc to create PDF and HTML documentation files])
221   fi
223   # PDF documentation
224   # To support Devanagari and other Indic scripts properly,
225   # we currently can use XeTeX only.
226   AC_CHECK_PROGS([LATEX], [xelatex], [no])
227   if test x"$PDFLATEX" == x"no"; then
228     TA_DOC([$pdf_file],
229            [Need xelatex to create documentation in PDF format])
230   fi
233 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
235 # pandoc (currently version 1.15.2.1) doesn't have the equivalent to
236 # a compiler's `-I' command line option to make it search image files
237 # in specified directories; for this reason, we create symlinks.
238 AC_CONFIG_COMMANDS([doc/img/create-links],
239                    [abs_top_srcdir=`(cd "$srcdir"; pwd)`
240                     abs_top_builddir=`pwd`
241                     if test "$abs_top_srcdir" != "$abs_top_builddir"; then
242                       cd doc \
243                       && $LN_S "$abs_top_srcdir"/doc/img/* img
244                     fi])
246 AC_CONFIG_HEADERS([config.h])
247 AC_CONFIG_FILES([Makefile
248                  gnulib/src/Makefile
249                  lib/Makefile
250                  frontend/Makefile
251                  doc/Makefile])
252 AC_OUTPUT
254 # end of configure.ac