chiark / gitweb /
A couple of fixes for Ubuntu Dapper:
[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, 2005, 2006, 2007 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 2 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, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # 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, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 # USA
21 #
22
23 AC_INIT([disorder], [2.0+], [richard+disorder@sfere.greenend.org.uk])
24 AC_CONFIG_AUX_DIR([config.aux])
25 AM_INIT_AUTOMAKE(disorder, [2.0+])
26 AC_CONFIG_SRCDIR([server/disorderd.c])
27 AM_CONFIG_HEADER([config.h])
28
29 # Find host type
30 AC_CANONICAL_HOST
31
32 # What we want to build
33 want_gtk=yes
34 want_python=yes
35
36 # APIs we want
37 want_alsa=yes
38 want_oss=yes
39 want_coreaudio=yes
40
41 # Checks for programs.
42 AC_PROG_CC
43 AC_SET_MAKE
44 if test "x$GCC" = xyes; then
45   gcc_werror=-Werror
46 else
47   gcc_werror=""
48 fi
49
50 AC_ARG_WITH([alsa],
51             [AS_HELP_STRING([--without-alsa],
52                             [do not build with ALSA support])],
53             [want_alsa=$withval])
54 AC_ARG_WITH([oss],
55             [AS_HELP_STRING([--without-oss],
56                             [do not build with OSS support])],
57             [want_oss=$withval])
58 AC_ARG_WITH([coreaudio],
59             [AS_HELP_STRING([--without-coreaudio],
60                             [do not build with Core Audio support])],
61             [want_coreaudio=$withval])
62
63 AC_MSG_CHECKING([for a known target platform])
64 case "$host" in
65 *empeg* )
66   AC_MSG_RESULT([empeg car stereo])
67   AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo])
68   # work around broken toolchain
69   AC_CHECK_LIB([gpg-error], [gpg_strerror])
70   AC_CHECK_LIB([pthread], [pthread_create])
71   want_server=no
72  ;;
73 *linux* | *Linux* )
74   AC_MSG_RESULT([Linux])
75   want_server=yes
76   ;;
77 *-apple-darwin* )
78   AC_MSG_RESULT([Mac OS X])
79   want_server=yes
80   if test $want_coreaudio = yes; then
81     COREAUDIO="-framework CoreAudio"
82   fi
83   browser=open
84   AC_MSG_CHECKING([Mac OS X target version])
85   # We honor MACOSX_DEPLOYMENT_TARGET in the environment, emulating gcc's
86   # behaviour.  But we provide a command line option to override it and
87   # we default to wide support instead of supporting only the build platform.
88   #
89   # Currently if you ask for 10.5 you will get a deprecation warning
90   # when building the CoreAudio support code.  For the time being the
91   # answer to this is "don't do that then".  If a good reason to ask
92   # for a 10.5 deployment target emerges then this will be fixed.
93   if test -z "$MACOSX_DEPLOYMENT_TARGET"; then
94     MACOSX_DEPLOYMENT_TARGET=10.0
95   fi
96   AC_ARG_WITH([deployment-target],
97               [AS_HELP_STRING([--with-deployment-target=TARGET],
98                               [set target OS X version])],
99               [MACOSX_DEPLOYMENT_TARGET=$withval])
100   # Convert to desired format
101   underscored=`echo $MACOSX_DEPLOYMENT_TARGET|sed 's/\./_/'`
102   minver="MAC_OS_X_VERSION_$underscored"
103   AC_MSG_RESULT([$minver])
104   AC_DEFINE_UNQUOTED([MAC_OS_X_VERSION_MIN_REQUIRED], [$minver],
105                      [define to minimum version of Mac OS X to support])
106   ;;
107 *-freebsd* )
108   AC_MSG_RESULT([FreeBSD])
109   want_server=yes
110   # Ports install to /usr/local but the compiler stupidly doesn't look
111   # there by default
112   LDFLAGS="${LDFLAGS} -L/usr/local/lib"
113   CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
114   # libdb installs elsewhere again
115   LDFLAGS="${LDFLAGS} -L/usr/local/lib/db44"
116   CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include/db44"
117   ;;
118 * )
119   AC_MSG_RESULT([unknown, winging it])
120   want_server=no
121   ;;
122 esac
123 AC_SUBST([COREAUDIO])
124
125 AC_ARG_WITH([browser],
126             [AS_HELP_STRING([--with-browser=BROWSER],
127                             [use BROWSER to display HTML])],
128             [browser=$withval])
129
130 AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
131   rjk_cv_browser=UNKNOWN
132   for candidate in x-www-browser sensible-browser firefox mozilla konqueror netscape; do
133     if type $candidate >/dev/null 2>&1; then
134       rjk_cv_browser="$candidate"
135       break
136     fi
137   done
138 ])
139 if test -z "$browser"; then
140   browser="$rjk_cv_browser"
141 fi
142 AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
143
144 AC_ARG_WITH([server],
145             [AS_HELP_STRING([--without-server],
146                             [do not build server])],
147             [want_server=$withval])
148 AC_ARG_WITH([gtk],
149             [AS_HELP_STRING([--without-gtk],
150                             [do not build GTK+ client])],
151             [want_gtk=$withval])
152 AC_ARG_WITH([python],
153             [AS_HELP_STRING([--without-python],
154                             [do not build Python support])],
155             [want_python=$withval])
156
157 subdirs="scripts lib clients doc examples debian"
158
159 if test $want_server = yes; then
160   subdirs="${subdirs} server plugins driver templates sounds images"
161 fi
162 if test $want_gtk = yes; then
163   subdirs="${subdirs} disobedience"
164   if test $want_server = no; then
165     subdirs="${subdirs} images"
166   fi
167 fi
168 if test $want_python = yes; then
169   AM_PATH_PYTHON([2.4])
170   subdirs="${subdirs} python tests"
171 fi
172 AC_SUBST([subdirs])
173
174 # libtool config
175 AC_LIBTOOL_DLOPEN
176 AC_DISABLE_STATIC
177
178 AC_PROG_LIBTOOL
179
180 AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[
181   rjk_cv_gnused="not found"
182   for candidate in sed gsed; do
183     if $candidate --version >/dev/null 2>&1; then
184       rjk_cv_gnused=$candidate 
185     fi
186   done
187 ])
188 GNUSED="${GNUSED:-$rjk_cv_gnused}"
189 if test "$GNUSED" = "not found"; then
190   AC_MSG_ERROR([GNU sed is required to build this program])
191 fi
192 AC_SUBST([GNUSED])
193
194 missing_libraries=""
195 missing_headers=""
196 missing_functions=""
197
198 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
199
200 # Macs might have libraries under fink's root
201 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
202 if test "x$FINK" != xnone; then
203   AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
204     rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
205   ])
206   finkdir="${rjk_cv_finkprefix}"
207   finkbindir="${rjk_cv_finkprefix}/bin"
208   CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
209   if test $want_server = yes; then
210     CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
211   fi
212   LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
213 else
214   finkbindir=""
215 fi
216 AC_SUBST([finkdir])
217 AC_SUBST([finkbindir])
218
219 # Checks for libraries.
220 # We save up a list of missing libraries that we can't do without
221 # and report them all at once.
222 AC_CHECK_LIB(gc, GC_malloc,            [AC_SUBST(LIBGC,[-lgc])],
223             [missing_libraries="$missing_libraries libgc"])
224 AC_CHECK_LIB(gcrypt, gcry_md_open,
225              [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
226             [missing_libraries="$missing_libraries libgcrypt"])
227 AC_CHECK_LIB(pcre, pcre_compile,
228              [AC_SUBST(LIBPCRE,[-lpcre])],
229              [missing_libraries="$missing_libraries libpcre"])
230 if test $want_alsa = yes; then
231   AC_CHECK_LIB([asound], [snd_pcm_open],
232                [AC_SUBST(LIBASOUND,[-lasound])])
233 fi
234 if test $want_server = yes; then
235   RJK_CHECK_LIB(db, db_create, [#include <db.h>],
236                [AC_SUBST(LIBDB,[-ldb])],
237                [missing_libraries="$missing_libraries libdb"])
238   AC_CHECK_LIB(vorbis, vorbis_info_clear,
239                [:],
240                [missing_libraries="$missing_libraries libvorbis"])
241   AC_CHECK_LIB(vorbisfile, ov_open,
242                [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
243                [missing_libraries="$missing_libraries libvorbisfile"],
244                [-lvorbis])
245   AC_CHECK_LIB(mad, mad_stream_init,
246                [AC_SUBST(LIBMAD,[-lmad])],
247                [missing_libraries="$missing_libraries libmad"])
248   AC_CHECK_LIB([ao], [ao_initialize],
249                [AC_SUBST(LIBAO,[-lao])],
250                [missing_libraries="$missing_libraries libao"])
251   AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
252                [AC_SUBST(LIBFLAC,[-lFLAC])],
253                [missing_libraries="$missing_libraries libFLAC"])
254 fi
255 AC_CHECK_LIB([pthread], [pthread_create],
256              [AC_SUBST(LIBPTHREAD,[-lpthread])],
257              [missing_libraries="$missing_libraries libpthread"])
258
259 if test $want_gtk = yes; then
260   AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
261   AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
262 fi
263
264 # Some platforms have iconv already
265 AC_CHECK_FUNC(iconv_open, [:],
266               [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
267                             [AC_SUBST(LIBICONV,[-liconv])],
268                             [missing_functions="$missing_functions iconv_open"])])
269 AC_CHECK_FUNC([gethostbyname],[:],[
270   AC_CHECK_LIB(nsl,gethostbyname,
271                [AC_SUBST(LIBNSL,[-lnsl])],
272                [missing_functions="$missing_functions gethostbyname"])])
273 AC_CHECK_FUNC([socket],[:],[
274   AC_CHECK_LIB(socket,socket,
275                [AC_SUBST(LIBSOCKET,[-lsocket])],
276                [missing_functions="$missing_functions socket"])])
277 AC_CHECK_FUNC([dlopen],[:],[
278   AC_CHECK_LIB(dl,dlopen,
279                [AC_SUBST(LIBDL,[-ldl])],
280                [missing_functions="$missing_functions dlopen"])])
281
282 if test ! -z "$missing_libraries"; then
283   AC_MSG_ERROR([missing libraries:$missing_libraries])
284 fi
285
286 # Checks for header files.
287 RJK_FIND_GC_H
288 if test $want_oss = yes; then
289   AC_CHECK_HEADERS([sys/soundcard.h])
290 fi
291 if test $want_alsa = yes; then
292   AC_CHECK_HEADERS([alsa/asoundlib.h])
293 fi
294 if test $want_coreaudio = yes; then
295   AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
296 fi
297 AC_CHECK_HEADERS([inttypes.h])
298 # We don't bother checking very standard stuff
299 # Compilation will fail if any of these headers are missing, so we
300 # check for them here and fail early.
301 if test $want_server = yes; then
302   AC_CHECK_HEADERS([db.h],[:],[
303     missing_headers="$missing_headers $ac_header"
304   ])
305   AC_CHECK_HEADERS([FLAC/file_decoder.h])
306 fi
307 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
308                  getopt.h iconv.h langinfo.h \
309                  pcre.h sys/ioctl.h \
310                  syslog.h unistd.h],[:],[
311   missing_headers="$missing_headers $ac_header"
312 ])
313
314 if test ! -z "$missing_headers"; then
315   AC_MSG_ERROR([missing headers:$missing_headers])
316 fi
317
318 # We require that libpcre support UTF-8
319 RJK_REQUIRE_PCRE_UTF8([-lpcre])
320
321 # Checks for typedefs, structures, and compiler characteristics.
322 AC_C_CONST
323 AC_TYPE_SIZE_T
324 AC_C_INLINE
325 AC_C_BIGENDIAN
326 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
327 #include <netinet/in.h>])
328
329 # enable -Werror when we check for certain characteristics:
330
331 old_CFLAGS="${CFLAGS}"
332 CFLAGS="${CFLAGS} $gcc_werror"
333 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
334
335 # Some GCC invocations warn for converting function pointers to void *.
336 # This is fair enough, as it's technically forbidden, but we use dlsym()
337 # which can pretty much only exist if object and function pointers are
338 # interconvertable.  So we disable -Werror if need be.
339 if test ! -z "$gcc_werror"; then
340   AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
341                  [rjk_cv_function_pointer_cast],[
342     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
343   void somefunction(void);],
344                       [(void *)somefunction])],
345                       [rjk_cv_function_pointer_cast=yes],
346                       [rjk_cv_function_pointer_cast=no])])
347   if test $rjk_cv_function_pointer_cast = no; then
348     gcc_werror=""
349   fi
350 fi
351
352 CFLAGS="${old_CFLAGS}"
353
354 # gcrypt maintainers keep changing everything.  Design your interface
355 # first, then implement it once, rather than getting it wrong three or
356 # four times and shipping between each attempt.
357 AC_CACHE_CHECK([for hash handle type in <grypt.h>],
358                [rjk_cv_gcrypt_hash_handle],[
359   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
360 #include <gcrypt.h>
361 ],
362                [gcry_md_hd_t h;])],
363                [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
364     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
365 #include <gcrypt.h>
366 ],
367                  [GcryMDHd h;])],
368                  [rjk_cv_gcrypt_hash_handle=GcryMDHd],
369                  [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
370 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
371                    [libgcrypt hash handle type])
372
373 AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
374                [rjk_cv_have_gcry_error_t],[
375   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
376 #include <gcrypt.h>
377 ],
378                  [gcry_error_t e;])],
379                  [rjk_cv_have_gcry_error_t=yes],
380                  [rjk_cv_have_gcry_error_t=no])])
381 if test $rjk_cv_have_gcry_error_t = yes; then
382   AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
383 fi
384
385 # Checks for functions
386 if test $ac_cv_type_long_long = yes; then
387   AC_CHECK_FUNCS([atoll strtoll],[:],[
388     missing_functions="$missing_functions $ac_func"
389   ])
390   # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
391   AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
392                  [rjk_cv_strtoll_declared],[
393     AC_EGREP_HEADER([strtoll], [stdlib.h],
394                     [rjk_cv_strtoll_declared=yes],
395                     [rjk_cv_strtoll_declared=no])])
396   if test $rjk_cv_strtoll_declared = yes; then
397     AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
398   fi
399   AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
400                  [rjk_cv_atoll_declared],[
401     AC_EGREP_HEADER([atoll], [stdlib.h],
402                     [rjk_cv_atoll_declared=yes],
403                     [rjk_cv_atoll_declared=no])])
404   if test $rjk_cv_atoll_declared = yes; then
405     AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
406   fi
407 fi
408 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
409   missing_functions="$missing_functions $ac_func"
410 ])
411 # fsync will do if fdatasync not available
412 AC_CHECK_FUNCS([fdatasync],[:],[
413   AC_CHECK_FUNCS([fsync],
414                  [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
415                  [missing_functions="$missing_functions fdatasync"])])
416 if test ! -z "$missing_functions"; then
417   AC_MSG_ERROR([missing functions:$missing_functions])
418 fi
419 if test $want_server = yes; then
420   # <db.h> had better be version 3 or later
421   AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
422     AC_PREPROC_IFELSE([
423                        #include <db.h>
424                        #ifndef DB_VERSION_MAJOR
425                        # error cannot determine db version
426                        #endif
427                        #if DB_VERSION_MAJOR < 4
428                        # error inadequate db version
429                        #endif
430                        #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2
431                        # error inadequate db version
432                        #endif
433                       ],
434                       [rjk_cv_db_version=ok],
435                       [rjk_cv_db_version=inadequate])
436   ])
437   if test $rjk_cv_db_version != ok; then
438     AC_MSG_ERROR([need db.h version at least 4.2])
439   fi
440 fi
441
442 if test "x$GCC" = xyes; then
443   # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
444   AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
445     old_CC="$CC"
446     if test $GCC = yes; then
447       CC="$CC -Wall -Werror"
448     fi
449     AC_COMPILE_IFELSE([
450       static int x(char *f) {
451        return *f;
452       }
453       int z(const char *g) {
454         return x((char *)g);
455       }],
456       [rjk_cv_pr29478=no],
457       [rjk_cv_pr29478=yes]
458     )
459     CC="$old_CC"
460   ])
461   if test $rjk_cv_pr29478 = yes; then
462     gcc_werror=''
463   fi
464
465   # a reasonable default set of warnings
466   CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
467         -Wwrite-strings -Wmissing-prototypes \
468         -Wmissing-declarations -Wnested-externs"
469
470   # Fix up GTK+ and GLib compiler flags
471   GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
472   GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
473
474   if test "$gcc_werror" != ''; then
475     # GCC 2.95 doesn't know to ignore warnings from system headers
476     AC_CACHE_CHECK([whether -Werror is usable],
477                     rjk_cv_werror, [
478       save_CFLAGS="${CFLAGS}"
479       CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
480       AC_TRY_COMPILE([#include <gtk/gtk.h>],
481                      [],
482                      [rjk_cv_werror=yes],
483                      [rjk_cv_werror=no])
484       CFLAGS="${save_CFLAGS}"
485     ])
486     if test $rjk_cv_werror = no; then
487       gcc_werror=''
488     fi
489   fi
490   CC="${CC} $gcc_werror"
491
492   # for older GCCs that don't know %ju (etc)
493   AC_CACHE_CHECK([whether -Wno-format is required],
494                  rjk_cv_noformat,
495                  AC_TRY_COMPILE([#include <stdio.h>
496 #include <stdint.h>
497 ],
498                                 [printf("%ju", (uintmax_t)0);],
499                                 [rjk_cv_noformat=no],
500                                 [rjk_cv_noformat=yes]))
501   if test $rjk_cv_noformat = yes; then
502     CC="${CC} -Wno-format"
503   fi
504
505   AC_CACHE_CHECK([whether -Wshadow is OK],
506                  rjk_cv_shadow,
507                  oldCC="${CC}"
508                  CC="${CC} -Wshadow"
509                  [AC_TRY_COMPILE([
510 #include <unistd.h>
511 #include <vorbis/vorbisfile.h>
512 ],
513                                 [],
514                                 [rjk_cv_shadow=yes],
515                                 [rjk_cv_shadow=no])
516                  CC="${oldCC}"])
517   if test $rjk_cv_shadow = yes; then
518     CC="${CC} -Wshadow"
519   fi
520 fi
521
522 RJK_GCOV
523
524 AH_BOTTOM([#ifdef __GNUC__
525 # define attribute(x) __attribute__(x)
526 #else
527 # define attribute(x)
528 #endif])
529
530 AC_CONFIG_FILES([Makefile
531                  templates/Makefile
532                  images/Makefile
533                  scripts/Makefile
534                  lib/Makefile
535                  server/Makefile
536                  clients/Makefile
537                  disobedience/Makefile
538                  doc/Makefile
539                  plugins/Makefile
540                  driver/Makefile
541                  debian/Makefile
542                  sounds/Makefile
543                  python/Makefile
544                  examples/Makefile
545                  tests/Makefile])
546 AC_OUTPUT
547
548 if test $GCC = yes && test "$gcc_werror" = ''; then
549   AC_MSG_WARN([building without -Werror])
550 fi
551 if test $want_python = no; then
552   AC_MSG_WARN([cannot run the test suit without Python])
553 fi