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