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
45 # Checks for programs.
48 if test "x$GCC" = xyes; then
55 [AS_HELP_STRING([--without-server],
56 [do not build server])],
57 [want_server=$withval])
59 [AS_HELP_STRING([--without-gtk],
60 [do not build GTK+ client])],
63 [AS_HELP_STRING([--without-python],
64 [do not build Python support])],
65 [want_python=$withval])
67 subdirs="scripts lib clients doc examples debian"
69 if test $want_server = yes; then
70 subdirs="${subdirs} server plugins driver templates sounds images"
72 if test $want_python = yes; then
74 subdirs="${subdirs} python"
76 if test $want_gtk = yes; then
77 subdirs="${subdirs} disobedience"
78 if test $want_server = no; then
79 subdirs="${subdirs} images"
82 subdirs="${subdirs} tests"
95 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
97 # Macs might have libraries under fink's root
98 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
99 if test "x$FINK" != xnone; then
100 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
101 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
103 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
104 if test $want_server = yes; then
105 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
107 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
110 # Checks for libraries.
111 # We save up a list of missing libraries that we can't do without
112 # and report them all at once.
113 AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
114 [missing_libraries="$missing_libraries libgc"])
115 AC_CHECK_LIB(gcrypt, gcry_md_open,
116 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
117 [missing_libraries="$missing_libraries libgcrypt"])
118 AC_CHECK_LIB(pcre, pcre_compile,
119 [AC_SUBST(LIBPCRE,[-lpcre])],
120 [missing_libraries="$missing_libraries libpcre"])
121 if test $want_server = yes; then
122 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
123 [AC_SUBST(LIBDB,[-ldb])],
124 [missing_libraries="$missing_libraries libdb"])
125 AC_CHECK_LIB(vorbis, vorbis_info_clear,
127 [missing_libraries="$missing_libraries libvorbis"])
128 AC_CHECK_LIB(vorbisfile, ov_open,
129 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
130 [missing_libraries="$missing_libraries libvorbisfile"],
132 AC_CHECK_LIB(mad, mad_stream_init,
133 [AC_SUBST(LIBMAD,[-lmad])],
134 [missing_libraries="$missing_libraries libmad"])
135 AC_CHECK_LIB([ao], [ao_initialize],
136 [AC_SUBST(LIBAO,[-lao])],
137 [missing_libraries="$missing_libraries libao"])
138 if test $want_alsa = yes; then
139 AC_CHECK_LIB([asound], [snd_pcm_open],
140 [AC_SUBST(LIBASOUND,[-lasound])],
141 [missing_libraries="$missing_libraries libasound"])
142 AC_DEFINE([API_ALSA],[1],[define to use the ALSA API])
146 if test $want_gtk = yes; then
147 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
148 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
151 # Some platforms have iconv already
152 AC_CHECK_FUNC(iconv_open, [:],
153 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
154 [AC_SUBST(LIBICONV,[-liconv])],
155 [missing_functions="$missing_functions iconv_open"])])
156 AC_CHECK_FUNC([gethostbyname],[:],[
157 AC_CHECK_LIB(nsl,gethostbyname,
158 [AC_SUBST(LIBNSL,[-lnsl])],
159 [missing_functions="$missing_functions gethostbyname"])])
160 AC_CHECK_FUNC([socket],[:],[
161 AC_CHECK_LIB(socket,socket,
162 [AC_SUBST(LIBSOCKET,[-lsocket])],
163 [missing_functions="$missing_functions socket"])])
164 AC_CHECK_FUNC([dlopen],[:],[
165 AC_CHECK_LIB(dl,dlopen,
166 [AC_SUBST(LIBDL,[-ldl])],
167 [missing_functions="$missing_functions dlopen"])])
169 if test ! -z "$missing_libraries"; then
170 AC_MSG_ERROR([missing libraries:$missing_libraries])
173 # We require that libpcre support UTF-8
174 RJK_REQUIRE_PCRE_UTF8([-lpcre])
176 # Checks for header files.
178 AC_CHECK_HEADERS([inttypes.h])
179 # Compilation will fail if any of these headers are missing, so we
180 # check for them here and fail early.
181 # We don't bother checking very standard stuff
182 if test $want_server = yes; then
183 AC_CHECK_HEADERS([db.h],[:],[
184 missing_headers="$missing_headers $ac_header"
186 AC_CHECK_HEADERS([sys/soundcard.h]) dnl can cope without
188 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
189 getopt.h iconv.h langinfo.h \
191 syslog.h unistd.h],[:],[
192 missing_headers="$missing_headers $ac_header"
195 if test ! -z "$missing_headers"; then
196 AC_MSG_ERROR([missing headers:$missing_headers])
199 # Checks for typedefs, structures, and compiler characteristics.
204 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
205 #include <netinet/in.h>])
207 # enable -Werror when we check for certain characteristics:
209 old_CFLAGS="${CFLAGS}"
210 CFLAGS="${CFLAGS} $gcc_werror"
211 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
213 # Some GCC invocations warn for converting function pointers to void *.
214 # This is fair enough, as it's technically forbidden, but we use dlsym()
215 # which can pretty much only exist if object and function pointers are
216 # interconvertable. So we disable -Werror if need be.
217 if test ! -z "$gcc_werror"; then
218 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
219 [rjk_cv_function_pointer_cast],[
220 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
221 void somefunction(void);],
222 [(void *)somefunction])],
223 [rjk_cv_function_pointer_cast=yes],
224 [rjk_cv_function_pointer_cast=no])])
225 if test $rjk_cv_function_pointer_cast = no; then
230 CFLAGS="${old_CFLAGS}"
232 # gcrypt maintainers keep changing everything. Design your interface
233 # first, then implement it once, rather than getting it wrong three or
234 # four times and shipping between each attempt.
235 AC_CACHE_CHECK([for hash handle type in <grypt.h>],
236 [rjk_cv_gcrypt_hash_handle],[
237 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
241 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
242 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
246 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
247 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
248 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
249 [libgcrypt hash handle type])
251 AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
252 [rjk_cv_have_gcry_error_t],[
253 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
257 [rjk_cv_have_gcry_error_t=yes],
258 [rjk_cv_have_gcry_error_t=no])])
259 if test $rjk_cv_have_gcry_error_t = yes; then
260 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
263 # Checks for functions
264 if test $ac_cv_type_long_long = yes; then
265 AC_CHECK_FUNCS([atoll strtoll],[:],[
266 missing_functions="$missing_functions $ac_func"
268 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
269 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
270 [rjk_cv_strtoll_declared],[
271 AC_EGREP_HEADER([strtoll], [stdlib.h],
272 [rjk_cv_strtoll_declared=yes],
273 [rjk_cv_strtoll_declared=no])])
274 if test $rjk_cv_strtoll_declared = yes; then
275 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
277 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
278 [rjk_cv_atoll_declared],[
279 AC_EGREP_HEADER([atoll], [stdlib.h],
280 [rjk_cv_atoll_declared=yes],
281 [rjk_cv_atoll_declared=no])])
282 if test $rjk_cv_atoll_declared = yes; then
283 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
286 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
287 missing_functions="$missing_functions $ac_func"
289 # fsync will do if fdatasync not available
290 AC_CHECK_FUNCS([fdatasync],[:],[
291 AC_CHECK_FUNCS([fsync],
292 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
293 [missing_functions="$missing_functions fdatasync"])])
294 if test ! -z "$missing_functions"; then
295 AC_MSG_ERROR([missing functions:$missing_functions])
297 if test $want_server = yes; then
298 # <db.h> had better be version 3 or later
299 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
302 #ifndef DB_VERSION_MAJOR
303 # error cannot determine db version
305 #if DB_VERSION_MAJOR < 4
306 # error inadequate db version
308 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 2
309 # error inadequate db version
312 [rjk_cv_db_version=ok],
313 [rjk_cv_db_version=inadequate])
315 if test $rjk_cv_db_version != ok; then
316 AC_MSG_ERROR([need db.h version at least 4.2])
320 if test "x$GCC" = xyes; then
321 # a reasonable default set of warnings
322 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
323 -Wwrite-strings -Wmissing-prototypes \
324 -Wmissing-declarations -Wnested-externs"
326 # Fix up GTK+ and GLib compiler flags
327 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
328 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
330 # GCC 2.95 doesn't know to ignore warnings from system headers
331 AC_CACHE_CHECK([whether -Werror is usable],
333 save_CFLAGS="${CFLAGS}"
334 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
335 AC_TRY_COMPILE([#include <gtk/gtk.h>],
339 CFLAGS="${save_CFLAGS}"
341 if test $rjk_cv_werror = no; then
344 CC="${CC} $gcc_werror"
346 # for older GCCs that don't know %ju (etc)
347 AC_CACHE_CHECK([whether -Wno-format is required],
349 AC_TRY_COMPILE([#include <stdio.h>
352 [printf("%ju", (uintmax_t)0);],
353 [rjk_cv_noformat=no],
354 [rjk_cv_noformat=yes]))
355 if test $rjk_cv_noformat = yes; then
356 CC="${CC} -Wno-format"
359 AC_CACHE_CHECK([whether -Wshadow is OK],
365 #include <vorbis/vorbisfile.h>
371 if test $rjk_cv_shadow = yes; then
378 AH_BOTTOM([#ifdef __GNUC__
379 # define attribute(x) __attribute__(x)
381 # define attribute(x)
384 AC_CONFIG_FILES([Makefile
391 disobedience/Makefile