chiark / gitweb /
split backends out into their own speaker-*.c
[disorder] / configure.ac
CommitLineData
460b9539 1# Process this file with autoconf to produce a configure script.
2#
3# This file is part of DisOrder.
dea8f8aa 4# Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
460b9539 5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19# USA
20#
21
187f23fb 22AC_INIT(disorder, 1.5.99+, richard+disorder@sfere.greenend.org.uk)
460b9539 23AC_CONFIG_AUX_DIR([config.aux])
187f23fb 24AM_INIT_AUTOMAKE(disorder, 1.5.99+)
460b9539 25AC_CONFIG_SRCDIR([server/disorderd.c])
26AM_CONFIG_HEADER([config.h])
27
dea8f8aa
RK
28# Find host type
29AC_CANONICAL_HOST
30
460b9539 31# What we want to build
32want_server=yes
33want_gtk=yes
34want_python=yes
35
dea8f8aa
RK
36case "$host" in
37*linux* | *Linux* )
8023f60b 38 want_alsa=yes
dea8f8aa 39 ;;
9086a105
RK
40*-apple-darwin* )
41 want_alsa=no
42 COREAUDIO="-framework CoreAudio"
43 ;;
dea8f8aa 44* )
8023f60b 45 want_alsa=no
dea8f8aa
RK
46 ;;
47esac
9086a105 48AC_SUBST([COREAUDIO])
dea8f8aa 49
460b9539 50# Checks for programs.
51AC_PROG_CC
52AC_SET_MAKE
53if test "x$GCC" = xyes; then
54 gcc_werror=-Werror
55else
56 gcc_werror=""
57fi
58
59AC_ARG_WITH([server],
60 [AS_HELP_STRING([--without-server],
61 [do not build server])],
62 [want_server=$withval])
63AC_ARG_WITH([gtk],
64 [AS_HELP_STRING([--without-gtk],
65 [do not build GTK+ client])],
66 [want_gtk=$withval])
67AC_ARG_WITH([python],
68 [AS_HELP_STRING([--without-python],
69 [do not build Python support])],
70 [want_python=$withval])
71
1798e51d 72subdirs="scripts lib clients doc examples debian"
460b9539 73
74if test $want_server = yes; then
75 subdirs="${subdirs} server plugins driver templates sounds images"
76fi
77if test $want_python = yes; then
78 AM_PATH_PYTHON
79 subdirs="${subdirs} python"
80fi
81if test $want_gtk = yes; then
82 subdirs="${subdirs} disobedience"
83 if test $want_server = no; then
84 subdirs="${subdirs} images"
85 fi
86fi
1798e51d 87subdirs="${subdirs} tests"
460b9539 88AC_SUBST([subdirs])
89
90# libtool config
91AC_LIBTOOL_DLOPEN
92AC_DISABLE_STATIC
93
94AC_PROG_LIBTOOL
95
96missing_libraries=""
97missing_headers=""
98missing_functions=""
99
100AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
101
102# Macs might have libraries under fink's root
103AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
104if test "x$FINK" != xnone; then
105 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
106 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
107 ])
e83d0967 108 finkbindir="${rjk_cv_finkprefix}/bin"
762f2539 109 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
460b9539 110 if test $want_server = yes; then
111 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
112 fi
113 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
e83d0967
RK
114else
115 finkbindir=""
460b9539 116fi
e83d0967 117AC_SUBST([finkbindir])
460b9539 118
119# Checks for libraries.
120# We save up a list of missing libraries that we can't do without
121# and report them all at once.
122AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
123 [missing_libraries="$missing_libraries libgc"])
124AC_CHECK_LIB(gcrypt, gcry_md_open,
125 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
126 [missing_libraries="$missing_libraries libgcrypt"])
127AC_CHECK_LIB(pcre, pcre_compile,
128 [AC_SUBST(LIBPCRE,[-lpcre])],
129 [missing_libraries="$missing_libraries libpcre"])
130if test $want_server = yes; then
131 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
132 [AC_SUBST(LIBDB,[-ldb])],
133 [missing_libraries="$missing_libraries libdb"])
134 AC_CHECK_LIB(vorbis, vorbis_info_clear,
135 [:],
136 [missing_libraries="$missing_libraries libvorbis"])
137 AC_CHECK_LIB(vorbisfile, ov_open,
138 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
139 [missing_libraries="$missing_libraries libvorbisfile"],
140 [-lvorbis])
141 AC_CHECK_LIB(mad, mad_stream_init,
142 [AC_SUBST(LIBMAD,[-lmad])],
143 [missing_libraries="$missing_libraries libmad"])
144 AC_CHECK_LIB([ao], [ao_initialize],
145 [AC_SUBST(LIBAO,[-lao])],
146 [missing_libraries="$missing_libraries libao"])
d19ccd72
RK
147fi
148if test $want_alsa = yes; then
149 AC_CHECK_LIB([asound], [snd_pcm_open],
150 [AC_SUBST(LIBASOUND,[-lasound])],
151 [missing_libraries="$missing_libraries libasound"])
152 AC_DEFINE([API_ALSA],[1],[define to use the ALSA API])
460b9539 153fi
154
155if test $want_gtk = yes; then
156 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
157 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
158fi
159
160# Some platforms have iconv already
161AC_CHECK_FUNC(iconv_open, [:],
162 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
163 [AC_SUBST(LIBICONV,[-liconv])],
164 [missing_functions="$missing_functions iconv_open"])])
165AC_CHECK_FUNC([gethostbyname],[:],[
166 AC_CHECK_LIB(nsl,gethostbyname,
167 [AC_SUBST(LIBNSL,[-lnsl])],
168 [missing_functions="$missing_functions gethostbyname"])])
169AC_CHECK_FUNC([socket],[:],[
170 AC_CHECK_LIB(socket,socket,
171 [AC_SUBST(LIBSOCKET,[-lsocket])],
172 [missing_functions="$missing_functions socket"])])
173AC_CHECK_FUNC([dlopen],[:],[
174 AC_CHECK_LIB(dl,dlopen,
175 [AC_SUBST(LIBDL,[-ldl])],
176 [missing_functions="$missing_functions dlopen"])])
177
178if test ! -z "$missing_libraries"; then
179 AC_MSG_ERROR([missing libraries:$missing_libraries])
180fi
181
182# We require that libpcre support UTF-8
183RJK_REQUIRE_PCRE_UTF8([-lpcre])
184
185# Checks for header files.
186RJK_FIND_GC_H
e83d0967 187AC_CHECK_HEADERS([inttypes.h CoreAudio/AudioHardware.h])
460b9539 188# Compilation will fail if any of these headers are missing, so we
189# check for them here and fail early.
190# We don't bother checking very standard stuff
191if test $want_server = yes; then
192 AC_CHECK_HEADERS([db.h],[:],[
193 missing_headers="$missing_headers $ac_header"
194 ])
195 AC_CHECK_HEADERS([sys/soundcard.h]) dnl can cope without
196fi
197AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
198 getopt.h iconv.h langinfo.h \
199 pcre.h sys/ioctl.h \
200 syslog.h unistd.h],[:],[
201 missing_headers="$missing_headers $ac_header"
202])
203
204if test ! -z "$missing_headers"; then
205 AC_MSG_ERROR([missing headers:$missing_headers])
206fi
207
208# Checks for typedefs, structures, and compiler characteristics.
209AC_C_CONST
210AC_TYPE_SIZE_T
211AC_C_INLINE
5330d674 212AC_C_BIGENDIAN
460b9539 213AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
214#include <netinet/in.h>])
215
216# enable -Werror when we check for certain characteristics:
217
218old_CFLAGS="${CFLAGS}"
219CFLAGS="${CFLAGS} $gcc_werror"
220AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
221
222# Some GCC invocations warn for converting function pointers to void *.
223# This is fair enough, as it's technically forbidden, but we use dlsym()
224# which can pretty much only exist if object and function pointers are
225# interconvertable. So we disable -Werror if need be.
226if test ! -z "$gcc_werror"; then
227 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
228 [rjk_cv_function_pointer_cast],[
229 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
230 void somefunction(void);],
231 [(void *)somefunction])],
232 [rjk_cv_function_pointer_cast=yes],
233 [rjk_cv_function_pointer_cast=no])])
234 if test $rjk_cv_function_pointer_cast = no; then
235 gcc_werror=""
236 fi
237fi
238
239CFLAGS="${old_CFLAGS}"
240
241# gcrypt maintainers keep changing everything. Design your interface
242# first, then implement it once, rather than getting it wrong three or
243# four times and shipping between each attempt.
244AC_CACHE_CHECK([for hash handle type in <grypt.h>],
245 [rjk_cv_gcrypt_hash_handle],[
246 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
247#include <gcrypt.h>
248],
249 [gcry_md_hd_t h;])],
250 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
251 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
252#include <gcrypt.h>
253],
254 [GcryMDHd h;])],
255 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
256 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
257AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
258 [libgcrypt hash handle type])
259
260AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
261 [rjk_cv_have_gcry_error_t],[
262 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
263#include <gcrypt.h>
264],
265 [gcry_error_t e;])],
266 [rjk_cv_have_gcry_error_t=yes],
267 [rjk_cv_have_gcry_error_t=no])])
268if test $rjk_cv_have_gcry_error_t = yes; then
269 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
270fi
271
272# Checks for functions
273if test $ac_cv_type_long_long = yes; then
274 AC_CHECK_FUNCS([atoll strtoll],[:],[
275 missing_functions="$missing_functions $ac_func"
276 ])
277 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
278 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
279 [rjk_cv_strtoll_declared],[
280 AC_EGREP_HEADER([strtoll], [stdlib.h],
281 [rjk_cv_strtoll_declared=yes],
282 [rjk_cv_strtoll_declared=no])])
283 if test $rjk_cv_strtoll_declared = yes; then
284 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
285 fi
286 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
287 [rjk_cv_atoll_declared],[
288 AC_EGREP_HEADER([atoll], [stdlib.h],
289 [rjk_cv_atoll_declared=yes],
290 [rjk_cv_atoll_declared=no])])
291 if test $rjk_cv_atoll_declared = yes; then
292 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
293 fi
294fi
295AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
296 missing_functions="$missing_functions $ac_func"
297])
298# fsync will do if fdatasync not available
299AC_CHECK_FUNCS([fdatasync],[:],[
300 AC_CHECK_FUNCS([fsync],
301 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
302 [missing_functions="$missing_functions fdatasync"])])
303if test ! -z "$missing_functions"; then
304 AC_MSG_ERROR([missing functions:$missing_functions])
305fi
306if test $want_server = yes; then
307 # <db.h> had better be version 3 or later
308 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
309 AC_PREPROC_IFELSE([
310 #include <db.h>
311 #ifndef DB_VERSION_MAJOR
312 # error cannot determine db version
313 #endif
314 #if DB_VERSION_MAJOR < 4
315 # error inadequate db version
316 #endif
317 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 2
318 # error inadequate db version
319 #endif
320 ],
321 [rjk_cv_db_version=ok],
322 [rjk_cv_db_version=inadequate])
323 ])
324 if test $rjk_cv_db_version != ok; then
325 AC_MSG_ERROR([need db.h version at least 4.2])
326 fi
327fi
328
329if test "x$GCC" = xyes; then
330 # a reasonable default set of warnings
331 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
332 -Wwrite-strings -Wmissing-prototypes \
333 -Wmissing-declarations -Wnested-externs"
334
335 # Fix up GTK+ and GLib compiler flags
336 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
337 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
338
339 # GCC 2.95 doesn't know to ignore warnings from system headers
340 AC_CACHE_CHECK([whether -Werror is usable],
341 rjk_cv_werror, [
342 save_CFLAGS="${CFLAGS}"
343 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
344 AC_TRY_COMPILE([#include <gtk/gtk.h>],
345 [],
346 [rjk_cv_werror=yes],
347 [rjk_cv_werror=no])
348 CFLAGS="${save_CFLAGS}"
349 ])
350 if test $rjk_cv_werror = no; then
351 gcc_werror=''
352 fi
353 CC="${CC} $gcc_werror"
354
355 # for older GCCs that don't know %ju (etc)
9a5f7aba 356 AC_CACHE_CHECK([whether -Wno-format is required],
460b9539 357 rjk_cv_noformat,
358 AC_TRY_COMPILE([#include <stdio.h>
359#include <stdint.h>
360],
361 [printf("%ju", (uintmax_t)0);],
362 [rjk_cv_noformat=no],
363 [rjk_cv_noformat=yes]))
364 if test $rjk_cv_noformat = yes; then
365 CC="${CC} -Wno-format"
366 fi
367
9a5f7aba 368 AC_CACHE_CHECK([whether -Wshadow is OK],
460b9539 369 rjk_cv_shadow,
370 oldCC="${CC}"
371 CC="${CC} -Wshadow"
372 [AC_TRY_COMPILE([
373#include <unistd.h>
374#include <vorbis/vorbisfile.h>
375],
376 [],
377 [rjk_cv_shadow=yes],
378 [rjk_cv_shadow=no])
379 CC="${oldCC}"])
380 if test $rjk_cv_shadow = yes; then
381 CC="${CC} -Wshadow"
382 fi
383
384
385fi
386
387AH_BOTTOM([#ifdef __GNUC__
388# define attribute(x) __attribute__(x)
389#else
390# define attribute(x)
391#endif])
392
393AC_CONFIG_FILES([Makefile
394 templates/Makefile
395 images/Makefile
396 scripts/Makefile
397 lib/Makefile
398 server/Makefile
399 clients/Makefile
400 disobedience/Makefile
401 doc/Makefile
402 plugins/Makefile
403 driver/Makefile
404 debian/Makefile
405 sounds/Makefile
406 python/Makefile
c5dbcd79
RK
407 examples/Makefile
408 tests/Makefile])
460b9539 409AC_OUTPUT