new function: set_stream_fds()
[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([readline], [readline], [],
55 [AC_MSG_ERROR([libreadline not found])])
56 AC_CHECK_LIB([menu], [new_menu], [extras="$extras para_dbadm"],
57 [AC_MSG_WARN([libmenu not found, cannot build para_dbadm])])
58
59
60 recv_cmdline_objs="recv.cmdline http_recv.cmdline dccp_recv.cmdline"
61 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
62 dccp fd"
63 recv_ldflags=""
64
65 filter_cmdline_objs="filter.cmdline compress_filter.cmdline"
66 filter_errlist_objs="filter_chain wav compress filter string"
67 filter_ldflags=""
68
69 audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
70 http_recv.cmdline dccp_recv.cmdline"
71 audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net
72 time grab_client filter_chain wav compress http_recv dccp dccp_recv recv_common fd"
73 audiod_ldflags=""
74
75 server_cmdline_objs="server.cmdline"
76 server_errlist_objs="server mp3 afs command net string signal random_selector
77 time daemon stat crypt http_send db close_on_fork playlist_selector
78 ipc dccp dccp_send fd"
79 server_ldflags=""
80
81 ########################################################################### ssl
82 dnl @synopsis CHECK_SSL
83 dnl
84 dnl based on the follwing macro from the autoconf archive
85 dnl
86 dnl @category InstalledPackages
87 dnl @author Mark Ethan Trostler <trostler@juniper.net>
88 dnl @version 2003-01-28
89 dnl @license AllPermissive
90
91 AC_DEFUN([CHECK_SSL],
92 [
93 for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
94 AC_MSG_CHECKING(for openssl in $ssldir)
95 if test -f "$ssldir/include/openssl/ssl.h"; then
96 found_ssl="yes"
97 AC_MSG_RESULT(yes)
98 SSL_CFLAGS="-I$ssldir/include/openssl"
99 SSL_CPPFLAGS="-I$ssldir/include/openssl"
100 break
101 fi
102 if test -f "$ssldir/include/ssl.h"; then
103 found_ssl="yes";
104 AC_MSG_RESULT(yes)
105 SSL_CFLAGS="-I$ssldir/include/";
106 SSL_CPPFLAGS="-I$ssldir/include/";
107 break
108 fi
109 AC_MSG_RESULT(no)
110 done
111 if test x_$found_ssl != x_yes; then
112 AC_MSG_ERROR(Cannot find ssl libraries)
113 else
114 SSL_LIBS="-lssl -lcrypto";
115 SSL_LDFLAGS="-L$ssldir/lib";
116 fi
117 AC_SUBST(SSL_CPPFLAGS)
118 AC_SUBST(SSL_CFLAGS)
119 AC_SUBST(SSL_LIBS)
120 AC_SUBST(SSL_LDFLAGS)
121 ])dnl
122
123 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
124 [Search for openssl also in path.])])
125 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
126 CHECK_SSL($enable_ssldir)
127 server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS"
128
129 ########################################################################### gtk2
130
131 pkg_modules="gtk+-2.0 >= 2.0.0"
132 PKG_CHECK_MODULES(GTK, [$pkg_modules], [extras="$extras para_krell.so"], [
133 AC_MSG_WARN([gtk+-2 not found, can not build para_krell])
134 ])
135 AC_SUBST(GTK_CFLAGS)
136 AC_SUBST(GTK_LIBS)
137
138 ########################################################################### sdl
139 AC_CHECK_LIB([SDL_image], [SDL_Init], [extras="$extras para_sdl_gui"], [
140 AC_MSG_WARN([libSDL_image not found, cannot build para_sdl_gui])
141 ])
142 AC_CHECK_HEADER(SDL/SDL.h, [],
143 [AC_MSG_WARN([SDL/SDL.h not found])])
144
145 ########################################################################### mysql
146 have_mysql="yes"
147 AC_CHECK_HEADER(mysql/mysql.h, [], [
148 have_mysql="no"
149 ])
150 AC_CHECK_LIB([mysqlclient], [mysql_init], [], [
151 have_mysql="no"
152 ])
153 if test "$have_mysql" = "yes"; then
154 server_ldflags="$server_ldflags -lmysqlclient"
155 server_errlist_objs="$server_errlist_objs mysql_selector"
156 AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
157 else
158 AC_MSG_WARN([cannot build mysql-based audio file selector])
159 fi
160 ########################################################################### ogg
161 have_ogg="yes"
162 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [
163 have_ogg="no"
164 ])
165 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [
166 have_ogg="no"
167 ])
168 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [
169 have_ogg="no"
170 ])
171 if test "$have_ogg" = "yes"; then
172 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
173 server_ldflags="$server_ldflags -logg -lvorbis -lvorbisfile"
174 filter_ldflags="$filter_ldflags -lvorbis -lvorbisfile"
175 audiod_ldflags="$audiod_ldflags -lvorbis -lvorbisfile"
176
177 filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
178 audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
179
180 server_errlist_objs="$server_errlist_objs ogg"
181 filter_errlist_objs="$filter_errlist_objs oggdec"
182 audiod_errlist_objs="$audiod_errlist_objs oggdec"
183 else
184 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
185 fi
186 ########################################################################### mad
187 have_mad="yes"
188 AC_CHECK_HEADERS([mad.h], [], [
189 have_mad="no"
190 ])
191 AC_CHECK_LIB([mad], [mad_stream_init], [], [
192 have_mad="no"
193 ])
194 if test "$have_mad" = "yes"; then
195 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
196 filter_errlist_objs="$filter_errlist_objs mp3dec"
197 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
198 filter_ldflags="$filter_ldflags -lmad"
199 audiod_ldflags="$audiod_ldflags -lmad"
200 else
201 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
202 fi
203 ########################################################################### alsa
204 play="para_play"
205 msg="will not build para_play"
206 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
207 AC_MSG_WARN([no alsa/asoundlib, $msg])
208 play=""
209 ])
210 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
211 AC_MSG_WARN([no libasound, $msg])
212 play=""
213 ])
214 extras="$extras $play"
215
216
217 ########################################################################### ortp
218 have_ortp="yes"
219 AC_CHECK_HEADERS([ortp/ortp.h], [], [
220 have_ortp="no"
221 ])
222 AC_CHECK_LIB([ortp], [ortp_init], [], [
223 have_ortp="no"
224 ])
225 if test "$have_ortp" = "yes"; then
226 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
227 recv_errlist_objs="$recv_errlist_objs ortp_recv"
228
229 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
230 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
231
232 server_errlist_objs="$server_errlist_objs ortp_send"
233
234 recv_ldflags="$recv_ldflags -lortp"
235 server_ldflags="$server_ldflags -lortp"
236 audiod_ldflags="$audiod_ldflags -lortp"
237 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
238
239 else
240 AC_MSG_WARN([deactivating ortp support])
241 fi
242 AC_SUBST(GLIB_CFLAGS)
243 AC_SUBST(GLIB_LIBS)
244
245 ########################################################################### zmw
246 slide="para_slider"
247 msg="can not build para_slider"
248 CPPFLAGS="$GTK_CFLAGS"
249 LDFLAGS="$LDFLAGS $GTK_LIBS"
250 AC_CHECK_HEADERS([zmw/zmw.h], [], [
251 AC_MSG_WARN([zero memory widget header files not found, $msg])
252 slide=""
253 ])
254 AC_CHECK_LIB([zmw], [zmw_init], [], [
255 AC_MSG_WARN([zero memory widget library not found, $msg])
256 slide=""
257 ])
258 extras="$extras $slide"
259
260
261
262
263
264 AC_SUBST(extra_binaries, [$extras])
265 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
266 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
267 AC_SUBST(install_sh, [$INSTALL])
268 AC_CONFIG_FILES([Makefile])
269
270
271
272 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
273 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) }])
274
275 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
276 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
277 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
278 server_objs="$server_cmdline_objs $server_errlist_objs"
279
280 AC_SUBST(recv_objs, add_dot_o($recv_objs))
281 AC_SUBST(recv_ldflags, $recv_ldflags)
282 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
283 errors used by para_recv)
284
285 AC_SUBST(filter_objs, add_dot_o($filter_objs))
286 AC_SUBST(filter_ldflags, $filter_ldflags)
287 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
288 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
289
290 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
291 AC_SUBST(audiod_ldflags, $audiod_ldflags)
292 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
293 errors used by para_audiod)
294
295 AC_SUBST(server_objs, add_dot_o($server_objs))
296 AC_SUBST(server_ldflags, $server_ldflags)
297 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
298 objlist_to_errlist($server_errlist_objs), errors used by para_server)
299
300 gui_cmdline_objs="gui.cmdline"
301 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
302 gui_other_objs="gui gui_common gui_theme"
303 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
304 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
305 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
306 AC_SUBST(gui_objs, add_dot_o($gui_objs))
307
308 AC_OUTPUT
309 AC_MSG_NOTICE([creating Makefile.deps])
310 gcc -MM -MG *.c > Makefile.deps
311 AC_MSG_NOTICE([
312 paraslash configuration:
313 ~~~~~~~~~~~~~~~~~~~~~~~~
314 mysql support: $have_mysql
315 ogg vorbis support: $have_ogg
316 mp3dec support (libmad): $have_mad
317 ortp support: $have_ortp
318 ])