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