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