1 # Process this file with autoconf to produce a configure script.
3 # This file is part of DisOrder.
4 # Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
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.
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.
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
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])
31 # What we want to build
35 # Checks for programs.
38 if test "x$GCC" = xyes; then
44 AC_MSG_CHECKING([for a known target platform])
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])
55 AC_MSG_RESULT([Linux])
59 AC_MSG_RESULT([Mac OS X])
61 COREAUDIO="-framework CoreAudio"
64 AC_MSG_RESULT([unknown, winging it])
71 [AS_HELP_STRING([--without-server],
72 [do not build server])],
73 [want_server=$withval])
75 [AS_HELP_STRING([--without-gtk],
76 [do not build GTK+ client])],
79 [AS_HELP_STRING([--without-python],
80 [do not build Python support])],
81 [want_python=$withval])
83 subdirs="scripts lib clients doc examples debian"
85 if test $want_server = yes; then
86 subdirs="${subdirs} server plugins driver templates sounds images"
88 if test $want_python = yes; then
90 subdirs="${subdirs} python"
92 if test $want_gtk = yes; then
93 subdirs="${subdirs} disobedience"
94 if test $want_server = no; then
95 subdirs="${subdirs} images"
98 subdirs="${subdirs} tests"
111 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
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$,,'`"
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"
124 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
128 AC_SUBST([finkbindir])
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,
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"],
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"])
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"])
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"])])
188 if test ! -z "$missing_libraries"; then
189 AC_MSG_ERROR([missing libraries:$missing_libraries])
192 # We require that libpcre support UTF-8
193 RJK_REQUIRE_PCRE_UTF8([-lpcre])
195 # Checks for header files.
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"
206 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
207 getopt.h iconv.h langinfo.h \
209 syslog.h unistd.h],[:],[
210 missing_headers="$missing_headers $ac_header"
213 if test ! -z "$missing_headers"; then
214 AC_MSG_ERROR([missing headers:$missing_headers])
217 # Checks for typedefs, structures, and compiler characteristics.
222 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
223 #include <netinet/in.h>])
225 # enable -Werror when we check for certain characteristics:
227 old_CFLAGS="${CFLAGS}"
228 CFLAGS="${CFLAGS} $gcc_werror"
229 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
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
248 CFLAGS="${old_CFLAGS}"
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
259 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
260 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
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])
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
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])
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"
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])
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])
304 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
305 missing_functions="$missing_functions $ac_func"
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])
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],[
320 #ifndef DB_VERSION_MAJOR
321 # error cannot determine db version
323 #if DB_VERSION_MAJOR < 4
324 # error inadequate db version
326 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 2
327 # error inadequate db version
330 [rjk_cv_db_version=ok],
331 [rjk_cv_db_version=inadequate])
333 if test $rjk_cv_db_version != ok; then
334 AC_MSG_ERROR([need db.h version at least 4.2])
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"
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'`"
348 # GCC 2.95 doesn't know to ignore warnings from system headers
349 AC_CACHE_CHECK([whether -Werror is usable],
351 save_CFLAGS="${CFLAGS}"
352 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
353 AC_TRY_COMPILE([#include <gtk/gtk.h>],
357 CFLAGS="${save_CFLAGS}"
359 if test $rjk_cv_werror = no; then
362 CC="${CC} $gcc_werror"
364 # for older GCCs that don't know %ju (etc)
365 AC_CACHE_CHECK([whether -Wno-format is required],
367 AC_TRY_COMPILE([#include <stdio.h>
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"
377 AC_CACHE_CHECK([whether -Wshadow is OK],
383 #include <vorbis/vorbisfile.h>
389 if test $rjk_cv_shadow = yes; then
396 AH_BOTTOM([#ifdef __GNUC__
397 # define attribute(x) __attribute__(x)
399 # define attribute(x)
402 AC_CONFIG_FILES([Makefile
409 disobedience/Makefile