make osx_write work for any bitrate
[paraslash.git] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.60)
5
6
7 AC_INIT(paraslash, [git], maan@systemlinux.org)
8 AC_CONFIG_HEADER([config.h])
9
10 ########################################################################### generic
11 AC_PROG_CC
12 AC_PROG_CPP
13 AC_PROG_INSTALL
14
15 AC_HEADER_DIRENT
16 AC_HEADER_STDC
17 AC_HEADER_SYS_WAIT
18 AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h \
19 string.h sys/socket.h sys/time.h sys/timeb.h sys/un.h sys/ipc.h unistd.h utime.h], \
20 [], [AC_MSG_ERROR([$ac_header not found])])
21
22 AC_CHECK_HEADER(linux/soundcard.h, [extras="$extras para_fade"],
23 [AC_MSG_WARN([linux/soundcard.h not found, \
24 cannot build para_fade])])
25
26 # Checks for typedefs, structures, and compiler characteristics.
27 AC_C_CONST
28 AC_TYPE_OFF_T
29 AC_TYPE_PID_T
30 AC_TYPE_SIZE_T
31 AC_HEADER_TIME
32 AC_STRUCT_TM
33
34 # Checks for library functions.
35 AC_FUNC_FORK
36 AC_PROG_GCC_TRADITIONAL
37 AC_FUNC_MALLOC
38 AC_FUNC_MEMCMP
39 AC_FUNC_MKTIME
40 AC_FUNC_MMAP
41 AC_FUNC_REALLOC
42 AC_FUNC_SELECT_ARGTYPES
43 AC_TYPE_SIGNAL
44 AC_FUNC_STAT
45 AC_FUNC_STRFTIME
46 AC_FUNC_VPRINTF
47 AC_CHECK_FUNCS([atexit dup2 gethostbyname inet_ntoa memchr memmove memset \
48 regcomp select socket strchr strdup strerror strstr strtol uname], [],
49 [AC_MSG_ERROR([function not found, cannot live without it])])
50 ########################################################################### curses
51 AC_CHECK_LIB([ncurses], [initscr], [],
52 [AC_MSG_ERROR([libncurses not found])])
53
54 AC_CHECK_LIB([menu], [new_menu], [extras="$extras para_dbadm"],
55 [AC_MSG_WARN([libmenu not found, cannot build para_dbadm])])
56
57
58 recv_cmdline_objs="recv.cmdline http_recv.cmdline dccp_recv.cmdline"
59 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
60 dccp fd sched stdout"
61 recv_ldflags=""
62
63 filter_cmdline_objs="filter.cmdline compress_filter.cmdline"
64 filter_errlist_objs="filter_chain wav compress filter string stdin stdout sched fd"
65 filter_ldflags=""
66
67 audioc_cmdline_objs="audioc.cmdline"
68 audioc_errlist_objs="audioc string net fd"
69
70 audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
71 http_recv.cmdline dccp_recv.cmdline file_write.cmdline client.cmdline"
72 audiod_errlist_objs="audiod signal string daemon stat net
73 time grab_client filter_chain wav compress http_recv dccp dccp_recv
74 recv_common fd sched write_common file_writer audiod_command crypt
75 client_common"
76 audiod_ldflags=""
77
78 server_cmdline_objs="server.cmdline"
79 server_errlist_objs="server mp3_afh afs command net string signal random_selector
80 time daemon stat crypt http_send db close_on_fork playlist_selector
81 ipc dccp dccp_send fd"
82 server_ldflags=""
83
84 write_cmdline_objs="write.cmdline file_write.cmdline"
85 write_errlist_objs="write write_common file_writer time fd string sched stdin"
86 write_ldflags=""
87 write_writers="file"
88
89 client_cmdline_objs="client.cmdline"
90 client_errlist_objs="client net string crypt fd sched stdin stdout client_common"
91 client_ldflags=""
92
93 ########################################################################### ssl
94 dnl @synopsis CHECK_SSL
95 dnl
96 dnl based on the follwing macro from the autoconf archive
97 dnl
98 dnl @category InstalledPackages
99 dnl @author Mark Ethan Trostler <trostler@juniper.net>
100 dnl @version 2003-01-28
101 dnl @license AllPermissive
102
103 AC_DEFUN([CHECK_SSL],
104 [
105 for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
106 AC_MSG_CHECKING(for openssl in $ssldir)
107 if test -f "$ssldir/include/openssl/ssl.h"; then
108 found_ssl="yes"
109 AC_MSG_RESULT(yes)
110 SSL_CFLAGS="-I$ssldir/include/openssl"
111 SSL_CPPFLAGS="-I$ssldir/include/openssl"
112 break
113 fi
114 if test -f "$ssldir/include/ssl.h"; then
115 found_ssl="yes";
116 AC_MSG_RESULT(yes)
117 SSL_CFLAGS="-I$ssldir/include/";
118 SSL_CPPFLAGS="-I$ssldir/include/";
119 break
120 fi
121 AC_MSG_RESULT(no)
122 done
123 if test x_$found_ssl != x_yes; then
124 AC_MSG_ERROR(Cannot find ssl libraries)
125 else
126 SSL_LIBS="-lssl -lcrypto";
127 SSL_LDFLAGS="-L$ssldir/lib";
128 fi
129 AC_SUBST(SSL_CPPFLAGS)
130 AC_SUBST(SSL_CFLAGS)
131 AC_SUBST(SSL_LIBS)
132 AC_SUBST(SSL_LDFLAGS)
133 ])dnl
134
135 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
136 [Search for openssl also in path.])])
137 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
138 CHECK_SSL($enable_ssldir)
139 server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS"
140 client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
141 audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS"
142
143 ########################################################################### ucred
144
145 AC_MSG_CHECKING(for struct ucred)
146 AC_TRY_LINK([
147 #include <sys/types.h>
148 #include <sys/socket.h>
149 ],[
150 struct ucred sucred; sucred.pid=0;
151 ],[have_ucred=yes],[have_ucred=no])
152 AC_MSG_RESULT($have_ucred)
153 if test ${have_ucred} = yes; then
154 AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
155 fi
156
157 ########################################################################### osx
158
159 AC_MSG_CHECKING(for CoreAudio (MacOs))
160 AC_TRY_LINK([
161 #include <CoreAudio/CoreAudio.h>
162 ],[
163 AudioDeviceID id;
164 ],[have_core_audio=yes],[have_core_audio=no])
165 AC_MSG_RESULT($have_core_audio)
166 if test ${have_core_audio} = yes; then
167 f1="-framework CoreAudio"
168 f2="-framework AudioToolbox"
169 f3="-framework AudioUnit"
170 f4="-framework CoreServices"
171 f="$f1 $f2 $f3 $f4"
172 audiod_errlist_objs="$audiod_errlist_objs osx_writer"
173 audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
174 audiod_ldflags="$audiod_ldflags $f"
175
176 write_errlist_objs="$write_errlist_objs osx_writer"
177 write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
178 write_ldflags="$write_ldflags $f"
179 write_writers="$write_writers osx"
180 AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on MacOs)
181 fi
182 ########################################################################### gtk2
183
184 pkg_modules="gtk+-2.0 >= 2.0.0"
185 build_para_krell="yes"
186 PKG_CHECK_MODULES(GTK, [$pkg_modules], [], [build_para_krell="no"])
187 AC_CHECK_HEADER(gkrellm2/gkrellm.h, [], [build_para_krell="no"])
188 if test build_para_krell = "yes"; then
189 AC_SUBST(GTK_CFLAGS)
190 AC_SUBST(GTK_LIBS)
191 extras="$extras para_krell.so"
192 else
193 AC_MSG_WARN([can not build para_krell])
194 fi
195
196 ########################################################################### sdl
197 AC_CHECK_LIB([SDL_image], [SDL_Init], [extras="$extras para_sdl_gui"], [
198 AC_MSG_WARN([libSDL_image not found, cannot build para_sdl_gui])
199 ])
200 AC_CHECK_HEADER(SDL/SDL.h, [],
201 [AC_MSG_WARN([SDL/SDL.h not found])])
202
203 ########################################################################### mysql
204 have_mysql="yes"
205 AC_ARG_ENABLE(mysql_headers, [AC_HELP_STRING(--enable-mysql-headers=dir,
206 [look for mysql.h also in dir])])
207 if test -n "$enable_mysql_headers"; then
208 mysql_cppflags="-I$enable_mysql_headers"
209 CPPFLAGS="$CPPFLAGS $mysql_cppflags"
210 fi
211 AC_ARG_ENABLE(mysql_libs, [AC_HELP_STRING(--enable-mysql-libs=dir,
212 [look for libmysqlclient also in dir])])
213 if test -n "$enable_mysql_libs"; then
214 mysql_libs="-L$enable_mysql_libs"
215 LDFLAGS="$LDFLAGS $mysql_libs"
216 fi
217 AC_CHECK_HEADER(mysql/mysql.h, [], [
218 have_mysql="no"
219 ])
220 AC_CHECK_LIB([mysqlclient], [mysql_init], [], [
221 have_mysql="no"
222 ])
223 if test "$have_mysql" = "yes"; then
224 server_ldflags="$server_ldflags $mysql_libs -lmysqlclient"
225 server_errlist_objs="$server_errlist_objs mysql_selector"
226 AC_SUBST(mysql_cppflags)
227 AC_SUBST(mysql_libs)
228 AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
229 else
230 AC_MSG_WARN([cannot build mysql-based audio file selector])
231 fi
232 ########################################################################### ogg
233 have_ogg="yes"
234 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [
235 have_ogg="no"
236 ])
237 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [
238 have_ogg="no"
239 ])
240 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [
241 have_ogg="no"
242 ])
243 if test "$have_ogg" = "yes"; then
244 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
245 server_ldflags="$server_ldflags -logg -lvorbis -lvorbisfile"
246 filter_ldflags="$filter_ldflags -lvorbis -lvorbisfile"
247 audiod_ldflags="$audiod_ldflags -lvorbis -lvorbisfile"
248
249 filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
250 audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
251
252 server_errlist_objs="$server_errlist_objs ogg_afh"
253 filter_errlist_objs="$filter_errlist_objs oggdec"
254 audiod_errlist_objs="$audiod_errlist_objs oggdec"
255 else
256 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
257 fi
258 ########################################################################### faad
259 have_faad=yes
260 AC_ARG_ENABLE(faad_headers, [AC_HELP_STRING(--enable-faad-headers=dir,
261 [look for neaacdec.h also in dir])])
262 if test -n "$enable_faad_headers"; then
263 faad_cppflags="-I$enable_faad_headers"
264 CPPFLAGS="$CPPFLAGS $faad_cppflags"
265 fi
266 AC_ARG_ENABLE(faad_libs, [AC_HELP_STRING(--enable-faad-libs=dir,
267 [look for libfaad also in dir])])
268 if test -n "$enable_faad_libs"; then
269 faad_libs="-L$enable_faad_libs"
270 LDFLAGS="$LDFLAGS $faad_libs"
271 fi
272 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
273 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
274 if test "$have_faad" = "yes"; then
275 AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
276 filter_errlist_objs="$filter_errlist_objs aacdec aac_common"
277 audiod_errlist_objs="$audiod_errlist_objs aacdec aac_common"
278 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
279 server_ldflags="$server_ldflags $faad_libs -lfaad"
280 filter_ldflags="$filter_ldflags $faad_libs -lfaad"
281 audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
282 AC_SUBST(faad_cppflags)
283 AC_SUBST(faad_libs)
284 else
285 AC_MSG_WARN([no aac support in para_audiod/para_filter])
286 fi
287 ########################################################################### mad
288 have_mad="yes"
289 AC_ARG_ENABLE(mad_headers, [AC_HELP_STRING(--enable-mad-headers=dir,
290 [look for mad.h also in dir])])
291 if test -n "$enable_mad_headers"; then
292 mad_cppflags="-I$enable_mad_headers"
293 CPPFLAGS="$CPPFLAGS $mad_cppflags"
294 fi
295 AC_ARG_ENABLE(mad_libs, [AC_HELP_STRING(--enable-mad-libs=dir,
296 [look for libmad also in dir])])
297 if test -n "$enable_mad_libs"; then
298 mad_libs="-L$enable_mad_libs"
299 LDFLAGS="$LDFLAGS $mad_libs"
300 fi
301 AC_CHECK_HEADERS([mad.h], [], [
302 have_mad="no"
303 ])
304 AC_CHECK_LIB([mad], [mad_stream_init], [], [
305 have_mad="no"
306 ])
307 if test "$have_mad" = "yes"; then
308 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
309 filter_errlist_objs="$filter_errlist_objs mp3dec"
310 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
311 filter_ldflags="$filter_ldflags $mad_libs -lmad"
312 audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
313 AC_SUBST(mad_cppflags)
314 AC_SUBST(mad_libs)
315 else
316 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
317 fi
318 ########################################################################### alsa
319 have_alsa="yes"
320 msg="=> no alsa support for para_audiod/para_write"
321 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
322 AC_MSG_WARN([no alsa/asoundlib $msg])
323 have_alsa="no"
324 ])
325 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
326 AC_MSG_WARN([no libasound $msg])
327 have_alsa="no"
328 ])
329 if test "$have_alsa" = "yes"; then
330 audiod_errlist_objs="$audiod_errlist_objs alsa_writer"
331 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write.cmdline"
332 audiod_ldflags="$audiod_ldflags -lasound"
333
334 write_errlist_objs="$write_errlist_objs alsa_writer"
335 write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline"
336 write_ldflags="$write_ldflags -lasound"
337 write_writers="$write_writers alsa"
338 fi
339 ########################################################################### ortp
340 have_ortp="yes"
341 AC_ARG_ENABLE(ortp, AC_HELP_STRING([--disable-ortp], [Disable ortp support]),
342 if test x$enableval = xno; then
343 have_ortp=no
344 fi
345 )
346 if test "$have_ortp" = "yes"; then
347 AC_CHECK_HEADERS([ortp/ortp.h], [], [
348 have_ortp="no"
349 ])
350 AC_CHECK_LIB([ortp], [ortp_init], [], [
351 have_ortp="no"
352 ])
353 fi
354 if test "$have_ortp" = "yes"; then
355 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
356 recv_errlist_objs="$recv_errlist_objs ortp_recv"
357
358 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
359 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
360
361 server_errlist_objs="$server_errlist_objs ortp_send"
362
363 recv_ldflags="$recv_ldflags -lortp"
364 server_ldflags="$server_ldflags -lortp"
365 audiod_ldflags="$audiod_ldflags -lortp"
366 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
367
368 else
369 AC_MSG_NOTICE([deactivating ortp support])
370 fi
371 AC_SUBST(GLIB_CFLAGS)
372 AC_SUBST(GLIB_LIBS)
373
374 ########################################################################### zmw
375 slide="para_slider"
376 msg="can not build para_slider"
377 CPPFLAGS="$GTK_CFLAGS"
378 LDFLAGS="$LDFLAGS $GTK_LIBS"
379 AC_CHECK_HEADERS([zmw/zmw.h], [], [
380 AC_MSG_WARN([zero memory widget header files not found, $msg])
381 slide=""
382 ])
383 AC_CHECK_LIB([zmw], [zmw_init], [], [
384 AC_MSG_WARN([zero memory widget library not found, $msg])
385 slide=""
386 ])
387 extras="$extras $slide"
388
389
390
391
392
393 AC_SUBST(extra_binaries, [$extras])
394 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
395 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
396 AC_SUBST(install_sh, [$INSTALL])
397 AC_CONFIG_FILES([Makefile])
398
399
400
401 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
402 AC_DEFUN([objlist_to_errlist],[$(for i in $@; do printf "DEFINE_ERRLIST($(echo $i| tr 'a-z' 'A-Z'));"; done) [const char **para_errlist[[]]] = {$(for i in $@; do printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; done) }])
403
404 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
405 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
406 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
407 server_objs="$server_cmdline_objs $server_errlist_objs"
408 write_objs="$write_cmdline_objs $write_errlist_objs"
409 client_objs="$client_cmdline_objs $client_errlist_objs"
410 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
411
412 AC_SUBST(recv_objs, add_dot_o($recv_objs))
413 AC_SUBST(recv_ldflags, $recv_ldflags)
414 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
415 errors used by para_recv)
416
417 AC_SUBST(filter_objs, add_dot_o($filter_objs))
418 AC_SUBST(filter_ldflags, $filter_ldflags)
419 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
420 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
421
422 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
423 AC_SUBST(audiod_ldflags, $audiod_ldflags)
424 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
425 errors used by para_audiod)
426
427 AC_SUBST(server_objs, add_dot_o($server_objs))
428 AC_SUBST(server_ldflags, $server_ldflags)
429 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
430 objlist_to_errlist($server_errlist_objs), errors used by para_server)
431
432 AC_SUBST(write_objs, add_dot_o($write_objs))
433 AC_SUBST(write_ldflags, $write_ldflags)
434 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
435 objlist_to_errlist($write_errlist_objs), errors used by para_write)
436
437 AC_SUBST(client_objs, add_dot_o($client_objs))
438 AC_SUBST(client_ldflags, $client_ldflags)
439 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
440 objlist_to_errlist($client_errlist_objs), errors used by para_client)
441
442 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
443 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
444 objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
445
446 enum="$(for i in $write_writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
447 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
448 enum of supported writers)
449 names="$(for i in $write_writers; do printf \"$i\",' ' ; done)"
450 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
451 inits="$(for i in $write_writers; do printf 'extern void '$i'_writer_init(struct writer *); '; done)"
452 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
453 array="$(for i in $write_writers; do printf '{.init = '$i'_writer_init},'; done)"
454 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
455
456 gui_cmdline_objs="gui.cmdline"
457 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
458 gui_other_objs="gui gui_common gui_theme"
459 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
460 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
461 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
462 AC_SUBST(gui_objs, add_dot_o($gui_objs))
463
464 AC_OUTPUT
465 AC_MSG_NOTICE([creating Makefile.deps])
466 gcc -MM -MG $mysql_cppflags $faad_cppflags $mad_cppflags *.c > Makefile.deps
467 AC_MSG_NOTICE([
468 paraslash configuration:
469 ~~~~~~~~~~~~~~~~~~~~~~~~
470 mysql support: $have_mysql
471 ogg vorbis support: $have_ogg
472 mp3dec support (libmad): $have_mad
473 aac support (libfaad): $have_faad
474 ortp support: $have_ortp
475 unix socket credentials: $have_ucred
476 supported writers for para_write: $write_writers
477 ])