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