Some fixes to make compilation with CC=g++ work.
[ttfautohint.git] / configure.ac
blob21a9fd42a69c24e51c5ab266733b3525faba10e4
1 # configure.ac
3 # Copyright (C) 2011-2014 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
31 PKG_PROG_PKG_CONFIG([0.24])
33 # AM_PROG_AR is new in automake 1.11.2;
34 # however, MinGW doesn't have it yet (May 2012)
35 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
37 gl_EARLY
38 gl_INIT
40 AC_TYPE_UINT64_T
42 if test x"$ac_cv_c_uint64_t" = x"yes"; then
43   AC_DEFINE([HAVE_UINT64_T], [1],
44     [Define if compiler accepts uint64_t data type.])
47 PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz >= 0.9.19])
49 AT_WITH_QT
50 AT_REQUIRE_QT_VERSION([4.6])
52 if test x"$with_qt" != x"no"; then
53   AC_MSG_CHECKING([for QLocale::quoteString])
54   AS_VERSION_COMPARE([$QT_VERSION], [4.8],
55     [AC_MSG_RESULT(no)],
56     [AC_MSG_RESULT(no)],
57     [AC_MSG_RESULT(yes)
58      AC_DEFINE([HAVE_QT_QUOTESTRING], [1],
59        [Define if Qt function QLocale::quoteString is available.])])
62 AM_CONDITIONAL([USE_QT], [test x"$with_qt" != x"no"])
64 LT_INIT
65 LT_LTLIZE_LANG([C])
68 AC_ARG_WITH([doc],
69             [AS_HELP_STRING([--with-doc],
70                             [install documentation @<:@default=yes@:>@])],
71             [],
72             [with_doc=yes])
74 AC_ARG_WITH([freetype-config],
75             [AS_HELP_STRING([--with-freetype-config=PROG],
76                             [use FreeType configuration program PROG])],
77             [freetype_config=$withval],
78             [freetype_config=yes])
80 if test "$freetype_config" = "yes"; then
81   AC_PATH_PROG(ft_config,
82                freetype-config,
83                no)
84   if test "$ft_config" = "no"; then
85     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
86   fi
87 else
88   ft_config="$freetype_config"
91 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
92 FREETYPE_LIBS="`$ft_config --libtool`"
94 # many platforms no longer install .la files for system libraries
95 if test ! -f $FREETYPE_LIBS; then
96   FREETYPE_LIBS="`$ft_config --libs`"
99 AC_SUBST(FREETYPE_CPPFLAGS)
100 AC_SUBST(FREETYPE_LIBS)
103 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
104 old_CPPFLAGS="$CPPFLAGS"
105 CPPFLAGS=$FREETYPE_CPPFLAGS
106 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
108 #include <ft2build.h>
109 #include FT_FREETYPE_H
110 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
111 #error Freetype version too low.
112 #endif
114 ]])],
115 [AC_MSG_RESULT(yes)
116  CPPFLAGS="$old_CPPFLAGS"],
117 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
120 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
121 old_CPPFLAGS="$CPPFLAGS"
122 CPPFLAGS=$FREETYPE_CPPFLAGS
123 old_LIBS="$LIBS"
124 LIBS=$FREETYPE_LIBS
125 AC_LANG_PUSH([LTLIZED C])
126 AC_RUN_IFELSE([AC_LANG_SOURCE([[
128 #include <stdlib.h>
129 #include <ft2build.h>
130 #include FT_FREETYPE_H
133 main()
135   FT_Error error;
136   FT_Library library;
137   FT_Int major, minor, patch;
139   error = FT_Init_FreeType(&library);
140   if (error)
141   {
142     printf("(test program reports error code %d)... ", error);
143     exit(EXIT_FAILURE);
144   }
146   FT_Library_Version(library, &major, &minor, &patch);
148   printf("(found %d.%d.%d)... ", major, minor, patch);
150   if (((major*1000 + minor)*1000 + patch) >= 2004005)
151     exit(EXIT_SUCCESS);
152   exit(EXIT_FAILURE);
155 ]])],
156 [AC_MSG_RESULT(yes)
157  CPPFLAGS="$old_CPPFLAGS"
158  LIBS="$old_LIBS"],
159 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])],
160 [AC_MSG_RESULT([skipped due to cross-compilation])])
161 AC_LANG_POP
164 if test $cross_compiling = no; then
165   AM_MISSING_PROG(HELP2MAN, help2man)
166 else
167   HELP2MAN=:
170 # The documentation is part of the distributed bundle.  In the following,
171 # tests for the documentation building tools are made fatal in case those
172 # files are missing (which can happen during bootstrap).
174 AC_DEFUN([TA_DOC],
175   [if test -f "$1"; then
176      AC_MSG_WARN([$2])
177      with_doc=no
178    else
179      AC_MSG_ERROR([$2])
180    fi])
182 image_file=$srcdir/doc/img/ttfautohintGUI.png
183 html_file=$srcdir/doc/ttfautohint.html
184 pdf_file=$srcdir/doc/ttfautohint.pdf
186 if test x"$with_doc" != x"no"; then
187   # snapshot image creation
188   if test x"$DISPLAY" == x; then
189     TA_DOC([$image_file],
190            [Need X11 to create snapshot image of ttfautohintGUI])
191   else
192     AC_CHECK_PROG([IMPORT], [import], [import], [no])
193     if test x"$IMPORT" == x"no"; then
194       TA_DOC([$image_file],
195              [Need ImageMagick to create snapshot image of ttfautohintGUI])
196     fi
197   fi
199   # conversion of SVG to PDF
200   AC_CHECK_PROG([INKSCAPE], [inkscape], [inkscape], [no])
201   if test x"$INKSCAPE" == x"no"; then
202     TA_DOC([$pdf_file],
203            [Need inkscape to convert SVG image files to PDF])
204   fi
206   # documentation creation
207   AC_CHECK_PROG([PANDOC], [pandoc], [pandoc], [no])
208   if test x"$PANDOC" == x"no"; then
209     TA_DOC([$html_file],
210            [Need pandoc to create PDF and HTML documentation files])
211   fi
213   # PDF documentation
214   AC_CHECK_PROGS([LATEX], [lualatex xelatex], [no])
215   if test x"$PDFLATEX" == x"no"; then
216     TA_DOC([$pdf_file],
217            [Need lualatex or xelatex to create documentation in PDF format])
218   fi
221 AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
223 AC_CONFIG_HEADERS([config.h])
224 AC_CONFIG_FILES([Makefile
225                  gnulib/src/Makefile
226                  lib/Makefile
227                  frontend/Makefile
228                  doc/Makefile])
229 AC_OUTPUT
231 # end of configure.ac