Protect against unknown arguments.
[ttfautohint.git] / configure.ac
blobe02bafd0566f4bb5bcbb93b7a4700f6d16320e6f
1 # configure.ac
3 # Copyright (C) 2011-2012 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 AM_INIT_AUTOMAKE([-Wall -Werror]
18                  m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [-],
19                            [gnu], [gnits]))
20 AC_CONFIG_MACRO_DIR([gnulib/m4
21                      m4])
22 AM_SILENT_RULES([yes])
24 AC_USE_SYSTEM_EXTENSIONS
26 AC_PROG_CPP
27 AC_PROG_CC
28 AC_PROG_CXX
30 # AM_PROG_AR is new in automake 1.11.2;
31 # however, MinGW doesn't have it yet (May 2012)
32 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
34 gl_EARLY
35 gl_INIT
37 AC_TYPE_UINT64_T
39 AT_WITH_QT
40 AT_REQUIRE_QT_VERSION([4.6])
42 if test x"$with_qt" != x"no"; then
43   AC_MSG_CHECKING([for QLocale::quoteString])
44   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
45     [AC_MSG_RESULT(no)],
46     [AC_MSG_RESULT(no)],
47     [AC_MSG_RESULT(yes)
48      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
49        [Define if Qt function QLocale::quoteString is available.])])
52 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
54 LT_INIT
55 LT_LTLIZE_LANG([C])
58 AC_ARG_WITH([doc],
59             [AS_HELP_STRING([--with-doc],
60                             [install documentation @<:@default=yes@:>@])],
61             [],
62             [with_doc=yes])
64 AC_ARG_WITH([freetype-config],
65             [AS_HELP_STRING([--with-freetype-config=PROG],
66                             [use FreeType configuration program PROG])],
67             [freetype_config=$withval],
68             [freetype_config=yes])
70 if test "$freetype_config" = "yes"; then
71   AC_PATH_PROG(ft_config,
72                freetype-config,
73                no)
74   if test "$ft_config" = "no"; then
75     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
76   fi
77 else
78   ft_config="$freetype_config"
81 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
82 FREETYPE_LIBS="`$ft_config --libtool`"
84 # many platforms no longer install .la files for system libraries
85 if test ! -f $FREETYPE_LIBS; then
86   FREETYPE_LIBS="`$ft_config --libs`"
89 AC_SUBST(FREETYPE_CPPFLAGS)
90 AC_SUBST(FREETYPE_LIBS)
93 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
94 old_CPPFLAGS="$CPPFLAGS"
95 CPPFLAGS=$FREETYPE_CPPFLAGS
96 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
98 #include <ft2build.h>
99 #include FT_FREETYPE_H
100 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
101 #error Freetype version too low.
102 #endif
104 ]])],
105 [AC_MSG_RESULT(yes)
106  CPPFLAGS="$old_CPPFLAGS"],
107 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
110 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
111 old_CPPFLAGS="$CPPFLAGS"
112 CPPFLAGS=$FREETYPE_CPPFLAGS
113 old_LIBS="$LIBS"
114 LIBS=$FREETYPE_LIBS
115 AC_LANG_PUSH([LTLIZED C])
116 AC_RUN_IFELSE([AC_LANG_SOURCE([[
118 #include <stdlib.h>
119 #include <ft2build.h>
120 #include FT_FREETYPE_H
123 main()
125   FT_Error error;
126   FT_Library library;
127   FT_Int major, minor, patch;
129   error = FT_Init_FreeType(&library);
130   if (error)
131   {
132     printf("(test program reports error code %d)... ", error);
133     exit(EXIT_FAILURE);
134   }
136   FT_Library_Version(library, &major, &minor, &patch);
138   printf("(found %d.%d.%d)... ", major, minor, patch);
140   if (((major*1000 + minor)*1000 + patch) >= 2004005)
141     exit(EXIT_SUCCESS);
142   exit(EXIT_FAILURE);
145 ]])],
146 [AC_MSG_RESULT(yes)
147  CPPFLAGS="$old_CPPFLAGS"
148  LIBS="$old_LIBS"],
149 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
150 AC_LANG_POP
153 if test $cross_compiling = no; then
154   AM_MISSING_PROG(HELP2MAN, help2man)
155 else
156   HELP2MAN=:
159 # The documentation is part of the distributed bundle.  In the following,
160 # tests for the documentation building tools are made fatal in case those
161 # files are missing (which can happen during bootstrap).
163 AC_DEFUN([TA_DOC],
164   [if test -f "$1"; then
165      AC_MSG_WARN([$2])
166      with_doc=no
167    else
168      AC_MSG_ERROR([$2])
169    fi])
171 image_file=$srcdir/doc/img/ttfautohintGUI.png
172 html_file=$srcdir/doc/ttfautohint.html
173 pdf_file=$srcdir/doc/ttfautohint.pdf
175 if test x"$with_doc" != x"no"; then
176   # snapshot image creation
177   if test x"$DISPLAY" == x; then
178     TA_DOC([$image_file],
179            [Need X11 to create snapshot image of ttfautohintGUI])
180   else
181     AC_CHECK_PROG([IMPORT], [import], [import], [no])
182     if test x"$IMPORT" == x"no"; then
183       TA_DOC([$image_file],
184              [Need ImageMagick to create snapshot image of ttfautohintGUI])
185     fi
186   fi
188   # conversion of SVG to PDF
189   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
190   if test x"$PANDOC" == x"no"; then
191     TA_DOC([$pdf_file],
192            [Need inkscape to convert SVG image files to PDF])
193   fi
195   # documentation creation
196   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
197   if test x"$PANDOC" == x"no"; then
198     TA_DOC([$html_file],
199            [Need pandoc to create PDF and HTML documentation files])
200   fi
201   AC_CHECK_PROG([GHC], [ghc], [ghc], [no])
202   if test x"$GHC" == x"no"; then
203     TA_DOC([$html_file],
204            [Need Glasgow Haskell Compiler (ghc) to create pandoc filter])
205   fi
207   # PDF documentation
208   AC_CHECK_PROG([PDFLATEX], [pdflatex], [pdflatex], [no])
209   if test x"$PDFLATEX" == x"no"; then
210     TA_DOC([$pdf_file],
211            [Need pdflatex to create documentation in PDF format])
212   fi
215 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
217 AC_CONFIG_HEADERS([config.h])
218 AC_CONFIG_FILES([Makefile
219                  gnulib/src/Makefile
220                  lib/Makefile
221                  frontend/Makefile
222                  doc/Makefile])
223 AC_OUTPUT
225 # end of configure.ac