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