fix conflict
[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-fadd-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_CHECK_HEADERS([mad.h], [], [
285 have_mad="no"
286 ])
287 AC_CHECK_LIB([mad], [mad_stream_init], [], [
288 have_mad="no"
289 ])
290 if test "$have_mad" = "yes"; then
291 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
292 filter_errlist_objs="$filter_errlist_objs mp3dec"
293 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
294 filter_ldflags="$filter_ldflags -lmad"
295 audiod_ldflags="$audiod_ldflags -lmad"
296 else
297 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
298 fi
299 ########################################################################### alsa
300 have_alsa="yes"
301 msg="=> no alsa support for para_audiod/para_write"
302 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
303 AC_MSG_WARN([no alsa/asoundlib $msg])
304 have_alsa="no"
305 ])
306 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
307 AC_MSG_WARN([no libasound $msg])
308 have_alsa="no"
309 ])
310 if test "$have_alsa" = "yes"; then
311 audiod_errlist_objs="$audiod_errlist_objs alsa_writer"
312 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write.cmdline"
313 audiod_ldflags="$audiod_ldflags -lasound"
314
315 write_errlist_objs="$write_errlist_objs alsa_writer"
316 write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline"
317 write_ldflags="$write_ldflags -lasound"
318 write_writers="$write_writers alsa"
319 fi
320 ########################################################################### ortp
321 have_ortp="yes"
322 AC_ARG_ENABLE(ortp, AC_HELP_STRING([--disable-ortp], [Disable ortp support]),
323 if test x$enableval = xno; then
324 have_ortp=no
325 fi
326 )
327 if test "$have_ortp" = "yes"; then
328 AC_CHECK_HEADERS([ortp/ortp.h], [], [
329 have_ortp="no"
330 ])
331 AC_CHECK_LIB([ortp], [ortp_init], [], [
332 have_ortp="no"
333 ])
334 fi
335 if test "$have_ortp" = "yes"; then
336 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
337 recv_errlist_objs="$recv_errlist_objs ortp_recv"
338
339 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
340 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
341
342 server_errlist_objs="$server_errlist_objs ortp_send"
343
344 recv_ldflags="$recv_ldflags -lortp"
345 server_ldflags="$server_ldflags -lortp"
346 audiod_ldflags="$audiod_ldflags -lortp"
347 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
348
349 else
350 AC_MSG_NOTICE([deactivating ortp support])
351 fi
352 AC_SUBST(GLIB_CFLAGS)
353 AC_SUBST(GLIB_LIBS)
354
355 ########################################################################### zmw
356 slide="para_slider"
357 msg="can not build para_slider"
358 CPPFLAGS="$GTK_CFLAGS"
359 LDFLAGS="$LDFLAGS $GTK_LIBS"
360 AC_CHECK_HEADERS([zmw/zmw.h], [], [
361 AC_MSG_WARN([zero memory widget header files not found, $msg])
362 slide=""
363 ])
364 AC_CHECK_LIB([zmw], [zmw_init], [], [
365 AC_MSG_WARN([zero memory widget library not found, $msg])
366 slide=""
367 ])
368 extras="$extras $slide"
369
370
371
372
373
374 AC_SUBST(extra_binaries, [$extras])
375 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
376 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
377 AC_SUBST(install_sh, [$INSTALL])
378 AC_CONFIG_FILES([Makefile])
379
380
381
382 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
383 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) }])
384
385 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
386 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
387 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
388 server_objs="$server_cmdline_objs $server_errlist_objs"
389 write_objs="$write_cmdline_objs $write_errlist_objs"
390 client_objs="$client_cmdline_objs $client_errlist_objs"
391 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
392
393 AC_SUBST(recv_objs, add_dot_o($recv_objs))
394 AC_SUBST(recv_ldflags, $recv_ldflags)
395 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
396 errors used by para_recv)
397
398 AC_SUBST(filter_objs, add_dot_o($filter_objs))
399 AC_SUBST(filter_ldflags, $filter_ldflags)
400 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
401 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
402
403 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
404 AC_SUBST(audiod_ldflags, $audiod_ldflags)
405 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
406 errors used by para_audiod)
407
408 AC_SUBST(server_objs, add_dot_o($server_objs))
409 AC_SUBST(server_ldflags, $server_ldflags)
410 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
411 objlist_to_errlist($server_errlist_objs), errors used by para_server)
412
413 AC_SUBST(write_objs, add_dot_o($write_objs))
414 AC_SUBST(write_ldflags, $write_ldflags)
415 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
416 objlist_to_errlist($write_errlist_objs), errors used by para_write)
417
418 AC_SUBST(client_objs, add_dot_o($client_objs))
419 AC_SUBST(client_ldflags, $client_ldflags)
420 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
421 objlist_to_errlist($client_errlist_objs), errors used by para_client)
422
423 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
424 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
425 objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
426
427 enum="$(for i in $write_writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
428 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
429 enum of supported writers)
430 names="$(for i in $write_writers; do printf \"$i\",' ' ; done)"
431 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
432 inits="$(for i in $write_writers; do printf 'extern void '$i'_writer_init(struct writer *); '; done)"
433 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
434 array="$(for i in $write_writers; do printf '{.init = '$i'_writer_init},'; done)"
435 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
436
437 gui_cmdline_objs="gui.cmdline"
438 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
439 gui_other_objs="gui gui_common gui_theme"
440 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
441 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
442 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
443 AC_SUBST(gui_objs, add_dot_o($gui_objs))
444
445 AC_OUTPUT
446 AC_MSG_NOTICE([creating Makefile.deps])
447 gcc -MM -MG $mysql_cppflags $faad_cppflags *.c > Makefile.deps
448 AC_MSG_NOTICE([
449 paraslash configuration:
450 ~~~~~~~~~~~~~~~~~~~~~~~~
451 mysql support: $have_mysql
452 ogg vorbis support: $have_ogg
453 mp3dec support (libmad): $have_mad
454 aac support (libfaad): $have_faad
455 ortp support: $have_ortp
456 unix socket credentials: $have_ucred
457 supported writers for para_write: $write_writers
458 ])