Run `update-copyright' script.
[ttfautohint.git] / configure.ac
blobf157252333747b00d32b9bda8111057e678a5244
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   if test "$ft_config" = "no"; then
137     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
138   fi
139 else
140   ft_config="$freetype_config"
143 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
144 FREETYPE_LIBS="`$ft_config --libtool`"
146 # many platforms no longer install .la files for system libraries
147 if test ! -f "$FREETYPE_LIBS"; then
148   FREETYPE_LIBS="`$ft_config --libs`"
151 AC_SUBST([FREETYPE_CPPFLAGS])
152 AC_SUBST([FREETYPE_LIBS])
155 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
156 old_CPPFLAGS="$CPPFLAGS"
157 CPPFLAGS=$FREETYPE_CPPFLAGS
158 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
160 #include <ft2build.h>
161 #include FT_FREETYPE_H
162 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
163 #error Freetype version too low.
164 #endif
166 ]])],
167 [AC_MSG_RESULT(yes)
168  CPPFLAGS="$old_CPPFLAGS"],
169 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
172 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
173 old_CPPFLAGS="$CPPFLAGS"
174 CPPFLAGS=$FREETYPE_CPPFLAGS
175 old_LIBS="$LIBS"
176 LIBS=$FREETYPE_LIBS
177 AC_LANG_PUSH([LTLIZED C])
178 AC_RUN_IFELSE([AC_LANG_SOURCE([[
180 #include <stdlib.h>
181 #include <ft2build.h>
182 #include FT_FREETYPE_H
185 main()
187   FT_Error error;
188   FT_Library library;
189   FT_Int major, minor, patch;
191   error = FT_Init_FreeType(&library);
192   if (error)
193   {
194     printf("(test program reports error code %d)... ", error);
195     exit(EXIT_FAILURE);
196   }
198   FT_Library_Version(library, &major, &minor, &patch);
200   printf("(found %d.%d.%d)... ", major, minor, patch);
202   if (((major*1000 + minor)*1000 + patch) >= 2004005)
203     exit(EXIT_SUCCESS);
204   exit(EXIT_FAILURE);
207 ]])],
208 [AC_MSG_RESULT(yes)
209  CPPFLAGS="$old_CPPFLAGS"
210  LIBS="$old_LIBS"],
211 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
212 [AC_MSG_RESULT([skipped due to cross-compilation])])
213 AC_LANG_POP
216 if test $cross_compiling = no; then
217   AM_MISSING_PROG(HELP2MAN, help2man)
218 else
219   HELP2MAN=:
222 # The documentation is part of the distributed bundle.  In the following,
223 # tests for the documentation building tools are made fatal in case those
224 # files are missing (which can happen during bootstrap).
226 AC_DEFUN([TA_DOC],
227   [if test -f "$1"; then
228      AC_MSG_WARN([$2])
229      with_doc=no
230    else
231      AC_MSG_ERROR([$2])
232    fi])
234 image_file=$srcdir/doc/img/ttfautohintGUI.png
235 html_file=$srcdir/doc/ttfautohint.html
236 pdf_file=$srcdir/doc/ttfautohint.pdf
238 # We use the Noto font family within the PDF documentation file, since it
239 # has the best Unicode coverage of all freely available fonts.  However, due
240 # to some bugs in the currently released version and lacking support for
241 # some scripts, it is necessary to access fonts from the `noto-fonts-alpha'
242 # git repository, which can be found at
244 #   https://github.com/googlei18n/noto-fonts-alpha/
246 # Interestingly, at least one font we need (`NotoSansGujarati-Regular.ttf')
247 # is not yet present in the `noto-fonts-alpha' repository, so we have to
248 # access the older
250 #   https://github.com/googlei18n/noto-fonts/
252 # also.
254 # To be more precise, we don't directly access the git repositories;
255 # instead, we simply test the presence of two typical font files (using the
256 # `kpsewhich' program as provided by TeXLive and other TeX distributions);
257 # the user should set the TTFONTS environment variable to add the
258 # corresponding directories to the TrueType font search path.
260 noto_font_file=NotoSansGujarati-Regular.ttf
261 noto_font_alpha_file=NotoSansArabic-Regular.ttf
263 if test x"$with_doc" != x"no"; then
264   # snapshot image creation
265   if test x"$DISPLAY" == x; then
266     TA_DOC([$image_file],
267            [Need X11 to create snapshot image of ttfautohintGUI])
268   else
269     AC_CHECK_PROG([IMPORT], [import], [import], [no])
270     if test x"$IMPORT" == x"no"; then
271       TA_DOC([$image_file],
272              [Need ImageMagick to create snapshot image of ttfautohintGUI])
273     fi
274   fi
276   # conversion of SVG to PDF
277   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
278   if test x"$INKSCAPE" == x"no"; then
279     TA_DOC([$pdf_file],
280            [Need inkscape to convert SVG image files to PDF])
281   fi
283   # documentation creation
284   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
285   if test x"$PANDOC" == x"no"; then
286     TA_DOC([$html_file],
287            [Need pandoc to create PDF and HTML documentation files])
288   fi
290   # PDF documentation
291   # To support Devanagari and other Indic scripts properly,
292   # we currently can use XeTeX only.
293   AC_CHECK_PROGS([LATEX], [xelatex], [no])
294   if test x"$PDFLATEX" == x"no"; then
295     TA_DOC([$pdf_file],
296            [Need xelatex to create documentation in PDF format])
297   else
298     AC_CHECK_PROGS([KPSEWHICH], [kpsewhich], [no])
299     if test x"$KPSEWHICH" == x"no"; then
300       AC_MSG_WARN([Can't find \`kpsewhich' to check presence of Noto font files automatically.])
301       TA_DOC([$pdf_file],
302              [Adjust the \`TTFONTS' environment variable so that the fonts are found.])
303     else
304       $KPSEWHICH $noto_font_file &> /dev/null
305       if test $? -ne 0; then
306         AC_MSG_WARN([Can't find \`$noto_font_file'.])
307         TA_DOC([$pdf_file],
308                [Adjust the \`TTFONTS' environment variable so that the Noto fonts are found.])
309       fi
311       $KPSEWHICH $noto_font_alpha_file &> /dev/null
312       if test $? -ne 0; then
313         AC_MSG_WARN([Can't find \`$noto_font_alpha_file'.])
314         TA_DOC([$pdf_file],
315                [Adjust the \`TTFONTS' environment variable so that the Noto alpha fonts are found.])
316       fi
317     fi
318   fi
321 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
323 # pandoc (currently version 1.15.2.1) doesn't have the equivalent to
324 # a compiler's `-I' command line option to make it search image files
325 # in specified directories; for this reason, we create symlinks.
326 AC_CONFIG_COMMANDS([doc/img/create-links],
327                    [abs_top_srcdir=`(cd "$srcdir"; pwd)`
328                     abs_top_builddir=`pwd`
329                     if test "$abs_top_srcdir" != "$abs_top_builddir"; then
330                       cd doc \
331                       && $LN_S "$abs_top_srcdir"/doc/img/* img
332                     fi])
334 AC_CONFIG_HEADERS([config.h])
335 AC_CONFIG_FILES([Makefile
336                  gnulib/src/Makefile
337                  lib/Makefile
338                  frontend/Makefile
339                  frontend/static-plugins.cpp
340                  doc/Makefile])
341 AC_OUTPUT
343 # end of configure.ac