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