[gui] Move error handling into a separate function.
[ttfautohint.git] / configure.ac
blob3402ac23cd921bf049ff4f17fe3a1af911ed796b
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         [0.6.1],
15         [freetype-devel@nongnu.org])
16 AC_CONFIG_AUX_DIR([gnulib])
17 AM_INIT_AUTOMAKE([-Wall -Werror gnits])
18 AC_CONFIG_MACRO_DIR([gnulib/m4
19                      m4])
20 AM_SILENT_RULES([yes])
22 AC_PROG_CPP
23 AC_PROG_CC
24 AC_PROG_CXX
26 gl_EARLY
27 gl_INIT
29 AC_TYPE_UINT64_T
31 AT_WITH_QT
33 LT_INIT
34 LT_LTLIZE_LANG([C])
37 AC_ARG_WITH(freetype-config,
38             [  --with-freetype-config=PROG   Use FreeType configuration program PROG],
39             freetype_config=$withval,
40             freetype_config=yes)
42 if test "$freetype_config" = "yes"; then 
43   AC_PATH_PROG(ft_config,
44                freetype-config,
45                no)
46   if test "$ft_config" = "no"; then
47     AC_MSG_ERROR([FreeType library is missing; see http://www.freetype.org/])
48   fi
49 else
50   ft_config="$freetype_config"
53 FREETYPE_CPPFLAGS="`$ft_config --cflags`"
54 FREETYPE_LIBS="`$ft_config --libtool`"
56 AC_SUBST(FREETYPE_CPPFLAGS)
57 AC_SUBST(FREETYPE_LIBS)
60 AC_MSG_CHECKING([whether FreeType header files are version 2.4.5 or higher])
61 old_CPPFLAGS="$CPPFLAGS"
62 CPPFLAGS=$FREETYPE_CPPFLAGS
63 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
65 #include <ft2build.h>
66 #include FT_FREETYPE_H
67 #if (FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 + FREETYPE_PATCH < 2004005
68 #error Freetype version too low.
69 #endif
71 ]])],
72 [AC_MSG_RESULT(yes)
73  CPPFLAGS="$old_CPPFLAGS"],
74 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
77 AC_MSG_CHECKING([whether FreeType library is version 2.4.5 or higher])
78 old_CPPFLAGS="$CPPFLAGS"
79 CPPFLAGS=$FREETYPE_CPPFLAGS
80 old_LIBS="$LIBS"
81 LIBS=$FREETYPE_LIBS
82 AC_LANG_PUSH([LTLIZED C])
83 AC_RUN_IFELSE([AC_LANG_SOURCE([[
85 #include <stdlib.h>
86 #include <ft2build.h>
87 #include FT_FREETYPE_H
89 int
90 main()
92   FT_Error error;
93   FT_Library library;
94   FT_Int major, minor, patch;
96   error = FT_Init_FreeType(&library);
97   if (error)
98   {
99     printf("(test program reports error code %d)... ", error);
100     exit(EXIT_FAILURE);
101   }
103   FT_Library_Version(library, &major, &minor, &patch);
105   printf("(found %d.%d.%d)... ", major, minor, patch);
107   if (((major*1000 + minor)*1000 + patch) >= 2004005)
108     exit(EXIT_SUCCESS);
109   exit(EXIT_FAILURE);
112 ]])],
113 [AC_MSG_RESULT(yes)
114  CPPFLAGS="$old_CPPFLAGS"
115  LIBS="$old_LIBS"],
116 [AC_MSG_ERROR([Need FreeType version 2.4.5 or higher])])
117 AC_LANG_POP
120 if test $cross_compiling = no; then
121   AM_MISSING_PROG(HELP2MAN, help2man)
122 else
123   HELP2MAN=:
127 AC_CONFIG_HEADERS([config.h])
128 AC_CONFIG_FILES([Makefile
129                  gnulib/src/Makefile
130                  lib/Makefile
131                  frontend/Makefile])
132 AC_OUTPUT
134 # end of configure.ac