2 # Process this file with autoconf to produce a configure script.
5 AC_INIT(ALE, 0.8.5-prerelease, ale@ventricle.dyndns.org)
6 AC_CONFIG_SRCDIR([ale_accum.h])
7 AC_CONFIG_HEADER([config.h])
11 # Checks for programs.
15 # The strtod check breaks cross-compilation, so disable it.
16 AC_DEFUN([AC_FUNC_STRTOD],[])
31 # Checks for libraries.
32 # FIXME: Replace `main' with a function in `-lm':
33 AC_CHECK_LIB([m], [main])
35 # Checks for header files.
38 AC_CHECK_HEADERS([limits.h stdint.h stdlib.h string.h sys/ioctl.h unistd.h])
40 # Checks for typedefs, structures, and compiler characteristics.
47 # Checks for library functions. (Commented calls cause problems for cross-compilation.)
50 AC_PROG_GCC_TRADITIONAL
53 AC_FUNC_SELECT_ARGTYPES
56 AC_CHECK_FUNCS([floor memset pow select sqrt strchr strcspn strdup strndup strspn strtol])
58 # Determine whether assertions should be enabled.
59 AC_ARG_ENABLE(assertions, [ --enable-assertions check runtime assertions (default=yes)])
60 if test x$enable_assertions = xno; then
61 ASSERT_FLAGS="-DNDEBUG"
63 ASSERT_FLAGS="-DDEBUG"
66 # Determine whether ImageMagick should be linked
67 AC_ARG_WITH(imagemagick, [ --with-imagemagick ImageMagick file handling: auto,no,yes (default=auto)])
68 if test x$with_imagemagick != xno; then
70 # AC_CHECK_TOOL is somewhat broken for cross-compilation in
71 # some versions of autoconf, so use a conditional instead.
73 if test x$host = x$build \
74 || test x$host = x; then
75 AC_CHECK_TOOL(MAGICK_CONFIG, Magick-config, no)
77 AC_CHECK_PROG(MAGICK_CONFIG, ${ac_tool_prefix}Magick-config, ${ac_tool_prefix}Magick-config, no)
80 if test x$MAGICK_CONFIG != xno; then
82 # Bugs have been encountered in certain versions of ImageMagick
83 # older than 6.0.6. Until a test is written to check for these
84 # bugs, check the version number instead.
86 IMAGEMAGICK_VERSION=`Magick-config --version`
87 IMAGEMAGICK_VERSION_A=`echo $IMAGEMAGICK_VERSION | cut -f 1 -d '.'`
88 IMAGEMAGICK_VERSION_B=`echo $IMAGEMAGICK_VERSION | cut -f 2 -d '.'`
89 IMAGEMAGICK_VERSION_C=`echo $IMAGEMAGICK_VERSION | cut -f 3 -d '.'`
91 if test $IMAGEMAGICK_VERSION_A -gt 6 \
92 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
93 && test $IMAGEMAGICK_VERSION_B -gt 0 ) \
94 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
95 && test $IMAGEMAGICK_VERSION_B -eq 0 \
96 && test $IMAGEMAGICK_VERSION_C -ge 6 ); then
97 IMAGEMAGICK_CFLAGS=`$MAGICK_CONFIG --cflags`
98 IMAGEMAGICK_CPPFLAGS="`$MAGICK_CONFIG --cppflags` -DUSE_MAGICK"
99 IMAGEMAGICK_LDFLAGS=`$MAGICK_CONFIG --ldflags`
100 IMAGEMAGICK_LIBS=`$MAGICK_CONFIG --libs`
102 AC_MSG_WARN([not using ImageMagick older than 6.0.6 (found $IMAGEMAGICK_VERSION)])
106 IMAGEMAGICK_CFLAGS=""
107 IMAGEMAGICK_CPPFLAGS=""
108 IMAGEMAGICK_LDFLAGS=""
112 # Fatal error if user flag for ImageMagick could not be satisified
113 if test x$with_imagemagick = xyes \
114 && test x$IMAGEMAGICK_CPPFLAGS = x; then
115 AC_MSG_ERROR([ImageMagick build requested (--enable-imagemagick=yes), but no suitable version was found.])
118 # Determine whether FFTW should be linked
119 AC_ARG_WITH(fftw3, [ --with-fftw3 FFTW3 fourier transforms: auto,no,yes (default=auto)])
120 if test x$with_fftw3 != xno; then
121 AC_CHECK_LIB([fftw3], [main], LIBS="-lfftw3 $LIBS" FFTW_CPPFLAGS="-DUSE_FFTW")
124 # Fatal error if user flag for FFTW could not be satisified
125 if test x$with_fftw3 = xyes \
126 && test x$FFTW_CPPFLAGS = x; then
127 AC_MSG_ERROR([FFTW3 build requested (--enable-fftw3=yes), but no suitable version was found.])
130 # Determine the precision of colors that should be used
131 AC_ARG_WITH(colors, [ --with-colors=[TYPE] use TYPE colors: single,double (default=single)])
132 if test x$with_colors = xsingle \
133 || test x$with_colors = x; then
134 COLOR_CPPFLAGS="-DALE_COLORS=SINGLE"
135 elif test x$with_colors = xdouble; then
136 COLOR_CPPFLAGS="-DALE_COLORS=DOUBLE"
138 AC_MSG_ERROR(option --with-colors=$with_colors is not currently supported)
141 # Determine the precision of coordinates that should be used
142 AC_ARG_WITH(coords, [ --with-coords=[TYPE] use TYPE coords: single,double (default=single)])
143 if test x$with_coords = xsingle \
144 || test x$with_coords = x; then
145 COORD_CPPFLAGS="-DALE_COORDINATES=SINGLE"
146 elif test x$with_coords = xdouble; then
147 COORD_CPPFLAGS="-DALE_COORDINATES=DOUBLE"
149 AC_MSG_ERROR(option --with-coords=$with_coords is not currently supported)
152 # Determine whether optimizations should be used
153 AC_ARG_ENABLE(optimization, [ --enable-optimizations use optimization code (default=yes)])
154 if test x$enable_optimizations = xyes \
155 || test x$enable_optimizations = x; then
156 OPTIMIZATION_CPPFLAGS="-DOPTIMIZATIONS=1"
157 elif test x$enable_optimizations = xno; then
158 OPTIMIZATION_CPPFLAGS="-DOPTIMIZATIONS=0"
160 AC_MSG_ERROR(option --enable-optimizations=$enable_optimizations is not currently supported)
163 # Determine whether hash maps should be used.
164 AC_ARG_WITH(hashmap, [ --with-hashmap=[TYPE] Use TYPE hash map: no,gnu,std (default=no)])
165 if test x$with_hashmap = xno \
166 || test x$with_hashmap = x; then
168 elif test x$with_hashmap = xgnu; then
169 AC_CACHE_CHECK(whether GNU hash maps are available, ac_cv_gnu_hash,[
173 #include <ext/hash_map>
176 size_t operator()(int n) const
178 return __gnu_cxx::hash<int>()(n);
181 typedef __gnu_cxx::hash_map<int, int, node_hash> int_map_t;
184 ], ac_cv_gnu_hash=yes, ac_cv_gnu_hash=no)
186 if test $ac_cv_gnu_hash = yes; then
187 STL_CPPFLAGS="-DHASH_MAP_GNU"
189 AC_MSG_ERROR([option --with-hashmap=gnu specified, but this configuration fails.])
191 elif test x$with_hashmap = xstd; then
192 AC_CACHE_CHECK(whether std hash maps are available, ac_cv_std_hash,[
196 #include <ext/hash_map>
197 typedef std::hash_map<int, int> int_map_t;
200 ], ac_cv_std_hash=yes, ac_cv_std_hash=no)
202 if test $ac_cv_std_hash = yes; then
203 STL_CPPFLAGS="-DHASH_MAP_STD"
205 AC_MSG_ERROR([option --with-hashmap=std specified, but this configuration fails.])
208 AC_MSG_ERROR(option --with-hashmap=$with_hashmap is not currently supported)
212 # Determine whether ioctl() should be used for determining window dimensions
213 AC_ARG_ENABLE(getsize, [ --enable-getsize get terminal size: auto,no,yes (default=auto)
214 (not doing this disables certain UI updates)])
215 if test x$enable_getsize != xno; then
217 # Check for Unix facilities.
218 AC_CHECK_HEADER(sys/ioctl.h, AC_DEFINE([HAVE_SYS_IOCTL_H]))
219 AC_CHECK_FUNC(ioctl, AC_DEFINE([HAVE_IOCTL], [], [ioctl() function is available.]))
220 AC_CHECK_DECL(TIOCGWINSZ, have_winsz=yes, have_winsz=no, [#include <sys/ioctl.h>])
222 if test x$ac_cv_header_sys_ioctl_h = xyes \
223 && test x$ac_cv_func_ioctl = xyes \
224 && test x$have_winsz = xyes; then
225 IOCTL_CPPFLAGS="-DUSE_IOCTL"
229 # Fatal error if IOCTL configuration could not be satisfied
230 if test x$enable_getsize = xyes \
231 && test x$IOCTL_CPPFLAGS = x; then
232 if test x$ac_cv_header_sys_ioctl_h != xyes; then
233 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but sys/ioctl.h was not found.])
235 if test x$ac_cv_func_ioctl != xyes; then
236 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but ioctl() was not found.])
238 if test x$have_winsz != xyes; then
239 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but TIOCGWINSZ was not found.])
241 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but this configuration fails.])
244 # Determine whether the --wmx flag should be supported
245 AC_ARG_ENABLE(wmx, [ --enable-wmx Enable --wmx option: auto,no,yes (default=auto)
246 (this option requires execlp() and fork())])
247 if test x$enable_wmx != xno; then
249 # Check for Unix facilities.
250 AC_CHECK_HEADER(unistd.h, AC_DEFINE([HAVE_UNISTD_H]))
251 AC_CHECK_FUNC(execlp, AC_DEFINE([HAVE_EXECLP], [], [execlp() function is available.]))
253 if test x$ac_cv_func_fork_works = xyes \
254 && test x$ac_cv_header_unistd_h = xyes \
255 && test x$ac_cv_func_execlp = xyes; then
256 UNIX_CPPFLAGS="-DUSE_UNIX"
260 # Fatal error if --wmx configuration could not be satisified
261 if test x$enable_wmx = xyes \
262 && test x$UNIX_CPPFLAGS = x; then
263 if test x$ac_cv_func_execlp != xyes; then
264 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but execlp() was not found.])
266 if test x$ac_cv_header_unistd_h != xyes; then
267 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but unistd.h header was not found.])
269 if test x$ac_cv_func_fork_works != xyes; then
270 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but a working fork() was not found.])
272 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but this configuration fails.])
275 OPTION_CPPFLAGS="$ASSERT_FLAGS $IMAGEMAGICK_CPPFLAGS $FFTW_CPPFLAGS $UNIX_CPPFLAGS $IOCTL_CPPFLAGS $COORD_CPPFLAGS $COLOR_CPPFLAGS $OPTIMIZATION_CPPFLAGS $STL_CPPFLAGS"
276 OPTION_CFLAGS="$IMAGEMAGICK_CFLAGS"
277 OPTION_LDFLAGS="$IMAGEMAGICK_LDFLAGS"
278 OPTION_LIBS="$IMAGEMAGICK_LIBS"
280 AC_SUBST(OPTION_CPPFLAGS)
281 AC_SUBST(OPTION_CFLAGS)
282 AC_SUBST(OPTION_LDFLAGS)
283 AC_SUBST(OPTION_LIBS)
285 AC_CONFIG_FILES([Makefile lib/Makefile])
289 # Since the generated Makefile seems to sometimes miss build steps that are
290 # required due to reconfiguration, 'make clean' here.
292 AC_MSG_NOTICE(making clean)
293 make clean &> /dev/null