- Set LIBS instead of LDFLAGS (LIBS are appended while LDFLAGS are prepended
[gliv.git] / configure.ac
blob3de71e41924a492421f6fe521b96608a62a87f14
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([gliv], esyscmd([echo -n $(head -n 1 NEWS)]), [guichaz@gmail.com])
3 AC_CONFIG_SRCDIR([src/main.c])
4 AM_INIT_AUTOMAKE([foreign])
5 AM_CONFIG_HEADER([config.h])
6 AC_LANG([C])
7 AC_GNU_SOURCE
10 # We check this before AC_PROG_CC fills blank CFLAGS with "-g -O2".
11 if test "x$CFLAGS" = "x"; then
12   DEFAULT_CFLAGS=yes
13 else
14   DEFAULT_CFLAGS=no
17 # Checks for programs.
18 AC_PROG_CC
19 AC_PROG_RANLIB
22 # Default CFLAGS.
23 if test "x$GCC" = "xyes" && test "$DEFAULT_CFLAGS" = "yes"; then
24   CFLAGS="-Wall -O2 -fomit-frame-pointer -ffast-math"
26 CFLAGS="$CFLAGS -I${srcdir}/../lib"
28 # Checks for LFS flags, we may not handle big files, but it doesn't hurt.
29 AC_SYS_LARGEFILE
32 AC_DEFUN([CHECK_MATH],
33          [OLD_CFLAGS="$CFLAGS"]
34          [CFLAGS="$CFLAGS -w"]
35          [AC_SEARCH_LIBS([$1],
36                          [m mx],
37                          [AC_DEFINE(AS_TR_CPP([HAVE_$1]),
38                                     1,
39                                     [Define to 1 if you have the `$1' function.])])]
40         [CFLAGS="$OLD_CFLAGS"])
42 CHECK_MATH([atan2])
45 # Checks for hypot (SVID 3, BSD 4.3).
46 # The replacement is #defined in the source.
47 CHECK_MATH([hypot])
50 # Checks for math functions using floats.
51 # Using floats instead of doubles makes gcc use SSE with -msse
52 # The replacement are #defined in math_floats.h.
53 CHECK_MATH([sqrtf])
54 CHECK_MATH([hypotf])
55 CHECK_MATH([atan2f])
56 CHECK_MATH([powf])
57 CHECK_MATH([ceilf])
58 CHECK_MATH([cosf])
59 CHECK_MATH([sinf])
60 CHECK_MATH([acosf])
61 CHECK_MATH([fmodf])
62 CHECK_MATH([fabsf])
63 CHECK_MATH([log10f])
65 # If we don't have ftello, we'll use ftell.
66 AC_CHECK_FUNCS([ftello])
68 # If we don't have fseeko, we'll use fseek.
69 AC_CHECK_FUNCS([fseeko])
72 # Checks for getdelim, this is a GNU extension.
73 CFLAGS="$CFLAGS -D_GNU_SOURCE"
74 AC_CHECK_FUNCS([getdelim], [
75   have_getdelim="yes"
76  ], [
77   have_getdelim="no"
80 AM_CONDITIONAL([GETDELIM], [test "$have_getdelim" = "yes"])
83 # Checks for getopt_long, another GNU extension.
84 AC_CHECK_FUNCS([getopt_long], [
85   have_getopt_long="yes"
86  ], [
87   have_getopt_long="no"
90 AM_CONDITIONAL([GETOPT_LONG], [test "$have_getopt_long" = "yes"])
93 if test "$have_getdelim"    = "no" ||
94    test "$have_getopt_long" = "no"; then
95      AM_CONDITIONAL([NEED_REPLACEMENTS], [true])
96 else
97      AM_CONDITIONAL([NEED_REPLACEMENTS], [false])
101 # Checks for flavours of varargs macros (borrowed from glib-2)
102 # ISO C99
103 AC_MSG_CHECKING([for ISO C99 varargs macros])
105 AC_TRY_COMPILE([],[
106   int a(int p1, int p2, int p3);
107   #define call_a(...) a(1,__VA_ARGS__)
108   call_a(2,3);
109  ], [have_iso_c_varargs=yes], [have_iso_c_varargs=no])
111 AC_MSG_RESULT([$have_iso_c_varargs])
113 if test $have_iso_c_varargs = yes; then
114   iso_c_varargs=1
115 else
116   iso_c_varargs=0
119 AC_DEFINE_UNQUOTED([HAVE_ISO_C_VARARGS], [$iso_c_varargs],
120                    [ISO C99 varargs macros in C])
122 if test $have_iso_c_varargs = no; then
123   AC_MSG_WARN([No ISO C99 variadic macros])
126 # 32bit or 64bit ?
127 AC_CHECK_SIZEOF([unsigned long])
129 # Checks for X.
130 AC_PATH_XTRA
131 CFLAGS="$X_CFLAGS $CFLAGS"
132 LIBS="$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
134 # Checks for GtkGLExt.
135 PKG_CHECK_MODULES(GTKGLEXT, [gtkglext-1.0 >= 0.7.0])
136 CFLAGS="$GTKGLEXT_CFLAGS $CFLAGS"
137 LIBS="$GTKGLEXT_LIBS $LIBS"
138 GTKGL_VERSION="$($PKG_CONFIG --modversion gtkglext-1.0)"
140 # Checks for OpenGL.
141 AC_TRY_LINK([#include "GL/gl.h"],
142             [glBegin(GL_QUADS);],
143             [ogl="yes"],
144             [ogl="no"])
146 if test "x$ogl" = "xno"; then
147  AC_MSG_NOTICE([maybe libGL requires libpthread...])
148  LIBS="$LIBS -lpthread"
149  AC_TRY_LINK([#include "GL/gl.h"],
150              [glBegin(GL_QUADS);],
151              [],
152              AC_MSG_ERROR([cannot use -lGL]))
155 # Checks for gtk.
156 AM_PATH_GTK_2_0([2.6.0], [
157   CFLAGS="$GTK_CFLAGS $CFLAGS"
158   LIBS="$GTK_LIBS $LIBS"
159   GTK_VERSION="$($PKG_CONFIG --modversion gtk+-2.0)"
160  ], [exit 1], [gthread])
162 # I18n.
163 ALL_LINGUAS=$(echo po/*.po | sed -e 's|\.po||g' -e 's|po/||g')
164 AM_GNU_GETTEXT_VERSION
165 AM_GNU_GETTEXT
166 CFLAGS="$CFLAGS -I../${srcdir}/intl"
167 LIBS="$LIBS $LIBINTL"
170 AC_CONFIG_FILES([ intl/Makefile
171  Makefile
172  lib/Makefile
173  po/Makefile.in
174  tools/Makefile
175  tools/glade/Makefile
176  tools/glade/actions/Makefile
177  tools/glade/image_nr/Makefile
178  tools/glade/options/Makefile
179  man/Makefile
180  man/cs/Makefile
181  man/de/Makefile
182  man/en/Makefile
183  man/fr/Makefile
184  man/ru/Makefile
185  src/Makefile
186  gliv.spec
189 AC_OUTPUT
191 echo
192 echo "Using GTK+ $GTK_VERSION with GtkGLExt $GTKGL_VERSION"
193 echo