bugs: Advantages for incremental library separation by analogy with incremental
[Ale.git] / configure.in
blob3df075c71f7233db0badfd843e590ce735339d44
1 #                                               -*- Autoconf -*-
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.
29 # Preliminaries
32 AC_PREREQ(2.60)
33 AC_INIT(m4_esyscmd(./version.sh -n package-name), m4_esyscmd(./version.sh -n version), m4_esyscmd(./version.sh -n mailing-list))
34 AC_CONFIG_SRCDIR([ale_accum.h])
35 AC_CONFIG_HEADER([config.h])
37 AM_INIT_AUTOMAKE
39 # Checks for programs.
40 AC_PROG_CXX
41 AC_PROG_CC
43 # The strtod check breaks cross-compilation, so disable it.
44 AC_DEFUN([AC_FUNC_STRTOD],[])
46 #GNULib startup
47 gl_EARLY
49 # Libtool
50 AC_PROG_LIBTOOL
52 # For gnulib.
53 #gl_SOURCE_BASE(gl)
54 #gl_M4_BASE(m4)
55 #gl_LIB(lib)
56 gl_MODULES(strndup)
57 gl_INIT
59 # Checks for libraries.
60 # FIXME: Replace `main' with a function in `-lm':
61 AC_CHECK_LIB([m], [main])
63 # Checks for header files.
64 AC_HEADER_STDC
65 AC_HEADER_SYS_WAIT
66 AC_CHECK_HEADERS([limits.h stdint.h stdlib.h string.h sys/ioctl.h unistd.h time.h sys/time.h])
68 # Checks for typedefs, structures, and compiler characteristics.
69 AC_C_CONST
70 AC_C_INLINE
71 AC_TYPE_INT16_T
72 AC_TYPE_SIZE_T
73 AC_TYPE_UINT16_T
75 # Checks for library functions.  (Commented calls cause problems for cross-compilation.)
76 AC_FUNC_ERROR_AT_LINE
77 AC_FUNC_FORK
78 AC_PROG_GCC_TRADITIONAL
79 # AC_FUNC_MALLOC
80 # AC_FUNC_REALLOC
81 AC_FUNC_SELECT_ARGTYPES
82 AC_FUNC_STRTOD
83 AC_FUNC_VPRINTF
84 AC_CHECK_FUNCS([floor memset pow select sqrt strchr strcspn strdup strndup strspn strtol nrand48 rand_r gettimeofday nanosleep])
86 if test x$enable_threads != xno; then
88         # Check for POSIX threads.
89         ACX_PTHREAD()
92 # Determine whether multithreading should be used.
93 AC_ARG_ENABLE(threads,    [  --enable-threads        enable multithreading: auto, no, yes (default=auto)])
94 if test x$enable_threads != xno \
95 && test x$acx_pthread_ok = xyes; then
96         PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DUSE_PTHREAD=1"
98         #
99         # XXX: This is probably wrong.
100         #
102         if test x$PTHREAD_CXX = x; then
103                 PTHREAD_CXX="$CXX"
104         fi
106         #
107         # CC replacement logic from ImageMagick's configuration process
108         #
110         if test "$CC" != "$PTHREAD_CC"; then 
111                 AC_MSG_WARN([Replacing compiler $CC with compiler $PTHREAD_CC to support pthreads.])
112                 CC="$PTHREAD_CC" 
113         fi 
114         if test  "$CXX" != "$PTHREAD_CXX"; then
115                 AC_MSG_WARN([Replacing compiler $CXX with compiler $PTHREAD_CXX to support pthreads.]) 
116                 CXX="$PTHREAD_CXX" 
117         fi
120 if test x$enable_threads = xyes \
121 && test x$acx_pthread_ok = xno; then
122         AC_MSG_ERROR([Multithreaded build requested (--enable-threads=yes), but no usable library was found.])
124                 
126 # Determine whether assertions should be enabled.
127 AC_ARG_ENABLE(assertions, [  --enable-assertions     check runtime assertions (default=yes)])
128 if test x$enable_assertions = xno; then
129         ASSERT_FLAGS="-DNDEBUG"
130 else
131         ASSERT_FLAGS="-DDEBUG"
134 # Determine GLUT support
135 AC_ARG_WITH(glut,        [  --with-glut             GL Utility Toolkit: auto,no,yes (default=auto)])
136 if test x$with_glut != xno; then
137         AX_CHECK_GLUT
138         if test x$no_glut != xyes; then
139                 GLUT_CFLAGS="$GLUT_CFLAGS -DUSE_GLUT=1 -DUSE_GL=1"
140                 AC_CHECK_HEADER(GL/freeglut.h, AC_DEFINE([USE_FREEGLUT], [], [GL/freeglut.h header is available]))
141                 AC_CHECK_HEADER(GL/glew.h, AC_DEFINE([USE_GLEW], [], [GL/glew.h header is available]))
142                 AC_CHECK_LIB([GLEW], [glewInit], LIBS="-lGLEW $LIBS")
143         fi
144 else
145         GLUT_CFLAGS=""
146         GLUT_LIBS=""
149 # Fatal error if user flag for GLUT could not be satisified
150 if test x$with_glut = xyes \
151 && test x$GLUT_CFLAGS = x; then
152         AC_MSG_ERROR([GLUT build requested (--with-glut=yes), but no usable library was found.])
156 # Determine whether ImageMagick should be linked
157 AC_ARG_WITH(imagemagick, [  --with-imagemagick      ImageMagick file handling: auto,no,yes (default=auto)])
158 if test x$with_imagemagick != xno; then
160         # AC_CHECK_TOOL is somewhat broken for cross-compilation in
161         # some versions of autoconf, so use a conditional instead.
162         
163         if test x$host = x$build \
164         || test x$host = x; then 
165                 AC_CHECK_TOOL(MAGICK_CONFIG, Magick-config, no)
166         else
167                 AC_CHECK_PROG(MAGICK_CONFIG, ${ac_tool_prefix}Magick-config, ${ac_tool_prefix}Magick-config, no)
168         fi
170         if test x$MAGICK_CONFIG != xno; then
172                 # Bugs have been encountered in certain versions of ImageMagick
173                 # older than 6.0.6.  Until a test is written to check for these
174                 # bugs, check the version number instead.
175                 #
176                 # Since GraphicsMagick uses different version numbering, accept
177                 # any version number from a GraphicsMagick installation.
179                 IMAGEMAGICK_VERSION=`Magick-config --version`
180                 IMAGEMAGICK_VERSION_A=`echo $IMAGEMAGICK_VERSION | cut -f 1 -d '.'`
181                 IMAGEMAGICK_VERSION_B=`echo $IMAGEMAGICK_VERSION | cut -f 2 -d '.'`
182                 IMAGEMAGICK_VERSION_C=`echo $IMAGEMAGICK_VERSION | cut -f 3 -d '.'`
184                 if test -x `which GraphicsMagick-config` \
185                 || test $IMAGEMAGICK_VERSION_A -gt 6 \
186                 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
187                   && test $IMAGEMAGICK_VERSION_B -gt 0 ) \
188                 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
189                   && test $IMAGEMAGICK_VERSION_B -eq 0 \
190                   && test $IMAGEMAGICK_VERSION_C -ge 6 ); then
191                         IMAGEMAGICK_CFLAGS=`$MAGICK_CONFIG --cflags`
192                         IMAGEMAGICK_CPPFLAGS="`$MAGICK_CONFIG --cppflags` -DUSE_MAGICK"
193                         IMAGEMAGICK_LDFLAGS=`$MAGICK_CONFIG --ldflags`
194                         IMAGEMAGICK_LIBS=`$MAGICK_CONFIG --libs`
195                 else
196                         AC_MSG_WARN([not using ImageMagick older than 6.0.6 (found $IMAGEMAGICK_VERSION)])
197                 fi
198         fi
199 else
200         IMAGEMAGICK_CFLAGS=""
201         IMAGEMAGICK_CPPFLAGS=""
202         IMAGEMAGICK_LDFLAGS=""
203         IMAGEMAGICK_LIBS=""
206 # Fatal error if user flag for ImageMagick could not be satisified
207 if test x$with_imagemagick = xyes \
208 && test x$IMAGEMAGICK_CPPFLAGS = x; then
209         AC_MSG_ERROR([ImageMagick build requested (--enable-imagemagick=yes), but no suitable version was found.])
212 # Determine whether FFTW should be linked
213 AC_ARG_WITH(fftw3, [  --with-fftw3            FFTW3 fourier transforms: auto,no,yes (default=auto)])
214 if test x$with_fftw3 != xno; then
215         AC_CHECK_LIB([fftw3], [main], LIBS="-lfftw3 $LIBS" FFTW_CPPFLAGS="-DUSE_FFTW")
218 # Fatal error if user flag for FFTW could not be satisified
219 if test x$with_fftw3 = xyes \
220 && test x$FFTW_CPPFLAGS = x; then
221         AC_MSG_ERROR([FFTW3 build requested (--enable-fftw3=yes), but no suitable version was found.])
224 # Determine the precision of colors that should be used
225 AC_ARG_WITH(colors, [  --with-colors=[TYPE]      use TYPE colors: single,double,fixed32,fixed16 (default=single)])
226 if test x$with_colors = xsingle \
227 || test x$with_colors = x; then
228         COLOR_CPPFLAGS="-DALE_COLORS=SINGLE"
229 elif test x$with_colors = xdouble; then
230         COLOR_CPPFLAGS="-DALE_COLORS=DOUBLE"
231 elif test x$with_colors = xfixed16; then
232         COLOR_CPPFLAGS="-DALE_COLORS=FIXED16"
233 elif test x$with_colors = xfixed32; then
234         COLOR_CPPFLAGS="-DALE_COLORS=FIXED32"
235 else
236         AC_MSG_ERROR(option --with-colors=$with_colors is not currently supported)
239 # Determine the precision of coordinates that should be used
240 AC_ARG_WITH(coords, [  --with-coords=[TYPE]      use TYPE coords: single,double,fixed32,fixed16 (default=single)])
241 if test x$with_coords = xsingle \
242 || test x$with_coords = x; then
243         COORD_CPPFLAGS="-DALE_COORDINATES=SINGLE"
244 elif test x$with_coords = xdouble; then
245         COORD_CPPFLAGS="-DALE_COORDINATES=DOUBLE"
246 elif test x$with_coords = xfixed16; then
247         COORD_CPPFLAGS="-DALE_COORDINATES=FIXED16"
248 elif test x$with_coords = xfixed32; then
249         COORD_CPPFLAGS="-DALE_COORDINATES=FIXED32"
250 else
251         AC_MSG_ERROR(option --with-coords=$with_coords is not currently supported)
254 # Determine whether optimizations should be used
255 AC_ARG_ENABLE(optimization, [  --enable-optimizations  use optimization code (default=yes)])
256 if test x$enable_optimizations = xyes \
257 || test x$enable_optimizations = x; then
258         OPTIMIZATION_CPPFLAGS="-DOPTIMIZATIONS=1"
259 elif test x$enable_optimizations = xno; then
260         OPTIMIZATION_CPPFLAGS="-DOPTIMIZATIONS=0"
261 else
262         AC_MSG_ERROR(option --enable-optimizations=$enable_optimizations is not currently supported)
265 # Determine whether hash maps should be used.
266 AC_ARG_WITH(hashmap, [  --with-hashmap=[TYPE]     Use TYPE hash map: no,gnu,std (default=no)])
267 if test x$with_hashmap = xno \
268 || test x$with_hashmap = x; then
269         STL_CPPFLAGS=""
270 elif test x$with_hashmap = xgnu; then
271         AC_CACHE_CHECK(whether GNU hash maps are available, ac_cv_gnu_hash,[
272                 AC_LANG_SAVE
273                 AC_LANG_CPLUSPLUS
274                 AC_TRY_COMPILE([
275                         #include <ext/hash_map>
276                         struct node_hash
277                         {
278                                 size_t operator()(int n) const
279                                 {
280                                         return __gnu_cxx::hash<int>()(n);
281                                 }
282                         };
283                         typedef __gnu_cxx::hash_map<int, int, node_hash> int_map_t;
284                 ],[
285                         int_map_t foo;
286                 ], ac_cv_gnu_hash=yes, ac_cv_gnu_hash=no)
287                 AC_LANG_RESTORE])
288         if test $ac_cv_gnu_hash = yes; then
289                 STL_CPPFLAGS="-DHASH_MAP_GNU"
290         else
291                 AC_MSG_ERROR([option --with-hashmap=gnu specified, but this configuration fails.])
292         fi
293 elif test x$with_hashmap = xstd; then
294         AC_CACHE_CHECK(whether std hash maps are available, ac_cv_std_hash,[
295                 AC_LANG_SAVE
296                 AC_LANG_CPLUSPLUS
297                 AC_TRY_COMPILE([
298                         #include <ext/hash_map>
299                         typedef std::hash_map<int, int> int_map_t;
300                 ],[
301                         int_map_t foo;
302                 ], ac_cv_std_hash=yes, ac_cv_std_hash=no)
303                 AC_LANG_RESTORE])
304         if test $ac_cv_std_hash = yes; then
305                 STL_CPPFLAGS="-DHASH_MAP_STD"
306         else
307                 AC_MSG_ERROR([option --with-hashmap=std specified, but this configuration fails.])
308         fi
309 else
310         AC_MSG_ERROR(option --with-hashmap=$with_hashmap is not currently supported)
313 # Determine whether ioctl() should be used for determining window dimensions
314 AC_ARG_ENABLE(getsize, [  --enable-getsize        get terminal size: auto,no,yes (default=auto)
315                             (not doing this disables certain UI updates)])
316 if test x$enable_getsize != xno; then
318         # Check for Unix facilities.
319         AC_CHECK_HEADER(sys/ioctl.h, AC_DEFINE([HAVE_SYS_IOCTL_H]))
320         AC_CHECK_FUNC(ioctl, AC_DEFINE([HAVE_IOCTL], [], [ioctl() function is available.]))
321         AC_CHECK_DECL(TIOCGWINSZ, have_winsz=yes, have_winsz=no, [#include <sys/ioctl.h>])
323         if test x$ac_cv_header_sys_ioctl_h = xyes \
324         && test x$ac_cv_func_ioctl = xyes \
325         && test x$have_winsz = xyes; then
326                 IOCTL_CPPFLAGS="-DUSE_IOCTL"
327         fi
330 # Fatal error if IOCTL configuration could not be satisfied
331 if test x$enable_getsize = xyes \
332 && test x$IOCTL_CPPFLAGS = x; then
333         if test x$ac_cv_header_sys_ioctl_h != xyes; then
334                 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but sys/ioctl.h was not found.])
335         fi
336         if test x$ac_cv_func_ioctl != xyes; then
337                 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but ioctl() was not found.])
338         fi
339         if test x$have_winsz != xyes; then
340                 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but TIOCGWINSZ was not found.])
341         fi
342         AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but this configuration fails.])
345 # Determine whether the --wmx flag should be supported
346 AC_ARG_ENABLE(wmx, [  --enable-wmx            Enable --wmx option: auto,no,yes (default=auto)
347                             (this option requires execlp() and fork())])
348 if test x$enable_wmx != xno; then
350         # Check for Unix facilities.
351         AC_CHECK_HEADER(unistd.h, AC_DEFINE([HAVE_UNISTD_H]))
352         AC_CHECK_FUNC(execlp, AC_DEFINE([HAVE_EXECLP], [], [execlp() function is available.]))
354         if test x$ac_cv_func_fork_works = xyes \
355         && test x$ac_cv_header_unistd_h = xyes \
356         && test x$ac_cv_func_execlp = xyes; then
357                 UNIX_CPPFLAGS="-DUSE_UNIX"
358         fi
361 # Fatal error if --wmx configuration could not be satisified
362 if test x$enable_wmx = xyes \
363 && test x$UNIX_CPPFLAGS = x; then
364         if test x$ac_cv_func_execlp != xyes; then
365                 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but execlp() was not found.])
366         fi
367         if test x$ac_cv_header_unistd_h != xyes; then
368                 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but unistd.h header was not found.])
369         fi
370         if test x$ac_cv_func_fork_works != xyes; then
371                 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but a working fork() was not found.])
372         fi
373         AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but this configuration fails.])
377 # Ale library check
380 AC_CHECK_LIB([ale], [ale_new_context],, [AC_MSG_ERROR([Usable ALE library not found (libale does not have ale_new_context).])])
381 AC_CHECK_HEADER(ale.h,, [AC_MSG_ERROR([Usable ALE library not found (ale.h not found)])])
383 OPTION_CPPFLAGS="$ASSERT_FLAGS $IMAGEMAGICK_CPPFLAGS $FFTW_CPPFLAGS $UNIX_CPPFLAGS $IOCTL_CPPFLAGS $COORD_CPPFLAGS $COLOR_CPPFLAGS $OPTIMIZATION_CPPFLAGS $STL_CPPFLAGS"
384 OPTION_CFLAGS="$IMAGEMAGICK_CFLAGS $PTHREAD_CFLAGS $GLUT_CFLAGS"
385 OPTION_LDFLAGS="$IMAGEMAGICK_LDFLAGS"
386 OPTION_LIBS="$PTHREAD_LIBS $IMAGEMAGICK_LIBS $GLUT_LIBS $LIBS"
388 AC_SUBST(OPTION_CPPFLAGS)
389 AC_SUBST(OPTION_CFLAGS)
390 AC_SUBST(OPTION_LDFLAGS)
391 AC_SUBST(OPTION_LIBS)
393 AC_CONFIG_FILES([Makefile lib/Makefile])
395 AC_OUTPUT
397 # Since the generated Makefile seems to sometimes miss build steps that are
398 # required due to reconfiguration, 'make clean' here.
400 AC_MSG_NOTICE(making clean)
401 make clean &> /dev/null