d2::combine::get_image_dynamic(): Use lrintf() instead of floor() and ceil().
[Ale.git] / configure.in
blob7ed44832d9ab04213907fd41a16996b1eb239ad7
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(ALE, translit(m4_include(VERSION),'
34 '), ale@ventricle.dyndns.org)
35 AC_CONFIG_SRCDIR([ale_accum.h])
36 AC_CONFIG_HEADER([config.h])
38 AM_INIT_AUTOMAKE
40 # Checks for programs.
41 AC_PROG_CXX
42 AC_PROG_CC
44 # The strtod check breaks cross-compilation, so disable it.
45 AC_DEFUN([AC_FUNC_STRTOD],[])
47 #GNULib startup
48 gl_EARLY
50 # Libtool
51 AC_PROG_LIBTOOL
53 # For gnulib.
54 #gl_SOURCE_BASE(gl)
55 #gl_M4_BASE(m4)
56 #gl_LIB(lib)
57 gl_MODULES(strndup)
58 gl_INIT
60 # Checks for libraries.
61 # FIXME: Replace `main' with a function in `-lm':
62 AC_CHECK_LIB([m], [main])
64 # Checks for header files.
65 AC_HEADER_STDC
66 AC_HEADER_SYS_WAIT
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.
70 AC_C_CONST
71 AC_C_INLINE
72 AC_TYPE_INT16_T
73 AC_TYPE_SIZE_T
74 AC_TYPE_UINT16_T
76 # Checks for library functions.  (Commented calls cause problems for cross-compilation.)
77 AC_FUNC_ERROR_AT_LINE
78 AC_FUNC_FORK
79 AC_PROG_GCC_TRADITIONAL
80 # AC_FUNC_MALLOC
81 # AC_FUNC_REALLOC
82 AC_FUNC_SELECT_ARGTYPES
83 AC_FUNC_STRTOD
84 AC_FUNC_VPRINTF
85 AC_CHECK_FUNCS([floor memset pow select sqrt strchr strcspn strdup strndup strspn strtol nrand48 rand_r gettimeofday nanosleep])
87 # Check for POSIX threads.
88 ACX_PTHREAD()
90 # Determine whether multithreading should be used.
91 AC_ARG_ENABLE(threads,    [  --enable-threads        enable multithreading: auto, no, yes (default=auto)])
92 if test x$enable_threads != xno \
93 && test x$acx_pthread_ok = xyes; then
94         PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DUSE_PTHREAD=1"
96         #
97         # XXX: This is probably wrong.
98         #
100         if test x$PTHREAD_CXX = x; then
101                 PTHREAD_CXX="$CXX"
102         fi
104         #
105         # CC replacement logic from ImageMagick's configuration process
106         #
108         if test "$CC" != "$PTHREAD_CC"; then 
109                 AC_MSG_WARN([Replacing compiler $CC with compiler $PTHREAD_CC to support pthreads.])
110                 CC="$PTHREAD_CC" 
111         fi 
112         if test  "$CXX" != "$PTHREAD_CXX"; then
113                 AC_MSG_WARN([Replacing compiler $CXX with compiler $PTHREAD_CXX to support pthreads.]) 
114                 CXX="$PTHREAD_CXX" 
115         fi
118 if test x$enable_threads = xyes \
119 && test x$acx_pthread_ok = xno; then
120         AC_MSG_ERROR([Multithreaded build requested (--enable-threads=yes), but usable library was found.])
122                 
124 # Determine whether assertions should be enabled.
125 AC_ARG_ENABLE(assertions, [  --enable-assertions     check runtime assertions (default=yes)])
126 if test x$enable_assertions = xno; then
127         ASSERT_FLAGS="-DNDEBUG"
128 else
129         ASSERT_FLAGS="-DDEBUG"
132 # Determine whether ImageMagick should be linked
133 AC_ARG_WITH(imagemagick, [  --with-imagemagick      ImageMagick file handling: auto,no,yes (default=auto)])
134 if test x$with_imagemagick != xno; then
136         # AC_CHECK_TOOL is somewhat broken for cross-compilation in
137         # some versions of autoconf, so use a conditional instead.
138         
139         if test x$host = x$build \
140         || test x$host = x; then 
141                 AC_CHECK_TOOL(MAGICK_CONFIG, Magick-config, no)
142         else
143                 AC_CHECK_PROG(MAGICK_CONFIG, ${ac_tool_prefix}Magick-config, ${ac_tool_prefix}Magick-config, no)
144         fi
146         if test x$MAGICK_CONFIG != xno; then
148                 # Bugs have been encountered in certain versions of ImageMagick
149                 # older than 6.0.6.  Until a test is written to check for these
150                 # bugs, check the version number instead.
152                 IMAGEMAGICK_VERSION=`Magick-config --version`
153                 IMAGEMAGICK_VERSION_A=`echo $IMAGEMAGICK_VERSION | cut -f 1 -d '.'`
154                 IMAGEMAGICK_VERSION_B=`echo $IMAGEMAGICK_VERSION | cut -f 2 -d '.'`
155                 IMAGEMAGICK_VERSION_C=`echo $IMAGEMAGICK_VERSION | cut -f 3 -d '.'`
157                 if test $IMAGEMAGICK_VERSION_A -gt 6 \
158                 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
159                   && test $IMAGEMAGICK_VERSION_B -gt 0 ) \
160                 || ( test $IMAGEMAGICK_VERSION_A -eq 6 \
161                   && test $IMAGEMAGICK_VERSION_B -eq 0 \
162                   && test $IMAGEMAGICK_VERSION_C -ge 6 ); then
163                         IMAGEMAGICK_CFLAGS=`$MAGICK_CONFIG --cflags`
164                         IMAGEMAGICK_CPPFLAGS="`$MAGICK_CONFIG --cppflags` -DUSE_MAGICK"
165                         IMAGEMAGICK_LDFLAGS=`$MAGICK_CONFIG --ldflags`
166                         IMAGEMAGICK_LIBS=`$MAGICK_CONFIG --libs`
167                 else
168                         AC_MSG_WARN([not using ImageMagick older than 6.0.6 (found $IMAGEMAGICK_VERSION)])
169                 fi
170         fi
171 else
172         IMAGEMAGICK_CFLAGS=""
173         IMAGEMAGICK_CPPFLAGS=""
174         IMAGEMAGICK_LDFLAGS=""
175         IMAGEMAGICK_LIBS=""
178 # Fatal error if user flag for ImageMagick could not be satisified
179 if test x$with_imagemagick = xyes \
180 && test x$IMAGEMAGICK_CPPFLAGS = x; then
181         AC_MSG_ERROR([ImageMagick build requested (--enable-imagemagick=yes), but no suitable version was found.])
184 # Determine whether FFTW should be linked
185 AC_ARG_WITH(fftw3, [  --with-fftw3            FFTW3 fourier transforms: auto,no,yes (default=auto)])
186 if test x$with_fftw3 != xno; then
187         AC_CHECK_LIB([fftw3], [main], LIBS="-lfftw3 $LIBS" FFTW_CPPFLAGS="-DUSE_FFTW")
190 # Fatal error if user flag for FFTW could not be satisified
191 if test x$with_fftw3 = xyes \
192 && test x$FFTW_CPPFLAGS = x; then
193         AC_MSG_ERROR([FFTW3 build requested (--enable-fftw3=yes), but no suitable version was found.])
196 # Determine the precision of colors that should be used
197 AC_ARG_WITH(colors, [  --with-colors=[TYPE]      use TYPE colors: single,double (default=single)])
198 if test x$with_colors = xsingle \
199 || test x$with_colors = x; then
200         COLOR_CPPFLAGS="-DALE_COLORS=SINGLE"
201 elif test x$with_colors = xdouble; then
202         COLOR_CPPFLAGS="-DALE_COLORS=DOUBLE"
203 else
204         AC_MSG_ERROR(option --with-colors=$with_colors is not currently supported)
207 # Determine the precision of coordinates that should be used
208 AC_ARG_WITH(coords, [  --with-coords=[TYPE]      use TYPE coords: single,double (default=single)])
209 if test x$with_coords = xsingle \
210 || test x$with_coords = x; then
211         COORD_CPPFLAGS="-DALE_COORDINATES=SINGLE"
212 elif test x$with_coords = xdouble; then
213         COORD_CPPFLAGS="-DALE_COORDINATES=DOUBLE"
214 else
215         AC_MSG_ERROR(option --with-coords=$with_coords is not currently supported)
218 # Determine whether optimizations should be used
219 AC_ARG_ENABLE(optimization, [  --enable-optimizations  use optimization code (default=yes)])
220 if test x$enable_optimizations = xyes \
221 || test x$enable_optimizations = x; then
222         OPTIMIZATION_CPPFLAGS="-DOPTIMIZATIONS=1"
223 elif test x$enable_optimizations = xno; then
224         OPTIMIZATION_CPPFLAGS="-DOPTIMIZATIONS=0"
225 else
226         AC_MSG_ERROR(option --enable-optimizations=$enable_optimizations is not currently supported)
229 # Determine whether hash maps should be used.
230 AC_ARG_WITH(hashmap, [  --with-hashmap=[TYPE]     Use TYPE hash map: no,gnu,std (default=no)])
231 if test x$with_hashmap = xno \
232 || test x$with_hashmap = x; then
233         STL_CPPFLAGS=""
234 elif test x$with_hashmap = xgnu; then
235         AC_CACHE_CHECK(whether GNU hash maps are available, ac_cv_gnu_hash,[
236                 AC_LANG_SAVE
237                 AC_LANG_CPLUSPLUS
238                 AC_TRY_COMPILE([
239                         #include <ext/hash_map>
240                         struct node_hash
241                         {
242                                 size_t operator()(int n) const
243                                 {
244                                         return __gnu_cxx::hash<int>()(n);
245                                 }
246                         };
247                         typedef __gnu_cxx::hash_map<int, int, node_hash> int_map_t;
248                 ],[
249                         int_map_t foo;
250                 ], ac_cv_gnu_hash=yes, ac_cv_gnu_hash=no)
251                 AC_LANG_RESTORE])
252         if test $ac_cv_gnu_hash = yes; then
253                 STL_CPPFLAGS="-DHASH_MAP_GNU"
254         else
255                 AC_MSG_ERROR([option --with-hashmap=gnu specified, but this configuration fails.])
256         fi
257 elif test x$with_hashmap = xstd; then
258         AC_CACHE_CHECK(whether std hash maps are available, ac_cv_std_hash,[
259                 AC_LANG_SAVE
260                 AC_LANG_CPLUSPLUS
261                 AC_TRY_COMPILE([
262                         #include <ext/hash_map>
263                         typedef std::hash_map<int, int> int_map_t;
264                 ],[
265                         int_map_t foo;
266                 ], ac_cv_std_hash=yes, ac_cv_std_hash=no)
267                 AC_LANG_RESTORE])
268         if test $ac_cv_std_hash = yes; then
269                 STL_CPPFLAGS="-DHASH_MAP_STD"
270         else
271                 AC_MSG_ERROR([option --with-hashmap=std specified, but this configuration fails.])
272         fi
273 else
274         AC_MSG_ERROR(option --with-hashmap=$with_hashmap is not currently supported)
278 # Determine whether ioctl() should be used for determining window dimensions
279 AC_ARG_ENABLE(getsize, [  --enable-getsize        get terminal size: auto,no,yes (default=auto)
280                             (not doing this disables certain UI updates)])
281 if test x$enable_getsize != xno; then
283         # Check for Unix facilities.
284         AC_CHECK_HEADER(sys/ioctl.h, AC_DEFINE([HAVE_SYS_IOCTL_H]))
285         AC_CHECK_FUNC(ioctl, AC_DEFINE([HAVE_IOCTL], [], [ioctl() function is available.]))
286         AC_CHECK_DECL(TIOCGWINSZ, have_winsz=yes, have_winsz=no, [#include <sys/ioctl.h>])
288         if test x$ac_cv_header_sys_ioctl_h = xyes \
289         && test x$ac_cv_func_ioctl = xyes \
290         && test x$have_winsz = xyes; then
291                 IOCTL_CPPFLAGS="-DUSE_IOCTL"
292         fi
295 # Fatal error if IOCTL configuration could not be satisfied
296 if test x$enable_getsize = xyes \
297 && test x$IOCTL_CPPFLAGS = x; then
298         if test x$ac_cv_header_sys_ioctl_h != xyes; then
299                 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but sys/ioctl.h was not found.])
300         fi
301         if test x$ac_cv_func_ioctl != xyes; then
302                 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but ioctl() was not found.])
303         fi
304         if test x$have_winsz != xyes; then
305                 AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but TIOCGWINSZ was not found.])
306         fi
307         AC_MSG_ERROR([ioctl() for window size requested (--enable-getsize=yes), but this configuration fails.])
310 # Determine whether the --wmx flag should be supported
311 AC_ARG_ENABLE(wmx, [  --enable-wmx            Enable --wmx option: auto,no,yes (default=auto)
312                             (this option requires execlp() and fork())])
313 if test x$enable_wmx != xno; then
315         # Check for Unix facilities.
316         AC_CHECK_HEADER(unistd.h, AC_DEFINE([HAVE_UNISTD_H]))
317         AC_CHECK_FUNC(execlp, AC_DEFINE([HAVE_EXECLP], [], [execlp() function is available.]))
319         if test x$ac_cv_func_fork_works = xyes \
320         && test x$ac_cv_header_unistd_h = xyes \
321         && test x$ac_cv_func_execlp = xyes; then
322                 UNIX_CPPFLAGS="-DUSE_UNIX"
323         fi
326 # Fatal error if --wmx configuration could not be satisified
327 if test x$enable_wmx = xyes \
328 && test x$UNIX_CPPFLAGS = x; then
329         if test x$ac_cv_func_execlp != xyes; then
330                 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but execlp() was not found.])
331         fi
332         if test x$ac_cv_header_unistd_h != xyes; then
333                 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but unistd.h header was not found.])
334         fi
335         if test x$ac_cv_func_fork_works != xyes; then
336                 AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but a working fork() was not found.])
337         fi
338         AC_MSG_ERROR([--wmx support requested (--enable-wmx=yes), but this configuration fails.])
341 OPTION_CPPFLAGS="$ASSERT_FLAGS $IMAGEMAGICK_CPPFLAGS $FFTW_CPPFLAGS $UNIX_CPPFLAGS $IOCTL_CPPFLAGS $COORD_CPPFLAGS $COLOR_CPPFLAGS $OPTIMIZATION_CPPFLAGS $STL_CPPFLAGS"
342 OPTION_CFLAGS="$IMAGEMAGICK_CFLAGS $PTHREAD_CFLAGS"
343 OPTION_LDFLAGS="$IMAGEMAGICK_LDFLAGS"
344 OPTION_LIBS="$PTHREAD_LIBS $IMAGEMAGICK_LIBS"
346 AC_SUBST(OPTION_CPPFLAGS)
347 AC_SUBST(OPTION_CFLAGS)
348 AC_SUBST(OPTION_LDFLAGS)
349 AC_SUBST(OPTION_LIBS)
351 AC_CONFIG_FILES([Makefile lib/Makefile])
353 AC_OUTPUT
355 # Since the generated Makefile seems to sometimes miss build steps that are
356 # required due to reconfiguration, 'make clean' here.
358 AC_MSG_NOTICE(making clean)
359 make clean &> /dev/null