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