configure: add command line options for libmad
[paraslash.git] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.53)
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 PKG_CHECK_MODULES(GTK, [$pkg_modules], [extras="$extras para_krell.so"], [
186 AC_MSG_WARN([gtk+-2 not found, can not build para_krell])
187 ])
188 AC_SUBST(GTK_CFLAGS)
189 AC_SUBST(GTK_LIBS)
190
191 ########################################################################### sdl
192 AC_CHECK_LIB([SDL_image], [SDL_Init], [extras="$extras para_sdl_gui"], [
193 AC_MSG_WARN([libSDL_image not found, cannot build para_sdl_gui])
194 ])
195 AC_CHECK_HEADER(SDL/SDL.h, [],
196 [AC_MSG_WARN([SDL/SDL.h not found])])
197
198 ########################################################################### mysql
199 have_mysql="yes"
200 AC_ARG_ENABLE(mysql_headers, [AC_HELP_STRING(--enable-mysql-headers=dir,
201 [look for mysql.h also in dir])])
202 if test -n "$enable_mysql_headers"; then
203 mysql_cppflags="-I$enable_mysql_headers"
204 CPPFLAGS="$CPPFLAGS $mysql_cppflags"
205 fi
206 AC_ARG_ENABLE(mysql_libs, [AC_HELP_STRING(--enable-mysql-libs=dir,
207 [look for libmysqlclient also in dir])])
208 if test -n "$enable_mysql_libs"; then
209 mysql_libs="-L$enable_mysql_libs"
210 LDFLAGS="$LDFLAGS $mysql_libs"
211 fi
212 AC_CHECK_HEADER(mysql/mysql.h, [], [
213 have_mysql="no"
214 ])
215 AC_CHECK_LIB([mysqlclient], [mysql_init], [], [
216 have_mysql="no"
217 ])
218 if test "$have_mysql" = "yes"; then
219 server_ldflags="$server_ldflags $mysql_libs -lmysqlclient"
220 server_errlist_objs="$server_errlist_objs mysql_selector"
221 AC_SUBST(mysql_cppflags)
222 AC_SUBST(mysql_libs)
223 AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
224 else
225 AC_MSG_WARN([cannot build mysql-based audio file selector])
226 fi
227 ########################################################################### ogg
228 have_ogg="yes"
229 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [
230 have_ogg="no"
231 ])
232 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [
233 have_ogg="no"
234 ])
235 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [
236 have_ogg="no"
237 ])
238 if test "$have_ogg" = "yes"; then
239 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
240 server_ldflags="$server_ldflags -logg -lvorbis -lvorbisfile"
241 filter_ldflags="$filter_ldflags -lvorbis -lvorbisfile"
242 audiod_ldflags="$audiod_ldflags -lvorbis -lvorbisfile"
243
244 filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
245 audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
246
247 server_errlist_objs="$server_errlist_objs ogg_afh"
248 filter_errlist_objs="$filter_errlist_objs oggdec"
249 audiod_errlist_objs="$audiod_errlist_objs oggdec"
250 else
251 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
252 fi
253 ########################################################################### faad
254 have_faad=yes
255 AC_ARG_ENABLE(faad_headers, [AC_HELP_STRING(--enable-faad-headers=dir,
256 [look for neaacdec.h also in dir])])
257 if test -n "$enable_faad_headers"; then
258 faad_cppflags="-I$enable_faad_headers"
259 CPPFLAGS="$CPPFLAGS $faad_cppflags"
260 fi
261 AC_ARG_ENABLE(faad_libs, [AC_HELP_STRING(--enable-faad-libs=dir,
262 [look for libfaad also in dir])])
263 if test -n "$enable_faad_libs"; then
264 faad_libs="-L$enable_faad_libs"
265 LDFLAGS="$LDFLAGS $faad_libs"
266 fi
267 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
268 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
269 if test "$have_faad" = "yes"; then
270 AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
271 filter_errlist_objs="$filter_errlist_objs aacdec aac_common"
272 audiod_errlist_objs="$audiod_errlist_objs aacdec aac_common"
273 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
274 server_ldflags="$server_ldflags $faad_libs -lfaad"
275 filter_ldflags="$filter_ldflags $faad_libs -lfaad"
276 audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
277 AC_SUBST(faad_cppflags)
278 AC_SUBST(faad_libs)
279 else
280 AC_MSG_WARN([no aac support in para_audiod/para_filter])
281 fi
282 ########################################################################### mad
283 have_mad="yes"
284 AC_ARG_ENABLE(mad_headers, [AC_HELP_STRING(--enable-mad-headers=dir,
285 [look for mad.h also in dir])])
286 if test -n "$enable_mad_headers"; then
287 mad_cppflags="-I$enable_mad_headers"
288 CPPFLAGS="$CPPFLAGS $mad_cppflags"
289 fi
290 AC_ARG_ENABLE(mad_libs, [AC_HELP_STRING(--enable-mad-libs=dir,
291 [look for libmad also in dir])])
292 if test -n "$enable_mad_libs"; then
293 mad_libs="-L$enable_mad_libs"
294 LDFLAGS="$LDFLAGS $mad_libs"
295 fi
296 AC_CHECK_HEADERS([mad.h], [], [
297 have_mad="no"
298 ])
299 AC_CHECK_LIB([mad], [mad_stream_init], [], [
300 have_mad="no"
301 ])
302 if test "$have_mad" = "yes"; then
303 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
304 filter_errlist_objs="$filter_errlist_objs mp3dec"
305 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
306 filter_ldflags="$filter_ldflags $mad_libs -lmad"
307 audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
308 AC_SUBST(mad_cppflags)
309 AC_SUBST(mad_libs)
310 else
311 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
312 fi
313 ########################################################################### alsa
314 have_alsa="yes"
315 msg="=> no alsa support for para_audiod/para_write"
316 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
317 AC_MSG_WARN([no alsa/asoundlib $msg])
318 have_alsa="no"
319 ])
320 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
321 AC_MSG_WARN([no libasound $msg])
322 have_alsa="no"
323 ])
324 if test "$have_alsa" = "yes"; then
325 audiod_errlist_objs="$audiod_errlist_objs alsa_writer"
326 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write.cmdline"
327 audiod_ldflags="$audiod_ldflags -lasound"
328
329 write_errlist_objs="$write_errlist_objs alsa_writer"
330 write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline"
331 write_ldflags="$write_ldflags -lasound"
332 write_writers="$write_writers alsa"
333 fi
334 ########################################################################### ortp
335 have_ortp="yes"
336 AC_ARG_ENABLE(ortp, AC_HELP_STRING([--disable-ortp], [Disable ortp support]),
337 if test x$enableval = xno; then
338 have_ortp=no
339 fi
340 )
341 if test "$have_ortp" = "yes"; then
342 AC_CHECK_HEADERS([ortp/ortp.h], [], [
343 have_ortp="no"
344 ])
345 AC_CHECK_LIB([ortp], [ortp_init], [], [
346 have_ortp="no"
347 ])
348 fi
349 if test "$have_ortp" = "yes"; then
350 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
351 recv_errlist_objs="$recv_errlist_objs ortp_recv"
352
353 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
354 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
355
356 server_errlist_objs="$server_errlist_objs ortp_send"
357
358 recv_ldflags="$recv_ldflags -lortp"
359 server_ldflags="$server_ldflags -lortp"
360 audiod_ldflags="$audiod_ldflags -lortp"
361 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
362
363 else
364 AC_MSG_NOTICE([deactivating ortp support])
365 fi
366 AC_SUBST(GLIB_CFLAGS)
367 AC_SUBST(GLIB_LIBS)
368
369 ########################################################################### zmw
370 slide="para_slider"
371 msg="can not build para_slider"
372 CPPFLAGS="$GTK_CFLAGS"
373 LDFLAGS="$LDFLAGS $GTK_LIBS"
374 AC_CHECK_HEADERS([zmw/zmw.h], [], [
375 AC_MSG_WARN([zero memory widget header files not found, $msg])
376 slide=""
377 ])
378 AC_CHECK_LIB([zmw], [zmw_init], [], [
379 AC_MSG_WARN([zero memory widget library not found, $msg])
380 slide=""
381 ])
382 extras="$extras $slide"
383
384
385
386
387
388 AC_SUBST(extra_binaries, [$extras])
389 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
390 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
391 AC_SUBST(install_sh, [$INSTALL])
392 AC_CONFIG_FILES([Makefile])
393
394
395
396 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
397 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) }])
398
399 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
400 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
401 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
402 server_objs="$server_cmdline_objs $server_errlist_objs"
403 write_objs="$write_cmdline_objs $write_errlist_objs"
404 client_objs="$client_cmdline_objs $client_errlist_objs"
405 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
406
407 AC_SUBST(recv_objs, add_dot_o($recv_objs))
408 AC_SUBST(recv_ldflags, $recv_ldflags)
409 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
410 errors used by para_recv)
411
412 AC_SUBST(filter_objs, add_dot_o($filter_objs))
413 AC_SUBST(filter_ldflags, $filter_ldflags)
414 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
415 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
416
417 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
418 AC_SUBST(audiod_ldflags, $audiod_ldflags)
419 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
420 errors used by para_audiod)
421
422 AC_SUBST(server_objs, add_dot_o($server_objs))
423 AC_SUBST(server_ldflags, $server_ldflags)
424 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
425 objlist_to_errlist($server_errlist_objs), errors used by para_server)
426
427 AC_SUBST(write_objs, add_dot_o($write_objs))
428 AC_SUBST(write_ldflags, $write_ldflags)
429 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
430 objlist_to_errlist($write_errlist_objs), errors used by para_write)
431
432 AC_SUBST(client_objs, add_dot_o($client_objs))
433 AC_SUBST(client_ldflags, $client_ldflags)
434 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
435 objlist_to_errlist($client_errlist_objs), errors used by para_client)
436
437 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
438 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
439 objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
440
441 enum="$(for i in $write_writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
442 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
443 enum of supported writers)
444 names="$(for i in $write_writers; do printf \"$i\",' ' ; done)"
445 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
446 inits="$(for i in $write_writers; do printf 'extern void '$i'_writer_init(struct writer *); '; done)"
447 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
448 array="$(for i in $write_writers; do printf '{.init = '$i'_writer_init},'; done)"
449 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
450
451 gui_cmdline_objs="gui.cmdline"
452 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
453 gui_other_objs="gui gui_common gui_theme"
454 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
455 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
456 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
457 AC_SUBST(gui_objs, add_dot_o($gui_objs))
458
459 AC_OUTPUT
460 AC_MSG_NOTICE([creating Makefile.deps])
461 gcc -MM -MG $mysql_cppflags $faad_cppflags $mad_cppflags *.c > Makefile.deps
462 AC_MSG_NOTICE([
463 paraslash configuration:
464 ~~~~~~~~~~~~~~~~~~~~~~~~
465 mysql support: $have_mysql
466 ogg vorbis support: $have_ogg
467 mp3dec support (libmad): $have_mad
468 aac support (libfaad): $have_faad
469 ortp support: $have_ortp
470 unix socket credentials: $have_ucred
471 supported writers for para_write: $write_writers
472 ])