22b194821c31891917bc67062071b498a88f9f56
[vlc.git] / configure.ac.in
1 dnl Autoconf settings for vlc
2
3 AC_INIT(vlc,0.5.0-cvs-am)
4
5 CONFIGURE_LINE="$0 $*"
6 CODENAME="Natalya"
7
8 AC_PREREQ(2.50)
9 AC_CONFIG_SRCDIR(src/libvlc.c)
10 AC_CANONICAL_SYSTEM
11
12 dnl XXX: we don't put any flags here, because automake 1.5 doesn't support
13 dnl them. And we need the comma otherwize automake will choke on it.
14 AM_INIT_AUTOMAKE(vlc,0.5.0-cvs-am)
15 AM_CONFIG_HEADER(config.h)
16
17 dnl
18 dnl  Save *FLAGS
19 dnl
20 CPPFLAGS_save="${CPPFLAGS}"
21 CFLAGS_save="${CFLAGS}"
22 CXXFLAGS_save="${CXXFLAGS}"
23 OBJCFLAGS_save="${OBJCFLAGS}"
24 LDFLAGS_save="${LDFLAGS}"
25
26 dnl
27 dnl Check for tools
28 dnl
29 AC_PROG_CC
30 AM_PROG_CC_C_O
31 AC_PROG_CPP
32 AC_PROG_CXX
33 AC_PROG_MAKE_SET
34 AC_PROG_INSTALL
35
36 dnl AC_PROG_OBJC doesn't seem to exist, this is the KDE workaround
37 AC_MSG_CHECKING(for an Objective-C compiler)
38 OBJC="${CXX}"
39 AC_SUBST(OBJC)
40 OBJCFLAGS="${CXXFLAGS} -fgnu-runtime -fconstant-string-class=NSConstantString"
41 AC_SUBST(OBJCFLAGS)
42 dnl _AM_DEPENDENCIES(OBJC) doesn't work, so hard code OBJCDEPMODE here
43 #OBJCDEPMODE="depmode=gcc3"
44 #AC_SUBST(OBJCDEPMODE)
45 _AM_DEPENDENCIES(OBJC)
46 AC_MSG_RESULT(not implemented yet)
47
48 dnl Find the right ranlib, even when cross-compiling
49 AC_CHECK_TOOL(RANLIB, ranlib, :)
50 AC_CHECK_TOOL(STRIP, strip, :)
51
52 dnl
53 dnl Gettext stuff
54 dnl
55 ALL_LINGUAS="de en_GB fr ja no ru nl pl se"
56 AM_GNU_GETTEXT_VERSION(0.10.40)
57 AM_GNU_GETTEXT
58 if test "${nls_cv_force_use_gnu_gettext}" = "yes"; then
59   AC_DEFINE(HAVE_INCLUDED_GETTEXT, 1, Define if we use the local libintl)
60   INCLUDES="${INCLUDES} -I\\\$(top_srcdir)/intl"
61 fi
62 AM_CONDITIONAL(BUILD_INTL, test "${nls_cv_force_use_gnu_gettext}" = "yes")
63
64 dnl AM_PROG_LIBTOOL
65 AC_PROG_INSTALL
66
67 dnl Check for compiler properties
68 AC_C_CONST
69 AC_C_INLINE
70
71 dnl
72 dnl  Set default values
73 dnl
74 LDFLAGS_vlc="${LDFLAGS}"
75 LIBEXT=".so"
76
77 dnl
78 dnl  Check the operating system
79 dnl
80 case "x${target_os}" in
81   x)
82     SYS=unknown
83     ;;
84   xlinux*)
85     SYS=linux
86     ;;
87   xbsdi*)
88     SYS=bsdi
89     CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
90     LDFLAGS_dvd="${LDFLAGS_dvd} -ldvd"
91     LDFLAGS_vcd="${LDFLAGS_vcd} -ldvd"
92     ;;
93   x*bsd*)
94     SYS="${target_os}"
95     CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
96     ;;
97   xdarwin*)
98     SYS=darwin
99     CFLAGS_save="${CFLAGS_save} -no-cpp-precomp"; CFLAGS="${CFLAGS_save}"
100     CXXFLAGS_save="${CXXFLAGS_save} -no-cpp-precomp"; CXXFLAGS="${CXXFLAGS_save}"
101     OBJCFLAGS_save="${OBJCFLAGS_save} -no-cpp-precomp"; OBJCFLAGS="${OBJCFLAGS_save}"
102     LDFLAGS_vlc="${LDFLAGS_vlc} -all_load"
103     LIBEXT=".dylib"
104     ;;
105   x*mingw32* | x*cygwin*)
106     AC_CHECK_TOOL(WINDRES, windres, :)
107     LIBEXT=".dll"
108
109     case "x${target_os}" in
110       x*mingw32*)
111         SYS=mingw32
112         ;;
113       x*cygwin*)
114         dnl Check if we are using the mno-cygwin mode in which case we are
115         dnl actually dealing with a mingw32 compiler.
116         AC_EGREP_CPP(yes,
117             [#ifdef WIN32
118              yes
119              #endif],
120             SYS=mingw32, SYS=cygwin)
121         ;;
122     esac
123
124     if test "x$SYS" = "xmingw32"; then
125         CPPFLAGS_save="${CPPFLAGS_save} -D_OFF_T_ -D_off_t=long"
126         CPPFLAGS="${CPPFLAGS_save}"
127         LDFLAGS_vlc="${LDFLAGS_vlc} -lws2_32 -lnetapi32 -mwindows"
128         LDFLAGS_ipv4="${LDFLAGS_ipv4} -lws2_32"
129         LDFLAGS_ipv6="${LDFLAGS_ipv6} -lws2_32"
130         LDFLAGS_access_http="${LDFLAGS_http} -lws2_32"
131         LDFLAGS_rc="${LDFLAGS_rc} -lws2_32"
132     fi
133     ;;
134   x*nto*)
135     SYS=nto
136     LDFLAGS_x11="${LDFLAGS_x11} -lsocket"
137     LDFLAGS_xvideo="${LDFLAGS_xvideo} -lsocket"
138     ;;
139   xsolaris*)
140     SYS=solaris
141     ;;
142   xhpux*)
143     SYS=hpux
144     LIBEXT=".sl"
145     ;;
146   xbeos)
147     SYS=beos
148     CFLAGS_save="${CFLAGS_save} -Wno-multichar -Wno-ctor-dtor-privacy -Woverloaded-virtual"; CFLAGS="${CFLAGS_save}"
149     CXXFLAGS_save="${CXXFLAGS_save} -Wno-multichar -Wno-ctor-dtor-privacy -Woverloaded-virtual"; CXXFLAGS="${CXXFLAGS_save}"
150     LDFLAGS_vlc="${LDFLAGS_vlc} -lbe"
151     LDFLAGS_plugins="${LDFLAGS_plugins} -nostart"
152     LDFLAGS_beos="${LDFLAGS_beos} -lbe -lmedia -lroot -ltracker -lstdc++.r4 -ltranslation"
153     LDFLAGS_ipv4="${LDFLAGS_ipv4} -lbind"
154     ;;
155   x*)
156     SYS="${target_os}"
157     ;;
158 esac
159 AM_CONDITIONAL(HAVE_BEOS, test "x${SYS}" = "xbeos")
160 AM_CONDITIONAL(HAVE_DARWIN, test "x${SYS}" = "xdarwin")
161 AM_CONDITIONAL(HAVE_WIN32, test "x${SYS}" = "xmingw32")
162
163 AC_MSG_CHECKING(for suffix of libraries)
164 AC_MSG_RESULT(${LIBEXT})
165
166 dnl Check for the need to include the mingwex lib for mingw32
167 if test x$SYS = xmingw32
168 then
169     AC_CHECK_LIB(mingwex,opendir,
170         AC_CHECK_LIB(mingw32,opendir,LDFLAGS_vlc="${LDFLAGS_vlc}",
171             [LDFLAGS_vlc="${LDFLAGS_vlc} -lmingwex"
172              LDFLAGS_gtk="${LDFLAGS_gtk} -lmingwex"])
173     )
174 fi
175
176 dnl Check for fnative-struct or mms-bitfields support for mingw32
177 if test x$SYS = xmingw32
178 then
179     AC_CACHE_CHECK([if \$CC accepts -mms-bitfields],
180         [ac_cv_c_mms_bitfields],
181         [CFLAGS="${CFLAGS_save} -mms-bitfields"
182          AC_TRY_COMPILE([],,ac_cv_c_mms_bitfields=yes, ac_cv_c_mms_bitfields=no)])
183     if test x"$ac_cv_c_mms_bitfields" != x"no"; then
184         CFLAGS_mingw32_special="-mms-bitfields"
185     else
186         CFLAGS_mingw32_special="-fnative-struct"
187     fi
188
189     CFLAGS_save="${CFLAGS_save} ${CFLAGS_mingw32_special}"; CFLAGS="${CFLAGS_save}"
190 fi
191
192 dnl Flags for plugin compilation
193 case "x${SYS}" in
194   xmingw32|xcygwin)
195     CFLAGS_pics="${CFLAGS_pics} ${CFLAGS_mingw32_special}"
196     CXXFLAGS_pics="${CXXFLAGS_pics} ${CFLAGS_mingw32_special}"
197     OBJCFLAGS_pics="${OBJCFLAGS_pics} ${CFLAGS_mingw32_special}"
198     CFLAGS_plugins="${CFLAGS_plugins} ${CFLAGS_mingw32_special}"
199     CXXFLAGS_plugins="${CXXFLAGS_plugins} ${CFLAGS_mingw32_special}"
200     OBJCFLAGS_plugins="${OBJCFLAGS_plugins} ${CFLAGS_mingw32_special}"
201     ;;
202   x*)
203     CFLAGS_pics="${CFLAGS_pics} -fPIC"
204     CXXFLAGS_pics="${CXXFLAGS_pics} -fPIC"
205     OBJCFLAGS_pics="${OBJCFLAGS_pics} -fPIC"
206     CFLAGS_plugins="${CFLAGS_plugins} -fPIC"
207     CXXFLAGS_plugins="${CXXFLAGS_plugins} -fPIC"
208     OBJCFLAGS_plugins="${OBJCFLAGS_plugins} -fPIC"
209     LDFLAGS_plugins="${LDFLAGS_plugins} -fPIC"
210     ;;
211 esac
212
213 dnl The -DSYS_FOO flag
214 CPPFLAGS_save="${CPPFLAGS_save} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`"; CPPFLAGS="${CPPFLAGS_save}"
215
216 dnl Check for system libs needed
217 AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol isatty vasprintf swab sigrelse getpwuid memalign posix_memalign gethostbyname2 atoll strndup)
218
219 AC_CHECK_FUNC(connect,,[
220   AC_CHECK_LIB(socket,connect,
221     LDFLAGS_ipv4="${LDFLAGS_ipv4} -lsocket"
222     LDFLAGS_vlc="${LDFLAGS_vlc} -lsocket"
223 )])
224
225 AC_CHECK_FUNC(send,,[
226   AC_CHECK_LIB(socket,send,
227     LDFLAGS_http="${LDFLAGS_http} -lsocket"
228 )])
229
230 AC_CHECK_FUNC(gethostbyname,,[
231   AC_CHECK_LIB(nsl,gethostbyname,LDFLAGS_ipv4="${LDFLAGS_ipv4} -lnsl",[
232     AC_CHECK_LIB(bind,gethostbyname,LDFLAGS_ipv4="${LDFLAGS_ipv4} -lbind")])
233 ])
234
235 have_nanosleep=false
236 AC_CHECK_FUNC(nanosleep,have_nanosleep=:,[
237   AC_CHECK_LIB(rt,nanosleep,
238     [LDFLAGS_vlc="${LDFLAGS_vlc} -lrt"; have_nanosleep=:],
239     [AC_CHECK_LIB(posix4,nanosleep,
240         [LDFLAGS_vlc="${LDFLAGS_vlc} -lposix4"; have_nanosleep=:])]
241   )
242 ])
243 if ${have_nanosleep}; then
244   AC_DEFINE(HAVE_NANOSLEEP, 1,
245             Define if nanosleep is available.)
246 fi
247 # HP/UX port
248 AC_CHECK_LIB(rt,sem_init, [LDFLAGS_vlc="${LDFLAGS_vlc} -lrt"])
249
250 AC_CHECK_FUNC(inet_aton,,[
251   AC_CHECK_LIB(resolv,inet_aton,LDFLAGS_ipv4="${LDFLAGS_ipv4} -lresolv")
252 ])
253 AC_CHECK_FUNC(textdomain,,[
254   AC_CHECK_LIB(intl,textdomain,
255     LDFLAGS_vlc="${LDFLAGS_vlc} -lintl"
256     LDFLAGS_plugins="${LDFLAGS_plugins} -lintl"
257   )
258 ])
259
260 dnl Check for getopt
261 need_getopt=false
262 AC_CHECK_FUNC(getopt_long,[AC_DEFINE(HAVE_GETOPT_LONG,1,long getopt support)],
263 [ # FreeBSD has a gnugetopt library for this:
264   AC_CHECK_LIB([gnugetopt],[getopt_long],
265     [AC_DEFINE(HAVE_GETOPT_LONG,1,getopt support) LDFLAGS_vlc="${LDFLAGS_vlc} -lgnugetopt"],
266     [need_getopt=:])])
267 AM_CONDITIONAL(BUILD_GETOPT, ${need_getopt})
268
269 AC_TYPE_SIGNAL
270 AC_CHECK_LIB(dl,dlopen,LDFLAGS_vlc="${LDFLAGS_vlc} -ldl")
271 AC_CHECK_LIB(m,cos,
272   LDFLAGS_imdct="${LDFLAGS_imdct} -lm"
273   LDFLAGS_filter_distort="${LDFLAGS_filter_distort} -lm")
274 AC_CHECK_LIB(m,pow,
275   LDFLAGS_ffmpeg="${LDFLAGS_ffmpeg} -lm"
276   LDFLAGS_imdct="${LDFLAGS_imdct} -lm"
277   LDFLAGS_imdct3dn="${LDFLAGS_imdct3dn} -lm"
278   LDFLAGS_imdctsse="${LDFLAGS_imdctsse} -lm"
279   LDFLAGS_i420_rgb="${LDFLAGS_i420_rgb} -lm"
280   LDFLAGS_faad="${LDFLAGS_faad} -lm"
281 )
282
283 dnl Check for pthreads - borrowed from XMMS
284 THREAD_LIB=error
285 if test "x${THREAD_LIB}" = "xerror"; then
286   AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread")
287 fi
288 if test "x${THREAD_LIB}" = "xerror"; then
289   AC_CHECK_LIB(pthreads,main,THREAD_LIB="-lpthreads")
290 fi
291 if test "x${THREAD_LIB}" = "xerror"; then
292   AC_CHECK_LIB(c_r,main,THREAD_LIB="-lc_r")
293 fi
294 if test "x${THREAD_LIB}" = "xerror"; then
295   AC_CHECK_FUNC(pthread_mutex_lock)
296   THREAD_LIB=""
297 fi
298
299 dnl Check for cthreads under GNU/Hurd for instance
300 AC_CHECK_LIB(threads,cthread_fork,THREAD_LIB="-lthreads")
301
302 dnl Check for misc headers
303 AC_EGREP_HEADER(pthread_cond_t,pthread.h,[
304   AC_DEFINE(PTHREAD_COND_T_IN_PTHREAD_H, 1,
305             Define if <pthread.h> defines pthread_cond_t.)])
306 AC_EGREP_HEADER(pthread_once,pthread.h,[
307   AC_DEFINE(PTHREAD_ONCE_IN_PTHREAD_H, 1,
308             Define if <pthread.h> defines pthread_once.)])
309 AC_EGREP_HEADER(strncasecmp,strings.h,[
310   AC_DEFINE(STRNCASECMP_IN_STRINGS_H, 1,
311             Define if <strings.h> defines strncasecmp.)])
312
313 dnl Check for headers
314 AC_CHECK_HEADERS(stdint.h getopt.h strings.h inttypes.h sys/int_types.h)
315 AC_CHECK_HEADERS(sys/sockio.h fcntl.h sys/types.h sys/time.h sys/times.h sys/ioctl.h)
316 AC_CHECK_HEADERS(dlfcn.h image.h)
317 AC_CHECK_HEADERS(arpa/inet.h net/if.h netinet/in.h sys/socket.h)
318 AC_CHECK_HEADERS(machine/param.h sys/shm.h)
319 AC_CHECK_HEADERS(linux/version.h)
320
321 AC_HEADER_TIME
322
323 dnl Mac OS X and other OSes don't have declaration for nanosleep
324 AC_EGREP_HEADER(nanosleep,time.h,[
325   AC_DEFINE(HAVE_DECL_NANOSLEEP, 1,
326             Define if <time.h> defines nanosleep.)
327 ])
328
329 dnl Make sure we have timespecs
330 AC_EGREP_HEADER(timespec,sys/time.h,[
331   AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1,
332             Define if <sys/time.h> defines struct timespec.)
333 ])
334
335 dnl Check for threads library
336 AC_CHECK_HEADERS(cthreads.h pthread.h kernel/scheduler.h kernel/OS.h)
337
338 dnl Default X headers and libraries
339 if test "x${x_includes}" = "xNONE"; then
340   x_includes="/usr/X11R6/include"
341 fi
342 if test "x${x_libraries}" = "xNONE"; then
343   x_libraries="/usr/X11R6/lib"
344 fi
345
346 dnl Build the gtk_main plugins?
347 NEED_GTK_MAIN=no
348 NEED_GNOME_MAIN=no
349
350 dnl Check for DPMS
351 if test "x${SYS}" != "xmingw32"
352 then
353   CPPFLAGS="${CPPFLAGS_save} -I${x_includes}"
354   AC_CHECK_HEADERS(X11/extensions/dpms.h, [
355     AC_EGREP_HEADER(DPMSInfo,X11/extensions/dpms.h,[
356       AC_DEFINE(DPMSINFO_IN_DPMS_H, 1,
357                 Define if <X11/extensions/dpms.h> defines DPMSInfo.)
358     ])
359   ])
360   CPPFLAGS="${CPPFLAGS_save}"
361 fi
362
363 dnl Check for ntohl, etc.
364 AC_CACHE_CHECK([for ntohl in sys/param.h],
365     [ac_cv_c_ntohl_sys_param_h],
366     [CFLAGS="${CFLAGS_save} -Wall -Werror"
367      AC_TRY_COMPILE([#include <sys/param.h>],
368         [void foo() { int meuh; ntohl(meuh); }],
369         ac_cv_c_ntohl_sys_param_h=yes, ac_cv_c_ntohl_sys_param_h=no)])
370 if test "x${ac_cv_c_ntohl_sys_param_h}" != "xno"; then
371     AC_DEFINE(NTOHL_IN_SYS_PARAM_H, 1, Define if <sys/param.h> defines ntohl.)
372 fi
373
374 dnl Check for inline function size limit
375 AC_CACHE_CHECK([if \$CC accepts -finline-limit],
376     [ac_cv_c_inline_limit],
377     [CFLAGS="${CFLAGS_save} -finline-limit-30000"
378      AC_TRY_COMPILE([],,ac_cv_c_inline_limit=yes, ac_cv_c_inline_limit=no)])
379 if test "x${ac_cv_c_inline_limit}" != "xno"; then
380     CFLAGS_save="${CFLAGS_save} -finline-limit-30000"; CFLAGS="${CFLAGS_save}"
381     CXXFLAGS_save="${CXXFLAGS_save} -finline-limit-30000"; CXXFLAGS="${CXXFLAGS_save}"
382     OBJCFLAGS_save="${OBJCFLAGS_save} -finline-limit-30000"; OBJCFLAGS="${OBJCFLAGS_save}"
383 fi
384
385 dnl Check for -W or -w flags
386 AC_CACHE_CHECK([if \$CC accepts -Wall -Winline],
387     [ac_cv_c_Wall_Winline],
388     [CFLAGS="-Wall -Winline ${CFLAGS_save}"
389      AC_TRY_COMPILE([],,ac_cv_c_Wall_Winline=yes, ac_cv_c_Wall_Winline=no)])
390 if test "x${ac_cv_c_Wall_Winline}" != "xno"; then
391     CFLAGS_save="-Wall -Winline ${CFLAGS_save}"; CFLAGS="${CFLAGS_save}"
392     CXXFLAGS_save="-Wall -Winline ${CXXFLAGS_save}"; CXXFLAGS="${CXXFLAGS_save}"
393     OBJCFLAGS_save="-Wall -Winline ${OBJCFLAGS_save}"; OBJCFLAGS="${OBJCFLAGS_save}"
394 else
395     AC_CACHE_CHECK([if \$CC accepts -wall -winline],
396         [ac_cv_c_wall_winline],
397         [CFLAGS="-wall -winline ${CFLAGS_save}"
398          AC_TRY_COMPILE([],,ac_cv_c_wall_winline=yes, ac_cv_c_wall_winline=no)])
399     if test "x${ac_cv_c_wall_winline}" != "xno"; then
400         CFLAGS_save="-wall -winline ${CFLAGS_save}"; CFLAGS="${CFLAGS_save}"
401         CXXFLAGS_save="-wall -winline ${CXXFLAGS_save}"; CXXFLAGS="${CXXFLAGS_save}"
402         OBJCFLAGS_save="-wall -winline ${OBJCFLAGS_save}"; OBJCFLAGS="${OBJCFLAGS_save}"
403     fi
404 fi
405
406 dnl Check for -pipe
407 AC_CACHE_CHECK([if \$CC accepts -pipe],
408     [ac_cv_c_pipe],
409     [CFLAGS="${CFLAGS_save} -pipe"
410      AC_TRY_COMPILE([],,ac_cv_c_pipe=yes, ac_cv_c_pipe=no)])
411 if test "x${ac_cv_c_pipe}" != "xno"; then
412     CFLAGS_save="${CFLAGS_save} -pipe"; CFLAGS="${CFLAGS_save}"
413     CXXFLAGS_save="${CXXFLAGS_save} -pipe"; CXXFLAGS="${CXXFLAGS_save}"
414     OBJCFLAGS_save="${OBJCFLAGS_save} -pipe"; OBJCFLAGS="${OBJCFLAGS_save}"
415 fi
416
417 dnl Check for various optimization flags
418 AC_CACHE_CHECK([if \$CC accepts -O3],
419     [ac_cv_c_o3],
420     [CFLAGS="${CFLAGS_save} -O3"
421      AC_TRY_COMPILE([],,ac_cv_c_o3=yes, ac_cv_c_o3=no)])
422 if test "x${ac_cv_c_o3}" != "xno"; then
423     CFLAGS_OPTIM="${CFLAGS_OPTIM} -O3"
424 else
425     AC_CACHE_CHECK([if \$CC accepts -O2],
426         [ac_cv_c_o2],
427         [CFLAGS="${CFLAGS_save} -O2"
428          AC_TRY_COMPILE([],,ac_cv_c_o2=yes, ac_cv_c_o2=no)])
429     if test "x${ac_cv_c_o2}" != "xno"; then
430         CFLAGS_OPTIM="${CFLAGS_OPTIM} -O2"
431     else
432         AC_CACHE_CHECK([if \$CC accepts -O],
433             [ac_cv_c_o],
434             [CFLAGS="${CFLAGS_save} -O"
435              AC_TRY_COMPILE([],,ac_cv_c_o=yes, ac_cv_c_o=no)])
436         if test "x${ac_cv_c_o}" != "xno"; then
437             CFLAGS_OPTIM="${CFLAGS_OPTIM} -O"
438         fi
439     fi
440 fi
441
442 dnl Check for -ffast-math
443 AC_CACHE_CHECK([if \$CC accepts -ffast-math],
444     [ac_cv_c_fast_math],
445     [CFLAGS="${CFLAGS_save} -ffast-math"
446      AC_TRY_COMPILE([],,ac_cv_c_fast_math=yes, ac_cv_c_fast_math=no)])
447 if test "x${ac_cv_c_fast_math}" != "xno"; then
448     CFLAGS_OPTIM="${CFLAGS_OPTIM} -ffast-math"
449 fi
450
451 dnl Check for -funroll-loops
452 AC_CACHE_CHECK([if \$CC accepts -funroll-loops],
453     [ac_cv_c_unroll_loops],
454     [CFLAGS="${CFLAGS_save} -funroll-loops"
455      AC_TRY_COMPILE([],,ac_cv_c_unroll_loops=yes, ac_cv_c_unroll_loops=no)])
456 if test "x${ac_cv_c_unroll_loops}" != "xno"; then
457     CFLAGS_OPTIM="${CFLAGS_OPTIM} -funroll-loops"
458 fi
459
460 dnl Check for -fomit-frame-pointer
461 AC_CACHE_CHECK([if \$CC accepts -fomit-frame-pointer],
462     [ac_cv_c_omit_frame_pointer],
463     [CFLAGS="${CFLAGS_save} -fomit-frame-pointer"
464      AC_TRY_COMPILE([],,ac_cv_c_omit_frame_pointer=yes, ac_cv_c_omit_frame_pointer=no)])
465 if test "x${ac_cv_c_omit_frame_pointer}" != "xno"; then
466     CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fomit-frame-pointer"
467     # this plugin does not compile without -fomit-frame-pointer, damn gcc!
468     CFLAGS_i420_yuy2_mmx="${CFLAGS_i420_yuy2_mmx} -fomit-frame-pointer"
469 fi
470
471 dnl Check for Darwin plugin linking flags
472 AC_CACHE_CHECK([if \$CC accepts -bundle -undefined error -lcc_dynamic],
473     [ac_cv_ld_darwin],
474     [CFLAGS="${CFLAGS_save} -bundle -undefined error -lcc_dynamic"
475      AC_TRY_COMPILE([],,ac_cv_ld_darwin=yes, ac_cv_ld_darwin=no)])
476 if test "x${ac_cv_ld_darwin}" != "xno"; then
477     LDFLAGS_plugins="${LDFLAGS_plugins} -bundle -undefined error -lcc_dynamic"
478 fi
479
480 dnl Check for standard plugin linking flags
481 AC_CACHE_CHECK([if \$CC accepts -shared],
482     [ac_cv_ld_plugins],
483     [CFLAGS="${CFLAGS_save} -shared"
484      AC_TRY_COMPILE([],, ac_cv_ld_plugins=yes, ac_cv_ld_plugins=no)])
485 if test "x${ac_cv_ld_plugins}" != "xno"; then
486     LDFLAGS_plugins="${LDFLAGS_plugins} -shared"
487 fi
488
489 dnl Check for variadic macros
490 AC_CACHE_CHECK([for variadic cpp macros],
491     [ac_cv_cpp_variadic_macros],
492     [CFLAGS="${CFLAGS_save}"
493      AC_TRY_COMPILE(
494          [#include <stdio.h>
495           #define a(b,c...) printf(b,##c)],
496          [a("foo");a("%s","bar");a("%s%s","baz","quux");],
497          ac_cv_cpp_variadic_macros=yes,
498          ac_cv_cpp_variadic_macros=no)])
499 if test "x${ac_cv_cpp_variadic_macros}" != "xno"; then
500     AC_DEFINE(HAVE_VARIADIC_MACROS, 1, Support for variadic macros)
501 fi
502
503 dnl Checks for __attribute__(aligned()) directive
504 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
505     [ac_cv_c_attribute_aligned],
506     [ac_cv_c_attribute_aligned=0
507         CFLAGS="${CFLAGS_save} -Werror"
508     for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do
509         AC_TRY_COMPILE([],
510         [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
511         [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
512     done
513         CFLAGS="${CFLAGS_save}"])
514 if test "x${ac_cv_c_attribute_aligned}" != "x0"; then
515     AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
516         [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
517 fi
518
519 dnl
520 dnl  Check the CPU
521 dnl
522 case "x${target_cpu}" in
523   x)
524     ARCH=unknown
525     ;;
526   *)
527     ARCH="${target_cpu}"
528     ;;
529 esac
530
531 case "${ARCH}" in
532   hppa64)
533     CFLAGS_mpeg_video="${CFLAGS_mpeg_video} -ffunction-sections"
534     ;;
535 esac
536
537 dnl
538 dnl  default modules
539 dnl
540 PLUGINS="${PLUGINS} dummy rc logger access_file memcpy"
541 PLUGINS="${PLUGINS} es audio mpeg_system ps ts"
542 PLUGINS="${PLUGINS} idct idctclassic motion mpeg_video spudec mpeg_audio"
543 #PLUGINS="${PLUGINS} a52old imdct downmix"
544 PLUGINS="${PLUGINS} lpcm a52"
545 PLUGINS="${PLUGINS} deinterlace invert wall transform distort clone crop motionblur"
546 PLUGINS="${PLUGINS} float32tos16 float32tos8 float32tou16 float32tou8 a52tospdif fixed32tofloat32 fixed32tos16 s16tofloat32 s16tofloat32swab"
547 PLUGINS="${PLUGINS} trivial_resampler ugly_resampler"
548 PLUGINS="${PLUGINS} trivial_channel_mixer"
549 PLUGINS="${PLUGINS} trivial_mixer spdif_mixer"
550 PLUGINS="${PLUGINS} aout_file"
551 #PLUGINS="${PLUGINS} scope"
552 PLUGINS="${PLUGINS} i420_rgb i420_yuy2 i422_yuy2 i420_ymga"
553 PLUGINS="${PLUGINS} id3"
554 PLUGINS="${PLUGINS} wav araw"
555
556 dnl
557 dnl  Network modules
558 dnl
559 NETWORK_MODULES="access_udp access_http access_rtp ipv4"
560
561 dnl
562 dnl  Accelerated modules
563 dnl
564 MMX_MODULES="memcpymmx idctmmx motionmmx i420_rgb_mmx i420_yuy2_mmx i422_yuy2_mmx i420_ymga_mmx"
565 MMXEXT_MODULES="memcpymmxext idctmmxext motionmmxext"
566 THREEDNOW_MODULES="memcpy3dn imdct3dn downmix3dn"
567 SSE_MODULES="imdctsse downmixsse"
568 ALTIVEC_MODULES="idctaltivec motionaltivec memcpyaltivec"
569
570 if test x${SYS} != xbeos
571 then
572   PLUGINS="${PLUGINS} ${NETWORK_MODULES}"
573 fi
574
575 AC_CACHE_CHECK([if \$CC groks MMX inline assembly],
576     [ac_cv_mmx_inline],
577     [CFLAGS="${CFLAGS_save}"
578      AC_TRY_COMPILE(,[void *p;asm volatile("packuswb %%mm1,%%mm2"::"r"(p));],
579                     ac_cv_mmx_inline=yes, ac_cv_mmx_inline=no)])
580 if test "x${ac_cv_mmx_inline}" != "xno"; then
581   ACCEL_MODULES="${ACCEL_MODULES} ${MMX_MODULES}"
582 fi
583
584 AC_CACHE_CHECK([if \$CC groks MMX EXT inline assembly],
585     [ac_cv_mmxext_inline],
586     [CFLAGS="${CFLAGS_save}"
587      AC_TRY_COMPILE(,[void *p;asm volatile("maskmovq %%mm1,%%mm2"::"r"(p));],
588                     ac_cv_mmxext_inline=yes, ac_cv_mmxext_inline=no)])
589 if test "x${ac_cv_mmxext_inline}" != "xno"; then
590   ACCEL_MODULES="${ACCEL_MODULES} ${MMXEXT_MODULES}"
591 fi
592
593 AC_CACHE_CHECK([if \$CC groks 3D Now! inline assembly],
594     [ac_cv_3dnow_inline],
595     [CFLAGS="${CFLAGS_save}"
596      AC_TRY_COMPILE(,[void *p;asm volatile("pfadd %%mm1,%%mm2"::"r"(p));],
597                     ac_cv_3dnow_inline=yes, ac_cv_3dnow_inline=no)])
598 if test "x${ac_cv_3dnow_inline}" != "xno"; then
599   AC_DEFINE(CAN_COMPILE_3DNOW, 1, Define if \$CC groks 3D Now! inline assembly.)
600   ACCEL_MODULES="${ACCEL_MODULES} ${THREEDNOW_MODULES}"
601 fi
602
603 AC_CACHE_CHECK([if \$CC groks SSE inline assembly],
604     [ac_cv_sse_inline],
605     [CFLAGS="${CFLAGS_save}"
606      AC_TRY_COMPILE(,[void *p;asm volatile("xorps %%xmm1,%%xmm2"::"r"(p));],
607                     ac_cv_sse_inline=yes, ac_cv_sse_inline=no)])
608 if test "x${ac_cv_sse_inline}" != "xno" -a "x${SYS}" != "xmingw32"; then
609   AC_DEFINE(CAN_COMPILE_SSE, 1, Define if \$CC groks SSE inline assembly.)
610   ACCEL_MODULES="${ACCEL_MODULES} ${SSE_MODULES}"
611 fi
612
613 # don't try to grok AltiVec with native mingw32 it doesn't work right now
614 # we should be able to remove this test with future versions of mingw32
615 if test "x${SYS}" != "xmingw32"; then
616 AC_CACHE_CHECK([if \$CC groks AltiVec inline assembly],
617     [ac_cv_altivec_inline],
618     [CFLAGS="${CFLAGS_save}"
619      AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
620          ac_cv_altivec_inline=yes,
621          [CFLAGS="${CFLAGS_save} -Wa,-m7400"
622           AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
623             [ac_cv_altivec_inline="-Wa,-m7400"],
624             ac_cv_altivec_inline=no)
625          ])])
626 if test "x${ac_cv_altivec_inline}" != "xno"; then
627   AC_DEFINE(CAN_COMPILE_ALTIVEC, 1, Define if \$CC groks AltiVec inline assembly.)
628   if test "x${ac_cv_altivec_inline}" != "xyes"; then
629     CFLAGS_idctaltivec="${CFLAGS_idctaltivec} ${ac_cv_altivec_inline}"
630     CFLAGS_motionaltivec="${CFLAGS_motionaltivec} ${ac_cv_altivec_inline}"
631     CFLAGS_memcpyaltivec="${CFLAGS_memcpyaltivec} ${ac_cv_altivec_inline}"
632     CFLAGS_vlc="${CFLAGS_vlc} ${ac_cv_altivec_inline}"
633   fi
634   ACCEL_MODULES="${ACCEL_MODULES} ${ALTIVEC_MODULES}"
635 fi
636
637 AC_CACHE_CHECK([if \$CC groks AltiVec C extensions],
638     [ac_cv_c_altivec],
639     [CFLAGS="${CFLAGS_save} -faltivec"
640      # Darwin test
641      AC_TRY_COMPILE(,[vec_mtvscr((vector unsigned int)(0));],
642         ac_cv_c_altivec=-faltivec, [
643         # Linux/PPC test
644         CFLAGS="${CFLAGS_save} ${CFLAGS_idctaltivec} -fvec"
645         AC_TRY_COMPILE(,[vec_mtvscr((vector unsigned int)(0));],
646             [ac_cv_c_altivec="-fvec"], ac_cv_c_altivec=no)
647         ])
648      CFLAGS="${CFLAGS_save}"])
649 if test "x${ac_cv_c_altivec}" != "xno"; then
650   AC_DEFINE(CAN_COMPILE_C_ALTIVEC, 1, Define if your compiler groks C AltiVec extensions.)
651   CFLAGS_idctaltivec="${CFLAGS_idctaltivec} ${ac_cv_c_altivec}"
652   CFLAGS_motionaltivec="${CFLAGS_motionaltivec} ${ac_cv_c_altivec}"
653   CFLAGS_memcpyaltivec="${CFLAGS_memcpyaltivec} ${ac_cv_c_altivec}"
654   CFLAGS_vlc="${CFLAGS_vlc} ${ac_cv_c_altivec}"
655   ACCEL_MODULES="${ACCEL_MODULES} ${ALTIVEC_MODULES}"
656 fi
657
658 AC_CACHE_CHECK([if linker needs -framework vecLib],
659     [ac_cv_ld_altivec],
660     [LDFLAGS="${LDFLAGS_vlc} -framework vecLib"
661      AC_TRY_LINK([],,ac_cv_ld_altivec=yes,ac_cv_ld_altivec=no)
662      LDFLAGS="${LDFLAGS_save}"
663     ])
664 if test "x${ac_cv_ld_altivec}" != "xno"; then
665   LDFLAGS_idctaltivec="${LDFLAGS_idctaltivec} -framework vecLib"
666   LDFLAGS_motionaltivec="${LDFLAGS_motionaltivec} -framework vecLib"
667   LDFLAGS_memcpyaltivec="${LDFLAGS_memcpyaltivec} -framework vecLib"
668   LDFLAGS_vlc="${LDFLAGS_vlc} -framework vecLib"
669 fi
670 fi # end if mingw32
671
672 AC_ARG_WITH(,[])
673 AC_ARG_WITH(,[Optimization options:])
674
675 dnl
676 dnl  Special arch tuning
677 dnl
678 AC_ARG_WITH(tuning,
679 [  --with-tuning=ARCH      enable special tuning for an architecture
680                           (default i686 on IA-32 and 750 on PPC)])
681 if test "x${with_tuning}" != "x"; then
682     if test "x${target_cpu}" = "xpowerpc"; then
683         CFLAGS_TUNING="-mtune=${with_tuning}"
684     else
685         CFLAGS_TUNING="-mcpu=${with_tuning}"
686     fi
687 else
688     if test "x${target_cpu}" = "xi686" -o "x${target_cpu}" = "xi586" -o "x${target_cpu}" = "xi486" -o "x${target_cpu}" = "xi386"; then CFLAGS_TUNING="-mcpu=pentiumpro"
689     else
690         if test "x${target_cpu}" = "xpowerpc"; then CFLAGS_TUNING="-mtune=750"; fi
691     fi
692 fi
693
694 dnl
695 dnl  x86 accelerations
696 dnl
697 if test "x${target_cpu}" = "xi686" -o "x${target_cpu}" = "xi586" -o "x${target_cpu}" = "xx86" -o "x${target_cpu}" = "xi386"
698 then
699     ARCH="${ARCH} mmx"
700     PLUGINS="${PLUGINS} ${ACCEL_MODULES}"
701 fi
702
703 dnl
704 dnl  Enable/disable optimizations
705 dnl
706 AC_ARG_ENABLE(optimizations,
707 [  --disable-optimizations disable compiler optimizations (default enabled)])
708 AM_CONDITIONAL(OPTIM, test "x${enable_optimizations}" != "xno")
709
710 dnl
711 dnl  AltiVec acceleration
712 dnl
713 AC_ARG_ENABLE(altivec,
714 [  --disable-altivec       disable AltiVec optimizations (default enabled on PPC)],
715 [ if test "x${enable_altivec}" = "xyes"; then ARCH="${ARCH} altivec";
716     BUILTINS="${BUILTINS} ${ACCEL_MODULES}"; fi ],
717 [ if test "x${target_cpu}" = "xpowerpc"; then ARCH="${ARCH} altivec";
718     BUILTINS="${BUILTINS} ${ACCEL_MODULES}"; fi ])
719
720 dnl
721 dnl  Debugging mode
722 dnl
723 AC_ARG_ENABLE(debug,
724 [  --enable-debug          debug mode (default disabled)])
725 AM_CONDITIONAL(DEBUG, test "x${enable_debug}" = "xyes")
726
727 dnl
728 dnl  Enable release-specific flags
729 dnl
730 AC_ARG_ENABLE(release,
731 [  --enable-release        activate extra optimizations (default disabled)])
732 AM_CONDITIONAL(RELEASE, test "x${enable_release}" = "xyes")
733
734 dnl
735 dnl  Input plugins
736 dnl
737
738 AC_ARG_WITH(,[Input plugins:])
739
740 dnl
741 dnl  DVD module: optionally check for installed libdvdcss
742 dnl
743 AC_ARG_ENABLE(dvd,
744 [  --enable-dvd            DVD input module (default enabled)])
745 if test "x${enable_dvd}" != "xno"
746 then
747   AC_ARG_WITH(dvdcss,
748   [    --with-dvdcss=PATH    libdvdcss headers and libraries])
749   AC_ARG_WITH(dvdcss-tree,
750   [    --with-dvdcss-tree=PATH libdvdcss tree for static linking])
751   case "x${with_dvdcss}" in
752   x|xyes)
753     if test "x${with_dvdcss_tree}" = x
754     then
755       AC_CHECK_HEADERS(dvdcss/dvdcss.h,
756         [ PLUGINS="${PLUGINS} dvd"
757           LDFLAGS_dvd="${LDFLAGS_dvd} -ldvdcss" ],
758         [ AC_MSG_WARN([libdvdcss is no longer provided with vlc; please get libdvdcss from http://www.videolan.org/libdvdcss/ and build it. Then either use --with-dvdcss=<path/where/libdvdcss/was/installed> for dynamic linking (recommended under Unix) or --with-dvdcss-tree=<path/where/libdvdcss/was/built> for static linking (recommended under BeOS, Windows, MacOS X). Alternatively you can use --disable-dvd to disable the DVD plugin.])
759           AC_MSG_ERROR([cannot find libdvdcss headers]) ])
760     else
761       AC_MSG_CHECKING(for libdvdcss.a in ${with_dvdcss_tree})
762       real_dvdcss_tree="`cd ${with_dvdcss_tree} 2>/dev/null && pwd`"
763       if test "x${real_dvdcss_tree}" = "x"
764       then
765         dnl  The given directory can't be found
766         AC_MSG_RESULT(no)
767         AC_MSG_ERROR([cannot cd to ${with_dvdcss_tree}])
768       fi
769       if test -f "${real_dvdcss_tree}/src/.libs/libdvdcss.a"
770       then
771         dnl  Use a custom libdvdcss
772         AC_MSG_RESULT(${real_dvdcss_tree}/src/.libs/libdvdcss.a)
773         BUILTINS="${BUILTINS} dvd"
774         LDFLAGS_dvd="${LDFLAGS_dvd} ${real_dvdcss_tree}/src/.libs/libdvdcss.a"
775         CPPFLAGS_dvd="${CPPFLAGS_dvd} -I${real_dvdcss_tree}/src"
776       else
777         dnl  The given libdvdcss wasn't built
778         AC_MSG_RESULT(no)
779         AC_MSG_ERROR([cannot find ${real_dvdcss_tree}/src/.libs/libdvdcss.a, make sure you compiled libdvdcss in ${with_dvdcss_tree}])
780       fi
781     fi
782   ;;
783   xno)
784     dnl  Compile without dvdcss (dlopen version, works only under Linux)
785     PLUGINS="${PLUGINS} dvd"
786     CPPFLAGS_dvd="${CPPFLAGS_dvd} -DGOD_DAMN_DMCA"
787     LDFLAGS_dvd="${LDFLAGS_dvd} -ldl"
788   ;;
789   *)
790     AC_MSG_CHECKING(for dvdcss headers in ${with_dvdcss})
791     if test -f ${with_dvdcss}/include/dvdcss/dvdcss.h
792     then
793       dnl  Use ${with_dvdcss}/include/dvdcss/dvdcss.h
794       AC_MSG_RESULT(yes)
795       PLUGINS="${PLUGINS} dvd"
796       LDFLAGS_dvd="${LDFLAGS_dvd} -L${with_dvdcss}/lib -ldvdcss"
797       CPPFLAGS_dvd="${CPPFLAGS_dvd} -I${with_dvdcss}/include"
798     else
799       dnl  No libdvdcss could be found, sorry
800       AC_MSG_RESULT(no)
801       AC_MSG_ERROR([cannot find ${with_dvdcss}/include/dvdcss/dvdcss.h])
802     fi
803   ;;
804   esac
805 fi
806
807 dnl
808 dnl dvdread module: check for libdvdread plugin
809 dnl
810 AC_ARG_ENABLE(dvdread,
811 [  --enable-dvdread        dvdread input module (default disabled)])
812 if test "x${enable_dvdread}" != "xno"
813 then
814   AC_ARG_WITH(dvdread,
815   [    --with-dvdread=PATH   libdvdread headers and libraries])
816   if test "x${with_dvdread}" = "x"
817   then
818     LDFLAGS_test=""
819     CPPFLAGS_test=""
820   else
821     LDFLAGS_test="-L${with_dvdread}/lib"
822     CPPFLAGS_test="-I${with_dvdread}/include"
823   fi
824   CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test}"
825   AC_CHECK_HEADERS(dvdread/dvd_reader.h, [
826      AC_TRY_COMPILE([#include <dvdread/dvd_reader.h>],
827         [int foo() { return DVD_VIDEO_LB_LEN; }],[
828           PLUGINS="${PLUGINS} dvdread"
829           LDFLAGS_dvdread="${LDFLAGS_dvdread} ${LDFLAGS_test} -ldvdread"
830           CPPFLAGS_dvdread="${CPPFLAGS_dvdread} ${CPPFLAGS_test}"
831         ],[
832           if test "x${enable_dvdread}" != "x"
833           then
834             AC_MSG_ERROR([Cannot find DVD_VIDEO_LB_LEN in dvdread/dvd_reader.h, please install libdvdread version 0.9.2 or later])
835           fi
836         ])
837   ],[
838     if test "x${enable_dvdread}" != "x"
839     then
840       if test "x${with_dvdread}" != "x"
841       then
842         AC_MSG_ERROR([Cannot find dvdread/dvd_reader.h in ${with_dvdread}/include])
843       else
844         AC_MSG_ERROR([Cannot find dvdread/dvd_reader.h])
845       fi
846     fi
847   ])
848   CPPFLAGS="${CPPFLAGS_save}"
849 fi
850
851 dnl
852 dnl dvdplay module: check for libdvdplay
853 dnl
854 AC_ARG_ENABLE(dvdplay,
855 [  --enable-dvdplay        dvdplay input module (default disabled)])
856 if test "x${enable_dvdplay}" != "xno"
857 then
858   AC_ARG_WITH(dvdplay,
859   [    --with-dvdplay=PATH   libdvdplay headers and libraries])
860   if test "x${with_dvdplay}" = x
861   then
862     LDFLAGS_test=""
863     CPPFLAGS_test=""
864   else
865     LDFLAGS_test="-L${with_dvdplay}/lib"
866     CPPFLAGS_test="-I${with_dvdplay}/include"
867   fi
868   CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test}"
869   AC_CHECK_HEADERS(dvdplay/dvdplay.h, [
870       PLUGINS="${PLUGINS} dvdplay"
871       LDFLAGS_dvdplay="${LDFLAGS_dvdplay} ${LDFLAGS_test} -ldvdplay -ldvdread"
872       CPPFLAGS_dvdplay="${CPPFLAGS_dvdplay} ${CPPFLAGS_test}"
873     ],[
874     if test "x${enable_dvdplay}" != x
875     then
876       if test "x${with_dvdplay}" != x
877       then
878         AC_MSG_ERROR([Cannot find dvdplay/dvdplay.h in ${with_dvdplay}/include])
879       else
880         AC_MSG_ERROR([Cannot find dvdplay/dvdplay.h])
881       fi
882     fi
883   ])
884   CPPFLAGS="${CPPFLAGS_save}"
885 fi
886
887
888 dnl
889 dnl  libdvbpsi ts demux
890 dnl
891 AC_ARG_ENABLE(dvbpsi,
892 [  --enable-dvbpsi        dvbpsi ts demux module (default disabled)])
893 if test "x${enable_dvbpsi}" != "xno"
894 then
895   AC_ARG_WITH(dvbpsi,
896   [    --with-dvbpsi=PATH    libdvbpsi headers and libraries])
897   AC_ARG_WITH(dvbpsi,
898   [    --with-dvbpsi-tree=PATH libdvbpsi tree for static linking])
899   case "x${with_dvbpsi}" in
900   x|xyes)
901     if test "x${with_dvbpsi_tree}" = "x"
902     then
903       AC_CHECK_HEADERS(dvbpsi/dr.h,
904         [ PLUGINS="${PLUGINS} ts_dvbpsi"
905           LDFLAGS_ts_dvbpsi="${LDFLAGS_ts_dvbpsi} -ldvbpsi" ], [],
906         [  AC_MSG_ERROR([cannot find libdvbpsi headers]) ])
907     else
908       AC_MSG_CHECKING(for libdvbpsi.a in ${with_dvbpsi_tree})
909       real_dvbpsi_tree="`cd ${with_dvbpsi_tree} 2>/dev/null && pwd`"
910       if test "x${real_dvbpsi_tree}" = "x"
911       then
912         dnl  The given directory can't be found
913         AC_MSG_RESULT(no)
914         AC_MSG_ERROR([cannot cd to ${with_dvbpsi_tree}])
915       fi
916       if test -f "${real_dvbpsi_tree}/src/.libs/libdvbpsi.a"
917       then
918         dnl  Use a custom libdvbpsi
919         AC_MSG_RESULT(${real_dvbpsi_tree}/src/.libs/libdvbpsi.a)
920         BUILTINS="${BUILTINS} ts_dvbpsi"
921         LDFLAGS_ts_dvbpsi="${LDFLAGS_ts_dvbpsi} ${real_dvbpsi_tree}/src/.libs/libdvbpsi.a"
922         CPPFLAGS_ts_dvbpsi="${CPPFLAGS_ts_dvbpsi} -I${real_dvbpsi_tree}/src"
923       else
924         dnl  The given libdvbpsi wasn't built
925         AC_MSG_RESULT(no)
926         AC_MSG_ERROR([cannot find ${real_dvbpsi_tree}/src/.libs/libdvbpsi.a, make sure you compiled libdvbpsi in ${with_dvbpsi_tree}])
927       fi
928     fi
929   ;;
930   xno)
931     dnl  Compile without dvbpsi
932   ;;
933   *)
934     AC_MSG_CHECKING(for dvbpsi headers in ${with_dvbpsi})
935     if test "x${with_dvbpsi}" = "x"
936     then
937       LDFLAGS_test=""
938       CPPFLAGS_test=""
939     else
940       LDFLAGS_test="-L${with_dvbpsi}/lib"
941       CPPFLAGS_test="-I${with_dvbpsi}/include"
942     fi
943     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test}"
944     AC_CHECK_HEADER([dvbpsi/dr.h],[
945       PLUGINS="${PLUGINS} ts_dvbpsi"
946       LDFLAGS_ts_dvbpsi="${LDFLAGS_ts_dvbpsi} ${LDFLAGS_test} -ldvbpsi"
947       CPPFLAGS_ts_dvbpsi="${CPPFLAGS_ts_dvbpsi} ${CPPFLAGS_test}"
948       ],[
949       if test "x${enable_dvbpsi}" != "x"
950       then
951         AC_MSG_ERROR([Could not find libdvbpsi on your system: you may get it from www.videolan.org, you'll need at least version 0.1.1])
952       fi
953     ])
954     CPPFLAGS="${CPPFLAGS_save}"
955   ;;
956   esac
957 fi
958
959 dnl
960 dnl  Video4Linux plugin
961 dnl
962 AC_ARG_ENABLE(v4l,
963   [  --enable-v4l            Video4Linux input support (default disabled)])
964 if test "x${enable_v4l}" = "xyes"
965 then
966   AC_CHECK_HEADERS(libv4l/v4l.h, [
967     PLUGINS="${PLUGINS} v4l"
968    ],[])
969 fi
970
971 dnl
972 dnl  VCD module
973 dnl
974 AC_ARG_ENABLE(vcd,
975   [  --enable-vcd            VCD support for Linux, FreeBSD, MacOS X and Win32 (default enabled)])
976
977 if test "x${enable_vcd}" != "xno"
978 then
979   AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[
980     PLUGINS="${PLUGINS} vcd"
981   ])
982
983   AC_EGREP_HEADER(ioc_toc_header ,sys/cdio.h,[
984     PLUGINS="${PLUGINS} vcd"
985     AC_DEFINE(HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H, 1, For FreeBSD VCD support)
986   ])
987
988   if test "x${SYS}" = "xbsdi" -o "x${SYS}" = "xmingw32"
989   then
990     PLUGINS="${PLUGINS} vcd"
991   fi
992
993   if test "x${SYS}" = "xdarwin"
994   then
995     PLUGINS="${PLUGINS} vcd"
996     LDFLAGS_vcd="${LDFLAGS_vcd} -framework IOKit -framework CoreFoundation"
997   fi
998 fi
999
1000 dnl
1001 dnl  Satellite input module
1002 dnl
1003 AC_ARG_ENABLE(satellite,
1004   [  --enable-satellite      satellite card support (default disabled)],
1005   [ if test "x${enable_satellite}" = "xyes"
1006     then
1007       PLUGINS="${PLUGINS} satellite"
1008     fi])
1009
1010 dnl
1011 dnl  ipv6 plugin - not for QNX yet
1012 dnl
1013 if test "x${SYS}" != "xnto" && test "x${SYS}" != "xmingw32"
1014 then
1015   have_ipv6=false
1016   AC_CHECK_FUNC(inet_pton,[have_ipv6=:],[
1017     AC_CHECK_LIB(resolv,inet_pton,
1018       [have_ipv6=:
1019        LDFLAGS_ipv6="${LDFLAGS_ipv6} -lresolv"])
1020   ])
1021   AC_MSG_CHECKING(for sockaddr_in6 in netinet/in.h)
1022   AC_EGREP_HEADER(sockaddr_in6,netinet/in.h,
1023     [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); have_ipv6=false])
1024   if ${have_ipv6}; then
1025     PLUGINS="${PLUGINS} ipv6"
1026   fi
1027 fi
1028 if test "x${SYS}" = "xmingw32"
1029 then
1030   AC_MSG_CHECKING(for getaddrinfo in ws2tcpip.h)
1031   AC_EGREP_HEADER(addrinfo,ws2tcpip.h,[AC_MSG_RESULT(yes)
1032     PLUGINS="${PLUGINS} ipv6"],[AC_MSG_RESULT(no)])
1033 fi
1034
1035 dnl
1036 dnl  AVI demux plugin
1037 dnl
1038 AC_ARG_ENABLE(avi,
1039   [  --enable-avi            AVI demux module (default enabled)])
1040 if test "x${enable_avi}" != "xno"
1041 then
1042   PLUGINS="${PLUGINS} avi"
1043 fi
1044
1045 dnl
1046 dnl  AAC demux plugin
1047 dnl
1048 AC_ARG_ENABLE(aac,
1049   [  --enable-aac            AAC demux module (default enabled)])
1050 if test "x${enable_aac}" != "xno"
1051 then
1052   PLUGINS="${PLUGINS} aac"
1053 fi
1054
1055 dnl
1056 dnl  Codec plugins
1057 dnl
1058
1059 AC_ARG_WITH(,[Codec plugins:])
1060
1061 dnl
1062 dnl  mad plugin
1063 dnl
1064 AC_ARG_ENABLE(mad,
1065   [  --enable-mad            libmad module (default disabled)])
1066 if test "x${enable_mad}" = "xyes"
1067 then
1068   AC_ARG_WITH(mad,
1069     [    --with-mad=PATH       path to libmad],[],[])
1070   if test "x${with_mad}" != "xno" -a "x${with_mad}" != "x"
1071   then
1072     CPPFLAGS_mad="${CPPFLAGS_mad} -I${with_mad}/include"
1073     LDFLAGS_mad="${LDFLAGS_mad} -L${with_mad}/lib"
1074   fi
1075
1076   AC_ARG_WITH(mad-tree,
1077     [    --with-mad-tree=PATH  mad tree for static linking],[],[])
1078   if test "x${with_mad_tree}" != "xno" -a "x${with_mad_tree}" != "x"
1079   then
1080     real_mad_tree="`cd ${with_mad_tree} 2>/dev/null && pwd`"
1081     if test "x${real_mad_tree}" = "x"
1082     then
1083       dnl  The given directory can't be found
1084       AC_MSG_RESULT(no)
1085       AC_MSG_ERROR([${with_mad_tree} directory doesn't exist])
1086     fi
1087     dnl  Use a custom libmad
1088     AC_MSG_CHECKING(for mad.h in ${real_mad_tree}/libmad)
1089     if test -f ${real_mad_tree}/libmad/mad.h
1090     then
1091       AC_MSG_RESULT(yes)
1092       CPPFLAGS_mad="${CPPFLAGS_mad} -I${real_mad_tree}/libmad"
1093       LDFLAGS_mad="${LDFLAGS_mad} -L${real_mad_tree}/libmad/.libs"
1094       LDFLAGS="${LDFLAGS_save} ${LDFLAGS_mad}"
1095       AC_CHECK_LIB(mad, mad_bit_init, [
1096         BUILTINS="${BUILTINS} mad"
1097         LDFLAGS_mad="${LDFLAGS_mad} -lmad"
1098         ],[ AC_MSG_ERROR([the specified tree hasn't been compiled ])
1099       ],[])
1100       LDFLAGS="${LDFLAGS_save}"
1101     else
1102       AC_MSG_RESULT(no)
1103       AC_MSG_ERROR([the specified tree doesn't have mad.h])
1104     fi
1105   else
1106     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_mad}"
1107     LDFLAGS="${LDFLAGS_save} ${LDFLAGS_mad}"
1108     AC_CHECK_HEADERS(mad.h, ,
1109       [ AC_MSG_ERROR([Cannot find development headers for libmad...]) ])
1110     AC_CHECK_LIB(mad, mad_bit_init, [
1111       PLUGINS="${PLUGINS} mad"
1112       LDFLAGS_mad="${LDFLAGS_mad} -lmad" ],
1113       [ AC_MSG_ERROR([Cannot find libmad library...]) ])
1114     CPPFLAGS="${CPPFLAGS_save}"
1115     LDFLAGS="${LDFLAGS_save}"
1116   fi
1117 fi
1118
1119 dnl
1120 dnl   libid3tag support
1121 dnl
1122 AC_CHECK_HEADERS(id3tag.h, [
1123   LDFLAGS_id3tag="${LDFLAGS_id3tag} -lz -lid3tag"
1124   PLUGINS="${PLUGINS} id3tag"])
1125
1126 dnl
1127 dnl  ffmpeg decoder plugin
1128 dnl
1129 AC_ARG_ENABLE(ffmpeg,
1130 [  --enable-ffmpeg         ffmpeg codec (default disabled)])
1131 if test "x${enable_ffmpeg}" = "xyes"
1132 then
1133   AC_ARG_WITH(ffmpeg,
1134     [    --with-ffmpeg=PATH    path to ffmpeg installation],[],[])
1135   if test "x${with_ffmpeg}" != "xno" -a "x${with_ffmpeg}" != "x"
1136   then
1137     CPPFLAGS_ffmpeg="${CPPFLAGS_ffmpeg} -I${with_ffmpeg}/include/libffmpeg"
1138     LDFLAGS_ffmpeg="${LDFLAGS_ffmpeg} -L${with_ffmpeg}/lib"
1139   fi
1140
1141   dnl Add postprocessing modules
1142   PLUGINS="${PLUGINS} postprocessing_c"
1143   if test "x${ac_cv_mmx_inline}" != "xno"; then
1144     PLUGINS="${PLUGINS} postprocessing_mmx"
1145   fi
1146
1147   if test "x${ac_cv_mmxext_inline}" != "xno"; then
1148     PLUGINS="${PLUGINS} postprocessing_mmxext"
1149   fi
1150
1151   AC_ARG_WITH(ffmpeg-tree,
1152   [    --with-ffmpeg-tree=PATH ffmpeg tree for static linking])
1153   if test "x${with_ffmpeg_tree}" != "x"
1154   then
1155     AC_MSG_CHECKING(for libavcodec.a in ${with_ffmpeg_tree})
1156     real_ffmpeg_tree="`cd ${with_ffmpeg_tree} 2>/dev/null && pwd`"
1157     if test "x${real_ffmpeg_tree}" = x
1158     then
1159       dnl  The given directory can't be found
1160       AC_MSG_RESULT(no)
1161       AC_MSG_ERROR([cannot cd to ${with_ffmpeg_tree}])
1162     fi
1163     if test -f "${real_ffmpeg_tree}/libavcodec/libavcodec.a"
1164     then
1165       dnl  Use a custom libffmpeg
1166       AC_MSG_RESULT(${real_ffmpeg_tree}/libavcodec/libavcodec.a)
1167       BUILTINS="${BUILTINS} ffmpeg"
1168       LDFLAGS_ffmpeg="${LDFLAGS_ffmpeg} ${real_ffmpeg_tree}/libavcodec/libavcodec.a"
1169       CPPFLAGS_ffmpeg="${CPPFLAGS_ffmpeg} -I${real_ffmpeg_tree}/libavcodec"
1170     else
1171       dnl  The given libavcodec wasn't built
1172       AC_MSG_RESULT(no)
1173       AC_MSG_ERROR([cannot find ${real_ffmpeg_tree}/libavcodec/libavcodec.a, make sure you compiled libavcodec in ${with_ffmpeg_tree}])
1174     fi
1175   else
1176     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_ffmpeg}"
1177     LDFLAGS="${LDFLAGS_save} ${LDFLAGS_ffmpeg}"
1178     AC_CHECK_LIB(avcodec, avcodec_init, [
1179       BUILTINS="${BUILTINS} ffmpeg"
1180       LDFLAGS_ffmpeg="${LDFLAGS_ffmpeg} -lavcodec" ],
1181       [ AC_MSG_ERROR([Cannot find libavcodec library...]) ])
1182     LDFLAGS="${LDFLAGS_save}"
1183     CPPFLAGS="${CPPFLAGS_save}"
1184   fi
1185 fi
1186
1187 dnl
1188 dnl  faad decoder plugin
1189 dnl
1190 AC_ARG_ENABLE(faad,
1191 [  --enable-faad           faad codec (default disabled)])
1192 if test "x${enable_faad}" = "xyes"
1193 then
1194   AC_ARG_WITH(faad,
1195     [    --with-faad=PATH      path to faad installation],[],[])
1196   if test "x${with_faad}" != "xno" -a "x${with_faad}" != "x"
1197   then
1198     CPPFLAGS_faad="${CPPFLAGS_faad} -I${with_faad}/include"
1199     LDFLAGS_faad="${LDFLAGS_faad} -L${with_faad}/lib"
1200   fi
1201   LDFLAGS_faad="${LDFLAGS_faad}"
1202
1203   AC_ARG_WITH(faad-tree,
1204   [    --with-faad-tree=PATH faad tree for static linking])
1205   if test "x${with_faad_tree}" != "x"
1206   then
1207     AC_MSG_CHECKING(for libfaad.a in ${with_faad_tree})
1208     real_faad_tree="`cd ${with_faad_tree} 2>/dev/null && pwd`"
1209     if test "x${real_faad_tree}" = x
1210     then
1211       dnl  The given directory can't be found
1212       AC_MSG_RESULT(no)
1213       AC_MSG_ERROR([cannot cd to ${with_faad_tree}])
1214     fi
1215     if test -f "${real_faad_tree}/libfaad/.libs/libfaad.a"
1216     then
1217       dnl  Use a custom faad
1218       AC_MSG_RESULT(${real_faad_tree}/libfaad/.libs/libfaad.a)
1219       BUILTINS="${BUILTINS} faad"
1220       LDFLAGS_faad="${LDFLAGS_faad} ${real_faad_tree}/libfaad/.libs/libfaad.a"
1221       CPPFLAGS_faad="${CPPFLAGS_faad} -I${real_faad_tree}/include"
1222     else
1223       dnl  The given libfaad wasn't built
1224       AC_MSG_RESULT(no)
1225       AC_MSG_ERROR([cannot find ${real_faad_tree}/libfaad/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}])
1226     fi
1227   else
1228     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_faad}"
1229     LDFLAGS="${LDFLAGS_save} ${LDFLAGS_faad}"
1230     AC_CHECK_HEADERS(faad.h, ,
1231       [ AC_MSG_ERROR([Cannot find development headers for libfaad...]) ])
1232     AC_CHECK_LIB(faad, faacDecOpen, [
1233       PLUGINS="${PLUGINS} faad"
1234       LDFLAGS_faad="${LDFLAGS_faad} -lfaad" ],
1235       [ AC_MSG_ERROR([Cannot find libfaad library...]) ])
1236     LDFLAGS="${LDFLAGS_save}"
1237     CPPFLAGS="${CPPFLAGS_save}"
1238   fi
1239 fi
1240
1241
1242
1243 dnl
1244 dnl MP4 module
1245 dnl
1246 AC_ARG_ENABLE(mp4,
1247   [  --enable-mp4            MP4 demux module (default enabled)])
1248 if test "x${enable_mp4}" != "xno"
1249 then
1250
1251     PLUGINS="${PLUGINS} mp4"
1252     AC_CHECK_HEADERS(zlib.h,
1253               [ LDFLAGS_mp4="${LDFLAGS_mp4} -lz" ] )
1254 fi
1255
1256 dnl
1257 dnl  a52 AC3 decoder plugin
1258 dnl
1259 AC_ARG_ENABLE(a52,
1260   [  --enable-a52            A/52 support with liba52 (default enabled)])
1261 if test "x${enable_a52}" != "xno"
1262 then
1263   AC_ARG_WITH(a52,
1264     [    --with-a52=PATH       a52 headers and libraries])
1265   AC_ARG_WITH(a52-tree,
1266     [    --with-a52-tree=PATH  a52dec tree for static linking ],[],[])
1267   if test "x${with_a52_tree}" != "xno" -a "x${with_a52_tree}" != "x"
1268   then
1269     real_a52_tree="`cd ${with_a52_tree} 2>/dev/null && pwd`"
1270     if test "x${real_a52_tree}" = "x"
1271     then
1272       dnl  The given directory can't be found
1273       AC_MSG_RESULT(no)
1274       AC_MSG_ERROR([${with_a52_tree} directory doesn't exist])
1275     fi
1276     dnl  Use a custom a52dec
1277     AC_MSG_CHECKING(for a52.h in ${real_a52_tree}/include)
1278     if test -f ${real_a52_tree}/include/a52.h
1279     then
1280       AC_MSG_RESULT(yes)
1281       CPPFLAGS_a52tofloat32="${CPPFLAGS_a52tofloat32} -I${real_a52_tree}"
1282       LDFLAGS_a52tofloat32="${LDFLAGS_a52tofloat32} -L${real_a52_tree}/liba52/.libs"
1283       LDFLAGS="${LDFLAGS_save} ${LDFLAGS_a52tofloat32}"
1284       AC_CHECK_LIB(a52, a52_free, [
1285         BUILTINS="${BUILTINS} a52tofloat32"
1286         LDFLAGS_a52tofloat32="${LDFLAGS_a52tofloat32} -la52 -lm"
1287         CPPFLAGS_a52tofloat32="${CPPFLAGS_a52tofloat32} -DUSE_A52DEC_TREE"
1288         ],[
1289         if test -f ${real_a52_tree}/liba52/.libs/liba52.a
1290         then
1291           AC_MSG_ERROR([make sure you have at least a52dec-0.7.3])
1292         else
1293           AC_MSG_ERROR([the specified tree hasn't been compiled])
1294         fi
1295       ],[-lm])
1296       LDFLAGS="${LDFLAGS_save}"
1297     else
1298       AC_MSG_RESULT(no)
1299       AC_MSG_ERROR([the specified tree doesn't have a52.h])
1300     fi
1301   else
1302     if test "x${with_a52}" = "x"
1303     then
1304       LDFLAGS_test=""
1305       CPPFLAGS_test=""
1306     else
1307       LDFLAGS_test="-L${with_a52}/lib"
1308       CPPFLAGS_test="-I${with_a52}/include"
1309     fi
1310     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test}"
1311     LDFLAGS="${LDFLAGS_save} ${LDFLAGS_test}"
1312     AC_CHECK_HEADERS(a52dec/a52.h, [
1313       AC_CHECK_LIB(a52, a52_free, [
1314         PLUGINS="${PLUGINS} a52tofloat32"
1315         LDFLAGS_a52tofloat32="${LDFLAGS_a52tofloat32} ${LDFLAGS_test} -la52 -lm"
1316         CPPFLAGS_a52tofloat32="${CPPFLAGS_a52tofloat32} ${CPPFLAGS_test}"
1317       ],[
1318         if test "x${enable_dvbpsi}" != "x"
1319         then
1320           AC_MSG_ERROR([Could not find a52 on your system: you may get it from http://liba52.sf.net])
1321         fi
1322       ],[-lm])
1323     ])
1324     CPPFLAGS="${CPPFLAGS_save}"
1325     LDFLAGS="${LDFLAGS_save}"
1326   fi
1327 fi
1328
1329 dnl
1330 dnl  cinepak plugin
1331 dnl
1332 AC_ARG_ENABLE(cinepak,
1333   [  --enable-cinepak        Cinepak decoder (default enabled)])
1334 if test "x${enable_cinepak}" != "xno"
1335 then
1336   PLUGINS="${PLUGINS} cinepak"
1337 fi
1338
1339 dnl
1340 dnl  ogg vorbis plugin
1341 dnl
1342 AC_ARG_ENABLE(vorbis,
1343   [  --enable-vorbis         Ogg/Vorbis decoder support (default enabled)])
1344 if test "x${enable_vorbis}" != "xno"
1345 then
1346   AC_CHECK_HEADERS(ogg/ogg.h, [
1347     dnl disabled for the moment
1348     #PLUGINS="${PLUGINS} ogg vorbis"
1349     LDFLAGS_vorbis="${LDFLAGS_vorbis} -lvorbis"
1350    ],[])
1351 fi
1352
1353 dnl
1354 dnl  DV plugin
1355 dnl
1356 AC_ARG_ENABLE(dv,
1357   [  --enable-dv             DV decoder support (default disabled)])
1358 if test "x${enable_dv}" = "xyes"
1359 then
1360   AC_CHECK_HEADERS(libdv/dv.h, [
1361     PLUGINS="${PLUGINS} dv"
1362     LDFLAGS_dv="${LDFLAGS_dv} -ldv"
1363    ],[])
1364 fi
1365
1366 dnl
1367 dnl  Video plugins
1368 dnl
1369
1370 AC_ARG_WITH(,[Video plugins:])
1371
1372 dnl
1373 dnl  X11 module
1374 dnl  (enabled by default except on win32)
1375 dnl
1376 AC_ARG_ENABLE(x11,
1377   [  --enable-x11            X11 support (default enabled)])
1378 if test "x${enable_x11}" != "xno" &&
1379   (test "x${SYS}" != "xmingw32" || test "x${enable_x11}" = "xyes"); then
1380   CPPFLAGS="${CPPFLAGS_save} -I${x_includes}"
1381   AC_CHECK_HEADERS(X11/Xlib.h, [
1382     PLUGINS="${PLUGINS} x11"
1383     LDFLAGS_x11="${LDFLAGS_x11} -L${x_libraries} -lX11 -lXext"
1384     CPPFLAGS_x11="${CPPFLAGS_x11} -I${x_includes}"
1385   ])
1386   CPPFLAGS="${CPPFLAGS_save}"
1387 fi
1388
1389 dnl
1390 dnl  XVideo module
1391 dnl  (enabled by default except on win32)
1392 dnl
1393 AC_ARG_ENABLE(xvideo,
1394   [  --enable-xvideo         XVideo support (default enabled)])
1395 if test "x${enable_xvideo}" != "xno" &&
1396   (test "x${SYS}" != "xmingw32" || test "x${enable_xvideo}" = "xyes"); then
1397   CPPFLAGS="${CPPFLAGS_save} -I${x_includes}"
1398   AC_CHECK_HEADERS(X11/extensions/Xv.h, [
1399     CFLAGS="${CFLAGS_save} -L${x_libraries} -lX11 -lXext"
1400     AC_CHECK_LIB(Xv_pic,XvPutImage,
1401       # We have Xv_pic, that's good, we can build an xvideo.so plugin !
1402       PLUGINS="${PLUGINS} xvideo"
1403       LDFLAGS_xvideo="${LDFLAGS_xvideo} -L${x_libraries} -lX11 -lXext -lXv_pic"
1404       CPPFLAGS_xvideo="${CPPFLAGS_xvideo} -I${x_includes}",
1405       AC_CHECK_LIB(Xv,XvPutImage,
1406         # We don't have Xv_pic, but we have Xv, let's make xvideo.a as builtin
1407         PLUGINS="${PLUGINS} xvideo"
1408         LDFLAGS_xvideo="${LDFLAGS_xvideo} -L${x_libraries} -lX11 -lXext -lXv"
1409         CPPFLAGS_xvideo="${CPPFLAGS_xvideo} -I${x_includes}",
1410         # Otherwise... well, do nothing.
1411         :
1412       )
1413     )
1414     CFLAGS="${CFLAGS_save}"
1415   ]
1416   CPPFLAGS="${CPPFLAGS_save}")
1417 fi
1418
1419 dnl
1420 dnl  SDL module
1421 dnl
1422 AC_ARG_ENABLE(sdl,
1423   [  --enable-sdl            SDL support (default enabled)])
1424 if test "x${enable_sdl}" != "xno"
1425 then
1426   SDL_PATH="${PATH}"
1427   AC_ARG_WITH(sdl-config-path,
1428     [    --with-sdl-config-path=PATH sdl-config path (default search in \$PATH)],
1429     [ if test "x${with_sdl_config_path}" != "xno"
1430       then
1431         SDL_PATH="${with_sdl_config_path}:${PATH}"
1432       fi ])
1433   AC_PATH_PROG(SDL12_CONFIG, sdl12-config, no, ${SDL_PATH})
1434   SDL_CONFIG="${SDL12_CONFIG}"
1435   SDL_HEADER="SDL12/SDL.h"
1436   if test "x${SDL_CONFIG}" = "xno"
1437   then
1438     AC_PATH_PROG(SDL11_CONFIG, sdl11-config, no, ${SDL_PATH})
1439     SDL_CONFIG=${SDL11_CONFIG}
1440     SDL_HEADER="SDL11/SDL.h"
1441   fi
1442   if test "x${SDL_CONFIG}" = "xno"
1443   then
1444     AC_PATH_PROG(SDL_CONFIG, sdl-config, no, ${SDL_PATH})
1445     SDL_HEADER="SDL/SDL.h"
1446   fi
1447   if test "x${SDL_CONFIG}" != "xno"
1448   then
1449     PLUGINS="${PLUGINS} vout_sdl aout_sdl"
1450     CFLAGS_vout_sdl="${CFLAGS_vout_sdl} `${SDL_CONFIG} --cflags`"
1451     LDFLAGS_vout_sdl="${LDFLAGS_vout_sdl} `${SDL_CONFIG} --libs | sed 's,-rdynamic,,'`"
1452     CFLAGS_aout_sdl="${CFLAGS_aout_sdl} `${SDL_CONFIG} --cflags`"
1453     LDFLAGS_aout_sdl="${LDFLAGS_aout_sdl} `${SDL_CONFIG} --libs | sed 's,-rdynamic,,'`"
1454     CPPFLAGS="${CPPFLAGS_save} ${CFLAGS_vout_sdl}"
1455     AC_CHECK_HEADERS(${SDL_HEADER}, AC_DEFINE_UNQUOTED(SDL_INCLUDE_FILE,
1456       <${SDL_HEADER}>, Indicate whether we should use SDL/SDL.h or SDL11/SDL.h),
1457       [ AC_MSG_ERROR([The development package for SDL is not installed.
1458 Please install it and try again. Alternatively you can also configure with
1459 --disable-sdl.])
1460       ])
1461     CPPFLAGS="${CPPFLAGS_save}"
1462     if expr 1.1.5 \> `${SDL_CONFIG} --version` >/dev/null
1463     then
1464       AC_MSG_ERROR([The development package for SDL is not installed.
1465 Please install it and try again. Alternatively you can also configure with
1466 --disable-sdl.])
1467     fi
1468   elif test "x${enable_sdl}" =  "xyes"
1469   then
1470     AC_MSG_ERROR([I couldn't find the SDL package. You can download libSDL
1471 from http://www.libsdl.org/, or configure with --disable-sdl. Have a nice day.
1472     ])
1473   fi
1474 fi
1475
1476 dnl
1477 dnl  Qt Embedded module
1478 dnl  (disabled by default)
1479 dnl
1480 AC_ARG_ENABLE(qte,
1481   [  --enable-qte            QT Embedded support (default disabled)])
1482 if test "x${enable_qte}" != "xno"
1483 then
1484   AC_ARG_WITH(qte,
1485   [    --with-qte=PATH    Qt Embedded headers and libraries])
1486   if test "x${with_qte}" = "x"
1487   then
1488     LDFLAGS_test="-L${QTDIR}/lib"
1489     CPPFLAGS_test="-I${QTDIR}/include"
1490   else
1491     LDFLAGS_test="-L${with_qte}/lib"
1492     CPPFLAGS_test="-I${with_qte}/include"
1493   fi
1494
1495   CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test}"
1496   AC_CHECK_HEADERS(qt.h, [
1497     CPPFLAGS_qte="${CPPFLAGS_qte} ${CPPFLAGS_test} -DQT_QWS_IPAQ -DQWS"
1498     CXXFLAGS_qte="${CXXFLAGS_qte} -fno-exceptions -fno-rtti"
1499     LDFLAGS_qte="${LDFLAGS_qte} ${LDFLAGS_test} -lqte"
1500     if test "x${with_qte}" = "x"
1501     then
1502       PLUGINS="${PLUGINS} qte"
1503     else
1504       BUILTINS="${BUILTINS} qte"
1505     fi
1506   ])
1507   CPPFLAGS="${CPPFLAGS_save}"
1508 fi
1509
1510 dnl
1511 dnl  Windows DirectX module
1512 dnl
1513 AC_ARG_ENABLE(directx,
1514   [  --enable-directx        Win32 DirectX support (default enabled on Win32)])
1515 if test "x${enable_directx}" != "xno"
1516 then
1517   if test "x${SYS}" = "xmingw32" -o "x${SYS}" = "xcygwin"
1518   then
1519     AC_ARG_WITH(directx,
1520     [    --with-directx=PATH   Win32 DirectX headers])
1521     if test "x${with_directx}" = "x"
1522     then
1523       AC_CHECK_HEADERS(ddraw.h,
1524       [ PLUGINS="${PLUGINS} vout_directx aout_directx"
1525         LDFLAGS_vout_directx="${LDFLAGS_directx} -lgdi32" ])
1526     else
1527       AC_MSG_CHECKING(for directX headers in ${with_directx})
1528       if test -f ${with_directx}/ddraw.h
1529       then
1530         PLUGINS="${PLUGINS} vout_directx aout_directx"
1531         LDFLAGS_vout_directx="${LDFLAGS_directx} -lgdi32"
1532         CPPFLAGS_vout_directx="${CPPFLAGS_vout_directx} -I${with_directx}"
1533         CPPFLAGS_aout_directx="${CPPFLAGS_aout_directx} -I${with_directx}"
1534         AC_MSG_RESULT(yes)
1535       else
1536         AC_MSG_RESULT(no)
1537         AC_MSG_ERROR([Cannot find ${with_directx}/ddraw.h!])
1538       fi
1539     fi
1540   fi
1541 fi
1542
1543 dnl
1544 dnl  Linux framebuffer module
1545 dnl
1546 AC_ARG_ENABLE(fb,
1547   [  --enable-fb             Linux framebuffer support (default enabled on Linux)])
1548     if test "x${enable_fb}" != "xno"
1549     then
1550       AC_CHECK_HEADERS(linux/fb.h, [
1551         PLUGINS="${PLUGINS} fb"
1552       ])
1553     fi
1554
1555 dnl
1556 dnl  Linux MGA module
1557 dnl
1558 AC_ARG_ENABLE(mga,
1559   [  --enable-mga            Linux kernel Matrox support (default disabled)],
1560   [ if test "x${enable_mga}" = "xyes"
1561     then
1562       PLUGINS="${PLUGINS} mga xmga"
1563     fi ])
1564
1565 dnl
1566 dnl  SVGAlib module
1567 dnl
1568 AC_ARG_ENABLE(svgalib,
1569   [  --enable-svgalib        SVGAlib support (default disabled)])
1570 if test "x${enable_svgalib}" = "xyes"
1571 then
1572   PLUGINS="${PLUGINS} svgalib"
1573   LDFLAGS_svgalib="${LDFLAGS_svgalib} -lvgagl -lvga"
1574 fi
1575
1576 dnl
1577 dnl  GGI module
1578 dnl
1579 AC_ARG_ENABLE(ggi,
1580   [  --enable-ggi            GGI support (default disabled)])
1581 if test "x${enable_ggi}" = "xyes"
1582 then
1583   PLUGINS="${PLUGINS} ggi"
1584   LDFLAGS_ggi="${LDFLAGS_ggi} -lggi"
1585   AC_ARG_WITH(ggi,
1586     [    --with-ggi=PATH       path to libggi],
1587     [ if test "x${with_ggi}" != "xno" -a "x${with_ggi}" != "x"
1588       then
1589         CPPFLAGS_ggi="${CPPFLAGS_ggi} -I${with_ggi}/include"
1590         LDFLAGS_ggi="${LDFLAGS_ggi} -L${with_ggi}/lib"
1591       fi ])
1592 fi
1593
1594 dnl
1595 dnl  Glide module
1596 dnl
1597 AC_ARG_ENABLE(glide,
1598   [  --enable-glide          Glide (3dfx) support (default disabled)])
1599 if test "x${enable_glide}" = "xyes"
1600 then
1601   PLUGINS="${PLUGINS} glide"
1602   LDFLAGS_glide="${LDFLAGS_glide} -lglide2x -lm"
1603   CPPFLAGS_glide="${CPPFLAGS_glide} -I/usr/include/glide"
1604   AC_ARG_WITH(glide,
1605     [    --with-glide=PATH     path to libglide],
1606     [ if test "x${with_glide}" != "xno" -a "x${with_glide}" != "x"
1607       then
1608         CPPFLAGS_glide="${CPPFLAGS_glide} -I${with_glide}/include"
1609         LDFLAGS_glide="${LDFLAGS_glide} -L${with_glide}/lib"
1610       fi ])
1611 fi
1612
1613 dnl
1614 dnl  AA plugin
1615 dnl
1616 AC_ARG_ENABLE(aa,
1617   [  --enable-aa             aalib output (default disabled)])
1618 if test "x${enable_aa}" = "xyes"
1619 then
1620   AC_CHECK_HEADER(aalib.h,have_aa="true",have_aa="false")
1621   if test "x${have_aa}" = "xtrue"
1622   then
1623     PLUGINS="${PLUGINS} aa"
1624     LDFLAGS_aa="${LDFLAGS_aa} -laa"
1625   fi
1626 fi
1627
1628 dnl
1629 dnl  Audio plugins
1630 dnl
1631
1632 AC_ARG_WITH(,[Audio plugins:])
1633
1634 dnl
1635 dnl  OSS /dev/dsp module (enabled by default except on win32)
1636 dnl
1637 AC_ARG_ENABLE(oss,
1638   [  --enable-oss            Linux OSS /dev/dsp support (enabled on Linux)])
1639
1640 if test "x${enable_oss}" != "xno" &&
1641   (test "x${SYS}" != "xmingw32" || test "x${enable_oss}" = "xyes")
1642 then
1643   AC_CHECK_HEADERS(soundcard.h sys/soundcard.h machine/soundcard.h, [
1644     PLUGINS="${PLUGINS} oss"
1645     AC_CHECK_LIB(ossaudio,main,LDFLAGS_oss="${LDFLAGS_oss} -lossaudio")
1646   ])
1647 fi
1648
1649 dnl
1650 dnl  Esound module
1651 dnl
1652 AC_ARG_ENABLE(esd,
1653   [  --enable-esd            Esound library support (default disabled)],
1654   [if test "x${enable_esd}" = "xyes"
1655    then
1656      AC_PATH_PROG(ESD_CONFIG, esd-config, no)
1657      if test "x${ESD_CONFIG}" != "xno"
1658      then
1659        PLUGINS="${PLUGINS} esd"
1660        CFLAGS_esd="${CFLAGS_esd} `${ESD_CONFIG} --cflags`"
1661        LDFLAGS_esd="${LDFLAGS_esd} `${ESD_CONFIG} --libs`"
1662      fi
1663    fi])
1664
1665 dnl
1666 dnl  aRts module
1667 dnl
1668 AC_ARG_ENABLE(arts,
1669   [  --enable-arts           aRts sound server (default disabled)],
1670   [if test "x${enable_arts}" = "xyes"
1671    then
1672      AC_PATH_PROG(ARTS_CONFIG, artsc-config, no)
1673      if test "x${ARTS_CONFIG}" != "xno"
1674      then
1675        PLUGINS="${PLUGINS} arts"
1676        CFLAGS_arts="${CFLAGS_arts} `${ARTS_CONFIG} --cflags`"
1677        LDFLAGS_arts="${LDFLAGS_arts} `${ARTS_CONFIG} --libs `"
1678      fi
1679    fi])
1680
1681 dnl
1682 dnl  ALSA module
1683 dnl
1684 AC_ARG_ENABLE(alsa,
1685   [  --enable-alsa           ALSA sound support for Linux (default disabled)],
1686   [if test "x${enable_alsa}" = "xyes"
1687    then
1688      AC_CHECK_HEADER(alsa/asoundlib.h, AC_CHECK_LIB(asound, main, have_alsa="true", have_alsa="false"),have_alsa="false")
1689      if test "x${have_alsa}" = "xtrue"
1690      then
1691        PLUGINS="${PLUGINS} alsa"
1692        LDFLAGS_alsa="${LDFLAGS_alsa} -lasound -lm -ldl"
1693      fi
1694    fi])
1695
1696 dnl
1697 dnl  win32 waveOut plugin
1698 dnl
1699 AC_ARG_ENABLE(waveout,
1700   [  --enable-waveout        Win32 waveOut module (default enabled on Win32)])
1701 if test "x${enable_waveout}" != "xno"; then
1702   if test "x${SYS}" = "xmingw32" -o "x${SYS}" = "xcygwin"; then
1703     PLUGINS="${PLUGINS} waveout"
1704     LDFLAGS_waveout="-lwinmm"
1705   fi
1706 fi
1707
1708 dnl
1709 dnl  Interface plugins
1710 dnl
1711
1712 AC_ARG_WITH(,[Interface plugins:])
1713
1714 dnl special case for BeOS
1715 if test "x${SYS}" = "xbeos"
1716 then
1717     PLUGINS="${PLUGINS} beos"
1718 fi
1719
1720 dnl
1721 dnl  Gtk+ module
1722 dnl
1723 AC_ARG_ENABLE(gtk,
1724   [  --enable-gtk            Gtk+ support (default enabled)])
1725 if test "x${enable_gtk}" != "xno"
1726 then
1727   GTK_PATH="${PATH}"
1728   AC_ARG_WITH(gtk-config-path,
1729     [    --with-gtk-config-path=PATH gtk-config path (default search in \$PATH)],
1730     [ if test "x${with_gtk_config_path}" != "xno"
1731       then
1732         GTK_PATH="${with_gtk_config_path}:${PATH}"
1733       fi ])
1734   # look for gtk-config
1735   AC_PATH_PROG(GTK12_CONFIG, gtk12-config, no, ${GTK_PATH})
1736   GTK_CONFIG=${GTK12_CONFIG}
1737   if test "x${GTK_CONFIG}" = "xno"
1738   then
1739     AC_PATH_PROG(GTK_CONFIG, gtk-config, no, ${GTK_PATH})
1740   fi
1741   if test "x${GTK_CONFIG}" != "xno"
1742   then
1743     if expr 1.2.0 \> `${GTK_CONFIG} --version` >/dev/null
1744     then
1745       AC_MSG_ERROR([Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-gtk.])
1746     fi
1747     if test "x${SYS}" != "xmingw32"; then
1748       CFLAGS_gtk="${CFLAGS_gtk} `${GTK_CONFIG} --cflags gtk gthread`"
1749       LDFLAGS_gtk="${LDFLAGS_gtk} `${GTK_CONFIG} --libs gtk gthread | sed 's,-rdynamic,,'`"
1750     else
1751       CFLAGS_gtk="${CFLAGS_gtk} `${GTK_CONFIG} --cflags gtk`"
1752       LDFLAGS_gtk="${LDFLAGS_gtk} `${GTK_CONFIG} --libs gtk | sed 's,-rdynamic,,'`"
1753     fi
1754     # now look for the gtk.h header
1755     CPPFLAGS="${CPPFLAGS_save} ${CFLAGS_gtk}"
1756     ac_cv_gtk_headers=yes
1757     AC_CHECK_HEADERS(gtk/gtk.h glib.h gdk/gdk.h, , [
1758       ac_cv_gtk_headers=no
1759       echo "Cannot find gtk development headers."
1760     ])
1761     if test "x${ac_cv_gtk_headers}" = "xyes"
1762     then
1763       PLUGINS="${PLUGINS} gtk"
1764       if test "x${SYS}" != "xmingw32"; then
1765         NEED_GTK_MAIN=yes
1766       fi
1767       ALIASES="${ALIASES} gvlc"
1768     fi
1769     CPPFLAGS="${CPPFLAGS_save}"
1770   fi
1771 fi
1772
1773 dnl
1774 dnl  Familiar module uses Gtk+ library
1775 dnl
1776 AC_ARG_ENABLE(familiar,
1777   [  --enable-familiar       Familiar Gtk+ support (default disabled)])
1778 if test "x${enable_familiar}" = "xyes"
1779 then
1780   GTK_PATH="${PATH}"
1781   AC_ARG_WITH(gtk-config-path,
1782     [    --with-gtk-config-path=PATH gtk-config path (default search in \$PATH)],
1783     [ if test "x${with_gtk_config_path}" != "xno"
1784       then
1785         GTK_PATH="${with_gtk_config_path}:${PATH}"
1786       fi ])
1787   # look for gtk-config
1788   AC_PATH_PROG(GTK12_CONFIG, gtk12-config, no, ${GTK_PATH})
1789   GTK_CONFIG=${GTK12_CONFIG}
1790   if test "x${GTK_CONFIG}" = "xno"
1791   then
1792     AC_PATH_PROG(GTK_CONFIG, gtk-config, no, ${GTK_PATH})
1793   fi
1794   if test "x${GTK_CONFIG}" != "xno"
1795   then
1796     if expr 1.2.0 \> `${GTK_CONFIG} --version` >/dev/null
1797     then
1798       AC_MSG_ERROR([Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-familiar.])
1799     fi
1800     CFLAGS_familiar="${CFLAGS_familiar} `${GTK_CONFIG} --cflags gtk gthread`"
1801     LDFLAGS_familiar="${LDFLAGS_familiar} `${GTK_CONFIG} --libs gtk gthread | sed 's,-rdynamic,,'`"
1802     # now look for the gtk.h header
1803     CPPFLAGS="${CPPFLAGS_save} ${CFLAGS_familiar}"
1804     ac_cv_gtk_headers=yes
1805     AC_CHECK_HEADERS(gtk/gtk.h glib.h gdk/gdk.h, , [
1806       ac_cv_gtk_headers=no
1807       echo "Cannot find gtk development headers."
1808     ])
1809     if test "x${ac_cv_gtk_headers}" = "xyes"
1810     then
1811       PLUGINS="${PLUGINS} familiar"
1812       NEED_GTK_MAIN=yes
1813     fi
1814     CPPFLAGS="${CPPFLAGS_save}"
1815   fi
1816 fi
1817
1818 dnl
1819 dnl  Gnome module
1820 dnl
1821 AC_ARG_ENABLE(gnome,
1822   [  --enable-gnome          Gnome interface support (default disabled)],
1823   [if test "x${enable_gnome}" = "xyes"; then
1824     # look for gnome-config
1825     AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
1826     if test -x ${GNOME_CONFIG}
1827     then
1828        CFLAGS_gnome="${CFLAGS_gnome} `${GNOME_CONFIG} --cflags gtk gnomeui`"
1829        LDFLAGS_gnome="${LDFLAGS_gnome} `${GNOME_CONFIG} --libs gnomeui | sed 's,-rdynamic,,'`"
1830     fi
1831     # now look for the gnome.h header
1832     CPPFLAGS="${CPPFLAGS_save} ${CFLAGS_gnome}"
1833     AC_CHECK_HEADERS(gnome.h, [
1834       PLUGINS="${PLUGINS} gnome"
1835       NEED_GTK_MAIN=yes
1836       NEED_GNOME_MAIN=yes
1837       ALIASES="${ALIASES} gnome-vlc"
1838      ],[
1839       AC_MSG_ERROR([Can't find gnome headers. Please install the gnome
1840 developement tools or remove the --enable-gnome option])
1841      ])
1842     CPPFLAGS="${CPPFLAGS_save}"
1843   fi])
1844
1845 dnl
1846 dnl  Qt module
1847 dnl
1848 AC_ARG_ENABLE(qt,
1849   [  --enable-qt             Qt interface support (default disabled)],
1850   [if test "x${enable_qt}" = "xyes"; then
1851      PLUGINS="${PLUGINS} qt"
1852      ALIASES="${ALIASES} qvlc"
1853      LDFLAGS_qt="${LDFLAGS_qt} -lqt -L${QTDIR}/lib"
1854      CPPFLAGS_qt="${CPPFLAGS_qt} -I/usr/include/qt -I${QTDIR}/include"
1855      if test -x ${QTDIR}/bin/moc
1856      then
1857        MOC=${QTDIR}/bin/moc
1858      else
1859        MOC=moc
1860      fi
1861    fi])
1862
1863 dnl
1864 dnl  KDE module
1865 dnl
1866 AC_ARG_ENABLE(kde,
1867   [  --enable-kde            KDE interface support (default disabled)],
1868   [if test "x${enable_kde}" = "xyes"; then
1869      PLUGINS="${PLUGINS} kde"
1870      ALIASES="${ALIASES} kvlc"
1871      LDFLAGS_kde="${LDFLAGS_kde} -L${KDEDIR}/lib -lkfile"
1872      CPPFLAGS_kde="${CPPFLAGS_kde} -I/usr/include/kde -I/usr/include/qt"
1873      CPPFLAGS_kde="${CPPFLAGS_kde} -I${KDEDIR}/include -I${QTDIR}/include"
1874      if test -x ${QTDIR}/bin/moc
1875      then
1876        MOC=${QTDIR}/bin/moc
1877      else
1878        MOC=moc
1879      fi
1880    fi])
1881
1882 dnl
1883 dnl  Opie QT embedded module
1884 dnl
1885 AC_ARG_ENABLE(opie,
1886   [  --enable-opie           Qt embedded interface support (default disabled)],
1887   [if test "x${enable_opie}" = "xyes"; then
1888      AC_ARG_WITH(qte,
1889      [    --with-qte=PATH    Qt Embedded headers and libraries])
1890      if test "x${with_qte}" = "x"
1891      then
1892        LDFLAGS_test="-L${QTDIR}/lib"
1893        CPPFLAGS_test="-I${QTDIR}/include"
1894      else
1895        LDFLAGS_test="-L${with_qte}/lib"
1896        CPPFLAGS_test="-I${with_qte}/include"
1897      fi
1898
1899      PLUGINS="${PLUGINS} opie"
1900      LDFLAGS_opie="${LDFLAGS_opie} ${LDFLAGS_test} -lqte"
1901      CPPFLAGS_opie="${CPPFLAGS_opie} ${CPPFLAGS_test}"
1902      if test -x ${QTEDIR}/bin/moc
1903      then
1904        MOC=${QTEDIR}/bin/moc
1905      else
1906        MOC=moc
1907      fi
1908    fi])
1909
1910 dnl
1911 dnl  MacOS X module
1912 dnl
1913 AC_ARG_ENABLE(macosx,
1914   [  --enable-macosx         MacOS X support (default enabled on MacOS X)],
1915   [if test "x${enable_macosx}" = "xyes"
1916    then
1917      BUILTINS="${BUILTINS} macosx"
1918      LDFLAGS_macosx="${LDFLAGS_macosx} -framework CoreAudio -framework AudioToolbox -framework IOKit -framework Cocoa -framework Carbon -framework AGL -framework QuickTime -lobjc -ObjC"
1919    fi],
1920   [AC_CHECK_HEADERS(Cocoa/Cocoa.h,
1921      BUILTINS="${BUILTINS} macosx"
1922      LDFLAGS_macosx="${LDFLAGS_macosx} -framework CoreAudio -framework AudioToolbox -framework IOKit -framework Cocoa -framework Carbon -framework AGL -framework QuickTime -lobjc -ObjC"
1923    )])
1924
1925 dnl
1926 dnl  QNX RTOS module
1927 dnl
1928 AC_ARG_ENABLE(qnx,
1929   [  --enable-qnx            QNX RTOS support (default enabled on QNX RTOS)])
1930     if test "x${enable_qnx}" != "xno"
1931     then
1932       AC_CHECK_HEADERS(Ph.h, [
1933         PLUGINS="${PLUGINS} qnx"
1934         LDFLAGS_qnx="${LDFLAGS_qnx} -lasound -lph"
1935       ])
1936     fi
1937
1938 dnl
1939 dnl  Windows native interface module, built with Borland C++ Builder
1940 dnl
1941 AC_ARG_ENABLE(intfwin,
1942 [  --enable-intfwin        Win32 interface support (default disabled)],
1943 [ if test "x${enable_intfwin}" != "xno"
1944   then
1945     AC_ARG_WITH(bcbuilder,
1946     [    --with-bcbuilder=PATH Borland C++ Builder installation path])
1947     if test "x${with_bcbuilder}" != "x"
1948     then
1949       BCBUILDER="${with_bcbuilder}"
1950     fi
1951     PLUGINS="${PLUGINS} win32"
1952   fi ])
1953
1954 dnl
1955 dnl  ncurses module
1956 dnl
1957 AC_ARG_ENABLE(ncurses,
1958   [  --enable-ncurses        ncurses interface support (default disabled)],
1959   [if test "x${enable_ncurses}" = "xyes"; then
1960      PLUGINS="${PLUGINS} ncurses"
1961      LDFLAGS_ncurses="${LDFLAGS_ncurses} -lncurses"
1962    fi])
1963
1964 dnl
1965 dnl  XOSD plugin
1966 dnl
1967 AC_ARG_ENABLE(xosd,
1968   [  --enable-xosd           xosd interface support (default disabled)])
1969 if test "x${enable_xosd}" = "xyes"
1970 then
1971   AC_CHECK_HEADER(xosd.h, have_xosd="true", have_xosd="false")
1972   AC_TRY_COMPILE([#include <xosd.h>],
1973      [void foo() { xosd_init("foo","bar",12,XOSD_top,2,12,42); }],,
1974       AC_DEFINE(HAVE_OLD_XOSD_H, 1, Define if <xosd.h> is pre-1.0.0))
1975   if test "x${have_xosd}" = "xtrue"
1976   then
1977     PLUGINS="${PLUGINS} xosd"
1978     LDFLAGS_xosd="${LDFLAGS_xosd} -lxosd"
1979   fi
1980 fi
1981
1982 dnl
1983 dnl  Lirc plugin
1984 dnl
1985 AC_ARG_ENABLE(lirc,
1986   [  --enable-lirc           lirc support (default disabled)])
1987 if test "x${enable_lirc}" = "xyes"
1988 then
1989   AC_CHECK_HEADER(lirc/lirc_client.h, AC_CHECK_LIB(lirc_client, lirc_init, have_lirc="true", have_lirc="false"),have_lirc="false")
1990   if test "x${have_lirc}" = "xtrue"
1991   then
1992     PLUGINS="${PLUGINS} lirc"
1993     LDFLAGS_lirc="${LDFLAGS_lirc} -llirc_client"
1994   fi
1995 fi
1996
1997 AC_ARG_WITH(,[Misc options:])
1998
1999 dnl
2000 dnl  Endianness check, AC_C_BIGENDIAN doesn't work if we are cross-compiling
2001 dnl
2002 dnl  We give the user the opportunity to specify
2003 dnl  --with-words=big or --with-words=little ; otherwise, try to guess
2004 dnl
2005 AC_ARG_WITH(words,
2006   [  --with-words=endianness set endianness (big or little)])
2007   case "x${with_words}" in
2008     xbig)
2009       ac_cv_c_bigendian=yes
2010       ;;
2011     xlittle)
2012       ac_cv_c_bigendian=no
2013       ;;
2014     *)
2015       dnl  Try to guess endianness by matching patterns on a compiled
2016       dnl  binary, by looking for an ASCII or EBCDIC string
2017       AC_CACHE_CHECK([whether the byte order is big-endian],
2018         [ac_cv_c_bigendian],
2019         [ac_cv_c_bigendian="unknown"
2020         [cat >conftest.c <<EOF
2021         short am[] = { 0x4249, 0x4765, 0x6e44, 0x6961, 0x6e53, 0x7953, 0 };
2022         short ai[] = { 0x694c, 0x5454, 0x656c, 0x6e45, 0x6944, 0x6e61, 0 };
2023         void _a(void) { char*s = (char*)am; s = (char *)ai; }
2024         short ei[] = { 0x89D3, 0xe3e3, 0x8593, 0x95c5, 0x89c4, 0x9581, 0 };
2025         short em[] = { 0xc2c9, 0xc785, 0x95c4, 0x8981, 0x95e2, 0xa8e2, 0 };
2026         void _e(void) { char*s = (char*)em; s = (char*)ei; }
2027         int main(void) { _a(); _e(); return 0; }
2028 EOF
2029         ]
2030         if test -f conftest.c
2031         then
2032           if ${CC-cc} -c conftest.c -o conftest.o >>config.log 2>&1 \
2033               && test -f conftest.o
2034           then
2035             if test "`strings conftest.o | grep BIGenDianSyS`"
2036             then
2037               ac_cv_c_bigendian="yes"
2038             fi
2039             if test "`strings conftest.o | grep LiTTleEnDian`"
2040             then
2041               ac_cv_c_bigendian="no"
2042             fi
2043           fi
2044         fi
2045       ])
2046       if test "x${ac_cv_c_bigendian}" = "xunknown"
2047       then
2048         AC_MSG_ERROR([Could not guess endianness, please use --with-words])
2049       fi
2050       ;;
2051   esac
2052 dnl  Now we know what to use for endianness, just put it in the header
2053 if test "${ac_cv_c_bigendian}" = "yes"
2054 then
2055   AC_DEFINE(WORDS_BIGENDIAN, 1, big endian system)
2056 fi
2057
2058 dnl
2059 dnl  Profiling
2060 dnl
2061 AC_ARG_ENABLE(gprof,
2062 [  --enable-gprof          gprof profiling (default disabled)])
2063 AC_ARG_ENABLE(cprof,
2064 [  --enable-cprof          cprof profiling (default disabled)])
2065 AM_CONDITIONAL(GPROF, test "x${enable_gprof}" = "xyes")
2066 AM_CONDITIONAL(CPROF, test "x${enable_gprof}" = "xyes")
2067
2068 dnl
2069 dnl  GNU portable threads
2070 dnl
2071 AC_ARG_ENABLE(pth,
2072   [  --enable-pth            GNU Pth support (default disabled)],
2073   [ if test "x${enable_pth}" = "xyes"; then
2074     AC_CHECK_LIB(pth,pth_init)
2075     AC_EGREP_HEADER(pth_init,pth.h,[
2076       AC_DEFINE(PTH_INIT_IN_PTH_H, 1,
2077                 Define if <pth.h> defines pth_init)
2078     THREAD_LIB="-lpth"
2079     fi])
2080 ])
2081
2082 dnl
2083 dnl  State Threads
2084 dnl
2085 AC_ARG_ENABLE(st,
2086   [  --enable-st             State Threads (default disabled)],
2087   [ if test "x${enable_st}" = "xyes"; then
2088     AC_CHECK_LIB(st,st_init)
2089     AC_EGREP_HEADER(st_init,st.h,[
2090       AC_DEFINE(ST_INIT_IN_ST_H, 1,
2091                 Define if <st.h> defines st_init)
2092     THREAD_LIB="-lst"
2093     fi])
2094 ])
2095
2096 if test "x${SYS}" != "xmingw32"; then
2097   LDFLAGS_vlc="${LDFLAGS_vlc} ${THREAD_LIB}"
2098   LDFLAGS_plugins="${LDFLAGS_plugins} ${THREAD_LIB}"
2099 fi
2100
2101 dnl
2102 dnl  Mozilla plugin
2103 dnl
2104 mozilla=false
2105 AC_ARG_ENABLE(mozilla,
2106   [  --enable-mozilla        build a vlc-based Mozilla plugin (default disabled)])
2107 if test "x${enable_mozilla}" = "xyes"
2108 then
2109   AC_PATH_PROG(MOZILLA_CONFIG, mozilla-config, no)
2110   if test "x${MOZILLA_CONFIG}" != "xno"
2111   then
2112     if test "x${SYS}" != "xmingw32"; then
2113       LDFLAGS="${LDFLAGS_save} -L${x_libraries}"
2114       AC_CHECK_LIB(Xt,XtStrings,[
2115         LDFLAGS_mozilla="${LDFLAGS_mozilla} -L${x_libraries} -lXt"
2116       ])
2117       LDFLAGS="${LDFLAGS_save}"
2118     fi
2119     mozilla=:
2120     dnl Workaround for http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=150490
2121     [CPPFLAGS_mozilla="${CPPFLAGS_mozilla} `${MOZILLA_CONFIG} --cflags plugin xpcom java | sed 's,-I\([^ ]*\)/mozilla/\([^ ]*\),-I\1/\2 -I\1/mozilla/\2,g' | xargs`"]
2122     #[CPPFLAGS_mozilla="${CPPFLAGS_mozilla} `${MOZILLA_CONFIG} --cflags plugin xpcom java --defines | sed 's,-I\([^ ]*\)/mozilla/\([^ ]*\),-I\1/\2 -I\1/mozilla/\2,g' | xargs`"]
2123     LDFLAGS_mozilla="${LDFLAGS_mozilla} `${MOZILLA_CONFIG} --libs plugin xpcom`"
2124     dnl Not necessarily in ${PATH}
2125     if test "x${XPIDL}" = "x" -o ! -x "${XPIDL}"
2126     then
2127       XPIDL="/usr/lib/mozilla/xpidl"
2128     fi
2129   fi
2130 fi
2131 AM_CONDITIONAL(BUILD_MOZILLA,${mozilla})
2132
2133 dnl
2134 dnl  test plugins
2135 dnl
2136 AC_ARG_ENABLE(testsuite,
2137   [  --enable-testsuite      build test modules (default disabled)])
2138 if test "x${enable_testsuite}" = "xyes"
2139 then
2140   TESTS="test1 test2 test3 test4"
2141
2142   dnl  we define those so that bootstrap sets the right linker
2143   CXXFLAGS_test2="${CXXFLAGS_test2}"
2144   OBJCFLAGS_test3="${OBJCFLAGS_test3}"
2145   dnl  this one is needed until automake knows what to do
2146   LDFLAGS_test3="${LDFLAGS_test3} -lobjc"
2147
2148   PLUGINS="${PLUGINS} ${TESTS}"
2149   #BUILTINS="${BUILTINS} ${TESTS}"
2150 fi
2151
2152 dnl
2153 dnl  gtk_main plugin
2154 dnl
2155 if test "x${NEED_GTK_MAIN}" != "xno"
2156 then
2157     PLUGINS="${PLUGINS} gtk_main"
2158     CFLAGS_gtk="${CFLAGS_gtk} -DNEED_GTK_MAIN"
2159     CFLAGS_gtk_main="${CFLAGS_gtk_main} ${CFLAGS_gtk} ${CFLAGS_familiar}"
2160     LDFLAGS_gtk_main="${LDFLAGS_gtk_main} ${LDFLAGS_gtk} ${LDFLAGS_familiar}"
2161 fi
2162
2163 if test "x${NEED_GNOME_MAIN}" != "xno"
2164 then
2165     PLUGINS="${PLUGINS} gnome_main"
2166     CFLAGS_gnome_main="${CFLAGS_gnome_main} ${CFLAGS_gtk} ${CFLAGS_familiar} ${CFLAGS_gnome}"
2167     LDFLAGS_gnome_main="${LDFLAGS_gnome_main} ${LDFLAGS_gtk} ${LDFLAGS_familiar} ${LDFLAGS_gnome}"
2168 fi
2169
2170 dnl
2171 dnl  Plugin and builtin checks
2172 dnl
2173 builtin_support=false
2174 plugin_support=:
2175
2176 dnl Support for plugins - this must be AT THE END
2177 AC_ARG_ENABLE(plugins,
2178   [  --disable-plugins       make all plugins built-in (default plugins enabled)],
2179   [if test "x${enable_plugins}" = "xno"
2180    then
2181      plugin_support=false
2182    fi])
2183
2184 dnl Automagically disable plugins if there is no system support for
2185 dnl dynamically loadable files (.so, .dll, .dylib).
2186 dnl don't forget vlc-win32 still can load .dll as plugins
2187 if test "x${ac_cv_header_dlfcn_h}" = "xno" -a "x${ac_cv_header_image_h}" = "xno" -a "x${SYS}" != "xmingw32"
2188 then
2189   echo "*** Your system doesn't have plugin support. All plugins will be built"
2190   echo "statically."
2191   plugin_support=false
2192 fi
2193
2194 dnl Export automake variables
2195 if ${plugin_support}
2196 then
2197   for plugin in `echo ${PLUGINS}`
2198   do
2199     eval "${plugin}_plugin=yes"
2200   done
2201 else
2202   BUILTINS="${BUILTINS} ${PLUGINS}"
2203   PLUGINS=
2204 fi
2205 AM_CONDITIONAL(HAVE_PLUGINS, ${plugin_support})
2206
2207 [if echo "${BUILTINS}" | grep '[^ ]' >/dev/null 2>&1
2208 then
2209   builtin_support=:
2210   for builtin in `echo ${BUILTINS}`
2211   do
2212     eval "${builtin}_builtin=yes"
2213   done
2214 fi]
2215 AM_CONDITIONAL(HAVE_BUILTINS, ${builtin_support})
2216
2217 dnl do not touch this line (bootstrap needs it)
2218
2219
2220 dnl
2221 dnl  Stuff used by the program
2222 dnl
2223 AC_DEFINE_UNQUOTED(VERSION_MESSAGE, "${VERSION} ${CODENAME}", [Simple version string])
2224 AC_DEFINE_UNQUOTED(COPYRIGHT_MESSAGE, "VideoLAN Client - version ${VERSION} ${CODENAME} - (c) 1996-2002 VideoLAN", [Copyright string])
2225 AC_DEFINE_UNQUOTED(CONFIGURE_LINE, "${CONFIGURE_LINE}", [The ./configure command line])
2226
2227 VLC_SYMBOL="`echo ${VERSION} | tr .- __`"
2228 AC_DEFINE_UNQUOTED(MODULE_SUFFIX, "__${VLC_SYMBOL}", [String suffix for module functions])
2229 AC_DEFINE_UNQUOTED(MODULE_SYMBOL, ${VLC_SYMBOL}, [Symbol suffix for module functions])
2230 AC_DEFINE_UNQUOTED(LIBEXT, "${LIBEXT}", [Dynamic object extension])
2231
2232 DATA_PATH="${ac_tool_prefix}/share/videolan"
2233 AC_SUBST(DATA_PATH)
2234 PLUGIN_PATH="${ac_tool_prefix}/share/videolan"
2235 AC_SUBST(PLUGIN_PATH)
2236
2237 dnl
2238 dnl  Restore *FLAGS
2239 dnl
2240 CPPFLAGS="${CPPFLAGS_save}"
2241 CFLAGS="${CFLAGS_save}"
2242 CXXFLAGS="${CXXFLAGS_save}"
2243 OBJCFLAGS="${OBJCFLAGS_save}"
2244 LDFLAGS="${LDFLAGS_save}"
2245
2246 dnl
2247 dnl  Fool automake (see Makefile.am)
2248 dnl
2249 AUTOMAKE_SUCKS="\$(L_builtin) \$(LDFLAGS_builtin)"
2250 AC_SUBST(AUTOMAKE_SUCKS)
2251
2252 dnl
2253 dnl  Create the vlc-config script
2254 dnl
2255 LDFLAGS_libvlc="${LDFLAGS_vlc} ${LDFLAGS_builtins}"
2256 for i in `echo "${BUILTINS}" | sed -e 's@[^ ]*/@@g'` ; do LDFLAGS_libvlc="${LDFLAGS_libvlc} ${libdir}/vlc/${i}.a `eval echo '$'{LDFLAGS_${i}}`" ; done
2257
2258 dnl
2259 dnl  Configuration is finished
2260 dnl
2261 AC_SUBST(SYS)
2262 AC_SUBST(ARCH)
2263 AC_SUBST(PLUGINS)
2264 AC_SUBST(BUILTINS)
2265 AC_SUBST(ALIASES)
2266 AC_SUBST(ASM)
2267 AC_SUBST(MOC)
2268 AC_SUBST(WINDRES)
2269 AC_SUBST(BCBUILDER)
2270 AC_SUBST(XPIDL)
2271 AC_SUBST(LIBEXT)
2272 AC_SUBST(INCLUDES)
2273
2274 AC_SUBST(CFLAGS_TUNING)
2275 AC_SUBST(CFLAGS_OPTIM)
2276 AC_SUBST(CFLAGS_OPTIM_NODEBUG)
2277 AC_SUBST(LDFLAGS)
2278
2279 AC_SUBST(CFLAGS_vlc)
2280 AC_SUBST(CFLAGS_pics)
2281 AC_SUBST(CFLAGS_plugins)
2282 AC_SUBST(CFLAGS_builtins)
2283 AC_SUBST(CPPFLAGS_mozilla)
2284
2285 AC_SUBST(LDFLAGS_vlc)
2286 AC_SUBST(LDFLAGS_libvlc)
2287 AC_SUBST(LDFLAGS_plugins)
2288 AC_SUBST(LDFLAGS_builtins)
2289 AC_SUBST(LDFLAGS_mozilla)
2290
2291 AC_OUTPUT([
2292   Makefile
2293   debian/Makefile
2294   doc/Makefile
2295   intl/Makefile
2296   ipkg/Makefile
2297   lib/Makefile
2298   m4/Makefile
2299   modules/Makefile
2300   po/Makefile.in
2301   share/Makefile
2302   src/Makefile
2303   vlc-config
2304 ],[
2305   chmod a+x vlc-config
2306 ])
2307
2308 printf "
2309 vlc configuration
2310 --------------------
2311 vlc version           : ${VERSION}
2312 system                : ${SYS}
2313 architecture          : ${ARCH}
2314 build flavour         : "
2315 test "x${DEBUG_TRUE}" = "x" && printf "debug "
2316 test "x${CPROF_TRUE}" = "x" && printf "cprof "
2317 test "x${GPROF_TRUE}" = "x" && printf "gprof "
2318 test "x${OPTIM_TRUE}" = "x" && printf "optim "
2319 test "x${RELEASE_TRUE}" = "x" && printf "release " || printf "devel "
2320 echo "
2321 vlc aliases           :${ALIASES}
2322
2323 To build vlc and its plugins, type \`make'.
2324 "
2325