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