configure.ac: Add check for unix socket credentials
[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 ########################################################################### ucred
130
131 AC_MSG_CHECKING(for struct ucred)
132 AC_TRY_LINK([
133 #include <sys/types.h>
134 #include <sys/socket.h>
135 ],[
136 struct ucred sucred; sucred.pid=0;
137 ],[have_ucred=yes],[have_ucred=no])
138 AC_MSG_RESULT($have_ucred)
139 if test ${have_ucred} = yes; then
140 AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
141 fi
142
143 ########################################################################### gtk2
144
145 pkg_modules="gtk+-2.0 >= 2.0.0"
146 PKG_CHECK_MODULES(GTK, [$pkg_modules], [extras="$extras para_krell.so"], [
147 AC_MSG_WARN([gtk+-2 not found, can not build para_krell])
148 ])
149 AC_SUBST(GTK_CFLAGS)
150 AC_SUBST(GTK_LIBS)
151
152 ########################################################################### sdl
153 AC_CHECK_LIB([SDL_image], [SDL_Init], [extras="$extras para_sdl_gui"], [
154 AC_MSG_WARN([libSDL_image not found, cannot build para_sdl_gui])
155 ])
156 AC_CHECK_HEADER(SDL/SDL.h, [],
157 [AC_MSG_WARN([SDL/SDL.h not found])])
158
159 ########################################################################### mysql
160 have_mysql="yes"
161 AC_CHECK_HEADER(mysql/mysql.h, [], [
162 have_mysql="no"
163 ])
164 AC_CHECK_LIB([mysqlclient], [mysql_init], [], [
165 have_mysql="no"
166 ])
167 if test "$have_mysql" = "yes"; then
168 server_ldflags="$server_ldflags -lmysqlclient"
169 server_errlist_objs="$server_errlist_objs mysql_selector"
170 AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
171 else
172 AC_MSG_WARN([cannot build mysql-based audio file selector])
173 fi
174 ########################################################################### ogg
175 have_ogg="yes"
176 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [
177 have_ogg="no"
178 ])
179 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [
180 have_ogg="no"
181 ])
182 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [
183 have_ogg="no"
184 ])
185 if test "$have_ogg" = "yes"; then
186 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
187 server_ldflags="$server_ldflags -logg -lvorbis -lvorbisfile"
188 filter_ldflags="$filter_ldflags -lvorbis -lvorbisfile"
189 audiod_ldflags="$audiod_ldflags -lvorbis -lvorbisfile"
190
191 filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
192 audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
193
194 server_errlist_objs="$server_errlist_objs ogg"
195 filter_errlist_objs="$filter_errlist_objs oggdec"
196 audiod_errlist_objs="$audiod_errlist_objs oggdec"
197 else
198 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
199 fi
200 ########################################################################### mad
201 have_mad="yes"
202 AC_CHECK_HEADERS([mad.h], [], [
203 have_mad="no"
204 ])
205 AC_CHECK_LIB([mad], [mad_stream_init], [], [
206 have_mad="no"
207 ])
208 if test "$have_mad" = "yes"; then
209 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
210 filter_errlist_objs="$filter_errlist_objs mp3dec"
211 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
212 filter_ldflags="$filter_ldflags -lmad"
213 audiod_ldflags="$audiod_ldflags -lmad"
214 else
215 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
216 fi
217 ########################################################################### alsa
218 play="para_play"
219 msg="will not build para_play"
220 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
221 AC_MSG_WARN([no alsa/asoundlib, $msg])
222 play=""
223 ])
224 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
225 AC_MSG_WARN([no libasound, $msg])
226 play=""
227 ])
228 extras="$extras $play"
229
230
231 ########################################################################### ortp
232 have_ortp="yes"
233 AC_CHECK_HEADERS([ortp/ortp.h], [], [
234 have_ortp="no"
235 ])
236 AC_CHECK_LIB([ortp], [ortp_init], [], [
237 have_ortp="no"
238 ])
239 if test "$have_ortp" = "yes"; then
240 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
241 recv_errlist_objs="$recv_errlist_objs ortp_recv"
242
243 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
244 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
245
246 server_errlist_objs="$server_errlist_objs ortp_send"
247
248 recv_ldflags="$recv_ldflags -lortp"
249 server_ldflags="$server_ldflags -lortp"
250 audiod_ldflags="$audiod_ldflags -lortp"
251 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
252
253 else
254 AC_MSG_WARN([deactivating ortp support])
255 fi
256 AC_SUBST(GLIB_CFLAGS)
257 AC_SUBST(GLIB_LIBS)
258
259 ########################################################################### zmw
260 slide="para_slider"
261 msg="can not build para_slider"
262 CPPFLAGS="$GTK_CFLAGS"
263 LDFLAGS="$LDFLAGS $GTK_LIBS"
264 AC_CHECK_HEADERS([zmw/zmw.h], [], [
265 AC_MSG_WARN([zero memory widget header files not found, $msg])
266 slide=""
267 ])
268 AC_CHECK_LIB([zmw], [zmw_init], [], [
269 AC_MSG_WARN([zero memory widget library not found, $msg])
270 slide=""
271 ])
272 extras="$extras $slide"
273
274
275
276
277
278 AC_SUBST(extra_binaries, [$extras])
279 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
280 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
281 AC_SUBST(install_sh, [$INSTALL])
282 AC_CONFIG_FILES([Makefile])
283
284
285
286 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
287 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) }])
288
289 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
290 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
291 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
292 server_objs="$server_cmdline_objs $server_errlist_objs"
293
294 AC_SUBST(recv_objs, add_dot_o($recv_objs))
295 AC_SUBST(recv_ldflags, $recv_ldflags)
296 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
297 errors used by para_recv)
298
299 AC_SUBST(filter_objs, add_dot_o($filter_objs))
300 AC_SUBST(filter_ldflags, $filter_ldflags)
301 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
302 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
303
304 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
305 AC_SUBST(audiod_ldflags, $audiod_ldflags)
306 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
307 errors used by para_audiod)
308
309 AC_SUBST(server_objs, add_dot_o($server_objs))
310 AC_SUBST(server_ldflags, $server_ldflags)
311 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
312 objlist_to_errlist($server_errlist_objs), errors used by para_server)
313
314 gui_cmdline_objs="gui.cmdline"
315 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
316 gui_other_objs="gui gui_common gui_theme"
317 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
318 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
319 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
320 AC_SUBST(gui_objs, add_dot_o($gui_objs))
321
322 AC_OUTPUT
323 AC_MSG_NOTICE([creating Makefile.deps])
324 gcc -MM -MG *.c > Makefile.deps
325 AC_MSG_NOTICE([
326 paraslash configuration:
327 ~~~~~~~~~~~~~~~~~~~~~~~~
328 mysql support: $have_mysql
329 ogg vorbis support: $have_ogg
330 mp3dec support (libmad): $have_mad
331 ortp support: $have_ortp
332 unix socket credentials: $have_ucred
333 ])