2 # Process this file with autoconf to produce a configure script.
4 # Copyright 2006 David Hilvert <dhilvert@auricle.dyndns.org>,
5 # <dhilvert@ugcs.caltech.edu>
7 # This file is part of the Anti-Lamenessing Engine.
9 # The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Anti-Lamenessing Engine; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 # Parts of this file were automatically generated by the GNU project's
24 # configuration generator 'autoscan', part of the 'autoconf' package from the
25 # 'autotools' family of build and installation tools.
33 AC_INIT(Ale, translit(m4_include(VERSION),'
34 '), ale@ventricle.dyndns.org)
35 AC_CONFIG_SRCDIR([ale_accum.h])
36 AC_CONFIG_HEADER([config.h])
40 # Checks for programs.
44 # The strtod check breaks cross-compilation, so disable it.
45 AC_DEFUN([AC_FUNC_STRTOD],[])
60 # Checks for libraries.
61 # FIXME: Replace `main' with a function in `-lm':
62 AC_CHECK_LIB([m], [main])
64 # Checks for header files.
67 AC_CHECK_HEADERS([limits.h stdint.h stdlib.h string.h sys/ioctl.h unistd.h time.h sys/time.h])
69 # Checks for typedefs, structures, and compiler characteristics.
76 # Checks for library functions. (Commented calls cause problems for cross-compilation.)
79 AC_PROG_GCC_TRADITIONAL
82 AC_FUNC_SELECT_ARGTYPES
85 AC_CHECK_FUNCS([floor memset pow select sqrt strchr strcspn strdup strndup strspn strtol nrand48 rand_r gettimeofday nanosleep])
87 if test x$enable_threads != xno; then
89 # Check for POSIX threads.
93 # Determine whether multithreading should be used.
94 AC_ARG_ENABLE(threads, [ --enable-threads enable multithreading: auto, no, yes (default=auto)])
95 if test x$enable_threads != xno \
96 && test x$acx_pthread_ok = xyes; then
97 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DUSE_PTHREAD=1"
100 # XXX: This is probably wrong.
103 if test x$PTHREAD_CXX = x; then
108 # CC replacement logic from ImageMagick's configuration process
111 if test "$CC" != "$PTHREAD_CC"; then
112 AC_MSG_WARN([Replacing compiler $CC with compiler $PTHREAD_CC to support pthreads.])
115 if test "$CXX" != "$PTHREAD_CXX"; then
116 AC_MSG_WARN([Replacing compiler $CXX with compiler $PTHREAD_CXX to support pthreads.])
121 if test x$enable_threads = xyes \
122 && test x$acx_pthread_ok = xno; then
123 AC_MSG_ERROR([Multithreaded build requested (--enable-threads=yes), but no usable library was found.])
127 # Determine whether assertions should be enabled.
128 AC_ARG_ENABLE(assertions, [ --enable-assertions check runtime assertions (default=yes)])
129 if test x$enable_assertions = xno; then
130 ASSERT_FLAGS="-DNDEBUG"
132 ASSERT_FLAGS="-DDEBUG"
135 # Determine GLUT support
136 AC_ARG_WITH(glut, [ --with-glut GL Utility Toolkit: auto,no,yes (default=auto)])
137 if test x$with_glut != xno; then
139 if test x$no_glut != xyes; then
140 GLUT_CFLAGS="$GLUT_CFLAGS -DUSE_GLUT=1 -DUSE_GL=1"
141 AC_CHECK_HEADER(GL/freeglut.h, AC_DEFINE([USE_FREEGLUT], [], [GL/freeglut.h header is available]))
142 AC_CHECK_HEADER(GL/glew.h, AC_DEFINE([USE_GLEW], [], [GL/glew.h header is available]))
143 AC_CHECK_LIB([GLEW], [glewInit], LIBS="-lGLEW $LIBS")
150 # Fatal error if user flag for GLUT could not be satisified
151 if test x$with_glut = xyes \
152 && test x$GLUT_CFLAGS = x; then
153 AC_MSG_ERROR([GLUT build requested (--with-glut=yes), but no usable library was found.])
157 # Determine whether ImageMagick should be linked
158 AC_ARG_WITH(imagemagick, [ --with-imagemagick ImageMagick file handling: auto,no,yes (default=auto)])
159 if test x$with_imagemagick != xno; then
161 # AC_CHECK_TOOL is somewhat broken for cross-compilation in
162 # some versions of autoconf, so use a conditional instead.
164 if test x$host = x$build \
165 || test x$host = x; then
166 AC_CHECK_TOOL(MAGICK_CONFIG, Magick-config, no)
168 AC_CHECK_PROG(MAGICK_CONFIG, ${ac_tool_prefix}Magick-config, ${ac_tool_prefix}Magick-config, no)
171 if test x$MAGICK_CONFIG != xno; then
173 # Bugs have been encountered in certain versions of ImageMagick
174 # older than 6.0.6. Until a test is written to check for these
175 # bugs, check the version number instead.
177 # Since GraphicsMagick uses different version numbering, accept
178 # any version number from a GraphicsMagick installation.
180 IMAGEMAGICK_VERSION=`Magick-config --version`
181 IMAGEMAGICK_VERSION_A=`echo $IMAGEMAGICK_VERSION | cut -f 1 -d '.'`
182 IMAGEMAGICK_VERSION_B=`echo $IMAGEMAGICK_VERSION | cut -f 2 -d '.'`
183 IMAGEMAGICK_VERSION_C=`echo $IMAGEMAGICK_VERSION | cut -f 3 -d '.'`
185 if test -x `which GraphicsMagick-config` \
186 || test $IMAGEMAGICK_VERSION_A -gt 6 \
187 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
188 && test $IMAGEMAGICK_VERSION_B -gt 0 ) \
189 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
190 && test $IMAGEMAGICK_VERSION_B -eq 0 \
191 && test $IMAGEMAGICK_VERSION_C -ge 6 ); then
192 IMAGEMAGICK_CFLAGS=`$MAGICK_CONFIG --cflags`
193 IMAGEMAGICK_CPPFLAGS="`$MAGICK_CONFIG --cppflags` -DUSE_MAGICK"
194 IMAGEMAGICK_LDFLAGS=`$MAGICK_CONFIG --ldflags`
195 IMAGEMAGICK_LIBS=`$MAGICK_CONFIG --libs`
197 AC_MSG_WARN([not using ImageMagick older than 6.0.6 (found $IMAGEMAGICK_VERSION)])
201 IMAGEMAGICK_CFLAGS=""
202 IMAGEMAGICK_CPPFLAGS=""
203 IMAGEMAGICK_LDFLAGS=""
207 # Fatal error if user flag for ImageMagick could not be satisified
208 if test x$with_imagemagick = xyes \
209 && test x$IMAGEMAGICK_CPPFLAGS = x; then
210 AC_MSG_ERROR([ImageMagick build requested (--enable-imagemagick=yes), but no suitable version was found.])
213 # Determine whether FFTW should be linked
214 AC_ARG_WITH(fftw3, [ --with-fftw3 FFTW3 fourier transforms: auto,no,yes (default=auto)])
215 if test x$with_fftw3 != xno; then
216 AC_CHECK_LIB([fftw3], [main], LIBS="-lfftw3 $LIBS" FFTW_CPPFLAGS="-DUSE_FFTW")
219 # Fatal error if user flag for FFTW could not be satisified
220 if test x$with_fftw3 = xyes \
221 && test x$FFTW_CPPFLAGS = x; then
222 AC_MSG_ERROR([FFTW3 build requested (--enable-fftw3=yes), but no suitable version was found.])
225 # Determine the precision of colors that should be used
226 AC_ARG_WITH(colors, [ --with-colors=[TYPE] use TYPE colors: single,double,fixed32,fixed16 (default=single)])
227 if test x$with_colors = xsingle \
228 || test x$with_colors = x; then
229 COLOR_CPPFLAGS="-DALE_COLORS=SINGLE"
230 elif test x$with_colors = xdouble; then
231 COLOR_CPPFLAGS="-DALE_COLORS=DOUBLE"
232 elif test x$with_colors = xfixed16; then
233 COLOR_CPPFLAGS="-DALE_COLORS=FIXED16"
234 elif test x$with_colors = xfixed32; then
235 COLOR_CPPFLAGS="-DALE_COLORS=FIXED32"
237 AC_MSG_ERROR(option --with-colors=$with_colors is not currently supported)
240 # Determine the precision of coordinates that should be used
241 AC_ARG_WITH(coords, [ --with-coords=[TYPE] use TYPE coords: single,double,fixed32,fixed16 (default=single)])
242 if test x$with_coords = xsingle \
243 || test x$with_coords = x; then
244 COORD_CPPFLAGS="-DALE_COORDINATES=SINGLE"
245 elif test x$with_coords = xdouble; then
246 COORD_CPPFLAGS="-DALE_COORDINATES=DOUBLE"
247 elif test x$with_coords = xfixed16; then
248 COORD_CPPFLAGS="-DALE_COORDINATES=FIXED16"
249 elif test x$with_coords = xfixed32; then
250 COORD_CPPFLAGS="-DALE_COORDINATES=FIXED32"
252 AC_MSG_ERROR(option --with-coords=$with_coords is not currently supported)
255 # Determine whether optimizations should be used
256 AC_ARG_ENABLE(optimization, [ --enable-optimizations use optimization code (default=yes)])
257 if test x$enable_optimizations = xyes \
258 || test x$enable_optimizations = x; then
259 OPTIMIZATION_CPPFLAGS="-DOPTIMIZATIONS=1"
260 elif test x$enable_optimizations = xno; then
261 OPTIMIZATION_CPPFLAGS="-DOPTIMIZATIONS=0"
263 AC_MSG_ERROR(option --enable-optimizations=$enable_optimizations is not currently supported)
266 # Determine whether hash maps should be used.
267 AC_ARG_WITH(hashmap, [ --with-hashmap=[TYPE] Use TYPE hash map: no,gnu,std (default=no)])
268 if test x$with_hashmap = xno \
269 || test x$with_hashmap = x; then
271 elif test x$with_hashmap = xgnu; then
272 AC_CACHE_CHECK(whether GNU hash maps are available, ac_cv_gnu_hash,[
276 #include <ext/hash_map>
279 size_t operator()(int n) const
281 return __gnu_cxx::hash<int>()(n);
284 typedef __gnu_cxx::hash_map<int, int, node_hash> int_map_t;
287 ], ac_cv_gnu_hash=yes, ac_cv_gnu_hash=no)
289 if test $ac_cv_gnu_hash = yes; then
290 STL_CPPFLAGS="-DHASH_MAP_GNU"
292 AC_MSG_ERROR([option --with-hashmap=gnu specified, but this configuration fails.])
294 elif test x$with_hashmap = xstd; then
295 AC_CACHE_CHECK(whether std hash maps are available, ac_cv_std_hash,[
299 #include <ext/hash_map>
300 typedef std::hash_map<int, int> int_map_t;
303 ], ac_cv_std_hash=yes, ac_cv_std_hash=no)
305 if test $ac_cv_std_hash = yes; then
306 STL_CPPFLAGS="-DHASH_MAP_STD"
308 AC_MSG_ERROR([option --with-hashmap=std specified, but this configuration fails.])
311 AC_MSG_ERROR(option --with-hashmap=$with_hashmap is not currently supported)
314 # Determine whether ioctl() should be used for determining window dimensions
315 AC_ARG_ENABLE(getsize, [ --enable-getsize get terminal size: auto,no,yes (default=auto)
316 (not doing this disables certain UI updates)])
317 if test x$enable_getsize != xno; then
319 # Check for Unix facilities.
320 AC_CHECK_HEADER(sys/ioctl.h, AC_DEFINE([HAVE_SYS_IOCTL_H]))
321 AC_CHECK_FUNC(ioctl, AC_DEFINE([HAVE_IOCTL], [], [ioctl() function is available.]))
322 AC_CHECK_DECL(TIOCGWINSZ, have_winsz=yes, have_winsz=no, [#include <sys/ioctl.h>])
324 if test x$ac_cv_header_sys_ioctl_h = xyes \
325 && test x$ac_cv_func_ioctl = xyes \
326 && test x$have_winsz = xyes; then
327 IOCTL_CPPFLAGS="-DUSE_IOCTL"
331 # Fatal error if IOCTL configuration could not be satisfied
332 if test x$enable_getsize = xyes \
333 && test x$IOCTL_CPPFLAGS = x; then
334 if test x$ac_cv_header_sys_ioctl_h != xyes; then
335 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but sys/ioctl.h was not found.])
337 if test x$ac_cv_func_ioctl != xyes; then
338 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but ioctl() was not found.])
340 if test x$have_winsz != xyes; then
341 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but TIOCGWINSZ was not found.])
343 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but this configuration fails.])
346 # Determine whether the --wmx flag should be supported
347 AC_ARG_ENABLE(wmx, [ --enable-wmx Enable --wmx option: auto,no,yes (default=auto)
348 (this option requires execlp() and fork())])
349 if test x$enable_wmx != xno; then
351 # Check for Unix facilities.
352 AC_CHECK_HEADER(unistd.h, AC_DEFINE([HAVE_UNISTD_H]))
353 AC_CHECK_FUNC(execlp, AC_DEFINE([HAVE_EXECLP], [], [execlp() function is available.]))
355 if test x$ac_cv_func_fork_works = xyes \
356 && test x$ac_cv_header_unistd_h = xyes \
357 && test x$ac_cv_func_execlp = xyes; then
358 UNIX_CPPFLAGS="-DUSE_UNIX"
362 # Fatal error if --wmx configuration could not be satisified
363 if test x$enable_wmx = xyes \
364 && test x$UNIX_CPPFLAGS = x; then
365 if test x$ac_cv_func_execlp != xyes; then
366 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but execlp() was not found.])
368 if test x$ac_cv_header_unistd_h != xyes; then
369 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but unistd.h header was not found.])
371 if test x$ac_cv_func_fork_works != xyes; then
372 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but a working fork() was not found.])
374 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but this configuration fails.])
381 AC_CHECK_LIB([ale], [ale_new_context],, [AC_MSG_ERROR([Usable ALE library not found (libale does not have ale_new_context).])])
382 AC_CHECK_HEADER(ale.h,, [AC_MSG_ERROR([Usable ALE library not found (ale.h not found)])])
384 OPTION_CPPFLAGS="$ASSERT_FLAGS $IMAGEMAGICK_CPPFLAGS $FFTW_CPPFLAGS $UNIX_CPPFLAGS $IOCTL_CPPFLAGS $COORD_CPPFLAGS $COLOR_CPPFLAGS $OPTIMIZATION_CPPFLAGS $STL_CPPFLAGS"
385 OPTION_CFLAGS="$IMAGEMAGICK_CFLAGS $PTHREAD_CFLAGS $GLUT_CFLAGS"
386 OPTION_LDFLAGS="$IMAGEMAGICK_LDFLAGS"
387 OPTION_LIBS="$PTHREAD_LIBS $IMAGEMAGICK_LIBS $GLUT_LIBS $LIBS"
389 AC_SUBST(OPTION_CPPFLAGS)
390 AC_SUBST(OPTION_CFLAGS)
391 AC_SUBST(OPTION_LDFLAGS)
392 AC_SUBST(OPTION_LIBS)
394 AC_CONFIG_FILES([Makefile lib/Makefile])
398 # Since the generated Makefile seems to sometimes miss build steps that are
399 # required due to reconfiguration, 'make clean' here.
401 AC_MSG_NOTICE(making clean)
402 make clean &> /dev/null