New command line options handling.
[gliv.git] / configure.ac
blob2f0a4d988632ead5e9707ffad12319eb42166d26
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([gliv], esyscmd([echo -n $(head -n 1 NEWS)]), [guichaz@yahoo.fr])
3 AC_CONFIG_SRCDIR([src/main.c])
4 AM_INIT_AUTOMAKE
5 AM_CONFIG_HEADER([config.h])
6 AC_LANG([C])
9 # We check this before AC_PROG_CC fills blank CFLAGS with "-g -O2".
10 if test "x$CFLAGS" = "x"; then
11   DEFAULT_CFLAGS=yes
12 else
13   DEFAULT_CFLAGS=no
16 # Checks for programs.
17 AC_PROG_CC
18 AC_PROG_RANLIB
21 # Default CFLAGS.
22 if test "x$GCC" = "xyes" && test "$DEFAULT_CFLAGS" = "yes"; then
23   CFLAGS="-Wall -O2 -fomit-frame-pointer -ffast-math"
27 # Checks for LFS flags, we may not handle big files, but it doesn't hurt.
28 AC_SYS_LARGEFILE
30 # Checks for libm.
31 AC_CHECK_LIB([m], [atan2], [
32   LDFLAGS="-lm $LDFLAGS"
33 ],[
34   AC_MSG_ERROR([Cannot use -lm])
38 # Checks for hypot (SVID 3, BSD 4.3).
39 # The replacement is #defined in the source.
40 AC_CHECK_FUNCS([hypot])
43 # Checks for math functions using floats.
44 # Using floats instead of doubles makes gcc use SSE with -msse
45 # The replacement are #defined in math_floats.h.
46 AC_CHECK_FUNCS([sqrtf])
47 AC_CHECK_FUNCS([hypotf])
48 AC_CHECK_FUNCS([atan2f])
49 AC_CHECK_FUNCS([powf])
50 AC_CHECK_FUNCS([ceilf])
51 AC_CHECK_FUNCS([cosf])
52 AC_CHECK_FUNCS([sinf])
53 AC_CHECK_FUNCS([acosf])
54 AC_CHECK_FUNCS([fmodf])
55 AC_CHECK_FUNCS([fabsf])
56 AC_CHECK_FUNCS([powf])
58 # If we don't have ftello, we'll use ftell.
59 AC_CHECK_FUNCS([ftello])
62 # Checks for getdelim, this is a GNU extension.
63 CFLAGS="$CFLAGS -D_GNU_SOURCE"
64 AC_CHECK_FUNCS([getdelim], [
65   have_getdelim="yes"
66  ], [
67   have_getdelim="no"
70 AM_CONDITIONAL([GETDELIM], [test "$have_getdelim" = "yes"])
73 # Checks for getopt_long, another GNU extension.
74 AC_CHECK_FUNCS([getopt_long], [
75   have_getopt_long="yes"
76  ], [
77   have_getopt_long="no"
80 AM_CONDITIONAL([GETOPT_LONG], [test "$have_getopt_long" = "yes"])
83 if test "$have_getdelim"    = "no" ||
84    test "$have_getopt_long" = "no"; then
85      AM_CONDITIONAL([NEED_REPLACEMENTS], [true])
86      CFLAGS="$CFLAGS -I${srcdir}/../lib"
87 else
88      AM_CONDITIONAL([NEED_REPLACEMENTS], [false])
92 # Checks for flavours of varargs macros (borrowed from glib-2)
93 # ISO C99
94 AC_MSG_CHECKING([for ISO C99 varargs macros])
96 AC_TRY_COMPILE([],[
97   int a(int p1, int p2, int p3);
98   #define call_a(...) a(1,__VA_ARGS__)
99   call_a(2,3);
100  ], [have_iso_c_varargs=yes], [have_iso_c_varargs=no])
102 AC_MSG_RESULT([$have_iso_c_varargs])
104 if test $have_iso_c_varargs = yes; then
105   iso_c_varargs=1
106 else
107   iso_c_varargs=0
110 AC_DEFINE_UNQUOTED([HAVE_ISO_C_VARARGS], [$iso_c_varargs],
111                    [ISO C99 varargs macros in C])
113 # GNU C
114 AC_MSG_CHECKING([for GNU C varargs macros])
116 AC_TRY_COMPILE([],[
117   int a(int p1, int p2, int p3);
118   #define call_a(params...) a(1,params)
119   call_a(2,3);
120  ], [have_gnu_c_varargs=yes], [have_gnu_c_varargs=no])
122 AC_MSG_RESULT([$have_gnu_c_varargs])
124 if test $have_gnu_c_varargs = yes; then
125   gnu_c_varargs=1
126 else
127   gnu_c_varargs=0
130 AC_DEFINE_UNQUOTED([HAVE_GNU_C_VARARGS], [$gnu_c_varargs],
131                    [GNU C varargs macros in C])
133 if test $have_gnu_c_varargs = no && $have_iso_c_varargs = no; then
134   AC_MSG_ERROR([no variadic macros, use gcc >= 2.95 or an ISO C99 compiler])
137 # Checks for X.
138 AC_PATH_XTRA
139 CFLAGS="$X_CFLAGS $CFLAGS"
140 LDFLAGS="$X_PRE_LIBS -lX11 $X_LIBS $X_EXTRA_LIBS $LDFLAGS"
143 # Checks for OpenGL.
144 AC_CHECK_LIB([GL], [glBegin], [LDFLAGS="-lGL $LDFLAGS"], [ogl="no"])
145 if test "x$ogl" = "xno"; then
146  AC_MSG_NOTICE([Maybe libGL requires libpthread...])
147  unset ac_cv_lib_GL_glBegin
148  AC_CHECK_LIB([GL], [glBegin], [LDFLAGS="-lpthread -lGL $LDFLAGS"],
149   AC_MSG_ERROR([Cannot use -lGL]), [-lpthread])
153 # Checks for gtk.
154 AM_PATH_GTK_2_0([2.2.0], [
155   CFLAGS="$GTK_CFLAGS $CFLAGS"
156   LDFLAGS="$GTK_LIBS $LDFLAGS"
157   GTK_VERSION="$($PKG_CONFIG --modversion gtk+-2.0)"
158  ], [exit 1], [gthread])
160 # Checks for GtkGLExt.
161 PKG_CHECK_MODULES(GTKGLEXT, [gtkglext-1.0 >= 0.7.0])
162 CFLAGS="$GTKGLEXT_CFLAGS $CFLAGS"
163 LDFLAGS="$GTKGLEXT_LIBS $LDFLAGS"
164 GTKGL_VERSION="$($PKG_CONFIG --modversion gtkglext-1.0)"
166 # I18n.
167 ALL_LINGUAS=$(echo po/*.po | sed 's|\.po||g' | sed 's|po/||g')
168 AM_GNU_GETTEXT_VERSION
169 AM_GNU_GETTEXT
170 CFLAGS="$CFLAGS -I../${srcdir}/intl"
171 LIBS="$LIBS $LIBINTL"
174 AC_CONFIG_FILES([
175  Makefile
176  lib/Makefile
177  intl/Makefile
178  po/Makefile.in
179  tools/Makefile
180  src/Makefile
181  gliv.spec
184 AC_OUTPUT
186 echo
187 echo "Using GTK+ $GTK_VERSION with GtkGLExt $GTKGL_VERSION"
188 echo