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