Commit | Line | Data |
---|---|---|
460b9539 | 1 | # Process this file with autoconf to produce a configure script. |
2 | # | |
3 | # This file is part of DisOrder. | |
5aff007d | 4 | # Copyright (C) 2004-2008 Richard Kettlewell |
313acc77 | 5 | # Portions copyright (C) 2007 Ross Younger |
460b9539 | 6 | # |
7 | # This program is free software; you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation; either version 2 of the License, or | |
10 | # (at your option) any later version. | |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, but | |
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | # General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program; if not, write to the Free Software | |
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
20 | # USA | |
21 | # | |
22 | ||
32918782 | 23 | AC_INIT([disorder], [4.0.2], [richard+disorder@sfere.greenend.org.uk]) |
460b9539 | 24 | AC_CONFIG_AUX_DIR([config.aux]) |
32918782 | 25 | AM_INIT_AUTOMAKE(disorder, [4.0.2]) |
460b9539 | 26 | AC_CONFIG_SRCDIR([server/disorderd.c]) |
27 | AM_CONFIG_HEADER([config.h]) | |
28 | ||
dea8f8aa RK |
29 | # Find host type |
30 | AC_CANONICAL_HOST | |
31 | ||
460b9539 | 32 | # What we want to build |
460b9539 | 33 | want_gtk=yes |
34 | want_python=yes | |
7affb407 | 35 | want_tests=yes |
4cbafe13 RK |
36 | want_server=yes |
37 | want_cgi=yes | |
460b9539 | 38 | |
e2f0c461 RK |
39 | # APIs we want |
40 | want_alsa=yes | |
41 | want_oss=yes | |
42 | want_coreaudio=yes | |
43 | ||
a9f0ad12 RK |
44 | # Checks for programs. |
45 | AC_PROG_CC | |
46 | AC_SET_MAKE | |
47 | if test "x$GCC" = xyes; then | |
48 | gcc_werror=-Werror | |
49 | else | |
fdca70ee | 50 | AC_MSG_ERROR([GNU C is required to build this program]) |
a9f0ad12 RK |
51 | gcc_werror="" |
52 | fi | |
53 | ||
e2f0c461 RK |
54 | AC_ARG_WITH([alsa], |
55 | [AS_HELP_STRING([--without-alsa], | |
56 | [do not build with ALSA support])], | |
57 | [want_alsa=$withval]) | |
58 | AC_ARG_WITH([oss], | |
59 | [AS_HELP_STRING([--without-oss], | |
60 | [do not build with OSS support])], | |
61 | [want_oss=$withval]) | |
62 | AC_ARG_WITH([coreaudio], | |
63 | [AS_HELP_STRING([--without-coreaudio], | |
64 | [do not build with Core Audio support])], | |
65 | [want_coreaudio=$withval]) | |
7affb407 RK |
66 | AC_ARG_WITH([tests], |
67 | [AS_HELP_STRING([--without-tests], | |
68 | [do not build test suit])], | |
69 | [want_tests=$withval]) | |
e2f0c461 | 70 | |
a9f0ad12 | 71 | AC_MSG_CHECKING([for a known target platform]) |
dea8f8aa | 72 | case "$host" in |
a9f0ad12 | 73 | *empeg* ) |
e3426f7b | 74 | AC_MSG_RESULT([empeg car stereo]) |
a9f0ad12 RK |
75 | AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo]) |
76 | # work around broken toolchain | |
77 | AC_CHECK_LIB([gpg-error], [gpg_strerror]) | |
e3426f7b | 78 | AC_CHECK_LIB([pthread], [pthread_create]) |
a9f0ad12 | 79 | want_server=no |
4cbafe13 | 80 | want_cgi=no |
a9f0ad12 | 81 | ;; |
dea8f8aa | 82 | *linux* | *Linux* ) |
a9f0ad12 | 83 | AC_MSG_RESULT([Linux]) |
dea8f8aa | 84 | ;; |
9086a105 | 85 | *-apple-darwin* ) |
e3426f7b | 86 | AC_MSG_RESULT([Mac OS X]) |
e2f0c461 RK |
87 | if test $want_coreaudio = yes; then |
88 | COREAUDIO="-framework CoreAudio" | |
89 | fi | |
0ec4c5e6 | 90 | browser=open |
8fcf5c48 RK |
91 | AC_MSG_CHECKING([Mac OS X target version]) |
92 | # We honor MACOSX_DEPLOYMENT_TARGET in the environment, emulating gcc's | |
93 | # behaviour. But we provide a command line option to override it and | |
94 | # we default to wide support instead of supporting only the build platform. | |
95 | # | |
96 | # Currently if you ask for 10.5 you will get a deprecation warning | |
97 | # when building the CoreAudio support code. For the time being the | |
98 | # answer to this is "don't do that then". If a good reason to ask | |
99 | # for a 10.5 deployment target emerges then this will be fixed. | |
100 | if test -z "$MACOSX_DEPLOYMENT_TARGET"; then | |
101 | MACOSX_DEPLOYMENT_TARGET=10.0 | |
102 | fi | |
103 | AC_ARG_WITH([deployment-target], | |
104 | [AS_HELP_STRING([--with-deployment-target=TARGET], | |
105 | [set target OS X version])], | |
106 | [MACOSX_DEPLOYMENT_TARGET=$withval]) | |
107 | # Convert to desired format | |
108 | underscored=`echo $MACOSX_DEPLOYMENT_TARGET|sed 's/\./_/'` | |
109 | minver="MAC_OS_X_VERSION_$underscored" | |
110 | AC_MSG_RESULT([$minver]) | |
111 | AC_DEFINE_UNQUOTED([MAC_OS_X_VERSION_MIN_REQUIRED], [$minver], | |
112 | [define to minimum version of Mac OS X to support]) | |
9086a105 | 113 | ;; |
70f47acd RK |
114 | *-freebsd* ) |
115 | AC_MSG_RESULT([FreeBSD]) | |
edbd470f | 116 | # Ports install to /usr/local but the compiler stupidly doesn't look |
117 | # there by default | |
70f47acd | 118 | LDFLAGS="${LDFLAGS} -L/usr/local/lib" |
e6ea27d8 | 119 | CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include" |
42f43a11 RK |
120 | # Look for a suitable version of libdb among the versions found in FreeBSD 7.0 |
121 | AC_CACHE_CHECK([looking for a libdb install],[rjk_cv_libdb],[ | |
122 | rjk_cv_libdb="none" | |
123 | for db in db43 db44 db45 db46; do | |
124 | if test -e /usr/local/lib/$db; then | |
125 | rjk_cv_libdb=$db | |
126 | break | |
127 | fi | |
128 | done | |
129 | ]) | |
130 | if test $rjk_cv_libdb != none; then | |
131 | LDFLAGS="${LDFLAGS} -L/usr/local/lib/$rjk_cv_libdb" | |
132 | CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include/$rjk_cv_libdb" | |
133 | fi | |
70f47acd | 134 | ;; |
dea8f8aa | 135 | * ) |
a9f0ad12 | 136 | AC_MSG_RESULT([unknown, winging it]) |
dea8f8aa RK |
137 | ;; |
138 | esac | |
9086a105 | 139 | AC_SUBST([COREAUDIO]) |
dea8f8aa | 140 | |
f486ea18 RK |
141 | AC_ARG_WITH([browser], |
142 | [AS_HELP_STRING([--with-browser=BROWSER], | |
143 | [use BROWSER to display HTML])], | |
144 | [browser=$withval]) | |
145 | ||
146 | AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[ | |
147 | rjk_cv_browser=UNKNOWN | |
58d97da4 | 148 | for candidate in x-www-browser sensible-browser firefox mozilla konqueror netscape; do |
f486ea18 RK |
149 | if type $candidate >/dev/null 2>&1; then |
150 | rjk_cv_browser="$candidate" | |
151 | break | |
152 | fi | |
153 | done | |
154 | ]) | |
155 | if test -z "$browser"; then | |
156 | browser="$rjk_cv_browser" | |
157 | fi | |
158 | AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer]) | |
159 | ||
460b9539 | 160 | AC_ARG_WITH([server], |
161 | [AS_HELP_STRING([--without-server], | |
162 | [do not build server])], | |
163 | [want_server=$withval]) | |
4cbafe13 RK |
164 | AC_ARG_WITH([cgi], |
165 | [AS_HELP_STRING([--without-cgi], | |
166 | [do not build CGI])], | |
167 | [want_cgi=$withval]) | |
460b9539 | 168 | AC_ARG_WITH([gtk], |
169 | [AS_HELP_STRING([--without-gtk], | |
170 | [do not build GTK+ client])], | |
171 | [want_gtk=$withval]) | |
172 | AC_ARG_WITH([python], | |
173 | [AS_HELP_STRING([--without-python], | |
174 | [do not build Python support])], | |
175 | [want_python=$withval]) | |
176 | ||
4cbafe13 RK |
177 | if test $want_server = no; then |
178 | want_cgi=no | |
179 | fi | |
180 | ||
64ac73bb RK |
181 | # |
182 | # OS Document Root CGI directory | |
183 | # == ============= ============= | |
184 | # Debian /var/www /usr/lib/cgi-bin | |
185 | # Ubuntu /var/www /usr/lib/cgi-bin | |
186 | # Red Hat /var/www/html /var/www/cgi-bin | |
187 | # or: /home/httpd/html/ /home/httpd/cgi-bin | |
188 | # Slackware /var/www/htdocs (unknown) | |
189 | # SuSE /srv/www/html /srv/www/cgi-bin | |
190 | # Gentoo /var/www/localhost/htdocs /var/www/localhost/cgi-bin/ | |
191 | # FreeBSD /usr/local/www/data /usr/local/www/cgi-bin | |
192 | # or: /usr/local/www/???/data /usr/local/www/???/cgi-bin | |
193 | # OS X /Library/WebServer/Documents /Library/WebServer/CGI-Executables | |
194 | # Apache /usr/local/apache/htdocs (none) | |
195 | # | |
196 | # Sources: | |
197 | # http://wiki.linuxquestions.org/wiki/Apache | |
198 | # http://mapserver.gis.umn.edu/docs/howto/suse-linux | |
199 | # http://www.yolinux.com/TUTORIALS/LinuxTutorialWebSiteConfig.html | |
200 | # http://sources.gentoo.org/viewcvs.py/apache/trunk/dist/2.2/conf/vhosts.d/default_vhost.include?rev=198&view=log | |
201 | # http://httpd.apache.org/docs/ | |
202 | # | |
4cbafe13 | 203 | if test $want_cgi = yes; then |
64ac73bb RK |
204 | if test -z "$httpdir"; then |
205 | AC_CACHE_CHECK([for httpd document root],[rjk_cv_httpdir],[ | |
206 | rjk_cv_httpdir="not found" | |
207 | for dir in /var/www/html \ | |
208 | /var/www/htdocs \ | |
209 | /var/www/localhost/htdocs \ | |
210 | /var/www \ | |
211 | /home/httpd/html \ | |
212 | /srv/www/html \ | |
213 | /usr/local/www/data \ | |
214 | /usr/local/www/*/data \ | |
215 | /Library/WebServer/Documents \ | |
216 | /usr/local/apache/htdocs; do | |
217 | if test -d "$dir"; then | |
218 | rjk_cv_httpdir="$dir" | |
219 | fi | |
220 | done | |
221 | ]) | |
f03d4184 | 222 | if test "$rjk_cv_cgiexecdir" = "not found"; then |
64ac73bb RK |
223 | AC_MSG_ERROR([cannot identify httpd documentroot. Set httpdir on configure command line]) |
224 | fi | |
225 | httpdir="$rjk_cv_httpdir" | |
226 | fi | |
f03d4184 RK |
227 | if test ! -z "$cgidir"; then |
228 | # This is a bit harsh but should stop any disasters | |
229 | AC_MSG_ERROR([cgidir has been renamed to cgiexecdir]) | |
230 | fi | |
231 | if test -z "$cgiexecdir"; then | |
232 | AC_CACHE_CHECK([for CGI directory],[rjk_cv_cgiexecdir],[ | |
233 | rjk_cv_cgiexecdir="not found" | |
4cbafe13 RK |
234 | for dir in /usr/lib/cgi-bin \ |
235 | /Library/WebServer/CGI-Executables \ | |
64ac73bb RK |
236 | /srv/www/cgi-bin \ |
237 | /var/www/cgi-bin \ | |
238 | /home/httpd/cgi-bin \ | |
239 | /var/www/localhost/cgi-bin \ | |
4cbafe13 RK |
240 | /usr/local/lib/cgi-bin \ |
241 | /usr/local/www/cgi-bin \ | |
242 | /usr/local/www/*/cgi-bin; do | |
243 | if test -d "$dir"; then | |
f03d4184 | 244 | rjk_cv_cgiexecdir="$dir" |
4cbafe13 RK |
245 | break |
246 | fi | |
247 | done | |
248 | ]) | |
f03d4184 RK |
249 | if test "$rjk_cv_cgiexecdir" = "not found"; then |
250 | AC_MSG_ERROR([cannot identify CGI install directory. Set cgiexecdir on configure command line]) | |
4cbafe13 | 251 | fi |
f03d4184 | 252 | cgiexecdir="$rjk_cv_cgiexecdir" |
4cbafe13 RK |
253 | fi |
254 | fi | |
f03d4184 | 255 | AC_ARG_VAR([cgiexecdir], [location of cgi-bin directory, e.g. /usr/lib/cgi-bin]) |
64ac73bb RK |
256 | AC_ARG_VAR([httpdir], [location of http document root, e.g. /var/www/htdocs]) |
257 | if test -z "$pkghttpdir"; then | |
258 | pkghttpdir='$(httpdir)/disorder' | |
259 | fi | |
260 | AC_SUBST([pkghttpdir]) | |
4cbafe13 | 261 | |
7affb407 RK |
262 | subdirs="scripts lib" |
263 | if test $want_tests = yes; then | |
264 | subdirs="${subdirs} libtests" | |
265 | fi | |
266 | subdirs="${subdirs} clients doc examples debian" | |
460b9539 | 267 | |
268 | if test $want_server = yes; then | |
4cbafe13 RK |
269 | subdirs="${subdirs} server plugins driver sounds" |
270 | fi | |
271 | if test $want_cgi = yes; then | |
272 | subdirs="${subdirs} cgi templates images" | |
460b9539 | 273 | fi |
460b9539 | 274 | if test $want_gtk = yes; then |
275 | subdirs="${subdirs} disobedience" | |
276 | if test $want_server = no; then | |
277 | subdirs="${subdirs} images" | |
278 | fi | |
279 | fi | |
7affb407 | 280 | if test $want_tests = yes && test $want_python = yes; then |
56fac00d RK |
281 | AM_PATH_PYTHON([2.4]) |
282 | subdirs="${subdirs} python tests" | |
283 | fi | |
460b9539 | 284 | AC_SUBST([subdirs]) |
285 | ||
286 | # libtool config | |
287 | AC_LIBTOOL_DLOPEN | |
288 | AC_DISABLE_STATIC | |
289 | ||
290 | AC_PROG_LIBTOOL | |
291 | ||
edbd470f | 292 | AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[ |
293 | rjk_cv_gnused="not found" | |
294 | for candidate in sed gsed; do | |
295 | if $candidate --version >/dev/null 2>&1; then | |
296 | rjk_cv_gnused=$candidate | |
297 | fi | |
298 | done | |
299 | ]) | |
300 | GNUSED="${GNUSED:-$rjk_cv_gnused}" | |
301 | if test "$GNUSED" = "not found"; then | |
302 | AC_MSG_ERROR([GNU sed is required to build this program]) | |
303 | fi | |
304 | AC_SUBST([GNUSED]) | |
305 | ||
4b9b77a6 RK |
306 | AC_CHECK_PROGS([GROG],[grog]) |
307 | AM_CONDITIONAL([GROG],[test "x$GROG" != xnone]) | |
308 | ||
460b9539 | 309 | missing_libraries="" |
310 | missing_headers="" | |
311 | missing_functions="" | |
312 | ||
313 | AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal]) | |
314 | ||
2eee4b0c RK |
315 | AC_PATH_PROG([SENDMAIL],[sendmail],[none],[$PATH:/usr/sbin:/usr/lib]) |
316 | ||
460b9539 | 317 | # Macs might have libraries under fink's root |
318 | AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin]) | |
319 | if test "x$FINK" != xnone; then | |
320 | AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[ | |
321 | rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`" | |
322 | ]) | |
f9592fe7 | 323 | finkdir="${rjk_cv_finkprefix}" |
e83d0967 | 324 | finkbindir="${rjk_cv_finkprefix}/bin" |
762f2539 | 325 | CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include" |
460b9539 | 326 | if test $want_server = yes; then |
327 | CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4" | |
328 | fi | |
329 | LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib" | |
e83d0967 RK |
330 | else |
331 | finkbindir="" | |
460b9539 | 332 | fi |
f9592fe7 | 333 | AC_SUBST([finkdir]) |
e83d0967 | 334 | AC_SUBST([finkbindir]) |
460b9539 | 335 | |
336 | # Checks for libraries. | |
337 | # We save up a list of missing libraries that we can't do without | |
338 | # and report them all at once. | |
339 | AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])], | |
340 | [missing_libraries="$missing_libraries libgc"]) | |
341 | AC_CHECK_LIB(gcrypt, gcry_md_open, | |
342 | [AC_SUBST(LIBGCRYPT,[-lgcrypt])], | |
343 | [missing_libraries="$missing_libraries libgcrypt"]) | |
344 | AC_CHECK_LIB(pcre, pcre_compile, | |
345 | [AC_SUBST(LIBPCRE,[-lpcre])], | |
346 | [missing_libraries="$missing_libraries libpcre"]) | |
e2f0c461 RK |
347 | if test $want_alsa = yes; then |
348 | AC_CHECK_LIB([asound], [snd_pcm_open], | |
349 | [AC_SUBST(LIBASOUND,[-lasound])]) | |
350 | fi | |
460b9539 | 351 | if test $want_server = yes; then |
352 | RJK_CHECK_LIB(db, db_create, [#include <db.h>], | |
353 | [AC_SUBST(LIBDB,[-ldb])], | |
354 | [missing_libraries="$missing_libraries libdb"]) | |
355 | AC_CHECK_LIB(vorbis, vorbis_info_clear, | |
356 | [:], | |
357 | [missing_libraries="$missing_libraries libvorbis"]) | |
358 | AC_CHECK_LIB(vorbisfile, ov_open, | |
359 | [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])], | |
360 | [missing_libraries="$missing_libraries libvorbisfile"], | |
361 | [-lvorbis]) | |
362 | AC_CHECK_LIB(mad, mad_stream_init, | |
363 | [AC_SUBST(LIBMAD,[-lmad])], | |
364 | [missing_libraries="$missing_libraries libmad"]) | |
365 | AC_CHECK_LIB([ao], [ao_initialize], | |
366 | [AC_SUBST(LIBAO,[-lao])], | |
367 | [missing_libraries="$missing_libraries libao"]) | |
c57f1201 | 368 | AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], |
369 | [AC_SUBST(LIBFLAC,[-lFLAC])], | |
370 | [missing_libraries="$missing_libraries libFLAC"]) | |
d19ccd72 | 371 | fi |
edbd470f | 372 | AC_CHECK_LIB([pthread], [pthread_create], |
373 | [AC_SUBST(LIBPTHREAD,[-lpthread])], | |
374 | [missing_libraries="$missing_libraries libpthread"]) | |
460b9539 | 375 | |
376 | if test $want_gtk = yes; then | |
377 | AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"]) | |
378 | AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"]) | |
379 | fi | |
380 | ||
381 | # Some platforms have iconv already | |
382 | AC_CHECK_FUNC(iconv_open, [:], | |
383 | [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>], | |
384 | [AC_SUBST(LIBICONV,[-liconv])], | |
385 | [missing_functions="$missing_functions iconv_open"])]) | |
386 | AC_CHECK_FUNC([gethostbyname],[:],[ | |
387 | AC_CHECK_LIB(nsl,gethostbyname, | |
388 | [AC_SUBST(LIBNSL,[-lnsl])], | |
389 | [missing_functions="$missing_functions gethostbyname"])]) | |
390 | AC_CHECK_FUNC([socket],[:],[ | |
391 | AC_CHECK_LIB(socket,socket, | |
392 | [AC_SUBST(LIBSOCKET,[-lsocket])], | |
393 | [missing_functions="$missing_functions socket"])]) | |
394 | AC_CHECK_FUNC([dlopen],[:],[ | |
395 | AC_CHECK_LIB(dl,dlopen, | |
396 | [AC_SUBST(LIBDL,[-ldl])], | |
397 | [missing_functions="$missing_functions dlopen"])]) | |
398 | ||
399 | if test ! -z "$missing_libraries"; then | |
400 | AC_MSG_ERROR([missing libraries:$missing_libraries]) | |
401 | fi | |
402 | ||
460b9539 | 403 | # Checks for header files. |
404 | RJK_FIND_GC_H | |
e2f0c461 RK |
405 | if test $want_oss = yes; then |
406 | AC_CHECK_HEADERS([sys/soundcard.h]) | |
407 | fi | |
408 | if test $want_alsa = yes; then | |
409 | AC_CHECK_HEADERS([alsa/asoundlib.h]) | |
410 | fi | |
411 | if test $want_coreaudio = yes; then | |
412 | AC_CHECK_HEADERS([CoreAudio/AudioHardware.h]) | |
413 | fi | |
414 | AC_CHECK_HEADERS([inttypes.h]) | |
146e86fb | 415 | # We don't bother checking very standard stuff |
460b9539 | 416 | # Compilation will fail if any of these headers are missing, so we |
417 | # check for them here and fail early. | |
460b9539 | 418 | if test $want_server = yes; then |
419 | AC_CHECK_HEADERS([db.h],[:],[ | |
420 | missing_headers="$missing_headers $ac_header" | |
421 | ]) | |
762806f1 | 422 | AC_CHECK_HEADERS([FLAC/file_decoder.h]) |
460b9539 | 423 | fi |
424 | AC_CHECK_HEADERS([dlfcn.h gcrypt.h \ | |
425 | getopt.h iconv.h langinfo.h \ | |
426 | pcre.h sys/ioctl.h \ | |
427 | syslog.h unistd.h],[:],[ | |
428 | missing_headers="$missing_headers $ac_header" | |
429 | ]) | |
430 | ||
431 | if test ! -z "$missing_headers"; then | |
432 | AC_MSG_ERROR([missing headers:$missing_headers]) | |
433 | fi | |
434 | ||
70f47acd RK |
435 | # We require that libpcre support UTF-8 |
436 | RJK_REQUIRE_PCRE_UTF8([-lpcre]) | |
437 | ||
460b9539 | 438 | # Checks for typedefs, structures, and compiler characteristics. |
439 | AC_C_CONST | |
440 | AC_TYPE_SIZE_T | |
441 | AC_C_INLINE | |
5330d674 | 442 | AC_C_BIGENDIAN |
460b9539 | 443 | AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT |
444 | #include <netinet/in.h>]) | |
445 | ||
446 | # enable -Werror when we check for certain characteristics: | |
447 | ||
448 | old_CFLAGS="${CFLAGS}" | |
449 | CFLAGS="${CFLAGS} $gcc_werror" | |
450 | AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t]) | |
451 | ||
452 | # Some GCC invocations warn for converting function pointers to void *. | |
453 | # This is fair enough, as it's technically forbidden, but we use dlsym() | |
454 | # which can pretty much only exist if object and function pointers are | |
455 | # interconvertable. So we disable -Werror if need be. | |
456 | if test ! -z "$gcc_werror"; then | |
457 | AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning], | |
458 | [rjk_cv_function_pointer_cast],[ | |
459 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT | |
460 | void somefunction(void);], | |
461 | [(void *)somefunction])], | |
462 | [rjk_cv_function_pointer_cast=yes], | |
463 | [rjk_cv_function_pointer_cast=no])]) | |
464 | if test $rjk_cv_function_pointer_cast = no; then | |
465 | gcc_werror="" | |
466 | fi | |
467 | fi | |
468 | ||
469 | CFLAGS="${old_CFLAGS}" | |
470 | ||
471 | # gcrypt maintainers keep changing everything. Design your interface | |
472 | # first, then implement it once, rather than getting it wrong three or | |
473 | # four times and shipping between each attempt. | |
474 | AC_CACHE_CHECK([for hash handle type in <grypt.h>], | |
475 | [rjk_cv_gcrypt_hash_handle],[ | |
476 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT | |
477 | #include <gcrypt.h> | |
478 | ], | |
479 | [gcry_md_hd_t h;])], | |
480 | [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[ | |
481 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT | |
482 | #include <gcrypt.h> | |
483 | ], | |
484 | [GcryMDHd h;])], | |
485 | [rjk_cv_gcrypt_hash_handle=GcryMDHd], | |
486 | [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])]) | |
487 | AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle], | |
488 | [libgcrypt hash handle type]) | |
489 | ||
490 | AC_CACHE_CHECK([for gcry_error_t in <grypt.h>], | |
491 | [rjk_cv_have_gcry_error_t],[ | |
492 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT | |
493 | #include <gcrypt.h> | |
494 | ], | |
495 | [gcry_error_t e;])], | |
496 | [rjk_cv_have_gcry_error_t=yes], | |
497 | [rjk_cv_have_gcry_error_t=no])]) | |
498 | if test $rjk_cv_have_gcry_error_t = yes; then | |
499 | AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t]) | |
500 | fi | |
501 | ||
502 | # Checks for functions | |
503 | if test $ac_cv_type_long_long = yes; then | |
504 | AC_CHECK_FUNCS([atoll strtoll],[:],[ | |
505 | missing_functions="$missing_functions $ac_func" | |
506 | ]) | |
507 | # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99) | |
508 | AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>], | |
509 | [rjk_cv_strtoll_declared],[ | |
510 | AC_EGREP_HEADER([strtoll], [stdlib.h], | |
511 | [rjk_cv_strtoll_declared=yes], | |
512 | [rjk_cv_strtoll_declared=no])]) | |
513 | if test $rjk_cv_strtoll_declared = yes; then | |
514 | AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll]) | |
515 | fi | |
516 | AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>], | |
517 | [rjk_cv_atoll_declared],[ | |
518 | AC_EGREP_HEADER([atoll], [stdlib.h], | |
519 | [rjk_cv_atoll_declared=yes], | |
520 | [rjk_cv_atoll_declared=no])]) | |
521 | if test $rjk_cv_atoll_declared = yes; then | |
522 | AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll]) | |
523 | fi | |
524 | fi | |
5b708e0c | 525 | AC_CHECK_FUNCS([ioctl nl_langinfo strsignal setenv unsetenv],[:],[ |
460b9539 | 526 | missing_functions="$missing_functions $ac_func" |
527 | ]) | |
528 | # fsync will do if fdatasync not available | |
529 | AC_CHECK_FUNCS([fdatasync],[:],[ | |
530 | AC_CHECK_FUNCS([fsync], | |
531 | [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])], | |
532 | [missing_functions="$missing_functions fdatasync"])]) | |
533 | if test ! -z "$missing_functions"; then | |
534 | AC_MSG_ERROR([missing functions:$missing_functions]) | |
535 | fi | |
7c8c2fc9 RK |
536 | |
537 | # Functions we can take or leave | |
538 | AC_CHECK_FUNCS([fls]) | |
539 | ||
460b9539 | 540 | if test $want_server = yes; then |
541 | # <db.h> had better be version 3 or later | |
542 | AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[ | |
543 | AC_PREPROC_IFELSE([ | |
544 | #include <db.h> | |
545 | #ifndef DB_VERSION_MAJOR | |
546 | # error cannot determine db version | |
547 | #endif | |
548 | #if DB_VERSION_MAJOR < 4 | |
549 | # error inadequate db version | |
550 | #endif | |
f4687532 | 551 | #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2 |
460b9539 | 552 | # error inadequate db version |
553 | #endif | |
554 | ], | |
555 | [rjk_cv_db_version=ok], | |
556 | [rjk_cv_db_version=inadequate]) | |
557 | ]) | |
558 | if test $rjk_cv_db_version != ok; then | |
559 | AC_MSG_ERROR([need db.h version at least 4.2]) | |
560 | fi | |
561 | fi | |
562 | ||
e63c38e8 | 563 | AM_CONDITIONAL([SERVER], [test x$want_server = xyes]) |
588b2763 RK |
564 | if test $want_gtk = yes; then |
565 | AC_DEFINE([WITH_GTK], [1], [define if using GTK+]) | |
566 | fi | |
e63c38e8 | 567 | |
460b9539 | 568 | if test "x$GCC" = xyes; then |
e84ca290 RK |
569 | # We need LLONG_MAX and annoyingly GCC doesn't always give it to us |
570 | # by default. | |
571 | AC_CACHE_CHECK([what C version to ask for],[rjk_cv_cstd],[ | |
572 | AC_TRY_COMPILE([#include <limits.h>],[ | |
573 | long long n = LLONG_MAX; | |
574 | ],[rjk_cv_cstd=default],[ | |
575 | old_CC="$CC" | |
576 | CC="${CC} -std=gnu99" | |
577 | AC_TRY_COMPILE([#include <limits.h>],[ | |
578 | long long n = LLONG_MAX; | |
579 | ],[rjk_cv_cstd=gnu99],[rjk_cv_cstd=unknown]) | |
580 | CC="$old_CC" | |
581 | ]) | |
582 | ]) | |
583 | case $rjk_cv_cstd in | |
584 | default | unknown ) | |
585 | ;; | |
586 | * ) | |
587 | CC="${CC} -std=${rjk_cv_cstd}" | |
588 | ;; | |
589 | esac | |
590 | ||
f368d6c7 RK |
591 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478 |
592 | AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[ | |
593 | old_CC="$CC" | |
594 | if test $GCC = yes; then | |
595 | CC="$CC -Wall -Werror" | |
596 | fi | |
597 | AC_COMPILE_IFELSE([ | |
598 | static int x(char *f) { | |
599 | return *f; | |
600 | } | |
601 | int z(const char *g) { | |
602 | return x((char *)g); | |
603 | }], | |
604 | [rjk_cv_pr29478=no], | |
605 | [rjk_cv_pr29478=yes] | |
606 | ) | |
607 | CC="$old_CC" | |
608 | ]) | |
609 | if test $rjk_cv_pr29478 = yes; then | |
610 | gcc_werror='' | |
611 | fi | |
612 | ||
460b9539 | 613 | # a reasonable default set of warnings |
614 | CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \ | |
615 | -Wwrite-strings -Wmissing-prototypes \ | |
616 | -Wmissing-declarations -Wnested-externs" | |
617 | ||
618 | # Fix up GTK+ and GLib compiler flags | |
619 | GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`" | |
620 | GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`" | |
621 | ||
f368d6c7 RK |
622 | if test "$gcc_werror" != ''; then |
623 | # GCC 2.95 doesn't know to ignore warnings from system headers | |
624 | AC_CACHE_CHECK([whether -Werror is usable], | |
625 | rjk_cv_werror, [ | |
626 | save_CFLAGS="${CFLAGS}" | |
627 | CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror" | |
588b2763 RK |
628 | AC_TRY_COMPILE([#if WITH_GTK |
629 | #include <gtk/gtk.h> | |
630 | #endif | |
631 | ||
632 | struct s { int a, b; }; | |
633 | const struct s sv = { .a = 1 };], | |
f368d6c7 RK |
634 | [], |
635 | [rjk_cv_werror=yes], | |
636 | [rjk_cv_werror=no]) | |
637 | CFLAGS="${save_CFLAGS}" | |
638 | ]) | |
639 | if test $rjk_cv_werror = no; then | |
640 | gcc_werror='' | |
641 | fi | |
460b9539 | 642 | fi |
643 | CC="${CC} $gcc_werror" | |
644 | ||
645 | # for older GCCs that don't know %ju (etc) | |
9a5f7aba | 646 | AC_CACHE_CHECK([whether -Wno-format is required], |
460b9539 | 647 | rjk_cv_noformat, |
648 | AC_TRY_COMPILE([#include <stdio.h> | |
649 | #include <stdint.h> | |
650 | ], | |
651 | [printf("%ju", (uintmax_t)0);], | |
652 | [rjk_cv_noformat=no], | |
653 | [rjk_cv_noformat=yes])) | |
654 | if test $rjk_cv_noformat = yes; then | |
655 | CC="${CC} -Wno-format" | |
656 | fi | |
657 | ||
9a5f7aba | 658 | AC_CACHE_CHECK([whether -Wshadow is OK], |
460b9539 | 659 | rjk_cv_shadow, |
660 | oldCC="${CC}" | |
661 | CC="${CC} -Wshadow" | |
662 | [AC_TRY_COMPILE([ | |
663 | #include <unistd.h> | |
664 | #include <vorbis/vorbisfile.h> | |
665 | ], | |
666 | [], | |
667 | [rjk_cv_shadow=yes], | |
668 | [rjk_cv_shadow=no]) | |
669 | CC="${oldCC}"]) | |
670 | if test $rjk_cv_shadow = yes; then | |
671 | CC="${CC} -Wshadow" | |
672 | fi | |
460b9539 | 673 | fi |
674 | ||
1a00f590 RK |
675 | RJK_GCOV |
676 | ||
460b9539 | 677 | AH_BOTTOM([#ifdef __GNUC__ |
678 | # define attribute(x) __attribute__(x) | |
679 | #else | |
680 | # define attribute(x) | |
681 | #endif]) | |
682 | ||
683 | AC_CONFIG_FILES([Makefile | |
460b9539 | 684 | images/Makefile |
685 | scripts/Makefile | |
686 | lib/Makefile | |
687 | server/Makefile | |
05b75f8d | 688 | cgi/Makefile |
460b9539 | 689 | clients/Makefile |
690 | disobedience/Makefile | |
691 | doc/Makefile | |
3e1616b6 | 692 | templates/Makefile |
460b9539 | 693 | plugins/Makefile |
694 | driver/Makefile | |
695 | debian/Makefile | |
696 | sounds/Makefile | |
697 | python/Makefile | |
c5dbcd79 | 698 | examples/Makefile |
7affb407 | 699 | libtests/Makefile |
c5dbcd79 | 700 | tests/Makefile]) |
460b9539 | 701 | AC_OUTPUT |
f368d6c7 RK |
702 | |
703 | if test $GCC = yes && test "$gcc_werror" = ''; then | |
704 | AC_MSG_WARN([building without -Werror]) | |
705 | fi | |
56fac00d RK |
706 | if test $want_python = no; then |
707 | AC_MSG_WARN([cannot run the test suit without Python]) | |
708 | fi | |
4cbafe13 RK |
709 | |
710 | # Local Variables: | |
711 | # indent-tabs-mode:nil | |
712 | # End: |