libale.c: Make macro names more explanatory.
[libale.git] / configure.ac
blob9381a02762b6a99d51ddf097fe75a18d6b274fab
1 # Copyright 2008 David Hilvert <dhilvert@gmail.com>
3 # This file is part of libale.
5 # libale is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU Affero General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
8 # any later version.
10 # libale is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for
13 # more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with libale.  If not, see <http://www.gnu.org/licenses/>.
19 ## Preliminaries
22 AC_PREREQ(2.60)
23 AC_INIT(libale,translit(m4_include(VERSION),'
24 '), ale@ventricle.dyndns.org)
25 AC_CONFIG_SRCDIR([include/ale.h])
26 AC_CONFIG_HEADER([config.h])
28 AC_PROG_LIBTOOL
30 AM_INIT_AUTOMAKE
33 ## C compiler
36 AC_PROG_CC
37 AX_CFLAGS_WARN_ALL
40 ## Types
43 AC_C_LONG_LONG
45 AC_CHECK_HEADER([stdint.h])
46 AC_CHECK_HEADER([inttypes.h])
47 AC_TYPE_UINTPTR_T
50 ## GLUT
53 AX_CHECK_GLUT
54 if test "x$no_glut" = xyes; then
55         AC_MSG_ERROR([Usable GLUT configuration was not found.])
58 AC_CHECK_HEADER(GL/glew.h,, [AC_MSG_ERROR([Usable GLEW configuration was not found. (GL/glew.h not found)])]) 
59 AC_CHECK_LIB([GLEW], [glewInit], [GLEW_LIBS="-lGLEW"], [AC_MSG_ERROR([Usable GLEW configuration was not found. (GLEW library not found)])])
63 ## Guile
66 AC_CHECK_HEADER(libguile.h,, [AC_MSG_ERROR([Usable guile library was not found. (libguile.h not found)])])
68 GUILE_PROGS
69 GUILE_FLAGS
71 AC_CHECK_DECL(scm_from_locale_string,, [AC_MSG_ERROR([Guile installation does not support scm_from_locale_string.  (Try upgrading to Guile 1.8 or later.)])], [#include <libguile.h>])
74 ## ImageMagick
78 # The following tests are taken from ALE's configure.in.
81 # Determine whether ImageMagick should be linked
82 AC_ARG_WITH(imagemagick, [  --with-imagemagick      ImageMagick file handling: auto,no,yes (default=auto)])
83 if test x$with_imagemagick != xno; then
85         # AC_CHECK_TOOL is somewhat broken for cross-compilation in
86         # some versions of autoconf, so use a conditional instead.
88         if test x$host = x$build \
89         || test x$host = x; then 
90                 AC_CHECK_TOOL(MAGICK_CONFIG, Magick-config, no)
91         else
92                 AC_CHECK_PROG(MAGICK_CONFIG, ${ac_tool_prefix}Magick-config, ${ac_tool_prefix}Magick-config, no)
93         fi
95         if test x$MAGICK_CONFIG != xno; then
97                 # Bugs have been encountered in certain versions of ImageMagick
98                 # older than 6.0.6.  Until a test is written to check for these
99                 # bugs, check the version number instead.
101                 IMAGEMAGICK_VERSION=`Magick-config --version`
102                 IMAGEMAGICK_VERSION_A=`echo $IMAGEMAGICK_VERSION | cut -f 1 -d '.'`
103                 IMAGEMAGICK_VERSION_B=`echo $IMAGEMAGICK_VERSION | cut -f 2 -d '.'`
104                 IMAGEMAGICK_VERSION_C=`echo $IMAGEMAGICK_VERSION | cut -f 3 -d '.'`
106                 if test -x `which GraphicsMagick-config` \
107                 || test $IMAGEMAGICK_VERSION_A -gt 6 \
108                 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
109                   && test $IMAGEMAGICK_VERSION_B -gt 0 ) \
110                 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
111                   && test $IMAGEMAGICK_VERSION_B -eq 0 \
112                   && test $IMAGEMAGICK_VERSION_C -ge 6 ); then
113                         AC_DEFINE([HAVE_IMAGEMAGICK], [1], 
114                                   [Use ImageMagick for file loading and saving.])
115                         IMAGEMAGICK_CFLAGS=`$MAGICK_CONFIG --cflags`
116                         IMAGEMAGICK_CPPFLAGS=`$MAGICK_CONFIG --cppflags`
117                         IMAGEMAGICK_LDFLAGS=`$MAGICK_CONFIG --ldflags`
118                         IMAGEMAGICK_LIBS=`$MAGICK_CONFIG --libs`
119                 else
120                         AC_MSG_WARN([not using ImageMagick older than 6.0.6 (found $IMAGEMAGICK_VERSION)])
121                 fi
122         fi
123 else
124         IMAGEMAGICK_CFLAGS=""
125         IMAGEMAGICK_CPPFLAGS=""
126         IMAGEMAGICK_LDFLAGS=""
127         IMAGEMAGICK_LIBS=""
130 # Fatal error if user flag for ImageMagick could not be satisified
131 if test x$with_imagemagick = xyes \
132 && test x$IMAGEMAGICK_CPPFLAGS = x; then
133         AC_MSG_ERROR([ImageMagick build requested (--enable-imagemagick=yes), but no suitable version was found.])
138 ## Substitution variables
141 LIBALE_CFLAGS="$GLUT_CFLAGS $GUILE_CFLAGS $IMAGEMAGICK_CFLAGS $IMAGEMAGICK_CPPFLAGS"
142 LIBALE_LIBS="$GLUT_LIBS $GLEW_LIBS $IMAGEMAGICK_LIBS"
143 LIBALE_LDFLAGS="$GUILE_LDFLAGS $IMAGEMAGICK_LDFLAGS"
145 AC_SUBST(LIBALE_CFLAGS)
146 AC_SUBST(LIBALE_LIBS)
147 AC_SUBST(LIBALE_LDFLAGS)
149 AC_CONFIG_FILES([Makefile])
151 AC_OUTPUT
153 # Since the generated Makefile seems to sometimes miss build steps that are
154 # required due to reconfiguration, 'make clean' here.
156 AC_MSG_NOTICE(making clean)
157 make clean &> /dev/null