Add support for creating and installing a libttfautohint DLL.
[ttfautohint.git] / configure.ac
blob755998e4f5a2b2bb706a64edb12c99c8d7bd5c9d
1 # configure.ac
3 # Copyright (C) 2011-2017 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_CXX
35 AC_C_INLINE
37 gl_EARLY
39 PKG_PROG_PKG_CONFIG([0.24])
41 # AM_PROG_AR is new in automake 1.11.2;
42 # however, MinGW doesn't have it yet (May 2012)
43 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
45 AC_PATH_PROG([BISON], [bison])
46 AC_PATH_PROG([FLEX], [flex])
48 gl_INIT
50 PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz >= 1.3.0])
52 AT_WITH_QT([], [], [QTPLUGIN.imageformats = -])
53 AT_REQUIRE_QT_VERSION([4.6])
55 if test x"$with_qt" != x"no"; then
56   AC_MSG_CHECKING([for QLocale::quoteString])
57   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
58     [AC_MSG_RESULT(no)],
59     [AC_MSG_RESULT(no)],
60     [AC_MSG_RESULT(yes)
61      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
62        [Define if Qt function QLocale::quoteString is available.])])
65 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
67 LT_INIT
68 LT_LTLIZE_LANG([C])
71 # We use libtool's convenient check for the math library.
72 LT_LIB_M
73 AC_SUBST(LIBM)
76 AC_ARG_WITH([doc],
77             [AS_HELP_STRING([--with-doc],
78                             [install documentation @<:@default=yes@:>@])],
79             [],
80             [with_doc=yes])
82 AC_ARG_WITH([freetype-config],
83             [AS_HELP_STRING([--with-freetype-config=PROG],
84                             [use FreeType configuration program PROG])],
85             [freetype_config=$withval],
86             [freetype_config=yes])
88 if test "$freetype_config" = "yes"; then
89   AC_PATH_TOOL(ft_config,
90                freetype-config,
91                no)
92   if test "$ft_config" = "no"; then
93     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
94   fi
95 else
96   ft_config="$freetype_config"
99 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
100 FREETYPE_LIBS="`$ft_config --libtool`"
102 # many platforms no longer install .la files for system libraries
103 if test ! -f "$FREETYPE_LIBS"; then
104   FREETYPE_LIBS="`$ft_config --libs`"
107 AC_SUBST(FREETYPE_CPPFLAGS)
108 AC_SUBST(FREETYPE_LIBS)
111 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
112 old_CPPFLAGS="$CPPFLAGS"
113 CPPFLAGS=$FREETYPE_CPPFLAGS
114 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
116 #include <ft2build.h>
117 #include FT_FREETYPE_H
118 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
119 #error Freetype version too low.
120 #endif
122 ]])],
123 [AC_MSG_RESULT(yes)
124  CPPFLAGS="$old_CPPFLAGS"],
125 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
128 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
129 old_CPPFLAGS="$CPPFLAGS"
130 CPPFLAGS=$FREETYPE_CPPFLAGS
131 old_LIBS="$LIBS"
132 LIBS=$FREETYPE_LIBS
133 AC_LANG_PUSH([LTLIZED C])
134 AC_RUN_IFELSE([AC_LANG_SOURCE([[
136 #include <stdlib.h>
137 #include <ft2build.h>
138 #include FT_FREETYPE_H
141 main()
143   FT_Error error;
144   FT_Library library;
145   FT_Int major, minor, patch;
147   error = FT_Init_FreeType(&library);
148   if (error)
149   {
150     printf("(test program reports error code %d)... ", error);
151     exit(EXIT_FAILURE);
152   }
154   FT_Library_Version(library, &major, &minor, &patch);
156   printf("(found %d.%d.%d)... ", major, minor, patch);
158   if (((major*1000 + minor)*1000 + patch) >= 2004005)
159     exit(EXIT_SUCCESS);
160   exit(EXIT_FAILURE);
163 ]])],
164 [AC_MSG_RESULT(yes)
165  CPPFLAGS="$old_CPPFLAGS"
166  LIBS="$old_LIBS"],
167 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
168 [AC_MSG_RESULT([skipped due to cross-compilation])])
169 AC_LANG_POP
172 if test $cross_compiling = no; then
173   AM_MISSING_PROG(HELP2MAN, help2man)
174 else
175   HELP2MAN=:
178 # The documentation is part of the distributed bundle.  In the following,
179 # tests for the documentation building tools are made fatal in case those
180 # files are missing (which can happen during bootstrap).
182 AC_DEFUN([TA_DOC],
183   [if test -f "$1"; then
184      AC_MSG_WARN([$2])
185      with_doc=no
186    else
187      AC_MSG_ERROR([$2])
188    fi])
190 image_file=$srcdir/doc/img/ttfautohintGUI.png
191 html_file=$srcdir/doc/ttfautohint.html
192 pdf_file=$srcdir/doc/ttfautohint.pdf
194 # We use the Noto font family within the PDF documentation file, since it
195 # has the best Unicode coverage of all freely available fonts.  However, due
196 # to some bugs in the currently released version and lacking support for
197 # some scripts, it is necessary to access fonts from the `noto-fonts-alpha'
198 # git repository, which can be found at
200 #   https://github.com/googlei18n/noto-fonts-alpha/
202 # Interestingly, at least one font we need (`NotoSansGujarati-Regular.ttf')
203 # is not yet present in the `noto-fonts-alpha' repository, so we have to
204 # access the older
206 #   https://github.com/googlei18n/noto-fonts/
208 # also.
210 # To be more precise, we don't directly access the git repositories;
211 # instead, we simply test the presence of two typical font files (using the
212 # `kpsewhich' program as provided by TeXLive and other TeX distributions);
213 # the user should set the TTFONTS environment variable to add the
214 # corresponding directories to the TrueType font search path.
216 noto_font_file=NotoSansGujarati-Regular.ttf
217 noto_font_alpha_file=NotoSansArabic-Regular.ttf
219 if test x"$with_doc" != x"no"; then
220   # snapshot image creation
221   if test x"$DISPLAY" == x; then
222     TA_DOC([$image_file],
223            [Need X11 to create snapshot image of ttfautohintGUI])
224   else
225     AC_CHECK_PROG([IMPORT], [import], [import], [no])
226     if test x"$IMPORT" == x"no"; then
227       TA_DOC([$image_file],
228              [Need ImageMagick to create snapshot image of ttfautohintGUI])
229     fi
230   fi
232   # conversion of SVG to PDF
233   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
234   if test x"$INKSCAPE" == x"no"; then
235     TA_DOC([$pdf_file],
236            [Need inkscape to convert SVG image files to PDF])
237   fi
239   # documentation creation
240   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
241   if test x"$PANDOC" == x"no"; then
242     TA_DOC([$html_file],
243            [Need pandoc to create PDF and HTML documentation files])
244   fi
246   # PDF documentation
247   # To support Devanagari and other Indic scripts properly,
248   # we currently can use XeTeX only.
249   AC_CHECK_PROGS([LATEX], [xelatex], [no])
250   if test x"$PDFLATEX" == x"no"; then
251     TA_DOC([$pdf_file],
252            [Need xelatex to create documentation in PDF format])
253   else
254     AC_CHECK_PROGS([KPSEWHICH], [kpsewhich], [no])
255     if test x"$KPSEWHICH" == x"no"; then
256       AC_MSG_WARN([Can't find \`kpsewhich' to check presence of Noto font files automatically.])
257       TA_DOC([$pdf_file],
258              [Adjust the \`TTFONTS' environment variable so that the fonts are found.])
259     else
260       $KPSEWHICH $noto_font_file &> /dev/null
261       if test $? -ne 0; then
262         AC_MSG_WARN([Can't find \`$noto_font_file'.])
263         TA_DOC([$pdf_file],
264                [Adjust the \`TTFONTS' environment variable so that the Noto fonts are found.])
265       fi
267       $KPSEWHICH $noto_font_alpha_file &> /dev/null
268       if test $? -ne 0; then
269         AC_MSG_WARN([Can't find \`$noto_font_alpha_file'.])
270         TA_DOC([$pdf_file],
271                [Adjust the \`TTFONTS' environment variable so that the Noto alpha fonts are found.])
272       fi
273     fi
274   fi
277 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
279 # pandoc (currently version 1.15.2.1) doesn't have the equivalent to
280 # a compiler's `-I' command line option to make it search image files
281 # in specified directories; for this reason, we create symlinks.
282 AC_CONFIG_COMMANDS([doc/img/create-links],
283                    [abs_top_srcdir=`(cd "$srcdir"; pwd)`
284                     abs_top_builddir=`pwd`
285                     if test "$abs_top_srcdir" != "$abs_top_builddir"; then
286                       cd doc \
287                       && $LN_S "$abs_top_srcdir"/doc/img/* img
288                     fi])
290 AC_CONFIG_HEADERS([config.h])
291 AC_CONFIG_FILES([Makefile
292                  gnulib/src/Makefile
293                  lib/Makefile
294                  frontend/Makefile
295                  frontend/static-plugins.cpp
296                  doc/Makefile])
297 AC_OUTPUT
299 # end of configure.ac