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