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