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