[doc] Update `ucharclasses.sty`.
[ttfautohint.git] / configure.ac
blob7f9106deb0b71b3a3a25979bcfefe80a0aaf2577
1 # configure.ac
3 # Copyright (C) 2011-2022 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 subdir-objects]
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 >= 2.4.0])
95 HARFBUZZ_CPPFLAGS="$HARFBUZZ_CFLAGS"
96 AC_SUBST([HARFBUZZ_CPPFLAGS])
98 AT_WITH_QT([], [], [QTPLUGIN.imageformats = -])
99 AT_REQUIRE_QT_VERSION([4.6])
101 if test x"$with_qt" != x"no"; then
102   AC_MSG_CHECKING([for QLocale::quoteString])
103   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
104     [AC_MSG_RESULT(no)],
105     [AC_MSG_RESULT(no)],
106     [AC_MSG_RESULT(yes)
107      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
108        [Define if Qt function QLocale::quoteString is available.])])
111 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
113 LT_INIT
114 LT_LTLIZE_LANG([C])
116 # We use libtool's convenient check for the math library.
117 LT_LIB_M
118 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 PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 2.4.5])
127 FREETYPE_CPPFLAGS="$FREETYPE_CFLAGS"
128 AC_SUBST([FREETYPE_CPPFLAGS])
130 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
131 old_CPPFLAGS="$CPPFLAGS"
132 CPPFLAGS=$FREETYPE_CPPFLAGS
133 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
135 #include <ft2build.h>
136 #include FT_FREETYPE_H
137 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
138 #error Freetype version too low.
139 #endif
141 ]])],
142 [AC_MSG_RESULT(yes)
143  CPPFLAGS="$old_CPPFLAGS"],
144 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
146 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
147 old_CPPFLAGS="$CPPFLAGS"
148 CPPFLAGS=$FREETYPE_CPPFLAGS
149 old_LIBS="$LIBS"
150 LIBS=$FREETYPE_LIBS
151 AC_LANG_PUSH([LTLIZED C])
152 AC_RUN_IFELSE([AC_LANG_SOURCE([[
154 #include <stdlib.h>
155 #include <ft2build.h>
156 #include FT_FREETYPE_H
159 main()
161   FT_Error error;
162   FT_Library library;
163   FT_Int major, minor, patch;
165   error = FT_Init_FreeType(&library);
166   if (error)
167   {
168     printf("(test program reports error code %d)... ", error);
169     exit(EXIT_FAILURE);
170   }
172   FT_Library_Version(library, &major, &minor, &patch);
174   printf("(found %d.%d.%d)... ", major, minor, patch);
176   if (((major*1000 + minor)*1000 + patch) >= 2004005)
177     exit(EXIT_SUCCESS);
178   exit(EXIT_FAILURE);
181 ]])],
182 [AC_MSG_RESULT(yes)
183  CPPFLAGS="$old_CPPFLAGS"
184  LIBS="$old_LIBS"],
185 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
186 [AC_MSG_RESULT([skipped due to cross-compilation])])
187 AC_LANG_POP
190 if test $cross_compiling = no; then
191   AM_MISSING_PROG(HELP2MAN, help2man)
192 else
193   HELP2MAN=:
196 # The documentation is part of the distributed bundle.  In the following,
197 # tests for the documentation building tools are made fatal in case those
198 # files are missing (which can happen during bootstrap).
200 AC_DEFUN([TA_DOC],
201   [if test -f "$1"; then
202      AC_MSG_WARN([$2])
203    else
204      AC_MSG_ERROR([$2])
205    fi])
207 image_file=$srcdir/doc/img/ttfautohintGUI.png
208 html_file=$srcdir/doc/ttfautohint.html
209 pdf_file=$srcdir/doc/ttfautohint.pdf
211 # We use the Noto font family within the PDF documentation file, since it
212 # has the best Unicode coverage of all freely available fonts.
214 #   https://github.com/googlei18n/noto-fonts/
216 # To be more precise, we don't directly access the git repository; instead,
217 # we simply test the presence of a typical font file (using the `kpsewhich'
218 # program as provided by TeX Live and other TeX distributions); the user
219 # should set the TTFONTS environment variable to add the corresponding
220 # directory to the TrueType font search path.
222 # Example:
224 #   TTFONTS="/path/to/git/noto-fonts/unhinted/ttf//;"
226 # (note the trailing `;').
228 noto_font_file=NotoSerifYezidi-Regular.ttf
231 if test x"$with_doc" != x"no"; then
232   # snapshot image creation
233   if test x"$DISPLAY" == x; then
234     TA_DOC([$image_file],
235            [Need X11 to create snapshot image of ttfautohintGUI])
236   else
237     AC_CHECK_PROG([IMPORT], [import], [import], [no])
238     if test x"$IMPORT" == x"no"; then
239       TA_DOC([$image_file],
240              [Need ImageMagick to create snapshot image of ttfautohintGUI])
241     fi
242   fi
244   # conversion of SVG to PDF
245   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
246   if test x"$INKSCAPE" == x"no"; then
247     TA_DOC([$pdf_file],
248            [Need inkscape to convert SVG image files to PDF])
249   fi
251   # documentation creation
252   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
253   if test x"$PANDOC" == x"no"; then
254     TA_DOC([$html_file],
255            [Need pandoc to create PDF and HTML documentation files])
256   fi
258   # PDF documentation
259   # To support Devanagari and other Indic scripts properly,
260   # we currently can use XeTeX only.
261   AC_CHECK_PROGS([LATEX], [xelatex], [no])
262   if test x"$LATEX" == x"no"; then
263     TA_DOC([$pdf_file],
264            [Need xelatex to create documentation in PDF format])
265   else
266     AC_CHECK_PROGS([KPSEWHICH], [kpsewhich], [no])
267     if test x"$KPSEWHICH" == x"no"; then
268       AC_MSG_WARN([Can't find `kpsewhich' to check presence of Noto font files automatically.])
269       TA_DOC([$pdf_file],
270              [Need kpsewhich to find fonts for documentation in PDF format.])
271     else
272       AC_MSG_CHECKING([for font $noto_font_file])
273       $KPSEWHICH $noto_font_file &> /dev/null
274       if test $? -eq 0; then
275         AC_MSG_RESULT([yes])
276       else
277         AC_MSG_RESULT([no])
278         AC_MSG_WARN([Can't find `$noto_font_file'.])
279         TA_DOC([$pdf_file],
280                [Adjust the `TTFONTS' environment variable so that the Noto fonts are found.])
281       fi
282     fi
283   fi
286 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
288 # Let autoconf create the `img' subdirectory, if necessary.
289 # `mkdir' is just a tag.
290 AC_CONFIG_COMMANDS([doc/img/mkdir], [true])
292 AC_CONFIG_HEADERS([config.h])
293 AC_CONFIG_FILES([Makefile
294                  frontend/static-plugins.cpp])
295 AC_OUTPUT
297 # end of configure.ac