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