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