Synchronize with FreeType.
[ttfautohint.git] / configure.ac
blob349bb574de4fc30752716f5c1559cfb8210c7d0c
1 # configure.ac
3 # Copyright (C) 2011-2018 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])
17 AC_CONFIG_SRCDIR([lib/ttfautohint.pc.in])
19 AM_INIT_AUTOMAKE([-Wall -Werror tar-ustar]
20                  m4_bmatch(m4_defn([AC_PACKAGE_VERSION]),
21                            [-], [gnu],
22                            [gnits]))
24 AC_CONFIG_MACRO_DIRS([gnulib/m4
25                       m4])
27 AM_SILENT_RULES([yes])
29 dnl Derive version triplet (major, minor, revision) from package version
30 dnl string.
32 dnl If `AC_PACKAGE_VERSION' contains the suffix `-dirty', we remove it.  If
33 dnl it then still contains a dash, we have to remove the last dot and
34 dnl everything appended to it (this was added by the `git-version-gen'
35 dnl script to reflect git commits after the last tagged commit, which we
36 dnl ignore).
38 dnl No quotes around first argument of `m4_bpatsubst'.
39 dnl No quotes around `m4_bpatsubst'.
40 m4_define([ttfa_version], m4_bpatsubst(AC_PACKAGE_VERSION, [-dirty$]))
41 m4_define([ttfa_version], m4_bpatsubst(ttfa_version, [\.[^.]+-.+$]))
43 dnl No quotes around first argument of `m4_split'.
44 dnl No quotes around `m4_split'.
45 m4_define([ttfa_triplet], m4_split(ttfa_version, [\.]))
47 dnl No quotes around second argument of `m4_argn'.
48 dnl No quotes around `m4_argn'.
49 m4_define([ttfa_major], m4_argn([1], ttfa_triplet))
50 m4_define([ttfa_minor], m4_argn([2], ttfa_triplet))
51 m4_define([ttfa_revision], m4_argn([3], ttfa_triplet))
53 dnl No quotes around first two arguments of `m4_if'.
54 m4_if(ttfa_revision,
55       ,
56       [m4_define([ttfa_revision], [0])],
57       [])
59 m4_if(ttfa_version,
60       AC_PACKAGE_VERSION,
61       [],
62       [AC_MSG_WARN([Revision number of version tuplet set to ttfa_revision.])])
64 ttfautohint_major=ttfa_major
65 ttfautohint_minor=ttfa_minor
66 ttfautohint_revision=ttfa_revision
68 AC_SUBST([ttfautohint_major])
69 AC_SUBST([ttfautohint_minor])
70 AC_SUBST([ttfautohint_revision])
72 AC_USE_SYSTEM_EXTENSIONS
74 AC_PROG_LN_S
76 AC_PROG_CPP
77 AC_PROG_CC
78 AC_PROG_CXX
79 AC_C_INLINE
81 gl_EARLY
83 PKG_PROG_PKG_CONFIG([0.24])
85 # AM_PROG_AR is new in automake 1.11.2;
86 # however, MinGW doesn't have it yet (May 2012)
87 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
89 AC_PATH_PROG([BISON], [bison])
90 AC_PATH_PROG([FLEX], [flex])
92 gl_INIT
94 PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz >= 1.3.0])
96 AT_WITH_QT([], [], [QTPLUGIN.imageformats = -])
97 AT_REQUIRE_QT_VERSION([4.6])
99 if test x"$with_qt" != x"no"; then
100   AC_MSG_CHECKING([for QLocale::quoteString])
101   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
102     [AC_MSG_RESULT(no)],
103     [AC_MSG_RESULT(no)],
104     [AC_MSG_RESULT(yes)
105      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
106        [Define if Qt function QLocale::quoteString is available.])])
109 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
111 LT_INIT
112 LT_LTLIZE_LANG([C])
115 # We use libtool's convenient check for the math library.
116 LT_LIB_M
117 AC_SUBST([LIBM])
120 AC_ARG_WITH([doc],
121             [AS_HELP_STRING([--with-doc],
122                             [install documentation @<:@default=yes@:>@])],
123             [],
124             [with_doc=yes])
126 AC_ARG_WITH([freetype-config],
127             [AS_HELP_STRING([--with-freetype-config=PROG],
128                             [use FreeType configuration program PROG])],
129             [freetype_config=$withval],
130             [freetype_config=yes])
132 if test "$freetype_config" = "yes"; then
133   AC_PATH_TOOL(ft_config,
134                freetype-config,
135                no)
136 else
137   ft_config="$freetype_config"
140 if test "$ft_config" = "no"; then
141   # freetype-config tool not found or disabled; try pkg-config
142   PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 2.4.5])
143   if { test -z "$FREETYPE_CFLAGS" || test -z "$FREETYPE_LIBS"; }; then
144     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
145   fi
146   FREETYPE_CPPFLAGS="$FREETYPE_CFLAGS"
147 else
148   FREETYPE_CPPFLAGS="`$ft_config --cflags`"
149   FREETYPE_LIBS="`$ft_config --libtool`"
151   # many platforms no longer install .la files for system libraries
152   if test ! -f "$FREETYPE_LIBS"; then
153     FREETYPE_LIBS="`$ft_config --libs`"
154   fi
157 AC_SUBST([FREETYPE_CPPFLAGS])
158 AC_SUBST([FREETYPE_LIBS])
161 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
162 old_CPPFLAGS="$CPPFLAGS"
163 CPPFLAGS=$FREETYPE_CPPFLAGS
164 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
166 #include <ft2build.h>
167 #include FT_FREETYPE_H
168 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
169 #error Freetype version too low.
170 #endif
172 ]])],
173 [AC_MSG_RESULT(yes)
174  CPPFLAGS="$old_CPPFLAGS"],
175 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
178 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
179 old_CPPFLAGS="$CPPFLAGS"
180 CPPFLAGS=$FREETYPE_CPPFLAGS
181 old_LIBS="$LIBS"
182 LIBS=$FREETYPE_LIBS
183 AC_LANG_PUSH([LTLIZED C])
184 AC_RUN_IFELSE([AC_LANG_SOURCE([[
186 #include <stdlib.h>
187 #include <ft2build.h>
188 #include FT_FREETYPE_H
191 main()
193   FT_Error error;
194   FT_Library library;
195   FT_Int major, minor, patch;
197   error = FT_Init_FreeType(&library);
198   if (error)
199   {
200     printf("(test program reports error code %d)... ", error);
201     exit(EXIT_FAILURE);
202   }
204   FT_Library_Version(library, &major, &minor, &patch);
206   printf("(found %d.%d.%d)... ", major, minor, patch);
208   if (((major*1000 + minor)*1000 + patch) >= 2004005)
209     exit(EXIT_SUCCESS);
210   exit(EXIT_FAILURE);
213 ]])],
214 [AC_MSG_RESULT(yes)
215  CPPFLAGS="$old_CPPFLAGS"
216  LIBS="$old_LIBS"],
217 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
218 [AC_MSG_RESULT([skipped due to cross-compilation])])
219 AC_LANG_POP
222 if test $cross_compiling = no; then
223   AM_MISSING_PROG(HELP2MAN, help2man)
224 else
225   HELP2MAN=:
228 # The documentation is part of the distributed bundle.  In the following,
229 # tests for the documentation building tools are made fatal in case those
230 # files are missing (which can happen during bootstrap).
232 AC_DEFUN([TA_DOC],
233   [if test -f "$1"; then
234      AC_MSG_WARN([$2])
235      with_doc=no
236    else
237      AC_MSG_ERROR([$2])
238    fi])
240 image_file=$srcdir/doc/img/ttfautohintGUI.png
241 html_file=$srcdir/doc/ttfautohint.html
242 pdf_file=$srcdir/doc/ttfautohint.pdf
244 # We use the Noto font family within the PDF documentation file, since it
245 # has the best Unicode coverage of all freely available fonts.  However, due
246 # to some bugs in the currently released version and lacking support for
247 # some scripts, it is necessary to access fonts from the `noto-fonts-alpha'
248 # git repository, which can be found at
250 #   https://github.com/googlei18n/noto-fonts-alpha/
252 # Interestingly, at least one font we need (`NotoSansGujarati-Regular.ttf')
253 # is not yet present in the `noto-fonts-alpha' repository, so we have to
254 # access the older
256 #   https://github.com/googlei18n/noto-fonts/
258 # also.
260 # To be more precise, we don't directly access the git repositories;
261 # instead, we simply test the presence of two typical font files (using the
262 # `kpsewhich' program as provided by TeXLive and other TeX distributions);
263 # the user should set the TTFONTS environment variable to add the
264 # corresponding directories to the TrueType font search path.
266 noto_font_file=NotoSansGujarati-Regular.ttf
267 noto_font_alpha_file=NotoSansArabic-Regular.ttf
269 if test x"$with_doc" != x"no"; then
270   # snapshot image creation
271   if test x"$DISPLAY" == x; then
272     TA_DOC([$image_file],
273            [Need X11 to create snapshot image of ttfautohintGUI])
274   else
275     AC_CHECK_PROG([IMPORT], [import], [import], [no])
276     if test x"$IMPORT" == x"no"; then
277       TA_DOC([$image_file],
278              [Need ImageMagick to create snapshot image of ttfautohintGUI])
279     fi
280   fi
282   # conversion of SVG to PDF
283   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
284   if test x"$INKSCAPE" == x"no"; then
285     TA_DOC([$pdf_file],
286            [Need inkscape to convert SVG image files to PDF])
287   fi
289   # documentation creation
290   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
291   if test x"$PANDOC" == x"no"; then
292     TA_DOC([$html_file],
293            [Need pandoc to create PDF and HTML documentation files])
294   fi
296   # PDF documentation
297   # To support Devanagari and other Indic scripts properly,
298   # we currently can use XeTeX only.
299   AC_CHECK_PROGS([LATEX], [xelatex], [no])
300   if test x"$PDFLATEX" == x"no"; then
301     TA_DOC([$pdf_file],
302            [Need xelatex to create documentation in PDF format])
303   else
304     AC_CHECK_PROGS([KPSEWHICH], [kpsewhich], [no])
305     if test x"$KPSEWHICH" == x"no"; then
306       AC_MSG_WARN([Can't find \`kpsewhich' to check presence of Noto font files automatically.])
307       TA_DOC([$pdf_file],
308              [Adjust the \`TTFONTS' environment variable so that the fonts are found.])
309     else
310       $KPSEWHICH $noto_font_file &> /dev/null
311       if test $? -ne 0; then
312         AC_MSG_WARN([Can't find \`$noto_font_file'.])
313         TA_DOC([$pdf_file],
314                [Adjust the \`TTFONTS' environment variable so that the Noto fonts are found.])
315       fi
317       $KPSEWHICH $noto_font_alpha_file &> /dev/null
318       if test $? -ne 0; then
319         AC_MSG_WARN([Can't find \`$noto_font_alpha_file'.])
320         TA_DOC([$pdf_file],
321                [Adjust the \`TTFONTS' environment variable so that the Noto alpha fonts are found.])
322       fi
323     fi
324   fi
327 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
329 # pandoc (currently version 1.15.2.1) doesn't have the equivalent to
330 # a compiler's `-I' command line option to make it search image files
331 # in specified directories; for this reason, we create symlinks.
332 AC_CONFIG_COMMANDS([doc/img/create-links],
333                    [abs_top_srcdir=`(cd "$srcdir"; pwd)`
334                     abs_top_builddir=`pwd`
335                     if test "$abs_top_srcdir" != "$abs_top_builddir"; then
336                       cd doc \
337                       && $LN_S "$abs_top_srcdir"/doc/img/* img
338                     fi])
340 AC_CONFIG_HEADERS([config.h])
341 AC_CONFIG_FILES([Makefile
342                  gnulib/src/Makefile
343                  lib/Makefile
344                  frontend/Makefile
345                  frontend/static-plugins.cpp
346                  doc/Makefile])
347 AC_OUTPUT
349 # end of configure.ac