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