first version of the osx writer
[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 malloc.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 audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
68 http_recv.cmdline dccp_recv.cmdline file_write.cmdline"
69 audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net
70 time grab_client filter_chain wav compress http_recv dccp dccp_recv
71 recv_common fd sched write_common file_writer audiod_command"
72 audiod_ldflags=""
73
74 server_cmdline_objs="server.cmdline"
75 server_errlist_objs="server mp3_afh afs command net string signal random_selector
76 time daemon stat crypt http_send db close_on_fork playlist_selector
77 ipc dccp dccp_send fd"
78 server_ldflags=""
79
80 write_cmdline_objs="write.cmdline file_write.cmdline"
81 write_errlist_objs="write write_common file_writer time fd string sched stdin"
82 write_ldflags=""
83 write_writers="file"
84
85 client_cmdline_objs="client.cmdline"
86 client_errlist_objs="client net string crypt"
87 client_ldflags=""
88
89 ########################################################################### ssl
90 dnl @synopsis CHECK_SSL
91 dnl
92 dnl based on the follwing macro from the autoconf archive
93 dnl
94 dnl @category InstalledPackages
95 dnl @author Mark Ethan Trostler <trostler@juniper.net>
96 dnl @version 2003-01-28
97 dnl @license AllPermissive
98
99 AC_DEFUN([CHECK_SSL],
100 [
101 for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
102 AC_MSG_CHECKING(for openssl in $ssldir)
103 if test -f "$ssldir/include/openssl/ssl.h"; then
104 found_ssl="yes"
105 AC_MSG_RESULT(yes)
106 SSL_CFLAGS="-I$ssldir/include/openssl"
107 SSL_CPPFLAGS="-I$ssldir/include/openssl"
108 break
109 fi
110 if test -f "$ssldir/include/ssl.h"; then
111 found_ssl="yes";
112 AC_MSG_RESULT(yes)
113 SSL_CFLAGS="-I$ssldir/include/";
114 SSL_CPPFLAGS="-I$ssldir/include/";
115 break
116 fi
117 AC_MSG_RESULT(no)
118 done
119 if test x_$found_ssl != x_yes; then
120 AC_MSG_ERROR(Cannot find ssl libraries)
121 else
122 SSL_LIBS="-lssl -lcrypto";
123 SSL_LDFLAGS="-L$ssldir/lib";
124 fi
125 AC_SUBST(SSL_CPPFLAGS)
126 AC_SUBST(SSL_CFLAGS)
127 AC_SUBST(SSL_LIBS)
128 AC_SUBST(SSL_LDFLAGS)
129 ])dnl
130
131 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
132 [Search for openssl also in path.])])
133 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
134 CHECK_SSL($enable_ssldir)
135 server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS"
136 client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
137
138 ########################################################################### ucred
139
140 AC_MSG_CHECKING(for struct ucred)
141 AC_TRY_LINK([
142 #include <sys/types.h>
143 #include <sys/socket.h>
144 ],[
145 struct ucred sucred; sucred.pid=0;
146 ],[have_ucred=yes],[have_ucred=no])
147 AC_MSG_RESULT($have_ucred)
148 if test ${have_ucred} = yes; then
149 AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
150 fi
151
152 ########################################################################### osx
153
154 AC_MSG_CHECKING(for CoreAudio (MacOs))
155 AC_TRY_LINK([
156 #include <CoreAudio/CoreAudio.h>
157 ],[
158 AudioDeviceID id;
159 ],[have_core_audio=yes],[have_core_audio=no])
160 AC_MSG_RESULT($have_core_audio)
161 if test ${have_core_audio} = yes; then
162 f1="-framework CoreAudio"
163 f2="-framework AudioToolbox"
164 f3="-framework AudioUnit"
165 f4="-framework CoreServices"
166 f="$f1 $f2 $f3 $f4"
167 audiod_errlist_objs="$audiod_errlist_objs osx_writer"
168 audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
169 audiod_ldflags="$audiod_ldflags $f"
170
171 write_errlist_objs="$write_errlist_objs osx_writer"
172 write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
173 write_ldflags="$write_ldflags $f"
174 write_writers="$write_writers osx"
175 AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on MacOs)
176 fi
177 ########################################################################### gtk2
178
179 pkg_modules="gtk+-2.0 >= 2.0.0"
180 PKG_CHECK_MODULES(GTK, [$pkg_modules], [extras="$extras para_krell.so"], [
181 AC_MSG_WARN([gtk+-2 not found, can not build para_krell])
182 ])
183 AC_SUBST(GTK_CFLAGS)
184 AC_SUBST(GTK_LIBS)
185
186 ########################################################################### sdl
187 AC_CHECK_LIB([SDL_image], [SDL_Init], [extras="$extras para_sdl_gui"], [
188 AC_MSG_WARN([libSDL_image not found, cannot build para_sdl_gui])
189 ])
190 AC_CHECK_HEADER(SDL/SDL.h, [],
191 [AC_MSG_WARN([SDL/SDL.h not found])])
192
193 ########################################################################### mysql
194 have_mysql="yes"
195 AC_ARG_ENABLE(mysql_headers, [AC_HELP_STRING(--enable-mysql-headers=dir,
196 [look for mysql.h also in dir])])
197 if test -n "$enable_mysql_headers"; then
198 mysql_cppflags="-I$enable_mysql_headers"
199 CPPFLAGS="$CPPFLAGS $mysql_cppflags"
200 fi
201 AC_ARG_ENABLE(mysql_libs, [AC_HELP_STRING(--enable-mysql-libs=dir,
202 [look for libmysqlclient also in dir])])
203 if test -n "$enable_mysql_libs"; then
204 mysql_libs="-L$enable_mysql_libs"
205 LDFLAGS="$LDFLAGS $mysql_libs"
206 fi
207 AC_CHECK_HEADER(mysql/mysql.h, [], [
208 have_mysql="no"
209 ])
210 AC_CHECK_LIB([mysqlclient], [mysql_init], [], [
211 have_mysql="no"
212 ])
213 if test "$have_mysql" = "yes"; then
214 server_ldflags="$server_ldflags $mysql_libs -lmysqlclient"
215 server_errlist_objs="$server_errlist_objs mysql_selector"
216 AC_SUBST(mysql_cppflags)
217 AC_SUBST(mysql_libs)
218 AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
219 else
220 AC_MSG_WARN([cannot build mysql-based audio file selector])
221 fi
222 ########################################################################### ogg
223 have_ogg="yes"
224 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [
225 have_ogg="no"
226 ])
227 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [
228 have_ogg="no"
229 ])
230 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [
231 have_ogg="no"
232 ])
233 if test "$have_ogg" = "yes"; then
234 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
235 server_ldflags="$server_ldflags -logg -lvorbis -lvorbisfile"
236 filter_ldflags="$filter_ldflags -lvorbis -lvorbisfile"
237 audiod_ldflags="$audiod_ldflags -lvorbis -lvorbisfile"
238
239 filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
240 audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
241
242 server_errlist_objs="$server_errlist_objs ogg_afh"
243 filter_errlist_objs="$filter_errlist_objs oggdec"
244 audiod_errlist_objs="$audiod_errlist_objs oggdec"
245 else
246 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
247 fi
248 ########################################################################### faad
249 have_faad=yes
250 AC_ARG_ENABLE(faad_headers, [AC_HELP_STRING(--enable-faad-headers=dir,
251 [look for neaacdec.h also in dir])])
252 if test -n "$enable_faad_headers"; then
253 faad_cppflags="-I$enable_faad_headers"
254 CPPFLAGS="$CPPFLAGS $faad_cppflags"
255 fi
256 AC_ARG_ENABLE(faad_libs, [AC_HELP_STRING(--enable-fadd-libs=dir,
257 [look for libfaad also in dir])])
258 if test -n "$enable_faad_libs"; then
259 faad_libs="-L$enable_faad_libs"
260 LDFLAGS="$LDFLAGS $faad_libs"
261 fi
262 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
263 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
264 if test "$have_faad" = "yes"; then
265 AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
266 filter_errlist_objs="$filter_errlist_objs aacdec aac_common"
267 audiod_errlist_objs="$audiod_errlist_objs aacdec aac_common"
268 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
269 server_ldflags="$server_ldflags $faad_libs -lfaad"
270 filter_ldflags="$filter_ldflags $faad_libs -lfaad"
271 audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
272 AC_SUBST(faad_cppflags)
273 AC_SUBST(faad_libs)
274 else
275 AC_MSG_WARN([no aac support in para_audiod/para_filter])
276 fi
277 ########################################################################### mad
278 have_mad="yes"
279 AC_CHECK_HEADERS([mad.h], [], [
280 have_mad="no"
281 ])
282 AC_CHECK_LIB([mad], [mad_stream_init], [], [
283 have_mad="no"
284 ])
285 if test "$have_mad" = "yes"; then
286 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
287 filter_errlist_objs="$filter_errlist_objs mp3dec"
288 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
289 filter_ldflags="$filter_ldflags -lmad"
290 audiod_ldflags="$audiod_ldflags -lmad"
291 else
292 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
293 fi
294 ########################################################################### alsa
295 have_alsa="yes"
296 msg="=> no alsa support for para_audiod/para_write"
297 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
298 AC_MSG_WARN([no alsa/asoundlib $msg])
299 have_alsa="no"
300 ])
301 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
302 AC_MSG_WARN([no libasound $msg])
303 have_alsa="no"
304 ])
305 if test "$have_alsa" = "yes"; then
306 audiod_errlist_objs="$audiod_errlist_objs alsa_writer"
307 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write.cmdline"
308 audiod_ldflags="$audiod_ldflags -lasound"
309
310 write_errlist_objs="$write_errlist_objs alsa_writer"
311 write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline"
312 write_ldflags="$write_ldflags -lasound"
313 write_writers="$write_writers alsa"
314 fi
315 ########################################################################### ortp
316 have_ortp="yes"
317 AC_ARG_ENABLE(ortp, AC_HELP_STRING([--disable-ortp], [Disable ortp support]),
318 if test x$enableval = xno; then
319 have_ortp=no
320 fi
321 )
322 if test "$have_ortp" = "yes"; then
323 AC_CHECK_HEADERS([ortp/ortp.h], [], [
324 have_ortp="no"
325 ])
326 AC_CHECK_LIB([ortp], [ortp_init], [], [
327 have_ortp="no"
328 ])
329 fi
330 if test "$have_ortp" = "yes"; then
331 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
332 recv_errlist_objs="$recv_errlist_objs ortp_recv"
333
334 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
335 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
336
337 server_errlist_objs="$server_errlist_objs ortp_send"
338
339 recv_ldflags="$recv_ldflags -lortp"
340 server_ldflags="$server_ldflags -lortp"
341 audiod_ldflags="$audiod_ldflags -lortp"
342 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
343
344 else
345 AC_MSG_NOTICE([deactivating ortp support])
346 fi
347 AC_SUBST(GLIB_CFLAGS)
348 AC_SUBST(GLIB_LIBS)
349
350 ########################################################################### zmw
351 slide="para_slider"
352 msg="can not build para_slider"
353 CPPFLAGS="$GTK_CFLAGS"
354 LDFLAGS="$LDFLAGS $GTK_LIBS"
355 AC_CHECK_HEADERS([zmw/zmw.h], [], [
356 AC_MSG_WARN([zero memory widget header files not found, $msg])
357 slide=""
358 ])
359 AC_CHECK_LIB([zmw], [zmw_init], [], [
360 AC_MSG_WARN([zero memory widget library not found, $msg])
361 slide=""
362 ])
363 extras="$extras $slide"
364
365
366
367
368
369 AC_SUBST(extra_binaries, [$extras])
370 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
371 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
372 AC_SUBST(install_sh, [$INSTALL])
373 AC_CONFIG_FILES([Makefile])
374
375
376
377 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
378 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) }])
379
380 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
381 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
382 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
383 server_objs="$server_cmdline_objs $server_errlist_objs"
384 write_objs="$write_cmdline_objs $write_errlist_objs"
385 client_objs="$client_cmdline_objs $client_errlist_objs"
386
387 AC_SUBST(recv_objs, add_dot_o($recv_objs))
388 AC_SUBST(recv_ldflags, $recv_ldflags)
389 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
390 errors used by para_recv)
391
392 AC_SUBST(filter_objs, add_dot_o($filter_objs))
393 AC_SUBST(filter_ldflags, $filter_ldflags)
394 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
395 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
396
397 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
398 AC_SUBST(audiod_ldflags, $audiod_ldflags)
399 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
400 errors used by para_audiod)
401
402 AC_SUBST(server_objs, add_dot_o($server_objs))
403 AC_SUBST(server_ldflags, $server_ldflags)
404 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
405 objlist_to_errlist($server_errlist_objs), errors used by para_server)
406
407 AC_SUBST(write_objs, add_dot_o($write_objs))
408 AC_SUBST(write_ldflags, $write_ldflags)
409 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
410 objlist_to_errlist($write_errlist_objs), errors used by para_write)
411
412 AC_SUBST(client_objs, add_dot_o($client_objs))
413 AC_SUBST(client_ldflags, $client_ldflags)
414 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
415 objlist_to_errlist($client_errlist_objs), errors used by para_client)
416
417 enum="$(for i in $write_writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
418 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
419 enum of supported writers)
420 names="$(for i in $write_writers; do printf \"$i\",' ' ; done)"
421 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
422 inits="$(for i in $write_writers; do printf 'extern void '$i'_writer_init(struct writer *); '; done)"
423 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
424 array="$(for i in $write_writers; do printf '{.init = '$i'_writer_init},'; done)"
425 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
426
427 gui_cmdline_objs="gui.cmdline"
428 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
429 gui_other_objs="gui gui_common gui_theme"
430 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
431 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
432 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
433 AC_SUBST(gui_objs, add_dot_o($gui_objs))
434
435 AC_OUTPUT
436 AC_MSG_NOTICE([creating Makefile.deps])
437 gcc -MM -MG $mysql_cppflags $faad_cppflags *.c > Makefile.deps
438 AC_MSG_NOTICE([
439 paraslash configuration:
440 ~~~~~~~~~~~~~~~~~~~~~~~~
441 mysql support: $have_mysql
442 ogg vorbis support: $have_ogg
443 mp3dec support (libmad): $have_mad
444 aac support (libfaad): $have_faad
445 ortp support: $have_ortp
446 unix socket credentials: $have_ucred
447 supported writers for para_write: $write_writers
448 ])