Fix problem of HTML entities not appearing in website search results
[zettair.git] / configure.ac
1 # This file gets processed with autoconf to produce a configure script
2 AC_INIT([zettair],[0.9.3patched],[nick@ndcode.org])
3
4 # calculate variables for target system
5 AC_CANONICAL_TARGET()
6
7 # check for valgrind
8 AC_ARG_WITH(valgrind, 
9   AS_HELP_STRING([--with-valgrind[=DIR]],[integrate valgrind support for better error detetion]))
10
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
14
15     # note that we use CHECK_FILES instead of CHECK_HEADERS, because
16     # CHECK_HEADERS tries to compile the headers, which fails and
17     # causes confusion
18
19     if test "x$with_valgrind" != "xyes"; then
20
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
25         path=$with_valgrind
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])
32                 fi
33                 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
34             fi
35         fi
36
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])
44                 fi
45                 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
46             fi
47         fi
48
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])
56                 fi
57                 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
58             fi
59         fi
60
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])
68                 fi
69                 AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
70             fi
71         fi
72     fi
73
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])
81             fi
82             AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
83         fi
84     fi
85
86     path=/usr/include/
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])
93             fi
94             AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
95         fi
96     fi
97
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])
105             fi
106             AC_DEFINE(HAVE_VALGRIND_H, 1, [valgrind.h])
107         fi
108     fi
109
110     if test "x$valgrind_include" == "x"; then
111         AC_MSG_ERROR([Can't find valgrind.h include file])
112     fi
113 fi
114
115 if test "x$valgrind_include" != "x"; then
116     CPPFLAGS="$CPPFLAGS -I $valgrind_include"
117 fi
118
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)
124
125 AC_CONFIG_SRCDIR(src/commandline.c)
126
127 # figure out which OS specific include directory should be used (FIXME)
128 case $target_os in
129 *linux*)
130   AC_SUBST(OS, LINUX) 
131   osinclude=linux ;;
132 *solaris*) 
133   AC_SUBST(OS, SUNOS) 
134   osinclude=sunos ;;
135 *freebsd*) 
136   AC_SUBST(OS, FREEBSD) 
137   osinclude=freebsd ;;
138 *darwin*) 
139   AC_SUBST(OS, DARWIN) 
140   osinclude=darwin ;;
141 *cygwin*)
142   AC_SUBST(OS, CYGWIN) 
143   osinclude=cygwin ;;
144 default)
145   AC_SUBST(OS, LINUX) 
146   osinclude=linux ;;
147 esac
148
149 # export variable for use in makefile
150 AC_SUBST(OSINCLUDE, [$osinclude]) 
151
152 # checks for programs
153 AM_PROG_CC_C_O()    # support subdir objects for automake
154 AC_PROG_CC
155 LT_INIT
156 AM_PATH_PYTHON(2.2,,:)  # need python2.2+ for build
157 AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
158
159 # Checks for header files.
160 AC_HEADER_STDC
161 AC_CHECK_HEADERS([fcntl.h float.h limits.h memory.h stdlib.h string.h strings.h sys/time.h unistd.h])
162
163 # determine endian-ness of target compiler (sets WORDS_BIGENDIAN if true)
164 AC_C_BIGENDIAN()
165
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)
170
171 # Checks for typedefs, structures, and compiler characteristics.
172 AC_C_CONST
173 AC_TYPE_SIZE_T
174 AC_HEADER_TIME
175
176 # Checks for library functions.
177 AC_FUNC_MALLOC
178 AC_FUNC_MEMCMP
179 AC_FUNC_REALLOC
180 AC_FUNC_STAT
181 AC_CHECK_FUNCS([getcwd gettimeofday memmove memset strcasecmp strchr strerror strncasecmp strrchr strtol])
182
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
187
188   # failed, look for sqrtf in libm
189   [AC_CHECK_LIB(m, sqrtf, 
190
191     # on success, do nothing (prevents -lm being added twice)
192     [echo -n ""], 
193
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
211     ])])
212      
213 AC_CONFIG_FILES([Makefile])
214 AC_OUTPUT
215 AC_CONFIG_FILES([setup.py])
216 AC_OUTPUT
217
218 # Nick (recommended by libtoolize)
219 AC_CONFIG_MACRO_DIRS([m4])