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