Allow cross-compilation.
[ttfautohint.git] / configure.ac
blob2bf889dd147870d8773351ba8d4e6cc383b3e456
1 # configure.ac
3 # Copyright (C) 2011-2013 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]))
21 AC_CONFIG_MACRO_DIRS([gnulib/m4
22                       m4])
24 AM_SILENT_RULES([yes])
26 AC_USE_SYSTEM_EXTENSIONS
28 AC_PROG_CPP
29 AC_PROG_CC
30 AC_PROG_CXX
32 # AM_PROG_AR is new in automake 1.11.2;
33 # however, MinGW doesn't have it yet (May 2012)
34 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
36 gl_EARLY
37 gl_INIT
39 AC_TYPE_UINT64_T
41 AT_WITH_QT
42 AT_REQUIRE_QT_VERSION([4.6])
44 if test x"$with_qt" != x"no"; then
45   AC_MSG_CHECKING([for QLocale::quoteString])
46   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
47     [AC_MSG_RESULT(no)],
48     [AC_MSG_RESULT(no)],
49     [AC_MSG_RESULT(yes)
50      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
51        [Define if Qt function QLocale::quoteString is available.])])
54 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
56 LT_INIT
57 LT_LTLIZE_LANG([C])
60 AC_ARG_WITH([doc],
61             [AS_HELP_STRING([--with-doc],
62                             [install documentation @<:@default=yes@:>@])],
63             [],
64             [with_doc=yes])
66 AC_ARG_WITH([freetype-config],
67             [AS_HELP_STRING([--with-freetype-config=PROG],
68                             [use FreeType configuration program PROG])],
69             [freetype_config=$withval],
70             [freetype_config=yes])
72 if test "$freetype_config" = "yes"; then
73   AC_PATH_PROG(ft_config,
74                freetype-config,
75                no)
76   if test "$ft_config" = "no"; then
77     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
78   fi
79 else
80   ft_config="$freetype_config"
83 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
84 FREETYPE_LIBS="`$ft_config --libtool`"
86 # many platforms no longer install .la files for system libraries
87 if test ! -f $FREETYPE_LIBS; then
88   FREETYPE_LIBS="`$ft_config --libs`"
91 AC_SUBST(FREETYPE_CPPFLAGS)
92 AC_SUBST(FREETYPE_LIBS)
95 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
96 old_CPPFLAGS="$CPPFLAGS"
97 CPPFLAGS=$FREETYPE_CPPFLAGS
98 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
100 #include <ft2build.h>
101 #include FT_FREETYPE_H
102 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
103 #error Freetype version too low.
104 #endif
106 ]])],
107 [AC_MSG_RESULT(yes)
108  CPPFLAGS="$old_CPPFLAGS"],
109 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
112 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
113 old_CPPFLAGS="$CPPFLAGS"
114 CPPFLAGS=$FREETYPE_CPPFLAGS
115 old_LIBS="$LIBS"
116 LIBS=$FREETYPE_LIBS
117 AC_LANG_PUSH([LTLIZED C])
118 AC_RUN_IFELSE([AC_LANG_SOURCE([[
120 #include <stdlib.h>
121 #include <ft2build.h>
122 #include FT_FREETYPE_H
125 main()
127   FT_Error error;
128   FT_Library library;
129   FT_Int major, minor, patch;
131   error = FT_Init_FreeType(&library);
132   if (error)
133   {
134     printf("(test program reports error code %d)... ", error);
135     exit(EXIT_FAILURE);
136   }
138   FT_Library_Version(library, &major, &minor, &patch);
140   printf("(found %d.%d.%d)... ", major, minor, patch);
142   if (((major*1000 + minor)*1000 + patch) >= 2004005)
143     exit(EXIT_SUCCESS);
144   exit(EXIT_FAILURE);
147 ]])],
148 [AC_MSG_RESULT(yes)
149  CPPFLAGS="$old_CPPFLAGS"
150  LIBS="$old_LIBS"],
151 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
152 [AC_MSG_RESULT([skipped due to cross-compilation])])
153 AC_LANG_POP
156 if test $cross_compiling = no; then
157   AM_MISSING_PROG(HELP2MAN, help2man)
158 else
159   HELP2MAN=:
162 # The documentation is part of the distributed bundle.  In the following,
163 # tests for the documentation building tools are made fatal in case those
164 # files are missing (which can happen during bootstrap).
166 AC_DEFUN([TA_DOC],
167   [if test -f "$1"; then
168      AC_MSG_WARN([$2])
169      with_doc=no
170    else
171      AC_MSG_ERROR([$2])
172    fi])
174 image_file=$srcdir/doc/img/ttfautohintGUI.png
175 html_file=$srcdir/doc/ttfautohint.html
176 pdf_file=$srcdir/doc/ttfautohint.pdf
178 if test x"$with_doc" != x"no"; then
179   # snapshot image creation
180   if test x"$DISPLAY" == x; then
181     TA_DOC([$image_file],
182            [Need X11 to create snapshot image of ttfautohintGUI])
183   else
184     AC_CHECK_PROG([IMPORT], [import], [import], [no])
185     if test x"$IMPORT" == x"no"; then
186       TA_DOC([$image_file],
187              [Need ImageMagick to create snapshot image of ttfautohintGUI])
188     fi
189   fi
191   # conversion of SVG to PDF
192   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
193   if test x"$INKSCAPE" == x"no"; then
194     TA_DOC([$pdf_file],
195            [Need inkscape to convert SVG image files to PDF])
196   fi
198   # documentation creation
199   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
200   if test x"$PANDOC" == x"no"; then
201     TA_DOC([$html_file],
202            [Need pandoc to create PDF and HTML documentation files])
203   fi
205   # PDF documentation
206   AC_CHECK_PROG([PDFLATEX], [pdflatex], [pdflatex], [no])
207   if test x"$PDFLATEX" == x"no"; then
208     TA_DOC([$pdf_file],
209            [Need pdflatex to create documentation in PDF format])
210   fi
213 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
215 AC_CONFIG_HEADERS([config.h])
216 AC_CONFIG_FILES([Makefile
217                  gnulib/src/Makefile
218                  lib/Makefile
219                  frontend/Makefile
220                  doc/Makefile])
221 AC_OUTPUT
223 # end of configure.ac