further empeg support
[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 #
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
22 AC_INIT(disorder, 1.5.99+, richard+disorder@sfere.greenend.org.uk)
23 AC_CONFIG_AUX_DIR([config.aux])
24 AM_INIT_AUTOMAKE(disorder, 1.5.99+)
25 AC_CONFIG_SRCDIR([server/disorderd.c])
26 AM_CONFIG_HEADER([config.h])
27
28 # Find host type
29 AC_CANONICAL_HOST
30
31 # What we want to build
32 want_gtk=yes
33 want_python=yes
34
35 # Checks for programs.
36 AC_PROG_CC
37 AC_SET_MAKE
38 if test "x$GCC" = xyes; then
39 gcc_werror=-Werror
40 else
41 gcc_werror=""
42 fi
43
44 AC_MSG_CHECKING([for a known target platform])
45 case "$host" in
46 *empeg* )
47 AC_MSG_RESULT([empeg car stereo])
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])
51 AC_CHECK_LIB([pthread], [pthread_create])
52 want_server=no
53 ;;
54 *linux* | *Linux* )
55 AC_MSG_RESULT([Linux])
56 want_server=yes
57 ;;
58 *-apple-darwin* )
59 AC_MSG_RESULT([Mac OS X])
60 want_server=no
61 COREAUDIO="-framework CoreAudio"
62 ;;
63 * )
64 AC_MSG_RESULT([unknown, winging it])
65 want_server=no
66 ;;
67 esac
68 AC_SUBST([COREAUDIO])
69
70 AC_ARG_WITH([server],
71 [AS_HELP_STRING([--without-server],
72 [do not build server])],
73 [want_server=$withval])
74 AC_ARG_WITH([gtk],
75 [AS_HELP_STRING([--without-gtk],
76 [do not build GTK+ client])],
77 [want_gtk=$withval])
78 AC_ARG_WITH([python],
79 [AS_HELP_STRING([--without-python],
80 [do not build Python support])],
81 [want_python=$withval])
82
83 subdirs="scripts lib clients doc examples debian"
84
85 if test $want_server = yes; then
86 subdirs="${subdirs} server plugins driver templates sounds images"
87 fi
88 if test $want_python = yes; then
89 AM_PATH_PYTHON
90 subdirs="${subdirs} python"
91 fi
92 if test $want_gtk = yes; then
93 subdirs="${subdirs} disobedience"
94 if test $want_server = no; then
95 subdirs="${subdirs} images"
96 fi
97 fi
98 subdirs="${subdirs} tests"
99 AC_SUBST([subdirs])
100
101 # libtool config
102 AC_LIBTOOL_DLOPEN
103 AC_DISABLE_STATIC
104
105 AC_PROG_LIBTOOL
106
107 missing_libraries=""
108 missing_headers=""
109 missing_functions=""
110
111 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
112
113 # Macs might have libraries under fink's root
114 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
115 if 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 ])
119 finkbindir="${rjk_cv_finkprefix}/bin"
120 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
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"
125 else
126 finkbindir=""
127 fi
128 AC_SUBST([finkbindir])
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.
133 AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
134 [missing_libraries="$missing_libraries libgc"])
135 AC_CHECK_LIB(gcrypt, gcry_md_open,
136 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
137 [missing_libraries="$missing_libraries libgcrypt"])
138 AC_CHECK_LIB(pcre, pcre_compile,
139 [AC_SUBST(LIBPCRE,[-lpcre])],
140 [missing_libraries="$missing_libraries libpcre"])
141 AC_CHECK_LIB([asound], [snd_pcm_open],
142 [AC_SUBST(LIBASOUND,[-lasound])])
143 if 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"])
160 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
161 [AC_SUBST(LIBFLAC,[-lFLAC])],
162 [missing_libraries="$missing_libraries libFLAC"])
163 fi
164
165 if 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"])
168 fi
169
170 # Some platforms have iconv already
171 AC_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"])])
175 AC_CHECK_FUNC([gethostbyname],[:],[
176 AC_CHECK_LIB(nsl,gethostbyname,
177 [AC_SUBST(LIBNSL,[-lnsl])],
178 [missing_functions="$missing_functions gethostbyname"])])
179 AC_CHECK_FUNC([socket],[:],[
180 AC_CHECK_LIB(socket,socket,
181 [AC_SUBST(LIBSOCKET,[-lsocket])],
182 [missing_functions="$missing_functions socket"])])
183 AC_CHECK_FUNC([dlopen],[:],[
184 AC_CHECK_LIB(dl,dlopen,
185 [AC_SUBST(LIBDL,[-ldl])],
186 [missing_functions="$missing_functions dlopen"])])
187
188 if test ! -z "$missing_libraries"; then
189 AC_MSG_ERROR([missing libraries:$missing_libraries])
190 fi
191
192 # We require that libpcre support UTF-8
193 RJK_REQUIRE_PCRE_UTF8([-lpcre])
194
195 # Checks for header files.
196 RJK_FIND_GC_H
197 AC_CHECK_HEADERS([inttypes.h CoreAudio/AudioHardware.h sys/soundcard.h alsa/asoundlib.h])
198 # We don't bother checking very standard stuff
199 # Compilation will fail if any of these headers are missing, so we
200 # check for them here and fail early.
201 if test $want_server = yes; then
202 AC_CHECK_HEADERS([db.h],[:],[
203 missing_headers="$missing_headers $ac_header"
204 ])
205 fi
206 AC_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
213 if test ! -z "$missing_headers"; then
214 AC_MSG_ERROR([missing headers:$missing_headers])
215 fi
216
217 # Checks for typedefs, structures, and compiler characteristics.
218 AC_C_CONST
219 AC_TYPE_SIZE_T
220 AC_C_INLINE
221 AC_C_BIGENDIAN
222 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
223 #include <netinet/in.h>])
224
225 # enable -Werror when we check for certain characteristics:
226
227 old_CFLAGS="${CFLAGS}"
228 CFLAGS="${CFLAGS} $gcc_werror"
229 AC_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.
235 if 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
246 fi
247
248 CFLAGS="${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.
253 AC_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])])])
266 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
267 [libgcrypt hash handle type])
268
269 AC_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])])
277 if 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])
279 fi
280
281 # Checks for functions
282 if 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
303 fi
304 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
305 missing_functions="$missing_functions $ac_func"
306 ])
307 # fsync will do if fdatasync not available
308 AC_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"])])
312 if test ! -z "$missing_functions"; then
313 AC_MSG_ERROR([missing functions:$missing_functions])
314 fi
315 if 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
336 fi
337
338 if 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)
365 AC_CACHE_CHECK([whether -Wno-format is required],
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
377 AC_CACHE_CHECK([whether -Wshadow is OK],
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
394 fi
395
396 AH_BOTTOM([#ifdef __GNUC__
397 # define attribute(x) __attribute__(x)
398 #else
399 # define attribute(x)
400 #endif])
401
402 AC_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
416 examples/Makefile
417 tests/Makefile])
418 AC_OUTPUT