1 # This file gets processed with autoconf to produce a configure script
2 AC_INIT([zettair],[0.9.3patched],[nick@ndcode.org])
4 # calculate variables for target system
9 AS_HELP_STRING([--with-valgrind[=DIR]],[integrate valgrind support for better error detetion]))
11 if test "x$with_valgrind" != "x"; then
12 AC_DEFINE(WITH_VALGRIND, 1, [indicates whether to use valgrind])
13 # check in various locations for valgrind headers
15 # note that we use CHECK_FILES instead of CHECK_HEADERS, because
16 # CHECK_HEADERS tries to compile the headers, which fails and
19 if test "x$with_valgrind" != "xyes"; then
21 # also note that trying to get valgrind_include, HAVE_VALGRIND_H
22 # and HAVE_MEMCHECK_H defined properly in this ridiculous
23 # frankenstein of a so-called programming environment is absurdly
24 # complicated, hence the mess below
26 if test "x$valgrind_include" == "x"; then
27 AC_CHECK_FILE($path/valgrind.h, [valgrind_include=$path])
28 if test "x$valgrind_include" != "x"; then
29 AC_CHECK_FILE($path/memcheck.h, [memcheck=yes])
30 if test "x$memcheck" == "xyes"; then
31 AC_DEFINE(HAVE_MEMCHECK_H, 1, [memcheck.h])
33 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
37 path=$with_valgrind/include
38 if test "x$valgrind_include" == "x"; then
39 AC_CHECK_FILE($path/valgrind.h, [valgrind_include=$path])
40 if test "x$valgrind_include" != "x"; then
41 AC_CHECK_FILE($path/memcheck.h, [memcheck=yes])
42 if test "x$memcheck" == "xyes"; then
43 AC_DEFINE(HAVE_MEMCHECK_H, 1, [memcheck.h])
45 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
49 path=$with_valgrind/include/valgrind
50 if test "x$valgrind_include" == "x"; then
51 AC_CHECK_FILE($path/valgrind.h, [valgrind_include=$path])
52 if test "x$valgrind_include" != "x"; then
53 AC_CHECK_FILE($path/memcheck.h, [memcheck=yes])
54 if test "x$memcheck" == "xyes"; then
55 AC_DEFINE(HAVE_MEMCHECK_H, 1, [memcheck.h])
57 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
61 path=$with_valgrind/valgrind
62 if test "x$valgrind_include" == "x"; then
63 AC_CHECK_FILE($path/valgrind.h, [valgrind_include=$path])
64 if test "x$valgrind_include" != "x"; then
65 AC_CHECK_FILE($path/memcheck.h, [memcheck=yes])
66 if test "x$memcheck" == "xyes"; then
67 AC_DEFINE(HAVE_MEMCHECK_H, 1, [memcheck.h])
69 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
74 path=/usr/include/valgrind
75 if test "x$valgrind_include" == "x"; then
76 AC_CHECK_FILE($path/valgrind.h, [valgrind_include=$path])
77 if test "x$valgrind_include" != "x"; then
78 AC_CHECK_FILE($path/memcheck.h, [memcheck=yes])
79 if test "x$memcheck" == "xyes"; then
80 AC_DEFINE(HAVE_MEMCHECK_H, 1, [memcheck.h])
82 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
87 if test "x$valgrind_include" == "x"; then
88 AC_CHECK_FILE($path/valgrind.h, [valgrind_include=$path])
89 if test "x$valgrind_include" != "x"; then
90 AC_CHECK_FILE($path/memcheck.h, [memcheck=yes])
91 if test "x$memcheck" == "xyes"; then
92 AC_DEFINE(HAVE_MEMCHECK_H, 1, [memcheck.h])
94 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
98 path=/usr/local/include/
99 if test "x$valgrind_include" == "x"; then
100 AC_CHECK_FILE($path/valgrind.h, [valgrind_include=$path])
101 if test "x$valgrind_include" != "x"; then
102 AC_CHECK_FILE($path/memcheck.h, [memcheck=yes])
103 if test "x$memcheck" == "xyes"; then
104 AC_DEFINE(HAVE_MEMCHECK_H, 1, [memcheck.h])
106 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
110 if test "x$valgrind_include" == "x"; then
111 AC_MSG_ERROR([Can't find valgrind.h include file])
115 if test "x$valgrind_include" != "x"; then
116 CPPFLAGS="$CPPFLAGS -I $valgrind_include"
119 # note that we've switch from config.h.in to config_h.in for
120 # compatibility with various crappy win32 zip programs :o(
121 AM_CONFIG_HEADER([src/include/config.h:src/include/config_h.in])
122 #AM_INIT_AUTOMAKE(subdir-objects)
123 AM_INIT_AUTOMAKE(dist-bzip2 dist-zip subdir-objects)
125 AC_CONFIG_SRCDIR(src/commandline.c)
127 # figure out which OS specific include directory should be used (FIXME)
136 AC_SUBST(OS, FREEBSD)
149 # export variable for use in makefile
150 AC_SUBST(OSINCLUDE, [$osinclude])
152 # checks for programs
153 AM_PROG_CC_C_O() # support subdir objects for automake
156 AM_PATH_PYTHON(2.2,,:) # need python2.2+ for build
157 AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
159 # Checks for header files.
161 AC_CHECK_HEADERS([fcntl.h float.h limits.h memory.h stdlib.h string.h strings.h sys/time.h unistd.h])
163 # determine endian-ness of target compiler (sets WORDS_BIGENDIAN if true)
166 AC_CHECK_TYPE(uint_fast32_t, unsigned long int)
167 AC_CHECK_TYPE(uint32_t, unsigned long int)
168 AC_CHECK_TYPE(uint16_t, unsigned short int)
169 AC_CHECK_TYPE(uint8_t, unsigned char)
171 # Checks for typedefs, structures, and compiler characteristics.
176 # Checks for library functions.
181 AC_CHECK_FUNCS([getcwd gettimeofday memmove memset strcasecmp strchr strerror strncasecmp strrchr strtol])
183 # check for libraries that we use
184 AC_CHECK_LIB(z, deflate)
185 AC_CHECK_LIB(m, sqrt)
186 AC_CHECK_LIB(mx, sqrtf, [], # mx contains the floating point functions on darwin
188 # failed, look for sqrtf in libm
189 [AC_CHECK_LIB(m, sqrtf,
191 # on success, do nothing (prevents -lm being added twice)
194 # define away sqrtf and friends in the firstinclude file, since we
195 # can't find them. Filter out previous #define's first.
196 [echo "reconfiguring to use double functions instead of float functions"
197 cat src/include/$osinclude/firstinclude.h | grep -v "define sqrtf" | grep -v "define logf" | grep -v "define ldexpf" | grep -v "define frexpf" > firstinclude.h
198 echo "#ifndef sqrtf /* define sqrtf */" >> firstinclude.h
199 echo "#define sqrtf sqrt" >> firstinclude.h
200 echo "#endif /* define sqrtf */" >> firstinclude.h
201 echo "#ifndef logf /* define logf */" >> firstinclude.h
202 echo "#define logf log" >> firstinclude.h
203 echo "#endif /* define logf */" >> firstinclude.h
204 echo "#ifndef ldexpf /* define ldexpf */" >> firstinclude.h
205 echo "#define ldexpf ldexp" >> firstinclude.h
206 echo "#endif /* define ldexpf */" >> firstinclude.h
207 echo "#ifndef frexpf /* define frexpf */" >> firstinclude.h
208 echo "#define frexpf frexp" >> firstinclude.h
209 echo "#endif /* define frexpf */" >> firstinclude.h
210 mv firstinclude.h src/include/$osinclude/firstinclude.h
213 AC_CONFIG_FILES([Makefile])
215 AC_CONFIG_FILES([setup.py])
218 # Nick (recommended by libtoolize)
219 AC_CONFIG_MACRO_DIRS([m4])