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