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