c4ad73691e23d1d71091051da8f4b7811a7f1bd4
[vlc.git] / configure.ac
1 dnl Autoconf settings for vlc
2
3 AC_INIT(vlc, 1.0.0-git)
4 VERSION_MAJOR="1"
5 VERSION_MINOR="0"
6 VERSION_REVISION="0"
7 VERSION_EXTRA="-git"
8
9 CONFIGURE_LINE="`echo "$0 $ac_configure_args" | sed -e 's/\\\/\\\\\\\/g'`"
10 CODENAME="Goldeneye"
11 COPYRIGHT_YEARS="1996-2008"
12
13 AC_PREREQ(2.59c)
14 AC_CONFIG_SRCDIR(src/libvlc.c)
15 AC_CONFIG_AUX_DIR(autotools)
16 AC_CANONICAL_BUILD
17 AC_CANONICAL_HOST
18
19 AM_INIT_AUTOMAKE(tar-ustar)
20 AM_CONFIG_HEADER(config.h)
21
22 dnl Too many people are not aware of maintainer mode:
23 dnl If you want to use it, you definitely know what you are doing, so
24 dnl you can specify "--disable-maintainer-mode". But if you want the default
25 dnl automake behavior, you've likely never heard of maintainer mode, so we
26 dnl can't expect you to enable it manually.
27
28 AS_IF([test "x${enable_maintainer_mode}" != "xno"],
29         [enable_maintainer_mode="yes"])
30 AM_MAINTAINER_MODE
31
32 dnl
33 dnl  Deprecated options
34 dnl  to notify packagers that stuff has changed
35 dnl
36 AC_ARG_ENABLE(python-bindings,
37   [  --enable-python-bindings Always fails for historical reasons)],,
38   [enable_python_bindings="no"])
39 AS_IF([test "${enable_python_bindings}" != "no"], [
40   AC_MSG_ERROR([Python bindings are now built from a separate source package])
41 ])
42
43 AC_ARG_ENABLE(java-bindings,
44   [  --enable-java-bindings  Always fails for historical reasons],,
45   [enable_java_bindings="no"])
46 AS_IF([test "${enable_java_bindings}" != "no"], [
47   AC_MSG_ERROR([Java bindings are now built from a separate source package])
48 ])
49
50 dnl
51 dnl  Save *FLAGS
52 dnl
53 VLC_SAVE_FLAGS
54
55 dnl
56 dnl Check for tools
57 dnl
58 AC_PROG_CC_C99
59 AC_USE_SYSTEM_EXTENSIONS
60 AC_DEFINE([_FORTIFY_SOURCE], 2, [Define to '2' to get glibc warnings.])
61 AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
62
63 AM_PROG_CC_C_O
64 AC_PROG_CXX
65 AC_PROG_CPP
66 AC_PROG_OBJC
67 _AM_DEPENDENCIES([OBJC])
68 AC_PROG_EGREP
69 AC_PROG_MAKE_SET
70 AC_PROG_INSTALL
71 AM_PROG_AS
72
73 dnl Find the right ranlib, even when cross-compiling
74 AC_CHECK_TOOL(RANLIB, ranlib, :)
75 AC_CHECK_TOOL(STRIP, strip, :)
76 AC_CHECK_TOOL(AR, ar, :)
77 AC_CHECK_TOOL(LD, ld, :)
78 AC_CHECK_TOOL(DLLTOOL, dlltool, :)
79
80 dnl Check for compiler properties
81 AC_C_CONST
82 AC_C_INLINE
83 AC_C_RESTRICT
84
85 dnl Allow binary package maintainer to pass a custom string to avoid 
86 dnl cache problem
87 AC_ARG_WITH(binary-version, 
88         AS_HELP_STRING([--with-binary-version=STRING],
89              [To avoid plugins cache problem between binary version]),[],[])
90 AS_IF([test -n "${with_binary_version}"],[
91       AC_DEFINE_UNQUOTED([DISTRO_VERSION],["${with_binary_version}"],
92                          [Binary specific version])
93       ])
94
95
96 dnl
97 dnl  Check for the contrib directory
98 dnl
99 AC_ARG_WITH(contrib,
100     [  --without-contrib       do not use the libraries in extras/contrib],[],[])
101   AS_IF([test "${with_contrib}" != "no"],[
102     AC_MSG_CHECKING([for libs in extras/contrib])
103     topdir="`dirname $0`"
104     if test "`echo \"$topdir\" | cut -c 1`" != "/"; then
105        topdir="`pwd`/$topdir"
106     fi
107   AS_IF([test -d ${topdir}/extras/contrib/lib],[
108    AS_IF([test "`grep HOST ${topdir}/extras/contrib/config.mak 2>/dev/null|awk '{print $3}'`" != "`$CC -dumpmachine`"],[
109       if test "${with_contrib}" = "yes"; then
110         AC_MSG_RESULT([no])
111         AC_MSG_ERROR([ not using the libs in extras/contrib as it is not the same host])
112       else
113         AC_MSG_RESULT([no])
114         AC_MSG_WARN([ not using the libs in extras/contrib as it is not the same host])
115       fi
116      ],[
117     AC_MSG_RESULT([yes])
118     export PATH=${topdir}/extras/contrib/bin:$PATH
119     CPPFLAGS="${CPPFLAGS} -I${topdir}/extras/contrib/include"
120     CPPFLAGS_save="${CPPFLAGS_save} -I${topdir}/extras/contrib/include"
121     CFLAGS="${CFLAGS} -I${topdir}/extras/contrib/include"
122     CFLAGS_save="${CFLAGS_save} -I${topdir}/extras/contrib/include"
123     CXXFLAGS="${CXXFLAGS} -I${topdir}/extras/contrib/include"
124     CXXFLAGS_save="${CXXFLAGS_save} -I${topdir}/extras/contrib/include"
125     OBJCFLAGS="${OBJCFLAGS} -I${topdir}/extras/contrib/include"
126     OBJCFLAGS_save="${OBJCFLAGS_save} -I${topdir}/extras/contrib/include"
127     if test $build = $host -o "$PKG_CONFIG_LIBDIR"; then
128         export PKG_CONFIG_PATH=${topdir}/extras/contrib/lib/pkgconfig:$PKG_CONFIG_PATH
129     else
130         export PKG_CONFIG_LIBDIR=${topdir}/extras/contrib/lib/pkgconfig
131     fi
132     LDFLAGS="${LDFLAGS} -L${topdir}/extras/contrib/lib"
133     LDFLAGS_save="${LDFLAGS_save} -L${topdir}/extras/contrib/lib"
134
135     if test -z $with_mozilla_sdk_path; then
136        with_mozilla_sdk_path=${topdir}/extras/contrib/gecko-sdk
137     fi
138     if test -z $with_cyberlink_tree; then
139        with_cyberlink_tree=${topdir}/extras/contrib/src/clinkcc
140     fi
141
142     if test ".`uname -s`" = ".Darwin"; then
143       export LD_LIBRARY_PATH=${topdir}/extras/contrib/lib:$LD_LIBRARY_PATH
144       export DYLD_LIBRARY_PATH=${topdir}/extras/contrib/lib:$DYLD_LIBRARY_PATH
145     elif test ".`uname -s`" = ".BeOS"; then
146       export LIBRARY_PATH=${topdir}/extras/contrib/lib:$LIBRARY_PATH
147       export BELIBRARIES=${topdir}/extras/contrib/lib:$BELIBRARIES
148     fi
149     ])
150   ],[
151     AC_MSG_RESULT([no])
152   ])
153 ])
154 dnl
155 dnl  Set default values
156 dnl
157 LDFLAGS_vlc="${LDFLAGS}"
158
159 dnl
160 dnl  Check the operating system
161 dnl
162 case "${host_os}" in
163   "")
164     SYS=unknown
165     ;;
166   linux*)
167     SYS=linux
168     ;;
169   bsdi*)
170     SYS=bsdi
171     CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
172     VLC_ADD_LIBS([dvd dvdcss vcd cdda vcdx cddax],[-ldvd])
173     ;;
174   *bsd*)
175     SYS="${host_os}"
176     CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
177     case "${host_os}" in
178       freebsd*)
179         CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include"
180         CPPFLAGS="${CPPFLAGS_save}"
181         LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib"
182         LDFLAGS="${LDFLAGS_save}"
183         ;;
184     esac
185     ;;
186   darwin*)
187     SYS=darwin
188     CFLAGS_save="${CFLAGS_save} -D_INTL_REDIRECT_MACROS"; CFLAGS="${CFLAGS_save}"
189     CXXFLAGS_save="${CXXFLAGS_save} -D_INTL_REDIRECT_MACROS"; CXXFLAGS="${CXXFLAGS_save}"
190     OBJCFLAGS_save="${OBJCFLAGS_save} -D_INTL_REDIRECT_MACROS -std=gnu99"; OBJCFLAGS="${OBJCFLAGS_save}"
191     LDFLAGS_save="${LDFLAGS_save} -Wl,-headerpad_max_install_names"; LDFLAGS="${LDFLAGS_save}"
192     VLC_ADD_LDFLAGS([mp4], [-Wl,-framework,IOKit,-framework,CoreFoundation])
193     VLC_ADD_LDFLAGS([mkv mp4], [-Wl,-framework,IOKit,-framework,CoreFoundation])
194     VLC_ADD_LDFLAGS([vlc],[-Wl,-undefined,dynamic_lookup])
195     VLC_ADD_LDFLAGS([libvlc_control],[-Wl,dynamic_lookup])
196     VLC_ADD_LDFLAGS([avcodec avformat swscale imgresample postproc i420_rgb_mmx x264],[-Wl,-read_only_relocs,suppress])
197     VLC_ADD_CFLAGS([motion],[-fconstant-cfstrings])
198     VLC_ADD_LDFLAGS([libvlc],[-Wl,-framework,CoreFoundation])
199     VLC_ADD_LDFLAGS([motion],[-Wl,-framework,IOKit,-framework,CoreFoundation])
200     AC_ARG_ENABLE(macosx-defaults,
201       AS_HELP_STRING([--enable-macosx-defaults],[Build the default configuration
202                      on Mac OS X (default enabled)]))
203     if test "x${enable_macosx_defaults}" != "xno"
204     then
205         echo ""
206         echo "Building with Mac OS X defaults:"
207         with_macosx_version_min="10.4"
208         echo "  Assuming --with-macosx-version-min=10.4"
209         build_dir=`pwd`
210         echo "  Assuming --prefix=${build_dir}/vlc_install_dir"
211         ac_default_prefix="${build_dir}/vlc_install_dir"
212         enable_macosx="yes"
213         echo "  Assuming --enable-macosx"
214         enable_faad="yes"
215         echo "  Assuming --enable-faad"
216         enable_flac="yes"
217         echo "  Assuming --enable-flac"
218         enable_theora="yes"
219         echo "  Assuming --enable-theora"
220         enable_shout="yes"
221         echo "  Assuming --enable-shout"
222         enable_cddax="yes"
223         echo "  Assuming --enable-cddax"
224         enable_vcdx="yes"
225         echo "  Assuming --enable-vcdx"
226         enable_caca="yes"
227         echo "  Assuming --enable-caca"
228         enable_goom="yes"
229         echo "  Assuming --enable-goom"
230         enable_ncurses="yes"
231         echo "  Assuming --enable-ncurses"
232         enable_twolame="yes"
233         echo "  Assuming --enable-twolame"
234         enable_realrtsp="yes"
235         echo "  Assuming --enable-realrtsp"
236         enable_update_check="yes"
237         echo "  Assuming --enable-update-check"
238         enable_libass="yes"
239         echo "  Assuming --enable-libass"
240         enable_asademux="yes"
241         echo "  Assuming --enable-asademux"
242
243         enable_skins2="no"
244         echo "  Assuming --disable-skins2"
245         enable_x11="no"
246         echo "  Assuming --disable-x11"
247         enable_glx="no"
248         echo "  Assuming --disable-glx"
249         enable_xvideo="no"
250         echo "  Assuming --disable-xvideo"
251     fi
252     if test ".`uname -p`" = ".i386"; then
253         dnl Due to a ld(64) bug in 10.5 we cannot use our mmx code
254         dnl without hacking it a lot, we disable mmx and sse.
255         dnl (that bug is about ld being unable to handle
256         dnl text relocation)
257         save_cflags="$CFLAGS"
258         CFLAGS="$CFLAGS -dynamiclib -single_module -read_only_relocs suppress"
259         AC_TRY_LINK(
260             [int a;], [asm("movq _a,%mm0\n");],
261             ac_ld_does_not_support_text_reloc=no,
262             ac_ld_does_not_support_text_reloc=yes)
263         CFLAGS="$save_cflags"
264
265         if test "x$ac_ld_does_not_support_text_reloc" = "xyes"; then
266             enable_mmx="no"
267             echo "  Assuming --disable-mmx (due to a bug in ld)"
268             enable_sse="no"
269             echo "  Assuming --disable-sse (due to a bug in ld)"
270         fi
271     fi
272     dnl
273     dnl  Check for Mac OS X SDK settings
274     dnl
275     AC_ARG_WITH(macosx-sdk,
276        [  --with-macosx-sdk=DIR   compile using the SDK in DIR])
277     if test "${with_macosx_sdk}" != "" ; then
278         CPP="${CPP} -isysroot ${with_macosx_sdk}" 
279         CC="${CC} -isysroot ${with_macosx_sdk}" 
280         CXX="${CXX} -isysroot ${with_macosx_sdk}"
281         OBJC="${OBJC} -isysroot ${with_macosx_sdk}"
282         LD="${LD} -syslibroot ${with_macosx_sdk}"
283     fi
284     AC_ARG_WITH(macosx-version-min,
285        [  --with-macosx-version-min=VERSION  compile for MacOSX VERSION and above])
286     if test "${with_macosx_version_min}" != "" ; then
287         CPP="${CPP} -mmacosx-version-min=${with_macosx_version_min}" 
288         CC="${CC} -mmacosx-version-min=${with_macosx_version_min}" 
289         CXX="${CXX} -mmacosx-version-min=${with_macosx_version_min}"
290         OBJC="${OBJC} -mmacosx-version-min=${with_macosx_version_min}"
291         LD="${LD} -macosx_version_min=${with_macosx_version_min}"
292         CFLAGS_save="${CFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; CFLAGS="${CFLAGS_save}"
293         CXXFLAGS_save="${CXXFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; CXXFLAGS="${CXXFLAGS_save}"
294         OBJCFLAGS_save="${OBJCFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; OBJCFLAGS="${OBJCFLAGS_save}"
295         MACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}
296         export MACOSX_DEPLOYMENT_TARGET
297     fi
298     ;;
299   *mingw32* | *cygwin* | *wince* | *mingwce* | *pe*)
300     AC_CHECK_TOOL(WINDRES, windres, :)
301
302     case "${host_os}" in
303       *wince* | *mingwce* | *mingw32ce* | *pe*)
304         SYS=mingwce
305         ;;
306       *mingw32*)
307         SYS=mingw32
308         ;;
309       *cygwin*)
310         dnl Check if we are using the mno-cygwin mode in which case we are
311         dnl actually dealing with a mingw32 compiler.
312         AC_EGREP_CPP(yes,
313             [#ifdef WIN32
314              yes
315              #endif],
316             SYS=mingw32, SYS=cygwin)
317         ;;
318     esac
319
320     if test "${SYS}" = "mingw32"; then
321         # add ws2_32 for closesocket, select, recv
322         VLC_ADD_LIBS([libvlc],[-lws2_32 -lnetapi32 -lwinmm])
323         VLC_ADD_LDFLAGS([vlc],[-mwindows])
324         VLC_ADD_LIBS([activex mozilla],[-lgdi32])
325         VLC_ADD_LIBS([cdda vcdx cddax sdl_image],[-lwinmm])
326         VLC_ADD_LIBS([access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp access_output_shout access_output_rtmp sap slp http stream_out_standard stream_out_rtp vod_rtsp access_realrtsp rtp telnet rc netsync gnutls growl_udp flac ts audioscrobbler lua remoteosd],[-lws2_32])
327     fi
328     if test "${SYS}" = "mingwce"; then
329         # add ws2 for closesocket, select, recv
330         VLC_ADD_LIBS([libvlc access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp sap http netsync audioscrobbler growl rtp stream_out_rtp remoteosd],[-lws2])
331         VLC_ADD_LIBS([libvlc],[-lmmtimer])
332    fi
333     ;;
334   *nto*)
335     SYS=nto
336     VLC_ADD_LIBS([x11 xvideo],[-lsocket])
337     ;;
338   solaris*)
339     SYS=solaris
340     # _POSIX_PTHREAD_SEMANTICS is needed to get the POSIX ctime_r
341     # Perhaps it is useful other places as well? 
342     CFLAGS_save="${CFLAGS_save} -D_POSIX_PTHREAD_SEMANTICS"; CFLAGS="${CFLAGS_save}"
343     ;;
344   hpux*)
345     SYS=hpux
346     ;;
347   beos)
348     SYS=beos
349     CFLAGS_save="${CFLAGS_save} -Wno-multichar"; CFLAGS="${CFLAGS_save}"
350     CXXFLAGS_save="${CXXFLAGS_save} -Wno-multichar"; CXXFLAGS="${CXXFLAGS_save}"
351     VLC_ADD_CXXFLAGS([beos],[])
352     VLC_ADD_LIBS([vlc libvlc logger],[-lbe])
353     VLC_ADD_LIBS([beos],[-lbe -lmedia -ltranslation -ltracker -lgame])
354     VLC_ADD_LIBS([dvdnav dvdread],[-ldl])
355     VLC_ADD_LIBS([access_file],[-lpoll])
356     LDFLAGS_save="${LDFLAGS_save} -lintl"; LDFLAGS="${LDFLAGS_save}"
357     dnl Check for BONE
358     if test -f /boot/beos/system/lib/libbind.so; then
359         VLC_ADD_LIBS([access_file access_ftp access_mms access_output_udp telnet netsync sap libvlc growl_udp],[-lbind -lsocket])
360     else
361         VLC_ADD_LIBS([access_file access_ftp access_mms access_output_udp telnet netsync sap libvlc growl_udp],[-lnet])
362     fi
363
364     dnl Ugly check for Zeta
365     if test -f /boot/beos/system/lib/libzeta.so; then
366         VLC_ADD_LIBS([beos],[-lzeta])
367     fi
368     ;;
369   *)
370     SYS="${host_os}"
371     ;;
372 esac
373 AM_CONDITIONAL(HAVE_BEOS, test "${SYS}" = "beos")
374 AM_CONDITIONAL(HAVE_DARWIN, test "${SYS}" = "darwin")
375 AM_CONDITIONAL(HAVE_LINUX, [test "${SYS}" = "linux"])
376 AM_CONDITIONAL(HAVE_WIN32, test "${SYS}" = "mingw32")
377 AM_CONDITIONAL(HAVE_WINCE, test "${SYS}" = "mingwce")
378
379 dnl
380 dnl Sadly autoconf doesn't think about testing foo.exe when ask to test 
381 dnl for program foo on win32
382
383 case "${build_os}" in
384     cygwin|msys)
385         ac_executable_extensions=".exe"
386     ;;
387     *)
388     ;;
389 esac
390
391 dnl 
392 dnl  Libtool
393 dnl  It's very bad, but our former custom system was worst
394 dnl  -- Courmisch
395 dnl
396
397 dnl override platform specific check for dependent libraries
398 dnl otherwise libtool linking of shared libraries will
399 dnl fail on anything other than pass_all.
400 AC_CACHE_VAL(lt_cv_deplibs_check_method,
401     [lt_cv_deplibs_check_method=pass_all])
402
403 AC_DISABLE_STATIC
404 dnl AC_DISABLE_FAST_INSTALL
405 AC_LIBTOOL_DLOPEN
406 AC_LIBTOOL_WIN32_DLL
407 m4_undefine([AC_PROG_F77])
408 m4_defun([AC_PROG_F77],[])
409 AC_PROG_LIBTOOL
410
411 m4_undefine([AC_DEPLIBS_CHECK_METHOD])
412 m4_defun([AC_DEPLIBS_CHECK_METHOD],[])
413
414 lt_cv_deplibs_check_method=pass_all
415
416
417 dnl
418 dnl Gettext stuff
419 dnl
420 AM_GNU_GETTEXT_VERSION([0.17])
421 AM_GNU_GETTEXT([external])
422 VLC_ADD_LIBS([libvlc vlc], [${LTLIBINTL}])
423
424 dnl
425 dnl Iconv stuff
426 dnl
427 AM_ICONV
428 VLC_ADD_CFLAGS([libvlc],[${INCICONV}])
429 VLC_ADD_LIBS([libvlc],[${LTLIBICONV}])
430
431 dnl Check for the need to include the mingwex lib for mingw32
432 if test "${SYS}" = "mingw32"
433 then
434     AC_CHECK_LIB(mingwex,opendir,
435         AC_CHECK_LIB(mingw32,opendir,,
436             [VLC_ADD_LIBS([libvlc gtk],[-lmingwex])])
437     )
438 fi
439
440 dnl Check for fnative-struct or mms-bitfields support for mingw32
441 if test "${SYS}" = "mingw32"
442 then
443     AC_CACHE_CHECK([if \$CC accepts -mms-bitfields],
444         [ac_cv_c_mms_bitfields],
445         [CFLAGS="${CFLAGS_save} -mms-bitfields"
446          AC_TRY_COMPILE([],,ac_cv_c_mms_bitfields=yes, ac_cv_c_mms_bitfields=no)])
447     if test "${ac_cv_c_mms_bitfields}" != "no"; then
448         CFLAGS_save="${CFLAGS_save} -mms-bitfields";
449         CXXFLAGS_save="${CXXFLAGS_save} -mms-bitfields";
450     else
451         AC_CACHE_CHECK([if \$CC accepts -fnative-struct],
452             [ac_cv_c_fnative_struct],
453             [CFLAGS="${CFLAGS_save} -fnative-struct"
454              AC_TRY_COMPILE([],,ac_cv_c_fnative_struct=yes, ac_cv_c_fnative_struct=no)])
455         if test "${ac_cv_c_fnative_struct}" != "no"; then
456             CFLAGS_save="${CFLAGS_save} -fnative-struct";
457             CXXFLAGS_save="${CXXFLAGS_save} -fnative-struct";
458         fi
459     fi
460
461     CFLAGS="${CFLAGS_save}"; CXXFLAGS="${CXXFLAGS_save}"
462 fi
463
464 dnl Check for fvtable-thunks support for mingw32
465 if test "${SYS}" = "mingw32" -a "${CXX}" != ""
466 then
467 AC_LANG_PUSH(C++)
468     AC_CACHE_CHECK([if \$CXX accepts -fvtable-thunks],
469         [ac_cv_cxx_fvtable_thunks],
470         [CXXFLAGS="${CXXFLAGS_save} -Wall -Werror -fvtable-thunks"
471          AC_TRY_COMPILE([],,ac_cv_cxx_fvtable_thunks=yes,
472                         ac_cv_cxx_fvtable_thunks=no)])
473     if test "${ac_cv_cxx_fvtable_thunks}" = "yes"; then
474         CXXFLAGS_mingw32_special="-fvtable-thunks"
475     fi
476
477     CXXFLAGS_save="${CXXFLAGS_save} ${CXXFLAGS_mingw32_special}"; CXXFLAGS="${CXXFLAGS_save}"
478 AC_LANG_POP(C++)
479 fi
480
481 dnl Plugin compilation stuff
482
483 VLC_LIBRARY_SUFFIX
484
485 dnl The -DSYS_FOO flag
486 CPPFLAGS_save="${CPPFLAGS_save} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`"; CPPFLAGS="${CPPFLAGS_save}"
487
488 dnl Check for system libs needed
489 need_libc=false
490
491 dnl Check for usual libc functions
492 AC_CHECK_FUNCS([gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid_r memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon scandir fork bsearch lstat strlcpy strdup strndup strnlen atof lldiv posix_fadvise posix_madvise uselocale])
493 AC_CHECK_FUNCS(strcasecmp,,[AC_CHECK_FUNCS(stricmp)])
494 AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)])
495 AC_CHECK_FUNCS(strcasestr,,[AC_CHECK_FUNCS(stristr)])
496 AC_FUNC_ALLOCA
497 AC_CHECK_FUNCS(fcntl)
498
499 AH_BOTTOM([#include <vlc_fixups.h>])
500
501 AC_CHECK_FUNCS(mmap, [VLC_ADD_PLUGIN([access_mmap])])
502
503 dnl Check for setlocal and langinfo
504 AC_CHECK_FUNCS(setlocale)
505 AC_CHECK_HEADERS(langinfo.h)
506 AC_CHECK_FUNCS(nl_langinfo)
507
508 AC_CACHE_CHECK([for nl_langinfo and CODESET], ac_cv_langinfo_codeset,
509   [AC_TRY_LINK([#include <langinfo.h>],
510     [char* cs = nl_langinfo(CODESET);],
511     ac_cv_langinfo_codeset=yes,
512     ac_cv_langinfo_codeset=no)
513   ])
514 if test ${ac_cv_langinfo_codeset} = yes; then
515   AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
516     [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
517 fi
518
519 AC_CHECK_FUNCS(connect,,[
520   AC_CHECK_LIB(socket,connect,[
521     VLC_ADD_LIBS([libvlc cdda cddax],-lsocket)
522     LIBS_socket="-lsocket"
523   ])
524 ])
525
526 AC_CHECK_FUNCS(send,,[
527   AC_CHECK_LIB(socket,send,[
528     VLC_ADD_LIBS([access_http access_mms access_udp access_tcp access_ftp access_rtmp sap access_output_udp access_output_rtmp stream_out_standard growl_udp remoteosd],[-lsocket])
529   ])
530 ])
531
532 AC_CHECK_FUNCS(gethostbyname,,[
533   AC_CHECK_LIB(nsl,gethostbyname,[
534     VLC_ADD_LIBS([cdda cddax libvlc],[-lnsl])
535   ],[
536     AC_CHECK_LIB(bind,gethostbyname,[
537       VLC_ADD_LIBS([access_mms],[-lbind])
538     ])
539   ])
540 ])
541
542 AC_CHECK_HEADERS(zlib.h, [
543   VLC_ADD_LIBS([access_http],[-lz])
544 ])
545
546 dnl Check for socklen_t
547 AH_TEMPLATE(socklen_t, [Define to `int' if <sys/socket.h> does not define.])
548 AC_CACHE_CHECK([for socklen_t in sys/socket.h],
549 ac_cv_type_socklen_t,
550 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
551 [#include <sys/types.h>
552 #ifdef WIN32
553 # include <winsock2.h>
554 # include <ws2tcpip.h>
555 #else
556 # include <sys/socket.h>
557 #endif]], [[socklen_t len; len = 0;]])],
558 ac_cv_type_socklen_t=yes,
559 ac_cv_type_socklen_t=no)])
560 AS_IF([test "$ac_cv_type_socklen_t" = no],
561  [AC_DEFINE(socklen_t, int)])
562
563 dnl Check for struct sockaddr_storage
564 AH_TEMPLATE(sockaddr_storage, [Define to `sockaddr' if <sys/socket.h> does not define.])
565 AH_TEMPLATE(ss_family, [Define to `sa_family' if <sys/socket.h> does not define.])
566 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_struct_sockaddr_storage,
567   [AC_TRY_COMPILE(
568     [#include <sys/types.h>
569      #if defined( UNDER_CE )
570      # include <winsock2.h>
571      #elif defined( WIN32 )
572      # include <winsock2.h>
573      #else
574      # include <sys/socket.h>
575      #endif], [struct sockaddr_storage addr;],
576      ac_cv_struct_sockaddr_storage=yes,
577      ac_cv_struct_sockaddr_storage=no)])
578 AS_IF([test "${ac_cv_struct_sockaddr_storage}" = no], [
579   AC_DEFINE(sockaddr_storage, sockaddr)
580   AC_DEFINE(ss_family, sa_family)
581 ])
582
583 dnl getaddrinfo, getnameinfo and gai_strerror check
584 dnl  -lnsl and -lsocket are needed on Solaris;
585 dnl  we purposedly make the test fail on Windows
586 LIBS_save="${LIBS}"
587 AH_TEMPLATE(HAVE_GETADDRINFO, [Define to 1 if you have the `getaddrinfo' function.])
588 AC_SEARCH_LIBS([getaddrinfo], [nsl], [AC_DEFINE(HAVE_GETADDRINFO)],, [${LIBS_socket}])
589
590 dnl NOTE: we assume getaddrinfo will be present if getnameinfo or gai_strerro
591 dnl are
592 LIBS="${LIBS_gai}"
593 AC_CHECK_FUNCS([getnameinfo gai_strerror])
594 LIBS="${LIBS_save}"
595
596 AH_TEMPLATE(HAVE_ADDRINFO, [Define to 1 if <netdb.h> defines `struct addrinfo'.])
597 AC_CHECK_TYPES([struct addrinfo],[AC_DEFINE(HAVE_ADDRINFO)],,
598 [#include <sys/types.h>
599 #if defined( WIN32 ) || defined( UNDER_CE )
600 # if defined(UNDER_CE) && defined(sockaddr_storage)
601 #  undef sockaddr_storage
602 # endif
603 # include <winsock2.h>
604 # include <ws2tcpip.h>
605 #else
606 # include <netdb.h>
607 #endif])
608
609 dnl Check for va_copy
610 AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy,
611   AC_TRY_LINK(
612     [#include <stdarg.h>],
613     [va_list ap1, ap2; va_copy(ap1,ap2);],
614     [ac_cv_c_va_copy="yes"],
615     [ac_cv_c_va_copy="no"]))
616 if test "${ac_cv_c_va_copy}" = "yes"; then
617   AC_DEFINE(HAVE_VA_COPY, 1, [Define if <stdarg.h> defines va_copy.])
618 fi
619 AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy,
620   AC_TRY_LINK(
621     [#include <stdarg.h>],
622     [va_list ap1, ap2; __va_copy(ap1,ap2);],
623     [ac_cv_c___va_copy="yes"],
624     [ac_cv_c___va_copy="no"]))
625 if test "${ac_cv_c___va_copy}" = "yes"; then
626   AC_DEFINE(HAVE___VA_COPY, 1, [Define if <stdarg.h> defines __va_copy.])
627 fi
628
629 AC_CHECK_FUNCS(inet_aton,,[
630   AC_CHECK_LIB(resolv,inet_aton,[
631     VLC_ADD_LIBS([libvlc],[-lresolv])
632   ])
633 ])
634
635 dnl Check for getopt (always use builtin one on win32)
636 if test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"; then
637 need_getopt=:
638 else
639 need_getopt=false
640 AC_CHECK_FUNCS(getopt_long,[AC_DEFINE(HAVE_GETOPT_LONG,1,long getopt support)],
641 [ # FreeBSD has a gnugetopt library for this:
642   AC_CHECK_LIB([gnugetopt],[getopt_long],
643     [AC_DEFINE(HAVE_GETOPT_LONG,1,getopt support)
644      VLC_ADD_LIBS([libvlc],[-lgnugetopt])],
645     [need_getopt=:])])
646 fi
647 AM_CONDITIONAL(BUILD_GETOPT, ${need_getopt})
648
649 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
650 AC_TYPE_SIGNAL
651 AC_CHECK_LIB(m,cos,[
652   VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene],[-lm])
653 ])
654 AC_CHECK_LIB(m,pow,[
655   VLC_ADD_LIBS([avcodec avformat swscale imgresample postproc ffmpegaltivec stream_out_transrate i420_rgb faad twolame equalizer spatializer param_eq libvlc vorbis freetype mod mpc dmo quicktime realaudio realvideo galaktos opengl],[-lm])
656 ])
657 AC_CHECK_LIB(m,sqrt,[
658   VLC_ADD_LIBS([headphone_channel_mixer normvol speex mono colorthres extract],[-lm])
659 ])
660 AC_CHECK_LIB(m,ceil,[
661   VLC_ADD_LIBS([mosaic],[-lm])
662 ])
663 AC_CHECK_LIB(m,exp,[
664   VLC_ADD_LIBS([gaussianblur],[-lm])
665 ])
666 AC_CHECK_LIB(m,round,[
667   VLC_ADD_LIBS([dbus],[-lm])
668 ])
669 AC_CHECK_LIB(mx,sqrtf,[
670   VLC_ADD_LIBS([x264],[-lmx])
671 ])
672 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
673
674 dnl Check for dynamic plugins
675 ac_cv_have_plugins=no
676
677 # OS X style
678 AC_CHECK_HEADERS(mach-o/dyld.h,
679   [AC_CHECK_FUNCS(NSLinkModule,
680     [AC_DEFINE(HAVE_DL_DYLD, 1, [Define if you have the Darwin dyld API])
681      ac_cv_have_plugins=yes])])
682
683 # HP-UX style
684 if test "${ac_cv_have_plugins}" = "no"; then
685   AC_CHECK_HEADERS(dl.h)
686   ac_cv_my_have_shl_load=no
687   AC_CHECK_FUNC(shl_load,
688    [ac_cv_my_have_shl_load=yes,
689     AC_CHECK_LIB(dld, shl_load,
690      [ac_cv_my_have_shl_load=yes
691       VLC_ADD_LIBS([libvlc],[-ldld])])])
692   if test "${ac_cv_my_have_shl_load}" = "yes"; then
693     AC_DEFINE(HAVE_DL_SHL_LOAD, 1, [Define if you have the shl_load API])
694     ac_cv_have_plugins=yes
695   fi
696 fi
697
698 # Whatever style
699 if test "${ac_cv_have_plugins}" = "no"; then
700   AC_CHECK_LIB(dld, dld_link,
701    [VLC_ADD_LIBS([libvlc],[-ldld])
702     AC_DEFINE(HAVE_DL_DLD_LINK, 1, [Define if you have the GNU dld library])
703     ac_cv_have_plugins=yes])
704 fi
705
706 # Win32 style
707 if test "${ac_cv_have_plugins}" = "no"; then
708   if test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"; then
709     AC_CHECK_LIB(kernel32, main,
710      [VLC_ADD_LIBS([libvlc],[-lkernel32])
711       AC_DEFINE(HAVE_DL_WINDOWS, 1, [Define if you have Windows' LoadLibrary])
712       ac_cv_have_plugins=yes])
713   fi
714 fi
715
716 # WinCE style
717 if test "${ac_cv_have_plugins}" = "no"; then
718   if test "${SYS}" = "mingwce"; then
719     AC_DEFINE(HAVE_DL_WINDOWS, 1, [Define if you have Windows' LoadLibrary])
720     ac_cv_have_plugins=yes
721   fi
722 fi
723
724 # BeOS style
725 if test "${ac_cv_have_plugins}" = "no"; then
726   AC_CHECK_HEADERS(image.h)
727   AC_CHECK_FUNCS(load_add_on,
728    [AC_DEFINE(HAVE_DL_BEOS, 1, [Define if you have the BeOS dl])
729     ac_cv_have_plugins=yes])
730 fi
731
732 # Only test for dlopen() if the others didn't work
733 if test "${ac_cv_have_plugins}" = "no"; then
734   AC_CHECK_HEADERS(dlfcn.h sys/dl.h)
735   ac_cv_my_have_dlopen=no
736   AC_CHECK_FUNC(dlopen,
737     ac_cv_my_have_dlopen=yes,
738     AC_CHECK_LIB(dl, dlopen,
739       ac_cv_my_have_dlopen=yes
740       VLC_ADD_LIBS([libvlc realaudio realvideo],[-ldl]),
741       AC_CHECK_LIB(svld, dlopen,
742         ac_cv_my_have_dlopen=yes
743         VLC_ADD_LIBS([libvlc],[-lsvld]))))
744   if test "${ac_cv_my_have_dlopen}" = "yes"; then
745     AC_DEFINE(HAVE_DL_DLOPEN, 1, [Define if you have the dlopen API])
746     ac_cv_have_plugins=yes
747   fi
748 fi
749
750 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
751 dnl Check for pthreads - borrowed from XMMS
752 THREAD_LIB=error
753 if test "${THREAD_LIB}" = "error"; then
754   AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread")
755 fi
756 if test "${THREAD_LIB}" = "error"; then
757   AC_CHECK_LIB(pthreads,main,THREAD_LIB="-lpthreads")
758 fi
759 if test "${THREAD_LIB}" = "error"; then
760   AC_CHECK_LIB(c_r,main,THREAD_LIB="-lc_r")
761 fi
762 if test "${THREAD_LIB}" = "error"; then
763   AC_CHECK_FUNCS(pthread_mutex_lock)
764   THREAD_LIB=""
765 fi
766
767 VLC_ADD_LIBS([libvlc plugin],[${THREAD_LIB}])
768
769 AC_CHECK_LIB(rt, clock_nanosleep, [
770   VLC_ADD_LIBS([libvlc],[-lrt])
771   AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define to 1 if you have clock_nanosleep.])
772 ], [
773   dnl HP/UX port
774   AC_CHECK_LIB(rt,sem_init, [VLC_ADD_LIBS([libvlc],[-lrt])])
775 ])
776
777 have_nanosleep=false
778 AC_CHECK_FUNCS(nanosleep,have_nanosleep=:,[
779   AC_CHECK_LIB(rt,nanosleep,
780     [VLC_ADD_LIBS([libvlc],[-lrt]) have_nanosleep=:],
781     [AC_CHECK_LIB(posix4,nanosleep,
782         [VLC_ADD_LIBS([libvlc],[-lposix4]) have_nanosleep=:])]
783   )
784 ])
785 if ${have_nanosleep}; then
786   AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if nanosleep is available.])
787 fi
788 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce" 
789
790 dnl Check for misc headers
791 AC_MSG_CHECKING(for strncasecmp in strings.h)
792 AC_EGREP_HEADER(strncasecmp,strings.h,[
793   AC_MSG_RESULT(yes)
794   AC_DEFINE(STRNCASECMP_IN_STRINGS_H, 1,
795             Define if <strings.h> defines strncasecmp.)],[
796   AC_MSG_RESULT(no)])
797
798 dnl Check for headers
799 AC_CHECK_HEADERS(signal.h time.h errno.h stdint.h stdbool.h getopt.h strings.h inttypes.h sys/int_types.h wchar.h locale.h)
800 AC_CHECK_HEADERS(sys/sockio.h fcntl.h sys/types.h sys/time.h sys/times.h sys/ioctl.h sys/stat.h xlocale.h)
801 AC_CHECK_HEADERS([arpa/inet.h netinet/in.h netinet/udplite.h])
802 AC_CHECK_HEADERS([net/if.h], [], [],
803   [
804     #include <sys/socket.h>
805   ])
806 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
807 AC_CHECK_HEADERS(machine/param.h sys/shm.h)
808 AC_CHECK_HEADERS([linux/version.h linux/dccp.h])
809 AC_CHECK_HEADERS(syslog.h)
810 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
811
812 AC_HEADER_TIME
813
814 dnl LP64 adn LLP64 architectures had better define ssize_t by themselves...
815 AH_TEMPLATE(ssize_t, [Define to `int' if <stddef.h> does not define.])
816 AC_CHECK_TYPE(ssize_t,, [
817   AC_DEFINE(ssize_t, int)
818 ])
819
820 dnl Check for poll
821 AC_SEARCH_LIBS(poll, [poll], [AC_DEFINE(HAVE_POLL, 1, [Define to 1 if the OS is usabl... err, has poll().])], [
822 if test ${SYS} != "mingw32"
823 then
824     AC_MSG_WARN([Your platform does not support poll(). VLC has it's own poll() implementation, but it is only intended to be used on Windows. VLC might crash or be insecure when you see this message. Either switch to an OS with a proper poll() implementation, or implement one for your OS in VLC])
825 fi
826 ])
827
828 dnl Check for dirent
829 need_dirent=false
830 AC_CHECK_HEADERS(dirent.h,,[need_dirent=:])
831 AM_CONDITIONAL(BUILD_DIRENT, ${need_dirent})
832
833 dnl Mac OS X and other OSes don't have declaration for nanosleep
834 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
835 AC_MSG_CHECKING(for nanosleep in time.h)
836 AC_EGREP_HEADER(nanosleep,time.h,[
837   AC_MSG_RESULT(yes)
838   AC_DEFINE(HAVE_DECL_NANOSLEEP, 1,
839             Define if <time.h> defines nanosleep.)
840 ],[
841   AC_MSG_RESULT(no)
842 ])
843 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
844
845 dnl Make sure we have timespecs
846 AC_MSG_CHECKING(for timespec in sys/time.h)
847 AC_EGREP_HEADER(timespec,sys/time.h,[
848   AC_MSG_RESULT(yes)
849   AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1,
850             Define if <sys/time.h> defines struct timespec.)
851 ],[
852   AC_MSG_RESULT(no)
853 ])
854
855 dnl Check for threads library
856 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
857 AC_CHECK_HEADERS(pthread.h)
858 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
859
860 dnl Find where are the X headers and libraries
861 AC_PATH_XTRA()
862
863 dnl it seems that autoconf do the pkg-config detection only for the first PKG_CHECK_MODULES in the configure.ac ( which is logical) but in our case it is nested in a if so it was not working if you're not on linux or have disable hal.
864 dnl Make PKG_CONFIG_PATH precious so that it appears in the help and get saved
865 AC_ARG_VAR(PKG_CONFIG_PATH, 
866            [Paths where to find .pc not at the default location])
867 PKG_PROG_PKG_CONFIG()
868
869 dnl Check for hal
870 AC_ARG_ENABLE(hal,
871   [  --enable-hal            Linux HAL services discovery (default enabled)])
872  
873 if test "${enable_hal}" != "no" -a "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
874 then
875   PKG_CHECK_MODULES(HAL, hal >= 0.5.0,
876     [
877       AC_DEFINE( HAVE_HAL, 1, [Define if you have the HAL library] )
878       VLC_ADD_PLUGIN([hal])
879       VLC_ADD_PLUGIN([probe_hal])
880       VLC_ADD_LIBS([libvlc hal probe_hal],[$HAL_LIBS])
881       VLC_ADD_CFLAGS([libvlc hal probe_hal],[$HAL_CFLAGS])],
882     [AC_MSG_WARN([libhal >= 0.5.0 was not found. Install libhal-dev ?])]
883   )
884 fi
885
886 dnl Check for dbus
887 AC_ARG_ENABLE(dbus,
888   [  --enable-dbus           Linux D-BUS message bus system (default enabled)])
889 case "${SYS}" in
890     linux*|*bsd*)
891 if test "${enable_dbus}" != "no" -a "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
892 then
893   dnl api stable dbus
894   PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0.0,
895     [ AC_DEFINE( HAVE_DBUS, 1, [Define if you have the D-BUS library] )
896       VLC_ADD_LIBS([screensaver libvlc],[$DBUS_LIBS])
897       VLC_ADD_CFLAGS([screensaver libvlc],[$DBUS_CFLAGS])
898       dnl Check for dbus control interface
899         AC_ARG_ENABLE(dbus-control, [  --disable-dbus-control  D-BUS control interface (default enabled)])
900         if test "${enable_dbus_control}" != "no"
901         then
902           VLC_ADD_PLUGIN([dbus])
903           VLC_ADD_LIBS([dbus],[$DBUS_LIBS])
904           VLC_ADD_CFLAGS([dbus],[$DBUS_CFLAGS])
905         fi
906       dnl Check for Telepathy
907         AC_ARG_ENABLE(telepathy,
908           AS_HELP_STRING([--enable-telepathy],[Telepathy Presence plugin through DBus(default enabled)]))
909         if test "${enable_telepathy}" != "no"; then
910           VLC_ADD_PLUGIN([telepathy])
911           VLC_ADD_LIBS([telepathy],[$DBUS_LIBS])
912           VLC_ADD_CFLAGS([telepathy],[$DBUS_CFLAGS])
913         fi
914         dnl Power Management Inhibiter
915         VLC_ADD_PLUGIN([inhibit])
916         VLC_ADD_LIBS([inhibit],[$DBUS_LIBS])
917         VLC_ADD_CFLAGS([inhibit],[$DBUS_CFLAGS])
918     ],
919     [AC_MSG_ERROR([Couldn't find DBus >= 1.0.0, install libdbus-dev ?])]
920   )
921 fi
922 ;;
923 esac
924
925 dnl Build the gtk_main plugins?
926 NEED_GTK_MAIN=no
927 NEED_GNOME_MAIN=no
928 NEED_GTK2_MAIN=no
929 NEED_GNOME2_MAIN=no
930
931 dnl build the qte plugin ?
932 NEED_QTE_MAIN=no
933
934 dnl Check for ntohl, etc.
935 AC_CACHE_CHECK([for ntohl in sys/param.h],
936     [ac_cv_c_ntohl_sys_param_h],
937     [CFLAGS="${CFLAGS_save} -Wall -Werror"
938      AC_TRY_COMPILE([#include <sys/param.h>],
939         [int meuh; ntohl(meuh);],
940         ac_cv_c_ntohl_sys_param_h=yes, ac_cv_c_ntohl_sys_param_h=no)])
941 if test "${ac_cv_c_ntohl_sys_param_h}" != "no"; then
942     AC_DEFINE(NTOHL_IN_SYS_PARAM_H, 1, Define if <sys/param.h> defines ntohl.)
943 fi
944 CFLAGS="${CFLAGS_save}"
945
946 RDC_PROG_CC_WFLAGS([all extra sign-compare undef pointer-arith bad-function-cast cast-align write-strings missing-prototypes volatile-register-var])
947 RDC_PROG_CC_FLAGS_IFELSE([-pipe])
948
949 dnl Check for various optimization flags
950 AC_CACHE_CHECK([if \$CC accepts -Os],
951     [ac_cv_c_os],
952     [CFLAGS="${CFLAGS_save} -Os"
953      AC_TRY_COMPILE([],,ac_cv_c_os=yes, ac_cv_c_os=no)])
954 if test "${ac_cv_c_os}" != "no"; then
955     CFLAGS_OPTIM_SIZE="${CFLAGS_OPTIM_SIZE} -Os"
956 else 
957     AC_CACHE_CHECK([if \$CC accepts -O],
958         [ac_cv_c_o],
959         [CFLAGS="${CFLAGS_save} -O"
960          AC_TRY_COMPILE([],,ac_cv_c_o=yes, ac_cv_c_o=no)])
961     if test "${ac_cv_c_o}" != "no"; then
962         if test "${ac_cv_c_o3}" = "no"; then
963             CFLAGS_OPTIM_SIZE="${CFLAGS_OPTIM_SIZE} -O"
964         fi
965     fi
966 fi
967
968 AC_CACHE_CHECK([if \$CC accepts -O3],
969     [ac_cv_c_o3],
970     [CFLAGS="${CFLAGS_save} -O3"
971      AC_TRY_COMPILE([],,ac_cv_c_o3=yes, ac_cv_c_o3=no)])
972 if test "${ac_cv_c_o3}" != "no" -a "x${enable_debug}" = "xno"; then
973     CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O3"
974 else
975     AC_CACHE_CHECK([if \$CC accepts -O2],
976         [ac_cv_c_o2],
977         [CFLAGS="${CFLAGS_save} -O2"
978          AC_TRY_COMPILE([],,ac_cv_c_o2=yes, ac_cv_c_o2=no)])
979     if test "${ac_cv_c_o2}" != "no"; then
980         CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O2"
981     else
982         AC_CACHE_CHECK([if \$CC accepts -O],
983             [ac_cv_c_o],
984             [CFLAGS="${CFLAGS_save} -O"
985              AC_TRY_COMPILE([],,ac_cv_c_o=yes, ac_cv_c_o=no)])
986         if test "${ac_cv_c_o}" != "no"; then
987             CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O"
988         fi
989     fi
990 fi
991
992 AC_CACHE_CHECK([if \$CC accepts -O0],
993     [ac_cv_c_o0],
994     [CFLAGS="${CFLAGS_save} -O0"
995      AC_TRY_COMPILE([],,ac_cv_c_o0=yes, ac_cv_c_o0=no)])
996 if test "${ac_cv_c_o0}" != "no"; then
997     CFLAGS_NOOPTIM="${CFLAGS_NOOPTIM} -O0"
998 fi
999
1000 dnl Check for -ffast-math
1001 AC_CACHE_CHECK([if \$CC accepts -ffast-math],
1002     [ac_cv_c_fast_math],
1003     [CFLAGS="${CFLAGS_save} -ffast-math"
1004      AC_TRY_COMPILE([],,ac_cv_c_fast_math=yes, ac_cv_c_fast_math=no)])
1005 if test "${ac_cv_c_fast_math}" != "no"; then
1006     CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -ffast-math"
1007 fi
1008
1009 dnl Check for -funroll-loops
1010 dnl Disabled on BeOS because BeOS' gcc is buggy and may crash with it
1011 if test "${SYS}" != "beos"
1012 then
1013   AC_CACHE_CHECK([if \$CC accepts -funroll-loops],
1014       [ac_cv_c_unroll_loops],
1015       [CFLAGS="${CFLAGS_save} -funroll-loops"
1016        AC_TRY_COMPILE([],,ac_cv_c_unroll_loops=yes, ac_cv_c_unroll_loops=no)])
1017   if test "${ac_cv_c_unroll_loops}" != "no"; then
1018       CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -funroll-loops"
1019   fi
1020 fi
1021
1022 dnl Check for -fomit-frame-pointer
1023 AC_CACHE_CHECK([if \$CC accepts -fomit-frame-pointer],
1024     [ac_cv_c_omit_frame_pointer],
1025     [CFLAGS="${CFLAGS_save} -fomit-frame-pointer"
1026      AC_TRY_COMPILE([],,ac_cv_c_omit_frame_pointer=yes, ac_cv_c_omit_frame_pointer=no)])
1027 if test "${ac_cv_c_omit_frame_pointer}" != "no"; then
1028  if test "${SYS}" != "darwin"; then
1029     CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fomit-frame-pointer"
1030  else
1031     dnl On darwin we explicitely disable it.
1032     CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fno-omit-frame-pointer"
1033  fi
1034 fi
1035
1036 dnl Check for Darwin plugin linking flags
1037 AC_CACHE_CHECK([if \$CC accepts -bundle -undefined error],
1038     [ac_cv_ld_darwin],
1039     [CFLAGS="${CFLAGS_save} -bundle -undefined error"
1040      AC_TRY_COMPILE([],,ac_cv_ld_darwin=yes, ac_cv_ld_darwin=no)])
1041 if test "${ac_cv_ld_darwin}" != "no"; then
1042     VLC_ADD_LDFLAGS([plugin],[-bundle -undefined error])
1043 fi
1044
1045 dnl Checks for __attribute__(aligned()) directive
1046 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
1047     [ac_cv_c_attribute_aligned],
1048     [ac_cv_c_attribute_aligned=0
1049         CFLAGS="${CFLAGS_save} -Werror"
1050     for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do
1051         AC_TRY_COMPILE([],
1052         [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
1053         [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
1054     done
1055         CFLAGS="${CFLAGS_save}"])
1056 if test "${ac_cv_c_attribute_aligned}" != "0"; then
1057     AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
1058         [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
1059 fi
1060
1061 dnl Check for __attribute__((packed))
1062 AC_CACHE_CHECK([for __attribute__((packed))],
1063   [ac_cv_c_attribute_packed],
1064   [ac_cv_c_attribute_packed=no
1065    AC_TRY_COMPILE(, [struct __attribute__((__packed__)) foo { int a; } b;],
1066                     [ac_cv_c_attribute_packed=yes])])
1067 if test "${ac_cv_c_attribute_packed}" != "no"; then
1068   AC_DEFINE(HAVE_ATTRIBUTE_PACKED, 1, Support for __attribute__((packed)) for structs)
1069 fi
1070
1071 dnl
1072 dnl  Check the CPU
1073 dnl
1074 case "${host_cpu}" in
1075   "")
1076     ARCH=unknown
1077     ;;
1078   *)
1079     ARCH="${host_cpu}"
1080     ;;
1081 esac
1082
1083 dnl Check for backtrace() support
1084 AC_CHECK_HEADERS(execinfo.h)
1085 AC_CHECK_FUNCS(backtrace)
1086
1087 dnl
1088 dnl  Enable profiling
1089 dnl
1090 AC_ARG_ENABLE(gprof,
1091 [  --enable-gprof          gprof profiling (default disabled)])
1092 AC_ARG_ENABLE(cprof,
1093 [  --enable-cprof          cprof profiling (default disabled)])
1094 test "${enable_gprof}" != "yes" && enable_gprof="no"
1095 test "${enable_cprof}" != "yes" && enable_cprof="no"
1096
1097 dnl
1098 dnl  default modules
1099 dnl
1100 dnl Video filters:
1101 VLC_ADD_PLUGIN([deinterlace])
1102 VLC_ADD_PLUGIN([yuvp])
1103 VLC_ADD_PLUGIN([invert])
1104 VLC_ADD_PLUGIN([adjust])
1105 VLC_ADD_PLUGIN([transform])
1106 VLC_ADD_PLUGIN([wave])
1107 VLC_ADD_PLUGIN([ripple])
1108 VLC_ADD_PLUGIN([psychedelic])
1109 VLC_ADD_PLUGIN([gradient])
1110 VLC_ADD_PLUGIN([motionblur])
1111 VLC_ADD_PLUGIN([rv32])
1112 VLC_ADD_PLUGIN([rotate])
1113 VLC_ADD_PLUGIN([noise])
1114 VLC_ADD_PLUGIN([grain])
1115 VLC_ADD_PLUGIN([extract])
1116 VLC_ADD_PLUGIN([sharpen])
1117 VLC_ADD_PLUGIN([croppadd])
1118 VLC_ADD_PLUGIN([canvas])
1119 VLC_ADD_PLUGIN([blendbench])
1120 VLC_ADD_PLUGIN([blend])
1121 VLC_ADD_PLUGIN([scale])
1122 VLC_ADD_PLUGIN([vmem])
1123 VLC_ADD_PLUGIN([logo])
1124 VLC_ADD_PLUGIN([magnify])
1125 VLC_ADD_PLUGIN([puzzle])
1126 VLC_ADD_PLUGIN([colorthres])
1127 VLC_ADD_PLUGIN([scene])
1128 VLC_ADD_PLUGIN([yuv])
1129
1130 ALIASES="${ALIASES} cvlc"
1131
1132 dnl
1133 dnl default modules that need g++
1134 dnl
1135 AC_LANG_PUSH(C++)
1136 VLC_ADD_PLUGIN([spatializer])
1137 AC_LANG_POP(C++)
1138
1139 if test "${SYS}" != "mingwce"; then
1140   VLC_ADD_PLUGIN([gestures])
1141   VLC_ADD_PLUGIN([rc])
1142   VLC_ADD_PLUGIN([hotkeys])
1143   VLC_ADD_PLUGIN([showintf])
1144   VLC_ADD_PLUGIN([marq])
1145   VLC_ADD_PLUGIN([podcast])
1146   VLC_ADD_PLUGIN([shout])
1147   VLC_ADD_PLUGIN([sap])
1148   VLC_ADD_PLUGIN([fake])
1149   VLC_ADD_PLUGIN([folder])
1150   VLC_ADD_PLUGIN([rss])
1151   VLC_ADD_PLUGIN([mosaic])
1152   VLC_ADD_PLUGIN([wall])
1153   VLC_ADD_PLUGIN([motiondetect])
1154   VLC_ADD_PLUGIN([clone])
1155   VLC_ADD_PLUGIN([crop])
1156   VLC_ADD_PLUGIN([erase])
1157   VLC_ADD_PLUGIN([bluescreen])
1158   VLC_ADD_PLUGIN([alphamask])
1159   VLC_ADD_PLUGIN([gaussianblur])
1160   VLC_ADD_PLUGIN([i420_yuy2])
1161   VLC_ADD_PLUGIN([i422_yuy2])
1162   VLC_ADD_PLUGIN([i420_ymga])
1163   VLC_ADD_PLUGIN([i422_i420])
1164   VLC_ADD_PLUGIN([yuy2_i422])
1165   VLC_ADD_PLUGIN([yuy2_i420])
1166   VLC_ADD_PLUGIN([chain])
1167   VLC_ADD_PLUGIN([aout_file])
1168   VLC_ADD_PLUGIN([linear_resampler])
1169   VLC_ADD_PLUGIN([bandlimited_resampler])
1170   VLC_ADD_PLUGIN([float32_mixer])
1171   VLC_ADD_PLUGIN([spdif_mixer])
1172   VLC_ADD_PLUGIN([simple_channel_mixer])
1173   VLC_ADD_PLUGIN([dolby_surround_decoder])
1174   VLC_ADD_PLUGIN([headphone_channel_mixer])
1175   VLC_ADD_PLUGIN([normvol])
1176   VLC_ADD_PLUGIN([equalizer])
1177   VLC_ADD_PLUGIN([param_eq])
1178   VLC_ADD_PLUGIN([scaletempo])
1179   VLC_ADD_PLUGIN([converter_float])
1180   VLC_ADD_PLUGIN([a52tospdif])
1181   VLC_ADD_PLUGIN([dtstospdif])
1182   VLC_ADD_PLUGIN([audio_format])
1183   ALIASES="${ALIASES} rvlc"
1184 fi
1185
1186 dnl
1187 dnl Some plugins aren't useful on some platforms
1188 dnl
1189 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
1190     VLC_ADD_PLUGIN([screensaver])
1191     VLC_ADD_PLUGIN([motion])
1192     VLC_ADD_PLUGIN([dynamicoverlay])
1193     VLC_ADD_PLUGIN([signals])
1194 elif test "${SYS}" != "mingwce"; then
1195     VLC_ADD_PLUGIN([ntservice])
1196     VLC_ADD_PLUGIN([access_smb])
1197     VLC_ADD_PLUGIN([dmo])
1198     VLC_ADD_PLUGIN([msn])
1199     VLC_ADD_LIBS([dmo],[-lole32 -luuid])
1200 else
1201     VLC_ADD_PLUGIN([win32text])
1202 fi
1203 if test "${SYS}" = "darwin"; then
1204     VLC_ADD_PLUGIN([quartztext])
1205     VLC_ADD_LDFLAGS([quartztext],[-Wl,-framework,Carbon,-framework,ApplicationServices])
1206 fi
1207
1208 dnl
1209 dnl  Accelerated modules
1210 dnl
1211 AC_ARG_WITH(,[])
1212 AC_ARG_WITH(,[Optimization options:])
1213
1214 dnl  Check for fully working MMX intrinsics
1215 dnl  We need support for -mmmx, we need <mmintrin.h>, and we also need a
1216 dnl  working compiler (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23963)
1217 AC_ARG_ENABLE(mmx,
1218 [  --disable-mmx           disable MMX optimizations (default auto)],,[
1219   case "${host_cpu}" in
1220     i?86|x86_64)
1221       enable_mmx="yes"
1222       ;;
1223     *)
1224       enable_mmx="no"
1225       ;;
1226   esac
1227 ])
1228 AS_IF([test "${enable_mmx}" != "no"], [
1229   ARCH="${ARCH} mmx"
1230
1231   AC_CACHE_CHECK([if $CC groks MMX intrinsics],
1232     [ac_cv_c_mmx_intrinsics],
1233     [CFLAGS="${CFLAGS_save} -O -mmmx"
1234      AC_TRY_COMPILE([#include <mmintrin.h>
1235                      #include <stdint.h>
1236                      uint64_t frobzor;],
1237                     [__m64 a, b, c;
1238                      a = b = c = (__m64)frobzor;
1239                      a = _mm_slli_pi16(a, 3);
1240                      a = _mm_adds_pi16(a, b);
1241                      c = _mm_srli_pi16(c, 8);
1242                      c = _mm_slli_pi16(c, 3);
1243                      b = _mm_adds_pi16(b, c);
1244                      a = _mm_unpacklo_pi8(a, b);
1245                      frobzor = (uint64_t)a;],
1246                     [ac_cv_c_mmx_intrinsics=yes],
1247                     [ac_cv_c_mmx_intrinsics=no])])
1248   AS_IF([test "${ac_cv_c_mmx_intrinsics}" != "no"], [
1249     AC_DEFINE(HAVE_MMX_INTRINSICS, 1,
1250               [Define to 1 if MMX intrinsics are available.])
1251     VLC_ADD_CFLAGS([memcpymmx i420_rgb_mmx i420_yuy2_mmx i422_yuy2_mmx i420_ymga_mmx],[-mmmx])
1252   ])
1253
1254   AC_CACHE_CHECK([if $CC groks MMX inline assembly],
1255     [ac_cv_mmx_inline],
1256     [CFLAGS="${CFLAGS_save}"
1257      AC_TRY_COMPILE(,[void *p;asm volatile("packuswb %%mm1,%%mm2"::"r"(p));],
1258                     ac_cv_mmx_inline=yes, ac_cv_mmx_inline=no)])
1259   AS_IF([test "${ac_cv_mmx_inline}" != "no"], [
1260     AC_DEFINE(CAN_COMPILE_MMX, 1,
1261               [Define to 1 inline MMX assembly is available.])
1262     VLC_ADD_PLUGIN([memcpymmx])
1263     VLC_ADD_PLUGIN([i420_rgb_mmx])
1264     VLC_ADD_PLUGIN([i420_yuy2_mmx])
1265     VLC_ADD_PLUGIN([i422_yuy2_mmx])
1266     VLC_ADD_PLUGIN([i420_ymga_mmx])
1267   ])
1268
1269   AC_CACHE_CHECK([if $CC groks MMX EXT inline assembly],
1270     [ac_cv_mmxext_inline],
1271     [CFLAGS="${CFLAGS_save}"
1272      AC_TRY_COMPILE(,[void *p;asm volatile("maskmovq %%mm1,%%mm2"::"r"(p));],
1273                     ac_cv_mmxext_inline=yes, ac_cv_mmxext_inline=no)])
1274   AS_IF([test "${ac_cv_mmxext_inline}" != "no"], [
1275     AC_DEFINE(CAN_COMPILE_MMXEXT, 1,
1276               [Define to 1 if MMX EXT inline assembly is available.])
1277     VLC_ADD_PLUGIN([memcpymmxext])
1278   ])
1279 ])
1280
1281 dnl  Check for fully workin SSE2 intrinsics
1282 dnl  We need support for -mmmx, we need <emmintrin.h>, and we also need a
1283 dnl  working compiler (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23963)
1284 AC_ARG_ENABLE(sse,
1285 [  --disable-sse           disable SSE (1 and 2) optimizations (default auto)]
1286 ,, [
1287   case "${host_cpu}" in
1288     i686|x86_64)
1289       enable_sse=yes
1290       ;;
1291     *)
1292       enable_sse=no
1293       ;;
1294   esac
1295 ])
1296 AS_IF([test "${enable_sse}" != "no"], [
1297   ARCH="${ARCH} sse sse2"
1298
1299   AC_CACHE_CHECK([if $CC groks SSE2 intrinsics],
1300     [ac_cv_c_sse2_intrinsics],
1301     [CFLAGS="${CFLAGS_save} -O -msse2"
1302      AC_TRY_COMPILE([#include <emmintrin.h>
1303                      #include <stdint.h>
1304                      uint64_t frobzor;],
1305                     [__m128i a, b, c;
1306                      a = b = c = _mm_set1_epi64((__m64)frobzor);
1307                      a = _mm_slli_epi16(a, 3);
1308                      a = _mm_adds_epi16(a, b);
1309                      c = _mm_srli_epi16(c, 8);
1310                      c = _mm_slli_epi16(c, 3);
1311                      b = _mm_adds_epi16(b, c);
1312                      a = _mm_unpacklo_epi8(a, b);
1313                      frobzor = (uint64_t)_mm_movepi64_pi64(a);],
1314                     [ac_cv_c_sse2_intrinsics=yes],
1315                     [ac_cv_c_sse2_intrinsics=no])])
1316   AS_IF([test "${ac_cv_c_sse2_intrinsics}" != "no"], [
1317     AC_DEFINE(HAVE_SSE2_INTRINSICS, 1,
1318               [Define to 1 if SSE2 intrinsics are available.])
1319     VLC_ADD_CFLAGS([i420_rgb_sse2 i420_yuy2_sse2 i422_yuy2_sse2],[-msse2])
1320   ])
1321
1322   AC_CACHE_CHECK([if $CC groks SSE inline assembly],
1323     [ac_cv_sse_inline],
1324     [CFLAGS="${CFLAGS_save}"
1325      AC_TRY_COMPILE(,[void *p;asm volatile("xorps %%xmm1,%%xmm2"::"r"(p));],
1326                     ac_cv_sse_inline=yes, ac_cv_sse_inline=no)])
1327   AS_IF([test "${ac_cv_sse_inline}" != "no" -a "${SYS}" != "solaris"], [
1328     AC_DEFINE(CAN_COMPILE_SSE, 1,
1329               [Define to 1 if SSE inline assembly is available.])
1330   ])
1331
1332   AC_CACHE_CHECK([if $CC groks SSE2 inline assembly],
1333     [ac_cv_sse2_inline],
1334     [CFLAGS="${CFLAGS_save}"
1335      AC_TRY_COMPILE(,[void *p;asm volatile("punpckhqdq %%xmm1,%%xmm2"::"r"(p));],
1336                     ac_cv_sse2_inline=yes, ac_cv_sse2_inline=no)])
1337   AS_IF([test "${ac_cv_sse2_inline}" != "no" -a "${SYS}" != "solaris"], [
1338     AC_DEFINE(CAN_COMPILE_SSE2, 1,
1339               [Define to 1 if SSE2 inline assembly is available.])
1340     VLC_ADD_PLUGIN([i420_rgb_sse2])
1341     VLC_ADD_PLUGIN([i420_yuy2_sse2])
1342     VLC_ADD_PLUGIN([i422_yuy2_sse2])
1343   ])
1344 ])
1345
1346 AC_CACHE_CHECK([if $CC groks 3D Now! inline assembly],
1347     [ac_cv_3dnow_inline],
1348     [CFLAGS="${CFLAGS_save}"
1349      AC_TRY_COMPILE(,[void *p;asm volatile("pfadd %%mm1,%%mm2"::"r"(p));],
1350                     ac_cv_3dnow_inline=yes, ac_cv_3dnow_inline=no)])
1351 AS_IF([test "${ac_cv_3dnow_inline}" != "no"], [
1352   AC_DEFINE(CAN_COMPILE_3DNOW, 1,
1353             [Define to 1 if 3D Now! inline assembly is available.])
1354   VLC_ADD_PLUGIN([memcpy3dn])
1355 ])
1356
1357 AC_ARG_ENABLE(altivec,
1358 [  --disable-altivec       disable AltiVec optimizations (default auto)],, [
1359   AS_IF([test "${host_cpu}" = "powerpc"],
1360         [enable_altivec=yes], [enable_altivec=no])
1361 ])
1362 AS_IF([test "${enable_altivec}" = "yes"], [
1363   ARCH="${ARCH} altivec";
1364   AC_CACHE_CHECK([if $CC groks AltiVec inline assembly],
1365     [ac_cv_altivec_inline],
1366     [CFLAGS="${CFLAGS_save}"
1367      AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
1368          ac_cv_altivec_inline="yes",
1369          [CFLAGS="${CFLAGS_save} -Wa,-m7400"
1370           AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
1371             [ac_cv_altivec_inline="-Wa,-m7400"],
1372             ac_cv_altivec_inline=no)
1373          ])])
1374   AS_IF([test "${ac_cv_altivec_inline}" != "no"], [
1375     AC_DEFINE(CAN_COMPILE_ALTIVEC, 1,
1376               [Define to 1 if AltiVec inline assembly is available.])
1377     AS_IF([test "${ac_cv_altivec_inline}" != "yes"], [
1378       VLC_ADD_CFLAGS([idctaltivec],[${ac_cv_altivec_inline}])
1379       VLC_ADD_CFLAGS([motionaltivec],[${ac_cv_altivec_inline}])
1380       VLC_ADD_CFLAGS([memcpyaltivec],[${ac_cv_altivec_inline}])
1381       VLC_ADD_CFLAGS([i420_yuy2_altivec],[${ac_cv_altivec_inline}])
1382       VLC_ADD_CFLAGS([libvlc],[${ac_cv_altivec_inline}])
1383     ])
1384     VLC_ADD_PLUGIN([memcpyaltivec])
1385     VLC_ADD_PLUGIN([i420_yuy2_altivec])
1386   ])
1387
1388 dnl The AltiVec C extensions
1389 dnl
1390 dnl There are several possible cases:
1391 dnl - OS X PPC, gcc 4.x: use -mpim-altivec -force_cpusubtype_ALL, don't
1392 dnl                      need <altivec.h>
1393 dnl - OS X PPC, gcc 3.x: need -faltivec, don't need <altivec.h>
1394 dnl - Linux PPC, gcc 3.4, 4.x: need <altivec.h> which requires -maltivec
1395 dnl - Linux PPC, gcc 3.3: need <altivec.h> and -maltivec -mabi=altivec
1396 dnl - Linux PPC, gcc 3.x: need <altivec.h> and -fvec
1397 dnl - Others: test should fail
1398   AC_CACHE_CHECK([if \$CC groks AltiVec C extensions],
1399   [ac_cv_c_altivec],
1400   [# OS X/PPC test (gcc 4.x)
1401    CFLAGS="${CFLAGS_save} -mpim-altivec -force_cpusubtype_ALL"
1402    AC_TRY_COMPILE([vector unsigned char foo;],
1403      [vec_ld(0, (unsigned char *)0);],
1404      [ac_cv_c_altivec="-mpim-altivec -force_cpusubtype_ALL"],
1405      [# OS X/PPC test (gcc 3.x)
1406       CFLAGS="${CFLAGS_save} -faltivec"
1407       AC_TRY_COMPILE([vector unsigned char foo;],
1408         [vec_ld(1 * sizeof(vector float), (unsigned char *)0);],
1409         [ac_cv_c_altivec="-faltivec"],
1410         dnl Below this are the Linux tests
1411         [# Linux/PPC test (gcc 4.x)
1412          CFLAGS="${CFLAGS_save} -maltivec"
1413          AC_TRY_COMPILE([#include <altivec.h>],
1414            [vec_ld(0, (unsigned char *)0);],
1415            [ac_cv_c_altivec="-maltivec"],
1416            [# Linux/PPC test (gcc 3.3)
1417             CFLAGS="${CFLAGS_save} -maltivec -mabi=altivec"
1418             AC_TRY_COMPILE([#include <altivec.h>],
1419               [vec_ld(0, (unsigned char *)0);],
1420               [ac_cv_c_altivec=""
1421                ac_cv_c_altivec_abi="-maltivec -mabi=altivec"],
1422               [# Linux/PPC test (gcc 3.3)
1423                CFLAGS="${CFLAGS_save} -fvec"
1424                AC_TRY_COMPILE([#include <altivec.h>],
1425                  [vec_ld(0, (unsigned char *)0);],
1426                  [ac_cv_c_altivec="-fvec"],
1427                  [ac_cv_c_altivec=no])
1428               ])
1429            ])
1430         ])
1431      ])
1432    CFLAGS="${CFLAGS_save}"
1433   ])
1434   AS_IF([test "${ac_cv_c_altivec}" != "no"], [
1435     CPPFLAGS="${CPPFLAGS_save} ${ac_cv_c_altivec}"
1436   ])
1437
1438   AC_CHECK_HEADERS(altivec.h)
1439   CPPFLAGS="${CPPFLAGS_save}"
1440   
1441   AS_IF([test "${ac_cv_c_altivec}" != "no"], [
1442     AC_DEFINE(CAN_COMPILE_C_ALTIVEC, 1,
1443               [Define to 1 if C AltiVec extensions are available.])
1444     VLC_ADD_CFLAGS([libvlc],[${ac_cv_c_altivec}])
1445     VLC_ADD_CFLAGS([idctaltivec motionaltivec],[${ac_cv_c_altivec}])
1446     VLC_ADD_CFLAGS([i420_yuy2_altivec memcpyaltivec deinterlace],[${ac_cv_c_altivec} ${ac_cv_c_altivec_abi}])
1447     VLC_ADD_PLUGIN([memcpyaltivec])
1448     VLC_ADD_PLUGIN([i420_yuy2_altivec])
1449   ])
1450
1451   AC_CACHE_CHECK([if linker needs -framework vecLib],
1452     [ac_cv_ld_altivec],
1453     [LDFLAGS="${LDFLAGS_vlc} -Wl,-framework,vecLib"
1454      AC_TRY_LINK([],,ac_cv_ld_altivec=yes,ac_cv_ld_altivec=no)
1455      LDFLAGS="${LDFLAGS_save}"
1456     ])
1457   AS_IF([test "${ac_cv_ld_altivec}" != "no"], [
1458     VLC_ADD_LDFLAGS([libvlc idctaltivec motionaltivec memcpyaltivec],[-Wl,-framework,vecLib])
1459   ])
1460 ])
1461
1462 dnl
1463 dnl  Special arch tuning
1464 dnl
1465 AC_ARG_WITH(tuning,
1466 [  --with-tuning=ARCH      enable special tuning for an architecture
1467                           (default Pentium 2 on IA-32 and G4 on PPC)])
1468 if test -n "${with_tuning}"; then
1469     if test "${with_tuning}" != "no"; then
1470         CFLAGS_TUNING="-mtune=${with_tuning}"
1471     fi
1472 else
1473     if test "${SYS}" = "darwin" -a "${host_cpu}" != "powerpc"; then
1474         CFLAGS_TUNING="-march=pentium-m -mtune=prescott"
1475     elif test "${host_cpu}" = "i686" -o "${host_cpu}" = "i586" -o "${host_cpu}" = "i486" -o "${host_cpu}" = "i386"; then
1476         CFLAGS_TUNING="-mtune=pentium2"
1477     elif test "${host_cpu}" = "x86_64"; then
1478         CFLAGS_TUNING="-mtune=athlon64"
1479     elif test "${host_cpu}" = "powerpc"; then
1480         CFLAGS_TUNING="-mtune=G4";
1481     fi
1482 fi
1483
1484 dnl NOTE: this can't be cached cleanly
1485 AS_IF([test "${CFLAGS_TUNING}"],
1486    [CFLAGS_save="${CFLAGS}"
1487     CFLAGS="${CFLAGS} ${CFLAGS_TUNING}"
1488
1489     AC_MSG_CHECKING([whether $CC accepts ${CFLAGS_TUNING}])
1490     AC_COMPILE_IFELSE([ ],
1491                       [tuning="yes"],
1492                       [CFLAGS_TUNING=""; tuning="no"
1493                        AS_IF([test "${with_tuning}"],
1494                              [AC_MSG_ERROR([requested tuning not supported])])])
1495
1496     AC_MSG_RESULT([$tuning])
1497     CFLAGS="${CFLAGS_save}"
1498 ])
1499
1500 dnl
1501 dnl  Memory usage
1502 dnl
1503 AC_ARG_ENABLE(optimize-memory,
1504 [  --enable-optimize-memory optimize memory usage over performance])
1505 if test "${enable_optimize_memory}" = "yes"; then
1506   AC_DEFINE(OPTIMIZE_MEMORY, 1, Define if you want to optimize memory usage over performance)
1507 fi
1508
1509 dnl
1510 dnl  Enable/disable optimizations
1511 dnl
1512 AC_ARG_ENABLE(optimizations,
1513 [  --disable-optimizations disable compiler optimizations (default enabled)])
1514 if test "${enable_optimizations}" != "no"; then
1515    if test "${enable_optimize_memory}" = "yes"; then
1516       enable_optimizations="size"
1517    else
1518       enable_optimizations="speed"
1519    fi
1520 fi
1521
1522 dnl
1523 dnl  Debugging mode
1524 dnl
1525 AC_ARG_ENABLE(debug,
1526 [  --enable-debug          debug mode (default disabled)])
1527 test "${enable_debug}" != "yes" && enable_debug="no"
1528 AH_TEMPLATE(NDEBUG,
1529             [Define to 1 if debug code should NOT be compiled])
1530 AS_IF([test "x${enable_debug}" = "xno"], [AC_DEFINE(NDEBUG)])
1531
1532 dnl
1533 dnl Allow runing as root (usefull for people runing on embedded platforms)
1534 dnl
1535 AC_ARG_ENABLE(run-as-root,
1536 [  --enable-run-as-root    allow runing VLC as root (default disabled)])
1537 AS_IF([test "${enable_run_as_root}" == "yes"],[
1538     AC_DEFINE(ALLOW_RUN_AS_ROOT, 1,
1539               [Define to 1 to allow runing VLC as root (uid 0).])
1540 ])
1541
1542 dnl
1543 dnl  Test coverage
1544 dnl
1545 AC_ARG_ENABLE(coverage,
1546         [  --enable-coverage       build for test coverage (default disabled)],,
1547         [enable_coverage="no"])
1548 AS_IF([test "${enable_coverage}" != "no"], [
1549         CFLAGS="-fprofile-arcs -ftest-coverage ${CFLAGS}"
1550         CXXFLAGS="-fprofile-arcs -ftest-coverage ${CXXFLAGS}"
1551         LDFLAGS="-lgcov ${LDFLAGS}"
1552         dnl ugly...
1553         CFLAGS_save="${CFLAGS}"
1554         CXXFLAGS_save="${CXXFLAGS}"
1555         LDFLAGS_save="${LDFLAGS}"
1556 ])
1557
1558 dnl
1559 dnl  Enable release-specific flags
1560 dnl
1561 AC_ARG_ENABLE(release,
1562 [  --enable-release        activate extra optimizations (default disabled)])
1563 test "${enable_release}" != "yes" && enable_release="no"
1564
1565 dnl
1566 dnl Stream output
1567 dnl
1568 AC_ARG_ENABLE(sout,
1569   [  --enable-sout           Stream output modules (default enabled)])
1570 AS_IF([test "${enable_sout}" != "no"], [
1571   AC_DEFINE(ENABLE_SOUT, 1, [Define to 1 for stream output support.])
1572 ])
1573 AM_CONDITIONAL(ENABLE_SOUT, [test "${enable_sout}" != "no"])
1574
1575 AC_ARG_ENABLE(switcher,
1576   [  --enable-switcher       Stream-out switcher plugin (default disabled)])
1577
1578 dnl Check for libshout
1579 AC_ARG_ENABLE(shout,
1580   [  --enable-shout          libshout output plugin (default disabled)])
1581 if test "${enable_shout}" = "yes"; then
1582   PKG_CHECK_MODULES(SHOUT, shout >= 2.1,
1583     [AC_DEFINE(HAVE_SHOUT, 1, [Define if you have the libshout library])
1584      VLC_ADD_PLUGIN([access_output_shout])
1585      VLC_ADD_LIBS([access_output_shout],[$SHOUT_LIBS])
1586      VLC_ADD_CFLAGS([access_output_shout],[$SHOUT_CFLAGS])],
1587     [AC_MSG_WARN(libshout library not found)])
1588 fi
1589
1590 dnl Lua modules
1591 AC_ARG_ENABLE(lua,
1592   AS_HELP_STRING([--enable-lua],[lua playlist, metafetcher and interface 
1593                   plugins (default enabled)]))
1594 if test "${enable_lua}" != "no"
1595 then
1596   PKG_CHECK_MODULES(LUA, lua5.1,
1597     [ have_lua=yes ],
1598     [
1599     AC_MSG_WARN([lua5.1 not found, trying lua >= 5.1 instead])
1600     PKG_CHECK_MODULES(LUA, lua >= 5.1,
1601       [ have_lua=yes ],
1602       [
1603         have_lua=yes
1604         AC_CHECK_HEADERS([lua.h lauxlib.h lualib.h],
1605           [],
1606           [ have_lua=no ] )
1607         AC_CHECK_LIB(  lua5.1 , luaL_newstate,
1608           [LUA_LIBS="-llua5.1"],
1609           AC_CHECK_LIB( lua51 , luaL_newstate,
1610             [LUA_LIBS="-llua51"],
1611             AC_CHECK_LIB( lua , luaL_newstate,
1612               [LUA_LIBS="-llua"],
1613               [ have_lua=no
1614                 AC_MSG_WARN([lua >= 5.1 not found!])
1615               ])
1616           )
1617         )
1618       ])
1619     ])
1620   if test "x${have_lua}" = "xyes" ;  then
1621      AC_DEFINE(HAVE_LUA, 1, [Define if you have the lua library])
1622      VLC_ADD_LIBS([lua],[$LUA_LIBS])
1623      VLC_ADD_CFLAGS([lua],[$LUA_CFLAGS])
1624   fi
1625 fi
1626 AM_CONDITIONAL(BUILD_LUA, [test "${have_lua}" = "yes"])
1627
1628 dnl
1629 dnl HTTP daemon
1630 dnl
1631 AC_ARG_ENABLE(httpd,
1632   [  --enable-httpd          HTTP daemon (default enabled)])
1633 if test "${enable_httpd}" != "no"
1634 then
1635   VLC_ADD_PLUGIN([http])
1636   AC_DEFINE(ENABLE_HTTPD, 1, Define if you want the HTTP dameon support)
1637 fi
1638 AM_CONDITIONAL(BUILD_HTTPD, [test "${enable_httpd}" != "no"])
1639
1640 dnl
1641 dnl libproxy support
1642 dnl
1643 AC_ARG_ENABLE(libproxy,
1644   [  --enable-libproxy       libproxy support (default auto)])
1645 AS_IF([test "${enable_libproxy}" != "no"], [
1646   AC_CHECK_HEADERS(proxy.h, [
1647     VLC_ADD_LIBS([access_http],[-lproxy])
1648   ], [
1649     AS_IF([test "x${enable_libproxy}" != "x"], [
1650       AC_MSG_ERROR([libproxy could not be found on your system])
1651     ])
1652   ])
1653 ])
1654
1655 dnl
1656 dnl VideoLAN manager
1657 dnl
1658 AC_ARG_ENABLE(vlm,
1659   [  --enable-vlm            VideoLAN manager (default enabled)],,
1660   [enable_vlm="${enable_sout}"])
1661 AS_IF([test "${enable_vlm}" != "no"], [
1662   AS_IF([test "${enable_sout}" = "no"], [
1663     AC_MSG_ERROR([VLM requires the stream output. Do not use --disable-sout.])
1664   ])
1665   AC_DEFINE(ENABLE_VLM, 1, [Define if you want the VideoLAN manager support])
1666   VLC_ADD_PLUGIN([telnet])
1667 ])
1668 AM_CONDITIONAL([ENABLE_VLM], [test "${enable_vlm}" != "no"])
1669
1670 dnl
1671 dnl Growl notification plugin
1672 dnl
1673 AC_ARG_ENABLE(growl,
1674   [  --enable-growl          growl notification plugin (default disabled)],,
1675   [enable_growl=no])
1676 AS_IF([test "${enable_growl}" != "no"], [
1677     VLC_ADD_PLUGIN([growl_udp])
1678     AC_CHECK_HEADERS(Growl/GrowlDefines.h, [
1679       VLC_ADD_PLUGIN([growl])
1680       VLC_ADD_LDFLAGS([growl], [-Wl,-framework,Growl,-framework,AppKit])
1681     ])
1682   ]
1683 )
1684
1685 dnl
1686 dnl Libnotify notification plugin
1687 dnl
1688
1689 AC_ARG_ENABLE(notify,
1690   [  --enable-notify         libnotify notification plugin (default enabled)])
1691 AS_IF([test "${enable_notify}" != "no" -a "${SYS}" != "mingw32"], [
1692     PKG_CHECK_MODULES(NOTIFY, libnotify,
1693       [
1694         VLC_ADD_PLUGIN([notify])
1695         VLC_ADD_CFLAGS(notify, [$NOTIFY_CFLAGS])
1696         VLC_ADD_LIBS(notify, [$NOTIFY_LIBS])
1697       ],[
1698     AS_IF([test "${enable_notify}" = "yes"],[
1699         AC_MSG_WARN( libnotify not found) ])
1700       ])
1701   ])
1702
1703 dnl
1704 dnl Audioscrobbler plugin
1705 dnl
1706
1707 AC_ARG_ENABLE(audioscrobbler,
1708   [  --disable-audioscrobbler Last.fm submission plugin (default enabled)])
1709 AS_IF([test "${enable_audioscrobbler}" != "no"], [
1710         VLC_ADD_PLUGIN([audioscrobbler])
1711   ])
1712
1713 dnl
1714 dnl Taglibplugin
1715 dnl
1716 AC_ARG_ENABLE(taglib,
1717   [  --disable-taglib Taglib support (default enabled) ])
1718   AS_IF([test "${enable_taglib}" != "no"],[
1719     PKG_CHECK_MODULES(TAGLIB, taglib,
1720       [ AC_DEFINE( HAVE_TAGLIB, 1, [Define if you have taglib plugin built] )
1721         VLC_ADD_PLUGIN([taglib])
1722         VLC_ADD_LIBS([taglib],[$TAGLIB_LIBS -lz])
1723        VLC_ADD_CXXFLAGS([taglib],[$TAGLIB_CFLAGS]) ],
1724       [AC_MSG_WARN(TagLib library not found)])
1725   ])
1726
1727
1728 dnl
1729 dnl  Input plugins
1730 dnl
1731
1732 AC_ARG_WITH(,[Input plugins:])
1733
1734 dnl  live555 input
1735 dnl
1736 if test "${enable_livedotcom}" 
1737 then
1738   AC_MSG_WARN(--{en|dis}able-livedotcom is deprecated. Use --{en|dis}able-live555 instead.)
1739 fi
1740 if test "${enable_livedotcom}" = "no"
1741 then
1742   enable_live555="no"
1743 fi
1744
1745 AC_ARG_ENABLE(live555,
1746 [  --enable-live555        live555 RTSP input plugin (default enabled)])
1747 if test "${enable_live555}" != "no"; then
1748   AC_ARG_WITH(live555-tree,
1749     [    --with-live555-tree=PATH live.com tree for static linking])
1750
1751   dnl
1752   dnl test for --with-live555-tree
1753   dnl
1754   if test "${with_livedotcom_tree}" 
1755   then
1756     AC_MSG_WARN(--with-livedotcom-tree is deprecated. Use --with-live555-tree instead.)
1757   with_live555_tree="${with_livedotcom_tree}"
1758   fi
1759
1760   if test -z "${with_live555_tree}" -a "${CXX}" != ""; then
1761     AC_LANG_PUSH(C++)
1762     CPPFLAGS_save="${CPPFLAGS}"
1763     CPPFLAGS_live555="-I/usr/include/liveMedia -I/usr/include/groupsock -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment"
1764     if test "${SYS}" = "solaris"; then
1765       CPPFLAGS_live555="${CPPFLAGS_live555} -DSOLARIS"
1766     fi
1767     CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_live555}"
1768
1769     AC_CHECK_HEADERS(liveMedia_version.hh, [
1770       AC_MSG_CHECKING(for liveMedia version >= 1214895600 )
1771       AC_EGREP_CPP(yes,
1772         [#include <liveMedia_version.hh>
1773          #ifdef LIVEMEDIA_LIBRARY_VERSION_INT
1774          #if LIVEMEDIA_LIBRARY_VERSION_INT < 1214895600
1775          yes
1776          #endif
1777          #endif],
1778         [AC_MSG_RESULT([no])
1779          AC_MSG_ERROR([Your version of liveMedia is too old: you may get a more recent one from http://www.live555.com/liveMedia. 
1780 lternatively you can use --disable-live555 to disable the liveMedia plugin.])
1781       ],[
1782          AC_MSG_RESULT([yes])
1783          ])
1784     ])
1785      other_libs="-lgroupsock -lBasicUsageEnvironment -lUsageEnvironment"
1786      other_libs_pic="-lgroupsock_pic -lBasicUsageEnvironment_pic -lUsageEnvironment_pic"
1787       if test "${SYS}" = "mingw32"; then
1788         # add ws2_32 for closesocket, select, recv
1789         other_libs="$other_libs -lws2_32"
1790       fi
1791     dnl We need to check for pic because live555 don't provide shared libs
1792     dnl and we want to build a plugins so we need -fPIC on some arch.
1793     AC_CHECK_HEADERS(liveMedia.hh, [
1794       VLC_ADD_CXXFLAGS([live555], [${CPPFLAGS_live555}])
1795         AC_CHECK_LIB(liveMedia_pic, main, [
1796           VLC_ADD_PLUGIN([live555])
1797          VLC_ADD_LIBS([live555], [-lliveMedia_pic ${other_libs_pic}])
1798          ],[
1799         AC_CHECK_LIB(liveMedia, main, [
1800           VLC_ADD_PLUGIN([live555])
1801           VLC_ADD_LIBS([live555], [-lliveMedia ${other_libs}])
1802         ],[],[${other_libs}]) ],[${other_libs_pic}])
1803     ],[
1804        AC_MSG_WARN([The development files for liveMedia (live555) can't be found])
1805     ])
1806     CPPFLAGS="${CPPFLAGS_save}"
1807     AC_LANG_POP(C++)
1808   else
1809     AC_MSG_CHECKING(for liveMedia/libliveMedia.a in ${with_live555_tree})
1810     real_live555_tree="`cd ${with_live555_tree} 2>/dev/null && pwd`"
1811     if test -z "${real_live555_tree}"; then
1812       dnl  The given directory can't be found
1813       AC_MSG_RESULT(no)
1814       AC_MSG_ERROR([cannot cd to ${with_live555_tree}])
1815     fi
1816     if test -f "${real_live555_tree}/liveMedia/libliveMedia.a"; then
1817       AC_MSG_RESULT(${real_live555_tree}/liveMedia/libliveMedia.a)
1818
1819       AC_CHECK_HEADERS(${real_live555_tree}/liveMedia/include/liveMedia_version.hh,[
1820         AC_MSG_CHECKING(for liveMedia version >= 1214895600 )
1821         AC_EGREP_CPP(yes,
1822           [#include "${real_live555_tree}/liveMedia/include/liveMedia_version.hh"
1823            #ifdef LIVEMEDIA_LIBRARY_VERSION_INT
1824            #if LIVEMEDIA_LIBRARY_VERSION_INT < 1214895600
1825            yes
1826            #endif
1827            #endif],
1828           [AC_MSG_RESULT([no])
1829            AC_MSG_ERROR([Your version of liveMedia is too old: you may get a more recent one from http://www.live555.com/liveMedia. 
1830 lternatively you can use --disable-live555 to disable the liveMedia plugin.])
1831         ],[
1832            AC_MSG_RESULT([yes])
1833            ])
1834       ])
1835
1836       VLC_ADD_PLUGIN([live555])
1837
1838       if test "${SYS}" = "mingw32"; then
1839         # add ws2_32 for closesocket, select, recv
1840         VLC_ADD_LIBS([live555],[-lws2_32])
1841       fi
1842
1843       VLC_ADD_LIBS([live555],[-L${real_live555_tree}/liveMedia -lliveMedia])
1844       VLC_ADD_LIBS([live555],[-L${real_live555_tree}/BasicUsageEnvironment -lBasicUsageEnvironment])
1845       VLC_ADD_LIBS([live555],[-L${real_live555_tree}/groupsock -lgroupsock])
1846       VLC_ADD_LIBS([live555],[-L${real_live555_tree}/UsageEnvironment -lUsageEnvironment])
1847
1848       VLC_ADD_CXXFLAGS([live555],[-I${real_live555_tree}/BasicUsageEnvironment/include])
1849       VLC_ADD_CXXFLAGS([live555],[-I${real_live555_tree}/groupsock/include])
1850       VLC_ADD_CXXFLAGS([live555],[-I${real_live555_tree}/liveMedia/include])
1851       VLC_ADD_CXXFLAGS([live555],[-I${real_live555_tree}/UsageEnvironment/include ])
1852       if test "${SYS}" = "solaris"; then
1853         VLC_ADD_CXXFLAGS([live555],[-DSOLARIS])
1854       fi
1855     else
1856       dnl  The given live555 wasn't built
1857         AC_MSG_RESULT(no)
1858       if test "${enable_live555}" = "yes"; then
1859         AC_MSG_ERROR([cannot find ${real_live555_tree}/liveMedia/libliveMedia.a, make sure you compiled live555 in ${with_live555_tree}])
1860       fi        
1861     fi
1862   fi
1863 fi
1864
1865 dnl
1866 dnl  special access module for dc1394 input
1867 dnl
1868 AC_ARG_ENABLE(dc1394,
1869   [  --enable-dc1394         dc1394 access module (default disabled)])
1870 if test "${enable_dc1394}" = "yes"
1871 then
1872   AC_CHECK_HEADERS(libraw1394/raw1394.h, [
1873     AC_CHECK_LIB( raw1394, raw1394_get_nodecount, [
1874         AC_CHECK_HEADERS(libdc1394/dc1394_control.h , [
1875 dnl         AC_CHECK_LIB( dc1394_control, dc1394_setup_capture, [
1876               VLC_ADD_PLUGIN([dc1394])
1877               VLC_ADD_LIBS([dc1394],[-ldc1394_control -lraw1394])
1878 dnl         ],
1879 dnl         [
1880 dnl           AC_MSG_ERROR([libdc1394 is mandatory for the dc1394 input module. try --disable-dc1394 or install this library])
1881 dnl         ])
1882       ],
1883       [
1884         AC_MSG_ERROR([libdc1394 is mandatory for the dc1394 input module. try --disable-dc1394 or install this library])
1885       ])
1886     ],
1887     [
1888       AC_MSG_ERROR([libraw1394 is mandatory for the dc1394 input module. try --disable-dc1394 or install this library])
1889     ])
1890   ],
1891   [
1892     AC_MSG_ERROR([libraw1394 is mandatory for the dc1394 input module. try --disable-dc1394 or install this library])
1893   ])
1894 fi
1895
1896 dnl
1897 dnl dv module: digital video module check for libraw1394
1898 dnl
1899 AC_ARG_ENABLE(dv,
1900 [  --enable-dv             dv input module (default disabled)])
1901 if test "${enable_dv}" = "yes"
1902 then
1903   AC_ARG_WITH(dv-raw1394,
1904   [    --with-dv-raw1394=PATH   libraw1394 headers and libraries])
1905   AC_ARG_WITH(dv-raw1394-tree,
1906   [    --with-dv-raw1394=PATH   libraw1394 tree for static linking])
1907
1908   if test -z "${with_dv_raw1394}" -a "${with_dv_raw1394}" != ""
1909   then
1910     AC_MSG_CHECKING(for raw1394 headers in ${with_dv_raw1394})
1911     if test -f ${with_dv_raw1394}/include/libraw1394/raw1394.h
1912     then
1913       dnl  Use ${with_dv_raw1394}/include/libraw1394/raw1394.h
1914       AC_MSG_RESULT(yes)
1915       VLC_ADD_PLUGIN([access_dv])
1916       VLC_ADD_LIBS([access_dv],[-L${with_dv_raw1394}/lib -lraw1394 -lpthread])
1917       VLC_ADD_CPPFLAGS([access_dv],[-I${with_dv_raw1394}/include])
1918     else
1919       dnl  No libraw1394 could be found, sorry
1920       AC_MSG_RESULT(no)
1921       AC_MSG_ERROR([cannot find ${with_dv_raw1394}/include/libraw1394/raw1394.h])
1922     fi
1923   else
1924     AC_CHECK_HEADERS(libraw1394/raw1394.h,
1925     [ VLC_ADD_PLUGIN([access_dv])
1926         VLC_ADD_LIBS([access_dv],[-lraw1394 -lavc1394])
1927     ],[
1928         if test -n "${enable_dv}"
1929         then
1930           AC_MSG_ERROR([cannot find libraw1394 headers])
1931         fi
1932     ])
1933   fi
1934
1935   dnl Check for static linking of libraw1394
1936   if test -z "${with_dv_raw1394_tree}" -a "${with_dv_raw1394_tree}" != ""
1937   then
1938     AC_MSG_CHECKING(for libraw1394.a in ${with_dv_raw1394_tree})
1939     real_dv_raw1394_tree="`cd ${with_dv_raw1394_tree} 2>/dev/null && pwd`"
1940     if test -z "${real_dv_raw1394_tree}"
1941     then
1942       dnl  The given directory can't be found
1943       AC_MSG_RESULT(no)
1944       AC_MSG_ERROR([cannot cd to ${real_dv_raw1394_tree}])
1945     fi
1946     if test -f "${real_dv_raw1394_tree}/src/.libs/libraw1394.a"
1947     then
1948       dnl  Use a custom libraw1394
1949       AC_MSG_RESULT(${real_dv_raw1394_tree}/src/.libs/libraw1394.a)
1950       VLC_ADD_PLUGIN([access_dv])
1951       VLC_ADD_LIBS([access_dv],[-L${real_dv_raw1394_tree}/src/.libs -lraw1394])
1952       VLC_ADD_CPPFLAGS([access_dv],[-I${real_dv_raw1394_tree}])
1953     else
1954       dnl  The given libraw1394 wasn't built
1955       AC_MSG_RESULT(no)
1956       AC_MSG_ERROR([cannot find ${real_dv_raw1394_tree}/src/.libs/libraw1394.a, make sure you compiled libraw1394 in ${with_dv_raw1394_tree}])
1957     fi
1958   fi
1959
1960   dnl
1961   dnl Check for libavc1394
1962   dnl
1963
1964   AC_ARG_WITH(dv-avc1394,
1965   [    --with-dv-avc1394=PATH   libavc1394 headers and libraries])
1966   AC_ARG_WITH(dv-avc1394-tree,
1967   [    --with-dv-avc1394=PATH   libavc1394 tree for static linking])
1968
1969   if test -z "${with_dv_avc1394}" -a "${with_dv_avc1394}" != ""
1970   then
1971     AC_MSG_CHECKING(for avc1394 headers in ${with_dv_avc1394})
1972     if test -f ${with_dv_avc1394}/include/libavc1394/avc1394.h
1973     then
1974       dnl  Use ${with_dv_avc1394}/include/libavc1394/avc1394.h
1975       AC_MSG_RESULT(yes)
1976       VLC_ADD_LIBS([access_dv],[-L${with_dv_avc1394}/lib -lavc1394 -lrom1394 -lpthread])
1977       VLC_ADD_CPPFLAGS([access_dv],[-I${with_avc1394}/include])
1978     else
1979       dnl  No libavc1394 could be found, sorry
1980       AC_MSG_RESULT(no)
1981       AC_MSG_ERROR([cannot find ${with_dv_avc1394}/include/libavc1394/avc1394.h])
1982     fi
1983   else
1984     AC_CHECK_HEADERS(libavc1394/avc1394.h,
1985     [ VLC_ADD_LIBS([access_dv],[-lavc1394 -lrom1394 -lpthread])
1986     ],[
1987         if test -n "${enable_dv}"
1988         then
1989           AC_MSG_ERROR([cannot find libavc1394 headers])
1990         fi
1991     ])
1992   fi
1993
1994   dnl Check for static linking of libavc1394
1995   if test -z "${with_dv_avc1394_tree}" -a "${with_dv_avc1394_tree}" != ""
1996   then
1997     AC_MSG_CHECKING(for libavc1394.a in ${with_dv_avc1394_tree})
1998     real_dv_avc1394_tree="`cd ${with_dv_avc1394_tree} 2>/dev/null && pwd`"
1999     if test -z "${real_dv_avc1394_tree}"
2000     then
2001       dnl  The given directory can't be found
2002       AC_MSG_RESULT(no)
2003       AC_MSG_ERROR([cannot cd to ${real_dv_avc1394_tree}])
2004     fi
2005     if test -f "${real_dv_avc1394_tree}/src/.libs/libavc1394.a"
2006     then
2007       dnl  Use a custom libavc1394
2008       AC_MSG_RESULT(${real_dv_avc1394_tree}/src/.libs/libavc1394.a)
2009       VLC_ADD_LIBS([access_dv],[-L${real_dv_avc1394_tree}/src/.libs -lavc1394 -lrom1394 -lpthread])
2010       VLC_ADD_CPPFLAGS([access_dv],[-I${real_dv_avc1394_tree}])
2011     else
2012       dnl  The given libavc1394 wasn't built
2013       AC_MSG_RESULT(no)
2014       AC_MSG_ERROR([cannot find ${real_dv_avc1394_tree}/src/.libs/libavc1394.a, make sure you compiled libavc1394 in ${with_dv_avc1394_tree}])
2015     fi
2016   fi
2017 fi
2018
2019 dnl
2020 dnl dvdread module: check for libdvdread
2021 dnl
2022 AC_ARG_ENABLE(dvdread,
2023 [  --enable-dvdread        dvdread input module (default disabled)])
2024 if test "${enable_dvdread}" != "no"
2025 then
2026   AC_ARG_WITH(dvdread,
2027   [    --with-dvdread=PATH   libdvdread headers and libraries])
2028   AC_ARG_WITH(dvdread-tree,
2029   [    --with-dvdread-tree=PATH libdvdread tree for static linking])
2030
2031   dnl Temporary hack (yeah, sure ;)
2032   if test "${SYS}" = "mingw32" || test "${SYS}" = "darwin" || test "${SYS}" = "beos" ; then
2033       VLC_ADD_LIBS([dvdread],[-ldvdcss])
2034   fi
2035
2036   if test -z "${with_dvdread}"
2037   then
2038     if test -z "${with_dvdread_tree}"
2039     then
2040       AC_CHECK_HEADERS(dvdread/dvd_reader.h,
2041         [ VLC_ADD_PLUGIN([dvdread])
2042           VLC_ADD_LIBS([dvdread],[-ldvdread ${LIBS_dvdcss}])
2043         ],[
2044           AC_CHECK_HEADERS(libdvdread/dvd_reader.h,
2045             [ VLC_ADD_PLUGIN([dvdread])
2046               VLC_ADD_LIBS([dvdread],[-ldvdread ${LIBS_dvdcss}])
2047             ],[
2048               if test -n "${enable_dvdread}"
2049               then
2050               AC_MSG_ERROR([cannot find libdvdread headers])
2051              fi
2052            ])
2053         ])
2054     else
2055       AC_MSG_CHECKING(for libdvdread.a in ${with_dvdread_tree})
2056       real_dvdread_tree="`cd ${with_dvdread_tree} 2>/dev/null && pwd`"
2057       if test -z "${real_dvdread_tree}"
2058       then
2059         dnl  The given directory can't be found
2060         AC_MSG_RESULT(no)
2061         AC_MSG_ERROR([cannot cd to ${with_dvdread_tree}])
2062       fi
2063       if test -f "${real_dvdread_tree}/dvdread/.libs/libdvdread.a"
2064       then
2065         dnl  Use a custom libdvdread
2066         AC_MSG_RESULT(${real_dvdread_tree}/dvdread/.libs/libdvdread.a)
2067         VLC_ADD_PLUGIN([dvdread])
2068         VLC_ADD_LIBS([dvdread],[-L${real_dvdread_tree}/dvdread/.libs -ldvdread ${LIBS_dvdcss}])
2069         VLC_ADD_CPPFLAGS([dvdread],[-I${real_dvdread_tree}])
2070       else
2071         dnl  The given libdvdread wasn't built
2072         AC_MSG_RESULT(no)
2073         AC_MSG_ERROR([cannot find ${real_dvdread_tree}/dvdread/.libs/libdvdread.a, make sure you compiled libdvdread in ${with_dvdread_tree}])
2074       fi
2075     fi
2076   else
2077     AC_MSG_CHECKING(for dvdread headers in ${with_dvdread})
2078     if test -f ${with_dvdread}/include/dvdread/dvd_reader.h
2079     then
2080       dnl  Use ${with_dvdread}/include/dvdread/dvd_reader.h
2081       AC_MSG_RESULT(yes)
2082       VLC_ADD_PLUGIN([dvdread])
2083       VLC_ADD_LIBS([dvdread],[-L${with_dvdread}/lib -ldvdread ${LIBS_dvdcss}])
2084       VLC_ADD_CPPFLAGS([dvdread],[-I${with_dvdread}/include])
2085     else
2086       dnl  No libdvdread could be found, sorry
2087       AC_MSG_RESULT(no)
2088       AC_MSG_ERROR([cannot find ${with_dvdread}/include/dvdread/dvd_reader.h])
2089     fi
2090   fi
2091 fi
2092
2093 dnl
2094 dnl  libdvdnav plugin
2095 dnl
2096 AC_ARG_ENABLE(dvdnav,
2097   [  --enable-dvdnav         dvdnav input module (default enabled)])
2098 if test "${enable_dvdnav}" != "no"
2099 then
2100   dnl Same hack than dvdread
2101   if test "${SYS}" = "mingw32" || test "${SYS}" = "darwin" || test "${SYS}" = "beos" ; then
2102       VLC_ADD_LIBS([dvdnav],[-ldvdcss])
2103   fi
2104
2105   DVDNAV_PATH="${PATH}"
2106   AC_ARG_WITH(dvdnav-config-path,
2107     [    --with-dvdnav-config-path=PATH dvdnav-config path (default search in \$PATH)],
2108     [ if test "${with_dvdnav_config_path}" != "no"
2109       then
2110         DVDNAV_PATH="${with_dvdnav_config_path}:${PATH}"
2111       fi ])
2112   AC_PATH_PROG(DVDNAV_CONFIG, dvdnav-config, no, ${DVDNAV_PATH})
2113   if test "${DVDNAV_CONFIG}" != "no"
2114   then
2115     VLC_ADD_PLUGIN([dvdnav])
2116     VLC_ADD_CFLAGS([dvdnav],[`${DVDNAV_CONFIG} --cflags`])
2117     VLC_ADD_LIBS([dvdnav],[`${DVDNAV_CONFIG} --libs`])
2118   fi
2119 fi
2120
2121 dnl
2122 dnl  Windows DirectShow access module
2123 dnl
2124 AC_ARG_ENABLE(dshow,
2125   [  --enable-dshow          Win32 DirectShow support (default enabled on Win32)])
2126 if test "${enable_dshow}" != "no"
2127 then
2128   if test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"
2129   then
2130     AC_LANG_PUSH(C++)
2131       AC_CHECK_HEADERS(dshow.h,
2132       [ VLC_ADD_PLUGIN([dshow])
2133         VLC_ADD_CXXFLAGS([dshow],[])
2134         VLC_ADD_LIBS([dshow],[-lole32 -loleaut32 -luuid]) ])
2135     AC_LANG_POP(C++)
2136   fi
2137 fi
2138
2139 dnl
2140 dnl  Windows DirectShow BDA access module
2141 dnl
2142 AC_ARG_ENABLE(bda,
2143   AS_HELP_STRING([--enable-bda],[Win32 DirectShow BDA support (default 
2144                   enabled on Win32)]))
2145 if test "${enable_bda}" != "no"
2146 then
2147   if test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"
2148   then
2149       AC_CHECK_HEADERS(dshow.h,
2150       [ VLC_ADD_PLUGIN([bda])
2151         VLC_ADD_CXXFLAGS([bda],[])
2152         VLC_ADD_LIBS([bda],[-lstrmiids -lole32 -loleaut32 -luuid]) ])
2153   fi
2154 fi
2155
2156
2157 dnl
2158 dnl  OpenCV wrapper and example filters
2159 dnl
2160 AC_ARG_ENABLE(opencv,
2161   [  --enable-opencv         OpenCV (computer vision) filter (default disabled)])
2162 if test "${enable_opencv}" = "yes" -a "${CXX}" != "";
2163 then
2164   AC_ARG_WITH(opencv-tree,
2165   [    --with-opencv-tree=PATH opencv tree for linking])
2166     if test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"
2167     then
2168       test -z "${with_opencv_tree}" && AC_MSG_ERROR([You have to specify --with-opencv-tree])
2169           AC_MSG_CHECKING(for opencv in ${with_opencv_tree})
2170           if test -f ${with_opencv_tree}/cv/include/cv.h -a -f ${with_opencv_tree}/cxcore/include/cxcore.h \
2171             -a -f ${with_opencv_tree}/cvaux/include/cvaux.h -a -f ${with_opencv_tree}/otherlibs/highgui/highgui.h
2172       then
2173         AC_MSG_RESULT(yes)
2174         VLC_ADD_PLUGIN([opencv_wrapper])
2175         VLC_ADD_LIBS([opencv_wrapper],[-L${with_opencv_tree}/lib -lcv -lcxcore -lcvaux -lhighgui])
2176         VLC_ADD_CFLAGS([opencv_wrapper],[-I${with_opencv_tree}/cv/include -I${with_opencv_tree}/cxcore/include -I${with_opencv_tree}/cvaux/include -I${with_opencv_tree}/otherlibs/highgui])
2177         AC_LANG_PUSH(C++)
2178         VLC_ADD_PLUGIN([opencv_example])
2179         VLC_ADD_LIBS([opencv_example],[-L${with_opencv_tree}/lib -lcv -lcxcore -lcvaux -lhighgui])
2180         VLC_ADD_CXXFLAGS([opencv_example],[-I${with_opencv_tree}/cv/include -I${with_opencv_tree}/cxcore/include -I${with_opencv_tree}/cvaux/include -I${with_opencv_tree}/otherlibs/highgui])
2181         AC_LANG_POP(C++)        
2182           else
2183         dnl  No opencv could be found, sorry
2184         AC_MSG_RESULT(no)
2185         AC_MSG_ERROR([cannot find opencv in ${with_opencv_tree}])
2186           fi
2187     else
2188       PKG_CHECK_MODULES(OPENCV, opencv,
2189         [
2190           VLC_ADD_PLUGIN([opencv_example])
2191           VLC_ADD_PLUGIN([opencv_wrapper])
2192           VLC_ADD_LIBS([opencv_example opencv_wrapper],[${OPENCV_LIBS}])
2193           VLC_ADD_CFLAGS([opencv_wrapper],[${OPENCV_CFLAGS}])
2194           VLC_ADD_CXXFLAGS([opencv_example],[${OPENCV_CFLAGS}])
2195         ],
2196         [AC_MSG_ERROR([libopencv not found!])]
2197       )
2198     fi
2199 fi
2200
2201
2202 dnl
2203 dnl  libsmbclient plugin
2204 dnl
2205 AC_ARG_ENABLE(smb,
2206   [  --enable-smb            smb input module (default enabled)])
2207 if test "${enable_smb}" != "no"; then
2208   AC_CHECK_HEADERS(libsmbclient.h,
2209     [ VLC_ADD_PLUGIN([access_smb])
2210       VLC_ADD_LIBS([access_smb],[-lsmbclient]) ],
2211     [ if test -n "${enable_smb}"; then
2212         AC_MSG_ERROR([cannot find libsmbclient headers])
2213      fi ])
2214   AC_CHECK_MEMBER([struct _SMBCCTX.close_fn],
2215     AC_DEFINE([HAVE__SMBCCTX_CLOSE_FN], 1, [Define if samba has _SMBCCTX.close_fn]),,
2216     [#include <libsmbclient.h>])
2217 fi
2218
2219 dnl
2220 dnl  libdvbpsi ts demux/mux
2221 dnl
2222 AC_ARG_ENABLE(dvbpsi,
2223   [  --enable-dvbpsi         dvbpsi ts mux and demux module (default enabled)])
2224 have_dvbpsi=no
2225 if test "${enable_dvbpsi}" != "no"
2226 then
2227   AC_ARG_WITH(dvbpsi,
2228   [    --with-dvbpsi=PATH    libdvbpsi headers and libraries])
2229   AC_ARG_WITH(dvbpsi,
2230   [    --with-dvbpsi-tree=PATH libdvbpsi tree for static linking])
2231   case "${with_dvbpsi}" in
2232   ""|yes)
2233     if test -z "${with_dvbpsi_tree}"
2234     then
2235       AC_CHECK_HEADERS(dvbpsi/dr.h,
2236         [ VLC_ADD_PLUGIN([ts])
2237           if test "${enable_sout}" != "no"; then
2238             VLC_ADD_PLUGIN([mux_ts])
2239           fi
2240           VLC_ADD_LIBS([mux_ts ts dvb],[-ldvbpsi])
2241           have_dvbpsi=yes],
2242         [  AC_MSG_WARN([cannot find libdvbpsi headers]) ],
2243         [#if defined( HAVE_STDINT_H )
2244 #   include <stdint.h>
2245 #elif defined( HAVE_INTTYPES_H )
2246 #   include <inttypes.h>
2247 #endif
2248 #include <dvbpsi/dvbpsi.h>
2249 #include <dvbpsi/descriptor.h>
2250 #include <dvbpsi/pat.h>
2251 #include <dvbpsi/pmt.h>])
2252     else
2253       AC_MSG_CHECKING(for libdvbpsi.a in ${with_dvbpsi_tree})
2254       real_dvbpsi_tree="`cd ${with_dvbpsi_tree} 2>/dev/null && pwd`"
2255       if test -z "${real_dvbpsi_tree}"
2256       then
2257         dnl  The given directory can't be found
2258         AC_MSG_RESULT(no)
2259         AC_MSG_ERROR([cannot cd to ${with_dvbpsi_tree}])
2260       fi
2261       if test -f "${real_dvbpsi_tree}/src/.libs/libdvbpsi.a"
2262       then
2263         dnl  Use a custom libdvbpsi
2264         AC_MSG_RESULT(${real_dvbpsi_tree}/src/.libs/libdvbpsi.a)
2265         VLC_ADD_PLUGIN([ts])
2266         if test "${enable_sout}" != "no"; then
2267           VLC_ADD_PLUGIN([mux_ts])
2268         fi
2269         VLC_ADD_CPPFLAGS([mux_ts ts dvb],[-I${real_dvbpsi_tree}/src])
2270         VLC_ADD_LIBS([mux_ts ts dvb],[${real_dvbpsi_tree}/src/.libs/libdvbpsi.a])
2271         have_dvbpsi=yes
2272       else
2273         dnl  The given libdvbpsi wasn't built
2274         AC_MSG_RESULT(no)
2275         AC_MSG_ERROR([cannot find ${real_dvbpsi_tree}/src/.libs/libdvbpsi.a, make sure you compiled libdvbpsi in ${with_dvbpsi_tree}])
2276       fi
2277     fi
2278   ;;
2279   no)
2280     dnl  Compile without dvbpsi
2281   ;;
2282   *)
2283     AC_MSG_CHECKING(for dvbpsi headers in ${with_dvbpsi})
2284     if test -z "${with_dvbpsi}"
2285     then
2286       LDFLAGS_test=""
2287       CPPFLAGS_test=""
2288     else
2289       LDFLAGS_test="-L${with_dvbpsi}/lib"
2290       CPPFLAGS_test="-I${with_dvbpsi}/include"
2291     fi
2292     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test}"
2293     AC_CHECK_HEADERS([dvbpsi/dr.h],[
2294       VLC_ADD_PLUGIN([ts])
2295       if test "${enable_sout}" != "no"; then
2296         VLC_ADD_PLUGIN([mux_ts])
2297       fi
2298       VLC_ADD_CPPFLAGS([mux_ts ts dvb],[${CPPFLAGS_test}])
2299       VLC_ADD_LIBS([mux_ts ts dvb],[${LDFLAGS_test} -ldvbpsi])
2300       have_dvbpsi=yes
2301     ],[
2302       if test -n "${enable_dvbpsi}"
2303       then
2304         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])
2305       fi
2306     ])
2307     CPPFLAGS="${CPPFLAGS_save}"
2308   ;;
2309   esac
2310   AC_CHECK_LIB(dvbpsi, dvbpsi_GenSDTSections, [
2311     AC_DEFINE(HAVE_DVBPSI_SDT, 1, [Define if you have dvbpsi_GenSDTSections.])
2312   ], [], [${LIBS_ts}])
2313
2314 fi
2315
2316 dnl
2317 dnl  Video4Linux plugin
2318 dnl
2319 AC_ARG_ENABLE(v4l,
2320   [  --enable-v4l            Video4Linux input support (default disabled)])
2321 if test "${enable_v4l}" = "yes"
2322 then
2323   AC_ARG_WITH(v4l,
2324     [    --with-v4l=PATH       path to a v4l-enabled kernel tree],[],[])
2325   if test "${with_v4l}" != "no" -a -n "${with_v4l}"
2326   then
2327     VLC_ADD_CPPFLAGS([v4l],[-I${with_v4l}/include])
2328   fi
2329
2330   CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_v4l}"
2331   AC_CHECK_HEADERS(linux/videodev.h, [
2332     VLC_ADD_PLUGIN([v4l])
2333   ],[])
2334   CPPFLAGS="${CPPFLAGS_save}"
2335 fi
2336
2337 dnl
2338 dnl  Video4Linux2 plugin
2339 dnl
2340 AC_ARG_ENABLE(v4l2,
2341   [  --enable-v4l2           Video4Linux2 input support (default enabled)])
2342 if test "${enable_v4l2}" != "no"
2343 then
2344   AC_ARG_WITH(v4l2,
2345     [    --with-v4l2=PATH       path to a v4l2-enabled kernel tree],[],[])
2346   if test "${with_v4l2}" != "no" -a -n "${with_v4l2}"
2347   then
2348     VLC_ADD_CPPFLAGS([v4l2],[-I${with_v4l2}/include])
2349   fi
2350
2351   if test "${enable_alsa}" != "no"
2352   then
2353     AC_CHECK_HEADER(alsa/asoundlib.h, AC_CHECK_LIB(asound, main, have_v4l2_alsa="true", have_v4l2_alsa="false"),have_v4l2_alsa="false")
2354   fi
2355
2356   if test "${have_v4l2_alsa}" = "true"
2357   then
2358     CFLAGS="${CFLAGS_save}"
2359     AC_TRY_COMPILE([#define ALSA_PCM_NEW_HW_PARAMS_API
2360                     #define ALSA_PCM_NEW_SW_PARAMS_API
2361                     #include <alsa/asoundlib.h>],
2362        [snd_pcm_hw_params_get_period_time(0,0,0);],
2363         AC_DEFINE(HAVE_ALSA_NEW_API, 1, Define if ALSA is at least rc4))
2364     VLC_ADD_LDFLAGS([v4l2],[-lasound -lm -ldl])
2365     AC_DEFINE(HAVE_ALSA, 1, Define if ALSA is present.)
2366   fi
2367
2368   CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_v4l2}"
2369   AC_CHECK_HEADERS(linux/videodev2.h, [
2370     VLC_ADD_PLUGIN([v4l2])
2371   ],[])
2372   CPPFLAGS="${CPPFLAGS_save}"
2373 fi
2374
2375
2376 dnl
2377 dnl  special access module for Hauppauge PVR cards
2378 dnl
2379 AC_ARG_ENABLE(pvr,
2380   [  --enable-pvr            PVR cards access module (default disabled)])
2381 if test "${enable_pvr}" = "yes"
2382 then
2383   VLC_ADD_PLUGIN([pvr])
2384   AC_ARG_WITH(videodev2,
2385     [  --with-videodev2=FILE   Location of videodev2.h file (default /usr/include/linux/videodev2.h)],[],[])
2386   if test "${with_videodev2}" != "no" -a -n "${with_videodev2}"
2387   then
2388     AC_DEFINE_UNQUOTED(VIDEODEV2_H_FILE, "${with_videodev2}", [Location of videodev2.h])
2389   fi
2390     
2391
2392   AC_CACHE_CHECK([for new linux/videodev2.h],
2393       [ac_cv_new_linux_videodev2_h],
2394       [AC_TRY_COMPILE([
2395           #include <sys/types.h>
2396           #   ifdef VIDEODEV2_H_FILE
2397           #   include VIDEODEV2_H_FILE
2398           #   else
2399           #   include <linux/videodev2.h>
2400           #   endif
2401           ],
2402           [struct v4l2_ext_controls ctrls; ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; ],
2403           ac_cv_new_linux_videodev2_h=yes,
2404           ac_cv_new_linux_videodev2_h=no)])
2405   if test "${ac_cv_new_linux_videodev2_h}" != "no"; then
2406     AC_DEFINE(HAVE_NEW_LINUX_VIDEODEV2_H, 1, [Define if new linux/videodev2.h present])
2407   fi
2408 fi
2409
2410 dnl
2411 dnl  gnomeVFS access module
2412 dnl
2413 AC_ARG_ENABLE(gnomevfs,
2414   [  --enable-gnomevfs       GnomeVFS access module (default disabled)])
2415 if test "${enable_gnomevfs}" = "yes" 
2416 then
2417   PKG_CHECK_MODULES(GNOMEVFS, gnome-vfs-2.0,
2418     VLC_ADD_LIBS([access_gnomevfs],[$GNOMEVFS_LIBS])
2419     VLC_ADD_CPPFLAGS([access_gnomevfs],[$GNOMEVFS_CPPFLAGS])
2420     VLC_ADD_CFLAGS([access_gnomevfs],[$GNOMEVFS_CFLAGS])
2421     VLC_ADD_PLUGIN([access_gnomevfs]),
2422     AC_MSG_WARN([GnomeVFS support disabled because GnomeVFS development headers not found]))
2423 fi
2424
2425 dnl Need to test libcdio and libvcdinfo for a number of things. Do it now.
2426 AC_ARG_ENABLE(libcdio,
2427   [  --enable-libcdio        CD input and control library support (default enabled)])
2428
2429 AC_ARG_ENABLE(vcdinfo,
2430   [  --enable-libvcdinfo     VCD information library support (default enabled)])
2431
2432 have_libcdio=no
2433 have_libvcdinfo=no
2434 if test "${enable_libcdio}" != "no"
2435 then
2436   PKG_CHECK_MODULES(LIBCDIO, libcdio >= 0.78.2,
2437      have_libcdio=yes
2438      AC_DEFINE(HAVE_LIBCDIO, 1, 
2439      [Define if you have libcdio 0.78.2 or greater installed]),
2440      [AC_MSG_WARN(CD Reading and information library not found)])
2441
2442   if test "${enable_vcdinfo}" != "no"
2443   then
2444     PKG_CHECK_MODULES(VCDINFO, libvcdinfo >= 0.7.22,
2445        [have_libvcdinfo=yes
2446        AC_DEFINE(HAVE_VCDINFO, 1, 
2447        [Define if you have libvcdinfo 0.7.22 or greater installed])],
2448        [AC_MSG_WARN(VCD information library not found)])
2449   fi
2450 fi
2451
2452 dnl
2453 dnl  VCDX and CDDAX modules
2454 dnl
2455 AC_ARG_ENABLE(cddax,
2456   AS_HELP_STRING([--enable-cddax],[audio CD plugin with CD Text and CD paranoia
2457                   via libcdio (default disabled)]))
2458  
2459 AC_ARG_ENABLE(libcddb,
2460   [  --enable-libcddb        CDDB support for libcdio audio CD (default enabled)])
2461  
2462 if test "${enable_cddax}" = "yes"
2463 then
2464   if test "$have_libcdio" = "yes"
2465   then
2466     AC_DEFINE(HAVE_CDDAX, 1, [Define for the audio CD plugin using libcdio])
2467     VLC_ADD_LIBS([cddax],[$LIBCDIO_LIBS])
2468     VLC_ADD_CFLAGS([cddax],[$LIBCDIO_CFLAGS])
2469     VLC_ADD_PLUGIN([cddax])
2470     PKG_CHECK_MODULES(LIBCDIO_PARANOIA, libcdio_paranoia >= 0.72, [
2471     VLC_ADD_LIBS([cddax],[$LIBCDIO_CDDA_LIBS $LIBCDIO_CDDA_LIBS $LIBCDIO_PARANOIA_LIBS])],
2472     AC_MSG_WARN([CD Paranoia support disabled because no libcdio >= 0.72 found]))
2473   else 
2474     AC_MSG_WARN([cddax plugin disabled because ok libcdio library not found or disabled])
2475     HAVE_CDDAX=no
2476   fi
2477
2478   if test "$enable_libcddb" != "no"; then
2479     PKG_CHECK_MODULES(LIBCDDB, libcddb >= 0.9.5, [
2480       HAVE_LIBCDDB=yes 
2481       AC_DEFINE(HAVE_LIBCDDB, 1, [Define this if you have libcddb installed])
2482       VLC_ADD_LIBS([cddax],[$LIBCDDB_LIBS])
2483       VLC_ADD_CFLAGS([cddax],[$LIBCDDB_CFLAGS])
2484       ],
2485       [AC_MSG_WARN(new enough libcddb not found. CDDB access disabled) 
2486       HAVE_LIBCDDB=no])
2487   fi
2488  
2489 fi
2490
2491 AC_ARG_ENABLE(vcdx,
2492   [  --enable-vcdx           VCD with navigation via libvcdinfo (default disabled)])
2493  
2494 if test "${enable_vcdx}" = "yes"
2495 then
2496   if test "${have_libvcdinfo}" = "yes"
2497   then
2498     VLC_ADD_LIBS([vcdx],[$VCDINFO_LIBS])
2499     VLC_ADD_CFLAGS([vcdx],[$VCDINFO_CFLAGS])
2500   else 
2501     AC_MSG_WARN([vcdx plugin disabled because ok libvcdinfo library not found or disabled])
2502     HAVE_VCDX=no
2503   fi
2504
2505   PKG_CHECK_MODULES(LIBCDIO, libiso9660 >= 0.72,
2506    [VLC_ADD_LIBS([vcdx],[$LIBISO9660_LIBS])
2507     VLC_ADD_CFLAGS([vcdx],[$LIBISO9660_CFLAGS])],
2508     [AC_MSG_WARN([vcdx plugin disabled because ok libiso9660 library not found])
2509     HAVE_VCDX=no])
2510
2511   if test "$have_libvcdinfo" = "yes"
2512   then
2513     AC_DEFINE(HAVE_VCDX, 1, 
2514     [Define for the VCD plugin using libcdio/libvcdinfo])
2515     VLC_ADD_LIBS([vcdx],[$VCDINFO_LIBS])
2516     VLC_ADD_CFLAGS([vcdx],[$VCDINFO_CFLAGS])
2517     VLC_ADD_PLUGIN([vcdx])
2518   else 
2519     AC_MSG_WARN([vcdx plugin disabled because ok libvcdinfo library not found])
2520     HAVE_VCDX=no
2521   fi
2522 fi
2523
2524 dnl
2525 dnl  Built-in CD-DA and VCD module
2526 dnl
2527 AC_ARG_ENABLE(cdda,           
2528   [  --enable-cdda           audio CD via built-in VCD (default enabled)])
2529  
2530 AC_ARG_ENABLE(vcd,
2531   [  --enable-vcd            built-in VCD (default enabled)])
2532
2533 if test "${enable_vcd}" != "no"
2534 then
2535   AC_MSG_CHECKING(for cdrom_msf0 in linux/cdrom.h)
2536   AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[
2537     AC_MSG_RESULT(yes)
2538     VLC_ADD_PLUGIN([vcd])
2539     VLC_ADD_PLUGIN([cdda])
2540   ],[
2541     AC_MSG_RESULT(no)
2542   ])
2543
2544   AC_MSG_CHECKING(for scsireq in sys/scsiio.h)
2545   AC_EGREP_HEADER(scsireq,sys/scsiio.h,[
2546     AC_MSG_RESULT(yes)
2547     VLC_ADD_PLUGIN([vcd])
2548     VLC_ADD_PLUGIN([cdda])
2549     AC_DEFINE(HAVE_SCSIREQ_IN_SYS_SCSIIO_H, 1, For NetBSD VCD support)
2550   ],[
2551     AC_MSG_RESULT(no)
2552   ])
2553
2554   AC_MSG_CHECKING(for ioc_toc_header in sys/cdio.h)
2555   AC_EGREP_HEADER(ioc_toc_header ,sys/cdio.h,[
2556     AC_MSG_RESULT(yes)
2557     VLC_ADD_PLUGIN([vcd])
2558     VLC_ADD_PLUGIN([cdda])
2559     AC_DEFINE(HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H, 1, For FreeBSD VCD support)
2560   ],[
2561     AC_MSG_RESULT(no)
2562   ])
2563
2564   if test "${SYS}" = "bsdi" -o "${SYS}" = "mingw32"
2565   then
2566     VLC_ADD_PLUGIN([vcd])
2567     VLC_ADD_PLUGIN([cdda])
2568   fi
2569
2570   if test "${SYS}" = "darwin"
2571   then
2572     VLC_ADD_PLUGIN([vcd])
2573     VLC_ADD_PLUGIN([cdda])
2574     VLC_ADD_LDFLAGS([vcd vcdx cdda cddax],[-Wl,-framework,IOKit,-framework,CoreFoundation])
2575     VLC_ADD_LIBS([vcdx cddax cdda],[-liconv])
2576   fi
2577
2578   if test "$enable_libcddb" != "no"; then
2579     PKG_CHECK_MODULES(LIBCDDB, libcddb >= 0.9.5, [
2580       HAVE_LIBCDDB=yes 
2581       AC_DEFINE(HAVE_LIBCDDB, 1, [Define this if you have libcddb installed])
2582       VLC_ADD_LIBS([cdda],[$LIBCDDB_LIBS])
2583       VLC_ADD_CFLAGS([cdda],[$LIBCDDB_CFLAGS])
2584       ],:
2585       [AC_MSG_WARN(new enough libcddb not found. CDDB access disabled) 
2586       HAVE_LIBCDDB=no])
2587   fi
2588 fi
2589
2590 dnl
2591 dnl  DVB-S/DVB-T/DVB-C satellite/teresterial/cable input using v4l2
2592 dnl
2593 AC_ARG_ENABLE(dvb,
2594   [  --enable-dvb            DVB-S/T/C card support (default enabled)])
2595
2596 if test "${enable_dvb}" != "no"
2597 then
2598     AS_IF([test "${have_dvbpsi}" = "yes" ],[  
2599     AC_ARG_WITH(dvb,
2600      [    --with-dvb=PATH       path to a dvb- and v4l2-enabled kernel tree],[],[])
2601      if test "${with_dvb}" != "no" -a -n "${with_dvb}"
2602      then
2603        VLC_ADD_CFLAGS([dvb],[-I${with_dvb}/include])
2604      fi
2605      CPPFLAGS="${CPPFLAGS_save} -I${with_dvb}/include"
2606      AC_CHECK_HEADERS(linux/dvb/version.h linux/dvb/frontend.h, [
2607      VLC_ADD_PLUGIN([dvb])
2608      ],[AC_MSG_WARN(linux-dvb headers not found, dvb disabled)])
2609      CPPFLAGS="${CPPFLAGS_save}"
2610    ],[
2611      AC_MSG_WARN([the dvb access module requires libdvbpsi])
2612     ]) 
2613 fi
2614
2615 dnl
2616 dnl  Screen capture module
2617 dnl
2618 AC_ARG_ENABLE(screen,
2619   [  --enable-screen         Screen capture support (default enabled)])
2620 if test "${enable_screen}" != "no"; then
2621   if test "${SYS}" = "darwin"; then
2622     AC_CHECK_HEADERS(OpenGL/gl.h, [
2623       AC_CHECK_HEADERS(ApplicationServices/ApplicationServices.h, [
2624         VLC_ADD_PLUGIN([screen])
2625         VLC_ADD_LDFLAGS([screen],[-Wl,-framework,OpenGL,-framework,ApplicationServices])
2626       ])
2627     ])
2628   elif test "${SYS}" = "mingw32"; then
2629     VLC_ADD_PLUGIN([screen])
2630     VLC_ADD_LIBS([screen],[-lgdi32])
2631   elif test "${SYS}" = "mingwce"; then
2632     CPPFLAGS="${CPPFLAGS_save}"
2633   elif test "${SYS}" = "beos"; then
2634     VLC_ADD_PLUGIN([screen])
2635     VLC_ADD_CXXFLAGS([screen],[])
2636     VLC_ADD_LIBS([screen],[-lbe])
2637   else
2638     CPPFLAGS="${CPPFLAGS_save} ${X_CFLAGS}"
2639     AC_CHECK_HEADERS(X11/Xlib.h, [
2640       VLC_ADD_PLUGIN([screen])
2641       VLC_ADD_LIBS([screen],[${X_LIBS} ${X_PRE_LIBS} -lX11])
2642       VLC_ADD_CPPFLAGS([screen],[${X_CFLAGS}])
2643     ])
2644     CPPFLAGS="${CPPFLAGS_save}"
2645   fi
2646 fi
2647
2648 dnl
2649 dnl  ipv6 plugin - not for QNX yet
2650 dnl
2651 have_ipv6=no
2652 AC_CHECK_FUNCS(inet_pton,[have_ipv6=yes],[
2653   AC_CHECK_LIB(nsl,inet_pton, [have_ipv6=yes])
2654 ])
2655
2656 AS_IF([test "${have_ipv6}" = "yes"], [
2657   AC_DEFINE(HAVE_INET_PTON, 1, [Define to 1 if you have inet_pton().])])
2658
2659
2660 AC_CHECK_FUNCS(inet_ntop,[
2661   AC_DEFINE(HAVE_INET_NTOP, 1, [Define to 1 if you have inet_ntop().])])
2662
2663
2664 dnl
2665 dnl  ogg demux plugin
2666 dnl
2667 AC_ARG_ENABLE(ogg,
2668   [  --enable-ogg            Ogg demux support (default enabled)])
2669 if test "${enable_ogg}" != "no"
2670 then
2671   AC_ARG_WITH(ogg-tree,
2672   [    --with-ogg-tree=PATH  ogg tree for static linking])
2673   if test -n "${with_ogg_tree}"
2674   then
2675     AC_MSG_CHECKING(for libogg.a in ${with_ogg_tree})
2676     real_ogg_tree="`cd ${with_ogg_tree} 2>/dev/null && pwd`"
2677     if test -z "${real_ogg_tree}"
2678     then
2679       dnl  The given directory can't be found
2680       AC_MSG_RESULT(no)
2681       AC_MSG_ERROR([cannot cd to ${with_ogg_tree}])
2682     fi
2683     if test -f "${real_ogg_tree}/src/.libs/libogg.a"
2684     then
2685       dnl  Use a custom ogg
2686       AC_MSG_RESULT(${real_ogg_tree}/src/.libs/libogg.a)
2687       VLC_ADD_PLUGIN([ogg])
2688       if test "${enable_sout}" != "no"; then
2689         VLC_ADD_PLUGIN([mux_ogg])
2690       fi
2691       VLC_ADD_LIBS([ogg mux_ogg speex vorbis],[${real_ogg_tree}/src/.libs/libogg.a])
2692       VLC_ADD_CFLAGS([ogg mux_ogg speex vorbis],[-I${real_ogg_tree}/include])
2693     else
2694       dnl  The given ogg wasn't built
2695       AC_MSG_RESULT(no)
2696       AC_MSG_ERROR([cannot find ${real_ogg_tree}/src/.libs/libogg.a, make sure you compiled ogg in ${with_ogg_tree}])
2697     fi
2698   else
2699     AC_CHECK_HEADERS(ogg/ogg.h, [
2700       AC_CHECK_LIB( ogg, oggpack_read, [
2701         VLC_ADD_PLUGIN([ogg])
2702         if test "${enable_sout}" != "no"; then
2703           VLC_ADD_PLUGIN([mux_ogg])
2704         fi
2705         VLC_ADD_LIBS([ogg mux_ogg],[-logg])])
2706      ],[])
2707   fi
2708 fi
2709
2710 dnl
2711 dnl  matroska demux plugin
2712 dnl
2713 AC_ARG_ENABLE(mkv,
2714   [  --enable-mkv            Matroska demux support (default enabled)])
2715 if test "${enable_mkv}" != "no" -a "${CXX}" != ""; then
2716   AC_LANG_PUSH(C++)
2717   AC_CHECK_HEADERS(ebml/EbmlVersion.h, [
2718     AC_MSG_CHECKING(for libebml version >= 0.7.7)
2719     AC_EGREP_CPP(yes,
2720       [#include <ebml/EbmlVersion.h>
2721        #ifdef LIBEBML_VERSION
2722        #if LIBEBML_VERSION >= 0x000706
2723        yes
2724        #endif
2725        #endif],
2726       [AC_MSG_RESULT([yes])
2727         AC_CHECK_HEADERS(matroska/KaxVersion.h, [
2728           AC_MSG_CHECKING(for libmatroska version >= 0.8.0)
2729           AC_EGREP_CPP(yes,
2730             [#include <matroska/KaxVersion.h>
2731              #ifdef LIBMATROSKA_VERSION
2732              #if LIBMATROSKA_VERSION >= 0x000705
2733              yes
2734              #endif
2735              #endif],
2736             [AC_MSG_RESULT([yes])
2737               AC_CHECK_HEADERS(matroska/KaxAttachments.h)
2738               VLC_ADD_CXXFLAGS([mkv],[])
2739               if test "${SYS}" = "darwin"; then
2740                 VLC_ADD_CXXFLAGS([mkv],[-O1])
2741               fi
2742               AC_CHECK_LIB(ebml_pic, main, [
2743                 VLC_ADD_PLUGIN([mkv])
2744                 VLC_ADD_LIBS([mkv],[-lmatroska -lebml_pic])
2745               ],
2746                 AC_CHECK_LIB(ebml, main, [
2747                   VLC_ADD_PLUGIN([mkv])
2748                   VLC_ADD_LIBS([mkv],[-lmatroska -lebml])
2749                 ]) 
2750               )
2751             ],
2752             [AC_MSG_RESULT([no])
2753               AC_MSG_ERROR([Your libmatroska is too old: you may get a more recent one from http://dl.matroska.org/downloads/libmatroska/. Alternatively you can use --disable-mkv to disable the matroska plugin.])
2754           ])
2755         ])
2756       ],
2757       [AC_MSG_RESULT([no])
2758         AC_MSG_ERROR([Your libebml is too old: you may get a more recent one from http://dl.matroska.org/downloads/libebml/. Alternatively you can use --disable-mkv to disable the matroska plugin.])
2759     ])
2760   ])
2761   AC_LANG_POP(C++)
2762 fi
2763
2764 dnl
2765 dnl  modplug demux plugin
2766 dnl
2767 AC_ARG_ENABLE(mod,
2768   [  --enable-mod            Mod demux support (default enabled)])
2769 if test "${enable_mod}" != "no"
2770 then
2771   AC_ARG_WITH(mod-tree,
2772   [    --with-mod-tree=PATH mod tree for static linking])
2773   if test -n "${with_mod_tree}"
2774   then
2775     AC_MSG_CHECKING(for libmodplug.a in ${with_mod_tree})
2776     real_mod_tree="`cd ${with_mod_tree} 2>/dev/null && pwd`"
2777     if test -z "${real_mod_tree}"
2778     then
2779       dnl  The given directory can't be found
2780       AC_MSG_RESULT(no)
2781       AC_MSG_ERROR([cannot cd to ${with_mod_tree}])
2782     fi
2783     if test -f "${real_mod_tree}/src/.libs/libmodplug.a"
2784     then
2785       dnl  Use a custom mod
2786       AC_MSG_RESULT(${real_mod_tree}/src/.libs/libmodplug.a)
2787       VLC_ADD_PLUGIN([mod])
2788       VLC_ADD_LIBS([mod],[${real_mod_tree}/src/.libs/libmodplug.a -lstdc++])
2789       VLC_ADD_CXXFLAGS([mod],[-I${real_mod_tree}/include])
2790     else
2791       dnl  The given mod wasn't built
2792       AC_MSG_RESULT(no)
2793       AC_MSG_ERROR([cannot find ${real_mod_tree}/src/.libs/libmodplug.a, make sure you compiled mod in ${with_mod_tree}])
2794     fi
2795   else
2796     AC_CHECK_HEADERS(libmodplug/modplug.h, [
2797       VLC_ADD_PLUGIN([mod])
2798       VLC_ADD_CXXFLAGS([mod],[])
2799       VLC_ADD_LIBS([mod],[-lmodplug -lstdc++])])
2800   fi
2801 fi
2802
2803 dnl
2804 dnl  mpc demux plugin
2805 dnl
2806 AC_ARG_ENABLE(mpc,
2807   [  --enable-mpc            Mpc demux support (default enabled)])
2808 if test "${enable_mpc}" != "no"
2809 then
2810   AC_CHECK_HEADERS(mpcdec/mpcdec.h, [
2811     VLC_ADD_PLUGIN([mpc])
2812     VLC_ADD_LIBS([mpc],[-lmpcdec])])
2813 fi
2814
2815 dnl
2816 dnl  game music emu demux plugin
2817 dnl
2818 AC_ARG_ENABLE(gme,
2819   [  --enable-gme            Game Music Emu demux support (default enabled)])
2820 if test "${enable_gme}" != "no" -a "${CXX}" != "";
2821 then
2822   AC_LANG_PUSH(C++)
2823   AC_ARG_WITH(gme-tree,
2824   [    --with-gme-tree=PATH gme tree for static linking])
2825   if test -n "${with_gme_tree}"
2826   then
2827     AC_MSG_CHECKING(for libgme.a in ${with_mod_tree})
2828     real_gme_tree="`cd ${with_gme_tree} 2>/dev/null && pwd`"
2829     if test -z "${real_gme_tree}"
2830     then
2831       dnl  The given directory can't be found
2832       AC_MSG_RESULT(no)
2833       AC_MSG_ERROR([cannot cd to ${with_gme_tree}])
2834     fi
2835     if test -f "${real_gme_tree}/gme/libgme.a"
2836     then
2837       dnl  Use a custom gme
2838       AC_MSG_RESULT(${real_gme_tree}/gme/libgme.a)
2839       VLC_ADD_PLUGIN([gme])
2840       VLC_ADD_LIBS([gme],[${real_gme_tree}/gme/libgme.a])
2841       VLC_ADD_CXXFLAGS([gme],[-I${real_gme_tree}/gme])
2842     else
2843       dnl  The given gme wasn't built
2844       AC_MSG_RESULT(no)
2845       AC_MSG_ERROR([cannot find ${real_mod_tree}/gme/libgme.a, make sure you compiled gme in ${with_gme_tree}])
2846     fi
2847   else
2848       AC_MSG_WARN([only static linking is available, you must provide a gme-tree])
2849   fi
2850   AC_LANG_POP(C++)
2851 fi
2852
2853 dnl
2854 dnl  Codec plugins
2855 dnl
2856
2857 AC_ARG_WITH(,[Codec plugins:])
2858
2859 dnl
2860 dnl  mad plugin
2861 dnl
2862 AC_ARG_ENABLE(mad,
2863   [  --enable-mad            libmad module (default enabled)])
2864 if test "${enable_mad}" != "no"
2865 then
2866   AC_ARG_WITH(mad,
2867     [    --with-mad=PATH       path to libmad],[],[])
2868   if test "${with_mad}" != "no" -a -n "${with_mad}"
2869   then
2870     VLC_ADD_CPPFLAGS([mpgatofixed32],[-I${with_mad}/include])
2871     VLC_ADD_LIBS([mpgatofixed32],[-L${with_mad}/lib])
2872   fi
2873
2874   AC_ARG_WITH(mad-tree,
2875     [    --with-mad-tree=PATH   mad tree for static linking],[],[])
2876   if test "${with_mad_tree}" != "no" -a -n "${with_mad_tree}"
2877   then
2878     real_mad_tree="`cd ${with_mad_tree} 2>/dev/null && pwd`"
2879     if test -z "${real_mad_tree}"
2880     then
2881       dnl  The given directory can't be found
2882       AC_MSG_RESULT(no)
2883       AC_MSG_ERROR([${with_mad_tree} directory doesn't exist])
2884     fi
2885     dnl  Use a custom libmad
2886     AC_MSG_CHECKING(for mad.h in ${real_mad_tree})
2887     if test -f ${real_mad_tree}/mad.h
2888     then
2889       AC_MSG_RESULT(yes)
2890       VLC_ADD_CPPFLAGS([mpgatofixed32],[-I${real_mad_tree}])
2891       VLC_ADD_LIBS([mpgatofixed32],[-L${real_mad_tree}/.libs])
2892       LDFLAGS="${LDFLAGS_save} ${LIBS_mpgatofixed32}"
2893       AC_CHECK_LIB(mad, mad_bit_init, [
2894         VLC_ADD_PLUGIN([mpgatofixed32])
2895         VLC_ADD_LIBS([mpgatofixed32],[-lmad])
2896         ],[ AC_MSG_ERROR([the specified tree hasn't been compiled ])
2897       ],[])
2898       LDFLAGS="${LDFLAGS_save}"
2899     else
2900       AC_MSG_RESULT(no)
2901       AC_MSG_ERROR([the specified tree doesn't have mad.h])
2902     fi
2903   else
2904     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_mpgatofixed32}"
2905     LDFLAGS="${LDFLAGS_save} ${LIBS_mpgatofixed32}"
2906     AC_CHECK_HEADERS(mad.h, ,
2907       [ AC_MSG_ERROR([Could not find libmad on your system: you may get it from http://www.underbit.com/products/mad/. Alternatively you can use --disable-mad to disable the mad plugin.]) ])
2908     AC_CHECK_LIB(mad, mad_bit_init, [
2909       VLC_ADD_PLUGIN([mpgatofixed32])
2910       VLC_ADD_LIBS([mpgatofixed32],[-lmad])],
2911       [ AC_MSG_ERROR([Cannot find libmad library...]) ])
2912     CPPFLAGS="${CPPFLAGS_save}"
2913     LDFLAGS="${LDFLAGS_save}"
2914   fi
2915 fi
2916
2917 dnl
2918 dnl   libid3tag support (FIXME!!! doesn't work with new input)
2919 dnl
2920 AC_ARG_ENABLE( id3tag,
2921 [  --disable-id3tag        id3tag metadata reader plugin (default enabled)])
2922 AS_IF([test "${enable_id3tag}" != "no"], [
2923   AC_CHECK_HEADERS(id3tag.h, [
2924     AC_CHECK_HEADERS(zlib.h, [
2925       VLC_ADD_LIBS([id3tag],[-lid3tag -lz])
2926       VLC_ADD_PLUGIN([id3tag])
2927     ])
2928   ])
2929 ])
2930
2931 dnl
2932 dnl  avcodec decoder/encoder plugin
2933 dnl
2934
2935 if test "${with_ffmpeg_tree}"
2936 then
2937   AC_MSG_WARN([--with-ffmpeg-tree is deprecated. Use PKG_CONFIG_PATH instead.])
2938 fi
2939
2940 AC_ARG_ENABLE(avcodec,
2941 [  --enable-avcodec        libavcodec codec (default enabled)])
2942 if test "${enable_avcodec}" != "no"
2943 then
2944   PKG_CHECK_MODULES(AVCODEC,[libavcodec libavutil],
2945     [
2946       VLC_SAVE_FLAGS
2947       CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}"
2948       CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}"
2949       AC_CHECK_HEADERS(libavcodec/avcodec.h ffmpeg/avcodec.h)
2950       AC_CHECK_HEADERS(libavutil/avutil.h ffmpeg/avutil.h)
2951       VLC_ADD_PLUGIN([avcodec])
2952       VLC_ADD_LIBS([avcodec],[$AVCODEC_LIBS])
2953       VLC_ADD_CFLAGS([avcodec],[$AVCODEC_CFLAGS])
2954       VLC_RESTORE_FLAGS
2955     ],[
2956       AC_MSG_FAILURE([Could not find libavcodec or libavutil. Use --disable-avcodec to ignore this error.])
2957   ])
2958 fi
2959
2960 dnl
2961 dnl  avformat demuxer/muxer plugin
2962 dnl
2963
2964 AC_ARG_ENABLE(avformat,
2965 [  --enable-avformat       libavformat containers (default enabled)])
2966 if test "${enable_avformat}" != "no"
2967 then
2968   PKG_CHECK_MODULES(AVFORMAT,[libavformat libavutil],
2969     [
2970       VLC_SAVE_FLAGS
2971       CPPFLAGS="${CPPFLAGS} ${AVFORMAT_CFLAGS}"
2972       CFLAGS="${CFLAGS} ${AVFORMAT_CFLAGS}"
2973       AC_CHECK_HEADERS(libavformat/avformat.h ffmpeg/avformat.h)
2974       AC_CHECK_HEADERS(libavutil/avutil.h ffmpeg/avutil.h)
2975       VLC_ADD_PLUGIN([avformat])
2976       VLC_ADD_LIBS([avformat],[$AVFORMAT_LIBS])
2977       VLC_ADD_CFLAGS([avformat],[$AVFORMAT_CFLAGS])
2978       VLC_RESTORE_FLAGS
2979     ],[
2980       AC_MSG_FAILURE([Could not find libavformat or libavutil. Use --disable-avformat to ignore this error.])
2981   ])
2982 fi
2983
2984 dnl
2985 dnl  swscale image scaling and conversion plugin
2986 dnl
2987
2988 AC_ARG_ENABLE(swscale,
2989   AS_HELP_STRING([--enable-swscale],[libswscale image scaling and conversion 
2990                   (default enabled)]))
2991 if test "${enable_swscale}" != "no"
2992 then
2993   PKG_CHECK_MODULES(SWSCALE,[libswscale],
2994     [
2995       VLC_SAVE_FLAGS
2996       CPPFLAGS="${CPPFLAGS} ${SWSCALE_CFLAGS}"
2997       CFLAGS="${CFLAGS} ${SWSCALE_CFLAGS}"
2998       AC_CHECK_HEADERS(libswscale/swscale.h ffmpeg/swscale.h)
2999       VLC_ADD_PLUGIN([swscale])
3000       VLC_ADD_LIBS([swscale],[$SWSCALE_LIBS])
3001       VLC_ADD_CFLAGS([swscale],[$SWSCALE_CFLAGS])
3002       VLC_RESTORE_FLAGS
3003     ],[
3004       AC_MSG_WARN([Could not find libswscale. Trying to enable imgresample.])
3005       enable_imgresample=yes
3006   ])
3007 fi
3008
3009 dnl
3010 dnl  avcodec (deprecated API) image scaling and conversion plugin
3011 dnl
3012 dnl  This is build as a seperate module than the avcodec one to prevent
3013 dnl  stupid run time library load errors from disabling most codecs
3014 dnl  from VLC.
3015 dnl
3016
3017 AC_ARG_ENABLE(imgresample,
3018   AS_HELP_STRING([--enable-imgresample],[deprecated libavcodec image scaling 
3019                   and conversion (default disabled)]))
3020 if test "${enable_imgresample}" = "yes"
3021 then
3022   PKG_CHECK_MODULES(IMGRESAMPLE,[libavcodec],
3023     [
3024       VLC_SAVE_FLAGS
3025       CPPFLAGS="${CPPFLAGS} ${IMGRESAMPLE_CFLAGS}"
3026       CFLAGS="${CFLAGS} ${IMGRESAMPLE_CFLAGS}"
3027       AC_CHECK_HEADERS(libavcodec/avcodec.h ffmpeg/avcodec.h)
3028       AC_CHECK_LIB(avcodec,img_resample,
3029         [
3030           VLC_ADD_PLUGIN([imgresample])
3031           VLC_ADD_LIBS([imgresample],[$IMGRESAMPLE_LIBS])
3032           VLC_ADD_CFLAGS([imgresample],[$IMGRESAMPLE_CFLAGS])
3033         ],[
3034           AC_MSG_WARN([Could not find img_resample in libavcodec.])
3035           if test "${enable_swscale}" != "no"
3036           then
3037             AC_MSG_FAILURE([swscale (and its fallback module imgresample) support will be missing. Use --disable-swscale to ignore this error. (This basically means that you will be missing any good software scaling module and some video chroma converters.)])
3038           fi
3039         # That sed hack to add -rpath is kind of ugly but at least it fixes
3040         # detection when linking against a shared libavcodec with
3041         # a libavutil not in one of your ld.so.conf directories.
3042         # (for example a local install)
3043         ],[${IMGRESAMPLE_LIBS} `echo ${IMGRESAMPLE_LIBS}|sed s'/-L/-Wl,-rpath=/'`])
3044       VLC_RESTORE_FLAGS
3045     ],[
3046       AC_MSG_WARN([Could not find libavcodec.])
3047   ])
3048 fi
3049
3050 dnl
3051 dnl  postproc plugin
3052 dnl
3053
3054 AC_ARG_ENABLE(postproc,
3055 [  --enable-postproc       libpostproc image post-processing (default enabled)])
3056 if test "${enable_postproc}" != "no"
3057 then
3058   PKG_CHECK_MODULES(POSTPROC,[libpostproc libavutil],
3059     [
3060       VLC_SAVE_FLAGS
3061       CPPFLAGS="${CPPFLAGS} ${POSTPROC_CFLAGS}"
3062       CFLAGS="${CFLAGS} ${POSTPROC_CFLAGS}"
3063       AC_CHECK_HEADERS(libpostproc/postproc.h postproc/postprocess.h)
3064       VLC_ADD_PLUGIN([postproc])
3065       VLC_ADD_LIBS([postproc],[$POSTPROC_LIBS])
3066       VLC_ADD_CFLAGS([postproc],[$POSTPROC_CFLAGS])
3067       VLC_RESTORE_FLAGS
3068     ],[
3069       AC_MSG_ERROR([Could not find libpostproc.])
3070   ])
3071 fi
3072
3073 dnl
3074 dnl  faad decoder plugin
3075 dnl
3076 AC_ARG_ENABLE(faad,
3077 [  --enable-faad           faad codec (default disabled)])
3078 if test "${enable_faad}" = "yes"
3079 then
3080   AC_ARG_WITH(faad-tree,
3081   [    --with-faad-tree=PATH faad tree for static linking])
3082   if test -n "${with_faad_tree}"
3083   then
3084     AC_MSG_CHECKING(for libfaad.a in ${with_faad_tree})
3085     real_faad_tree="`cd ${with_faad_tree} 2>/dev/null && pwd`"
3086     if test -z "${real_faad_tree}"
3087     then
3088       dnl  The given directory can't be found
3089       AC_MSG_RESULT(no)
3090       AC_MSG_ERROR([cannot cd to ${with_faad_tree}])
3091     fi
3092     if test -f "${real_faad_tree}/libfaad/.libs/libfaad.a"
3093     then
3094       dnl  Use a custom faad
3095       AC_MSG_RESULT(${real_faad_tree}/libfaad/.libs/libfaad.a)
3096       VLC_ADD_PLUGIN([faad])
3097       VLC_ADD_LIBS([faad],[${real_faad_tree}/libfaad/.libs/libfaad.a])
3098       VLC_ADD_CPPFLAGS([faad],[-I${real_faad_tree}/include])
3099     else
3100       dnl  The given libfaad wasn't built
3101       AC_MSG_RESULT(no)
3102       AC_MSG_ERROR([cannot find ${real_faad_tree}/libfaad/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}])
3103     fi
3104   else
3105     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_faad}"
3106     LDFLAGS="${LDFLAGS_save} ${LIBS_faad}"
3107     AC_CHECK_HEADERS(faad.h, ,
3108       [ AC_MSG_ERROR([Cannot find development headers for libfaad...]) ])
3109     AC_CHECK_LIB(faad, faacDecOpen, [
3110       VLC_ADD_PLUGIN([faad])
3111       VLC_ADD_LIBS([faad],[-lfaad]) ],
3112       AC_CHECK_LIB(faad, NeAACDecOpen, [
3113         VLC_ADD_PLUGIN([faad])
3114         VLC_ADD_LIBS([faad],[-lfaad]) ],
3115         [ AC_MSG_ERROR([Cannot find libfaad library...]) ]))
3116     LDFLAGS="${LDFLAGS_save}"
3117     CPPFLAGS="${CPPFLAGS_save}"
3118   fi
3119 fi
3120
3121 dnl
3122 dnl twolame encoder plugin
3123 dnl
3124 AC_ARG_ENABLE(twolame,
3125 [  --enable-twolame        twolame codec (default disabled)])
3126 if test "${enable_twolame}" = "yes"
3127 then
3128   AC_ARG_WITH(twolame-tree,
3129   [    --with-twolame-tree=PATH twolame tree for static linking])
3130   if test -n "${with_twolame_tree}"
3131   then
3132     AC_MSG_CHECKING(for libtwolame.a in ${with_twolame_tree})
3133     real_twolame_tree="`cd ${with_twolame_tree} 2>/dev/null && pwd`"
3134     if test -z "${real_twolame_tree}"
3135     then
3136       dnl  The given directory can't be found
3137       AC_MSG_RESULT(no)
3138       AC_MSG_ERROR([cannot cd to ${with_twolame_tree}])
3139     fi
3140     if test -f "${real_twolame_tree}/libtwolame/.libs/libtwolame.a"
3141     then
3142       dnl  Use a custom twolame
3143       AC_MSG_RESULT(${real_twolame_tree}/libtwolame/.libs/libtwolame.a)
3144       VLC_ADD_PLUGIN([twolame])
3145       VLC_ADD_LIBS([twolame],[${real_twolame_tree}/libtwolame/.libs/libtwolame.a])
3146       VLC_ADD_CPPFLAGS([twolame],[-I${real_twolame_tree}/libtwolame -DLIBTWOLAME_STATIC])
3147     else
3148       dnl  The given libtwolame wasn't built
3149       AC_MSG_RESULT(no)
3150       AC_MSG_ERROR([cannot find ${real_twolame_tree}/libtwolame/.libs/libtwolame.a, make sure you compiled libtwolame in ${with_twolame_tree}])
3151     fi
3152   else
3153     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_twolame} -DLIBTWOLAME_STATIC"
3154     LDFLAGS="${LDFLAGS_save} ${LIBS_twolame}"
3155     AC_CHECK_HEADERS(twolame.h, ,
3156       [ AC_MSG_ERROR([Cannot find development header for libtwolame...]) ])
3157     AC_CHECK_LIB(twolame, twolame_init, [
3158       VLC_ADD_PLUGIN([twolame])
3159       VLC_ADD_CPPFLAGS([twolame],[-DLIBTWOLAME_STATIC])
3160       VLC_ADD_LIBS([twolame],[-ltwolame]) ],
3161         [ AC_MSG_ERROR([Cannot find libtwolame library...]) ])
3162     LDFLAGS="${LDFLAGS_save}"  
3163     CPPFLAGS="${CPPFLAGS_save}"
3164   fi
3165 fi
3166
3167 dnl
3168 dnl  QuickTime plugin
3169 dnl
3170 AC_ARG_ENABLE(quicktime,
3171   [  --enable-quicktime      QuickTime module (default enabled on MacOS X)])
3172 if test "${enable_quicktime}" != "no" &&
3173   (test "${SYS}" = "darwin" || test "${enable_quicktime}" = "yes")
3174 then
3175   if test "${SYS}" = "mingw32"; then
3176     VLC_ADD_PLUGIN([quicktime])
3177   else
3178   AC_CHECK_HEADERS(QuickTime/QuickTime.h,
3179     [ VLC_ADD_PLUGIN([quicktime])
3180       VLC_ADD_LDFLAGS([quicktime],[-Wl,-framework,QuickTime,-framework,Carbon])
3181     ], [ AC_MSG_ERROR([cannot find QuickTime headers]) ])
3182   fi
3183 fi
3184
3185 dnl
3186 dnl  Real plugin
3187 dnl
3188 AC_ARG_ENABLE(real,
3189   [  --enable-real           Real media module (default disabled)])
3190 if test "${enable_real}" = "yes"; then
3191   VLC_ADD_PLUGIN([realaudio])
3192   VLC_ADD_PLUGIN([realvideo])
3193 fi
3194
3195 dnl
3196 dnl  Real RTSP plugin
3197 dnl
3198 AC_ARG_ENABLE(realrtsp,
3199   [  --enable-realrtsp       Real RTSP module (default disabled)])
3200 if test "${enable_realrtsp}" = "yes"; then
3201   VLC_ADD_PLUGIN([access_realrtsp])
3202 fi
3203
3204 dnl
3205 dnl MP4 module
3206 dnl
3207 AC_CHECK_HEADERS(zlib.h, [
3208   VLC_ADD_LIBS([mp4 skins2 sap mkv gme],[-lz])
3209 ] )
3210
3211 AC_CHECK_HEADERS(sysfs/libsysfs.h, [
3212   VLC_ADD_LIBS([mp4 mkv],[-lsysfs])
3213 ] )
3214
3215 dnl
3216 dnl skins2 module
3217 dnl
3218 AC_ARG_ENABLE(libtar,
3219   [  --enable-libtar         libtar support for skins2 (default enabled)])
3220
3221 AS_IF([test "${enable_libtar}" != "no"],[
3222   AC_CHECK_HEADERS(libtar.h, [
3223     VLC_ADD_LIBS([skins2],[-ltar])
3224   ] )
3225 ])
3226
3227 dnl
3228 dnl A52/AC3 decoder plugin
3229 dnl
3230 AC_ARG_ENABLE(a52,
3231   [  --enable-a52            A/52 support with liba52 (default enabled)])
3232 if test "${enable_a52}" != "no"
3233 then
3234   AC_ARG_WITH(a52,
3235     [    --with-a52=PATH       a52 headers and libraries])
3236   AC_ARG_WITH(a52-tree,
3237     [    --with-a52-tree=PATH  a52dec tree for static linking ],[],[])
3238   if test "${with_a52_tree}" != "no" -a -n "${with_a52_tree}"
3239   then
3240     real_a52_tree="`cd ${with_a52_tree} 2>/dev/null && pwd`"
3241     if test -z "${real_a52_tree}"
3242     then
3243       dnl  The given directory can't be found
3244       AC_MSG_RESULT(no)
3245       AC_MSG_ERROR([${with_a52_tree} directory doesn't exist])
3246     fi
3247     dnl  Use a custom a52dec
3248     AC_MSG_CHECKING(for a52.h in ${real_a52_tree}/include)
3249     if test -f ${real_a52_tree}/include/a52.h
3250     then
3251       AC_MSG_RESULT(yes)
3252       VLC_ADD_CPPFLAGS([a52tofloat32],[-I${real_a52_tree}])
3253       VLC_ADD_LIBS([a52tofloat32],[-L${real_a52_tree}/liba52/.libs])
3254       LDFLAGS="${LDFLAGS_save} ${LIBS_a52tofloat32}"
3255       AC_CHECK_LIB(a52, a52_free, [
3256         VLC_ADD_PLUGIN([a52tofloat32])
3257         VLC_ADD_CPPFLAGS([a52tofloat32],[-DUSE_A52DEC_TREE])
3258         VLC_ADD_LIBS([a52tofloat32],[-la52])
3259         ],[
3260         if test -f ${real_a52_tree}/liba52/.libs/liba52.a
3261         then
3262           AC_MSG_ERROR([make sure you have at least a52dec-0.7.3 ($real_a52_tree)])
3263         else
3264           AC_MSG_ERROR([the specified tree hasn't been compiled])
3265         fi
3266       ])
3267       LDFLAGS="${LDFLAGS_save}"
3268     else
3269       AC_MSG_RESULT(no)
3270       AC_MSG_ERROR([the specified tree doesn't have a52.h])
3271     fi
3272   else
3273     if test -z "${with_a52}"
3274     then
3275       LDFLAGS_test=""
3276       CPPFLAGS_test=""
3277     else
3278       LDFLAGS_test="-L${with_a52}/lib"
3279       CPPFLAGS_test="-I${with_a52}/include"
3280     fi
3281     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test} ${CPPFLAGS_a52tofloat32}"
3282     LDFLAGS="${LDFLAGS_save} ${LDFLAGS_test} ${LIBS_a52tofloat32}"
3283     AC_CHECK_HEADERS(a52dec/a52.h, [
3284       AC_CHECK_LIB(a52, a52_free, [
3285         VLC_ADD_PLUGIN([a52tofloat32])
3286         VLC_ADD_LIBS([a52tofloat32],[${LDFLAGS_test} -la52])
3287         VLC_ADD_CPPFLAGS([a52tofloat32],[${CPPFLAGS_test}])
3288       ],[
3289         AC_MSG_ERROR([Could not find liba52 on your system: you may get it from http://liba52.sf.net/. Alternatively you can use --disable-a52 to disable the a52 plugin.])
3290         ])
3291     ],[
3292       AC_MSG_ERROR([Could not find liba52 on your system: you may get it from http://liba52.sf.net/. Alternatively you can use --disable-a52 to disable the a52 plugin.])
3293     ])
3294     CPPFLAGS="${CPPFLAGS_save}"
3295     LDFLAGS="${LDFLAGS_save}"
3296   fi
3297 fi
3298
3299 AC_ARG_WITH(a52-fixed,
3300       [    --with-a52-fixed      specify if liba52 has been compiled with fixed point support],
3301       [
3302         VLC_ADD_CPPFLAGS([a52tofloat32],[-DLIBA52_FIXED]) ])
3303
3304 dnl
3305 dnl DTS Coherent Acoustics decoder plugin
3306 dnl
3307 AS_IF([test "x${enable_dts}" != "x"], [
3308   AC_MSG_ERROR([--enable-dts is obsolete. Please use libdca and --enable-dca.])
3309 ])
3310 AS_IF([test "x${with_dts_tree}" != "x"], [
3311   AC_MSG_ERROR([--with-dts-tree is obsolete. Please use libdca and --with-dca-tree.])
3312 ])
3313
3314 AC_ARG_ENABLE(dca,
3315   AS_HELP_STRING([--enable-dca],[DTS Coherent Acoustics support with libdca 
3316                   (default enabled)]))
3317 AS_IF([test "${enable_dca}" != "no"], [
3318   AC_ARG_WITH(dca-tree,
3319     [    --with-dca-tree=PATH  libdca tree for static linking],,
3320     [with_dca_tree="no"])
3321   AS_IF([test "${with_dca_tree}" != "no"], [
3322     real_dca_tree="`cd ${with_dca_tree} 2>/dev/null && pwd`"
3323     AS_IF([test -z "${real_dca_tree}"], [
3324       dnl  The given directory can't be found
3325       AC_MSG_RESULT(no)
3326       AC_MSG_ERROR([${with_dca_tree} directory doesn't exist])
3327     ])
3328     dnl  Use a custom libdca
3329     AC_MSG_CHECKING(for libdca in ${real_dca_tree})
3330     AS_IF([test -f "${real_dca_tree}/libdca/.libs/libdca.a"], [
3331       AC_MSG_RESULT(yes)
3332       VLC_ADD_LIBS([dtstofloat32],[${real_dca_tree}/libdca/.libs/libdca.a])
3333       AS_IF([test -f "${real_dca_tree}/include/dca.h"], [
3334         VLC_ADD_CPPFLAGS([dtstofloat32],[-I${real_dca_tree}/include])
3335       ], [
3336         VLC_ADD_CPPFLAGS([dtstofloat32],[-I${real_dca_tree}/../include])
3337       ])
3338     ], [
3339       AC_MSG_RESULT(no)
3340       AC_MSG_ERROR([the specified tree doesn't have libdca/.libs/libdca.a])
3341     ])
3342   ], [
3343     PKG_CHECK_MODULES([DCA], [libdca >= 0.0.5], [
3344       VLC_ADD_PLUGIN([dtstofloat32])
3345       VLC_ADD_CPPFLAGS([dtstofloat32], [${DCA_CFLAGS}])
3346       VLC_ADD_LIBS([dtstofloat32], [${DCA_LIBS}])
3347     ], [
3348       AS_IF([test "x${enable_dca}" != "x"], [
3349         AC_MSG_ERROR([${DCA_PKG_ERRORS}])
3350       ])
3351     ])
3352   ])
3353 ])
3354
3355 dnl
3356 dnl  Flac plugin
3357 dnl
3358 AC_ARG_ENABLE(flac,
3359   [  --enable-flac           libflac decoder/encoder support (default disabled)])
3360 if test "${enable_flac}" = "yes"
3361 then
3362   AC_ARG_WITH(flac-tree,
3363   [    --with-flac-tree=PATH flac tree for static linking])
3364   if test -n "${with_flac_tree}"
3365   then
3366     AC_MSG_CHECKING(for libFLAC.a in ${with_flac_tree})
3367     real_flac_tree="`cd ${with_flac_tree} 2>/dev/null && pwd`"
3368     if test -z "${real_flac_tree}"
3369     then
3370       dnl  The given directory can't be found
3371       AC_MSG_RESULT(no)
3372       AC_MSG_ERROR([cannot cd to ${with_flac_tree}])
3373     fi
3374     if test -f "${real_flac_tree}/src/libFLAC/.libs/libFLAC.a"
3375     then
3376       dnl  Use a custom flac
3377       AC_MSG_RESULT(${real_flac_tree}/src/libFLAC/.libs/libFLAC.a)
3378       VLC_ADD_LIBS([flac],[${real_flac_tree}/src/libFLAC/.libs/libFLAC.a])
3379       VLC_ADD_CFLAGS([flac],[-I${real_flac_tree}/include])
3380       AC_DEFINE(HAVE_FLAC_STREAM_DECODER_H, 1, [Define if you have FLAC])
3381     else
3382       dnl  The given flac wasn't built
3383       AC_MSG_RESULT(no)
3384       AC_MSG_ERROR([cannot find ${real_flac_tree}/src/libFLAC/.libs/libFLAC.a, make sure you compiled flac in ${with_flac_tree}])
3385     fi
3386   else
3387     AC_CHECK_HEADERS(FLAC/stream_decoder.h, [
3388       VLC_ADD_LIBS([flac],[-lFLAC -logg])
3389      ],[])
3390   fi
3391 fi
3392
3393 dnl
3394 dnl  Libmpeg2 plugin
3395 dnl
3396 AC_ARG_ENABLE(libmpeg2,
3397   [  --enable-libmpeg2       libmpeg2 decoder support (default enabled)])
3398 if test "${enable_libmpeg2}" != "no"
3399 then
3400   AC_ARG_WITH(libmpeg2-tree,
3401   [    --with-libmpeg2-tree=PATH libmpeg2 tree for static linking])
3402   AS_IF([test -n "${with_libmpeg2_tree}"],[
3403     AC_MSG_CHECKING(for libmpeg2.a in ${with_libmpeg2_tree})
3404     real_libmpeg2_tree="`cd ${with_libmpeg2_tree} 2>/dev/null && pwd`"
3405     if test -z "${real_libmpeg2_tree}"
3406     then
3407       dnl  The given directory can't be found
3408       AC_MSG_RESULT(no)
3409       AC_MSG_ERROR([cannot cd to ${with_libmpeg2_tree}])
3410     fi
3411     if test -f "${real_libmpeg2_tree}/libmpeg2/.libs/libmpeg2.a"
3412     then
3413       dnl  Use a custom libmpeg2
3414       AC_MSG_RESULT(${real_libmpeg2_tree}/libmpeg2/.libs/libmpeg2.a)
3415       VLC_ADD_PLUGIN([libmpeg2])
3416       VLC_ADD_LIBS([libmpeg2],[-L${real_libmpeg2_tree}/libmpeg2/.libs -lmpeg2])
3417       VLC_ADD_CFLAGS([libmpeg2],[-I${real_libmpeg2_tree}/include])
3418     else
3419       dnl  The given libmpeg2 wasn't built
3420       AC_MSG_RESULT(no)
3421       AC_MSG_ERROR([cannot find ${real_libmpeg2_tree}/libmpeg2/.libs/libmpeg2.a, make sure you compiled libmpeg2 in ${with_libmpeg2_tree}])
3422     fi
3423   ],[
3424    PKG_CHECK_MODULES(LIBMPEG2,[libmpeg2 > 0.3.2],[ 
3425           VLC_ADD_PLUGIN([libmpeg2])
3426           VLC_ADD_LIBS([libmpeg2], $LIBMPEG2_LIBS)
3427           VLC_ADD_CFLAGS([libmpeg2], $LIBMPEG2_CFLAGS)
3428        ], 
3429       AC_MSG_WARN([Could not find libmpeg2 on your system: you may get it from http://libmpeg2.sf.net/ . Alternatively you can use --disable-libmpeg2 to disable the libmpeg2 plugin.]))
3430   ])
3431 fi
3432
3433 dnl
3434 dnl  Vorbis plugin
3435 dnl
3436 AC_ARG_ENABLE(vorbis,
3437   [  --enable-vorbis         Vorbis decoder support (default enabled)])
3438 if test "${enable_vorbis}" != "no"
3439 then
3440   AC_ARG_WITH(vorbis-tree,
3441   [    --with-vorbis-tree=PATH vorbis tree for static linking])
3442   if test -n "${with_vorbis_tree}"
3443   then
3444     AC_MSG_CHECKING(for libvorbis.a in ${with_vorbis_tree})
3445     real_vorbis_tree="`cd ${with_vorbis_tree} 2>/dev/null && pwd`"
3446     if test -z "${real_vorbis_tree}"
3447     then
3448       dnl  The given directory can't be found
3449       AC_MSG_RESULT(no)
3450       AC_MSG_ERROR([cannot cd to ${with_vorbis_tree}])
3451     fi
3452     if test -f "${real_vorbis_tree}/lib/.libs/libvorbis.a"
3453     then
3454       dnl  Use a custom vorbis 
3455       AC_MSG_RESULT(${real_vorbis_tree}/lib/.libs/libvorbis.a)
3456       VLC_ADD_PLUGIN([vorbis])
3457       VLC_ADD_LIBS([vorbis],[${real_vorbis_tree}/lib/.libs/libvorbis.a ${real_vorbis_tree}/lib/.libs/libvorbisenc.a])
3458       VLC_ADD_CFLAGS([vorbis],[-I${real_vorbis_tree}/include])
3459     else
3460       dnl  The given vorbis wasn't built
3461       AC_MSG_RESULT(no)
3462       AC_MSG_ERROR([cannot find ${real_vorbis_tree}/lib/.libs/libvorbis.a, make sure you compiled vorbis in ${with_vorbis_tree}])
3463     fi
3464   else
3465     AC_CHECK_HEADERS(vorbis/codec.h, [
3466       VLC_ADD_PLUGIN([vorbis])
3467       VLC_ADD_LIBS([vorbis],[-lvorbis -logg -lm]) ],[])
3468
3469     AC_CHECK_HEADERS(vorbis/vorbisenc.h, [
3470       VLC_ADD_LIBS([vorbis],[-lvorbisenc -lm]) ],[])
3471   fi
3472 fi
3473
3474 dnl
3475 dnl  Tremor plugin
3476 dnl
3477 AC_ARG_ENABLE(tremor,
3478   [  --enable-tremor         Tremor decoder support (default disabled)])
3479 if test "${enable_tremor}" = "yes"
3480 then
3481   AC_CHECK_HEADERS(tremor/ivorbiscodec.h, [
3482     VLC_ADD_PLUGIN([tremor])
3483     VLC_ADD_LIBS([tremor],[-lvorbisidec -logg])
3484    ],[])
3485 fi
3486
3487 dnl
3488 dnl  Speex plugin
3489 dnl
3490 AC_ARG_ENABLE(speex,
3491   [  --enable-speex          Speex decoder support (default enabled)])
3492 if test "${enable_speex}" != "no"
3493 then
3494   AC_ARG_WITH(speex-tree,
3495   [    --with-speex-tree=PATH speex tree for static linking])
3496   if test -n "${with_speex_tree}"
3497   then
3498     AC_MSG_CHECKING(for libspeex.a in ${with_speex_tree})
3499     real_speex_tree="`cd ${with_speex_tree} 2>/dev/null && pwd`"
3500     if test -z "${real_speex_tree}"
3501     then
3502       dnl  The given directory can't be found
3503       AC_MSG_RESULT(no)
3504       AC_MSG_ERROR([cannot cd to ${with_speex_tree}])
3505     fi
3506     if test -f "${real_speex_tree}/libspeex/.libs/libspeex.a"
3507     then
3508       dnl  Use a custom speex
3509       AC_MSG_RESULT(${real_speex_tree}/libspeex/.libs/libspeex.a)
3510       VLC_ADD_PLUGIN([speex])
3511       VLC_ADD_LIBS([speex],[${real_speex_tree}/libspeex/.libs/libspeex.a])
3512       VLC_ADD_CFLAGS([speex],[-I${real_speex_tree}/include])
3513     else
3514       dnl  The given speex wasn't built
3515       AC_MSG_RESULT(no)
3516       AC_MSG_ERROR([cannot find ${real_speex_tree}/libspeex/.libs/libspeex.a, make sure you compiled speex in ${with_speex_tree}])
3517     fi
3518   else
3519     AC_CHECK_HEADERS(speex/speex.h, [
3520       LDFLAGS="${LDFLAGS_save} ${LIBS_speex}"
3521       AC_CHECK_LIB(speex, speex_decode_int, [
3522         VLC_ADD_PLUGIN([speex])
3523         VLC_ADD_LIBS([speex],[-lspeex]) ],
3524         [ AC_MSG_RESULT([no])
3525           AC_MSG_WARN([Your libspeex is too old, please get the development
3526                        version.]) ],[])
3527       LDFLAGS="${LDFLAGS_save}"
3528       ],[])
3529   fi
3530 fi
3531
3532 dnl
3533 dnl  tarkin decoder plugin
3534 dnl
3535 AC_ARG_ENABLE(tarkin,
3536 [  --enable-tarkin         experimental tarkin codec (default disabled)])
3537 if test "${enable_tarkin}" = "yes"
3538 then
3539   AC_ARG_WITH(tarkin-tree,
3540   [    --with-tarkin-tree=PATH tarkin tree for static linking])
3541   if test -n "${with_tarkin_tree}"
3542   then
3543     AC_MSG_CHECKING(for tarkin.o in ${with_tarkin_tree})
3544     real_tarkin_tree="`cd ${with_tarkin_tree} 2>/dev/null && pwd`"
3545     if test -f "${real_tarkin_tree}/tarkin.o"
3546     then
3547       VLC_ADD_PLUGIN([tarkin])
3548       VLC_ADD_CPPFLAGS([tarkin],[-I${real_tarkin_tree}])
3549       VLC_ADD_LIBS([tarkin],[${real_tarkin_tree}/mem.o ${real_tarkin_tree}/pnm.o ${real_tarkin_tree}/wavelet.o ${real_tarkin_tree}/wavelet_xform.o ${real_tarkin_tree}/wavelet_coeff.o ${real_tarkin_tree}/yuv.o ${real_tarkin_tree}/tarkin.o ${real_tarkin_tree}/info.o -logg])
3550       AC_MSG_RESULT(yes)
3551     else
3552       dnl  The given tarkin tree wasn't built
3553       AC_MSG_RESULT(no)
3554       AC_MSG_ERROR([cannot find ${real_tarkin_tree}/tarkin.o,
3555                     make sure you compiled tarkin in ${with_tarkin_tree}])
3556     fi
3557   fi
3558 fi
3559
3560 dnl
3561 dnl  theora decoder plugin
3562 dnl
3563 AC_ARG_ENABLE(theora,
3564 [  --enable-theora         experimental theora codec (default disabled)])
3565 if test "${enable_theora}" = "yes"
3566 then
3567   AC_CHECK_HEADERS(theora/theora.h, [
3568     AC_CHECK_LIB(theora, theora_granule_time, [
3569       VLC_ADD_PLUGIN([theora])
3570       theora_libs="-ltheora -logg"
3571       VLC_ADD_LIBS([theora],[${theora_libs}]) ],[
3572       AC_MSG_ERROR([libtheora doesn't appear to be installed on your system.
3573 You also need to check that you have a libogg posterior to the 1.0 release.])],
3574       [-logg])
3575   ])
3576 fi
3577
3578 dnl
3579 dnl  dirac decoder plugin
3580 dnl
3581 AC_ARG_ENABLE(dirac,
3582 [  --enable-dirac          experimental dirac codec (default disabled)])
3583 if test "${enable_dirac}" = "yes"; then
3584   PKG_CHECK_MODULES(DIRAC,[dirac >= 0.10.0], [
3585       VLC_ADD_PLUGIN([dirac])
3586       VLC_ADD_CFLAGS([dirac],[$DIRAC_CFLAGS])
3587       VLC_ADD_LIBS([dirac],[$DIRAC_LIBS -lstdc++]) ],[
3588       AC_MSG_ERROR([libdirac >= 0.10.0 doesn't appear to be installed on your system.])
3589   ])
3590 fi
3591
3592 dnl
3593 dnl  schroedinger decoder plugin (for dirac format video)
3594 dnl
3595 AC_ARG_ENABLE(schroedinger,
3596 [  --disable-schroedinger  high performance dirac codec (default enabled)])
3597 if test "${enable_schroedinger}" != "no"; then
3598   PKG_CHECK_MODULES(SCHROEDINGER,[schroedinger-1.0 >= 1.0], [
3599       VLC_ADD_PLUGIN([schroedinger])
3600       VLC_ADD_CFLAGS([schroedinger],[$SCHROEDINGER_CFLAGS])
3601       VLC_ADD_LIBS([schroedinger],[$SCHROEDINGER_LIBS]) ], [
3602         AS_IF([test "x${enable_schroedinger}" != "x"], [
3603           AC_MSG_ERROR([${SCHROEDINGER_PKG_ERRORS}])
3604         ])
3605 ])
3606 fi
3607
3608 dnl
3609 dnl  PNG decoder module
3610 dnl
3611 AC_ARG_ENABLE(png,
3612   [  --enable-png            PNG support (default enabled)])
3613 if test "${enable_png}" != "no"; then
3614 AC_CHECK_HEADERS(png.h, [
3615   LDFLAGS="${LDFLAGS_save} -lz"
3616   AC_CHECK_LIB(png, png_set_rows, [
3617     VLC_ADD_LIBS([png],[-lpng -lz])
3618     VLC_ADD_PLUGIN([png])
3619     VLC_ADD_PLUGIN([osdmenu])
3620     VLC_ADD_PLUGIN([osd_parser])
3621     AC_DEFINE(HAVE_LIBPNG, 1, [Define if you have the PNG library: libpng])],
3622     [],[-lz])
3623     LDFLAGS="${LDFLAGS_save}"
3624   ])
3625 fi
3626 AM_CONDITIONAL(BUILD_OSDMENU, [test "${enable_png}" != "no"])
3627
3628 dnl
3629 dnl H264 encoder plugin (using libx264)
3630 dnl
3631 AC_ARG_ENABLE(x264,
3632   [  --enable-x264           H264 encoding support with libx264 (default enabled)])
3633 if test "${enable_x264}" != "no"; then
3634   AC_ARG_WITH(x264-tree,
3635     [    --with-x264-tree=PATH x264 tree for static linking ],[],[])
3636   if test "${with_x264_tree}" != "no" -a -n "${with_x264_tree}"
3637   then
3638     real_x264_tree="`cd ${with_x264_tree} 2>/dev/null && pwd`"
3639     if test -z "${real_x264_tree}"
3640     then
3641       dnl  The given directory can't be found
3642       AC_MSG_RESULT(no)
3643       AC_MSG_ERROR([${with_x264_tree} directory doesn't exist])
3644     fi
3645     dnl  Use a custom libx264
3646     AC_MSG_CHECKING(for x264.h in ${real_x264_tree})
3647     if test -f ${real_x264_tree}/x264.h
3648     then
3649       AC_MSG_RESULT(yes)
3650       VLC_ADD_CPPFLAGS([x264],[-I${real_x264_tree}])
3651       VLC_ADD_LIBS([x264],[-L${real_x264_tree}])
3652       PKG_CHECK_MODULES(X264,x264, [
3653         VLC_ADD_PLUGIN([x264])
3654         VLC_ADD_LDFLAGS([x264],[${X264_LIBS}])
3655         VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}])
3656       ],[
3657         AC_MSG_ERROR([the specified tree hasn't been compiled])
3658       ])
3659       LDFLAGS="${LDFLAGS_save}"
3660     else
3661       AC_MSG_RESULT(no)
3662       AC_MSG_ERROR([the specified tree doesn't have x264.h])
3663     fi
3664   else
3665       PKG_CHECK_MODULES(X264,x264, [
3666         VLC_ADD_PLUGIN([x264])
3667         VLC_ADD_LDFLAGS([x264],[${X264_LIBS}])
3668         VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}])
3669       ],[
3670         if test "${enable_x264}" = "yes"; then
3671             AC_MSG_ERROR([Could not find libx264 on your system: you may get it from http://www.videolan.org/x264.html])
3672           fi
3673       ])
3674     LDFLAGS="${LDFLAGS_save}"
3675   fi
3676 fi
3677
3678 dnl
3679 dnl libfluidsynth (MIDI synthetizer) plugin
3680 dnl
3681 AC_ARG_ENABLE(fluidsynth,
3682   [  --enable-fluidsynth     MIDI synthesisr with libfluidsynth (default enabled)])
3683 AS_IF([test "x${enable_fluidsynth}" != "xno"], [
3684   PKG_CHECK_MODULES(FLUIDSYNTH, fluidsynth, [
3685     VLC_ADD_PLUGIN(fluidsynth)
3686     VLC_ADD_CFLAGS(fluidsynth, [${FLUIDSYNTH_CFLAGS}])
3687     VLC_ADD_LIBS(fluidsynth, [${FLUIDSYNTH_LIBS}])
3688   ], [
3689     AS_IF([test "x${enable_fluidsynth}" != "x"], [
3690       AC_MSG_ERROR([${FLUIDSYNTH_PKG_ERRORS}])
3691     ])
3692   ])
3693 ])
3694
3695 dnl
3696 dnl Teletext Modules
3697 dnl vbi decoder plugin (using libzbvi)
3698 dnl telx module
3699 dnl uncompatible
3700 dnl
3701 AC_ARG_ENABLE(zvbi,
3702   AS_HELP_STRING([--enable-zvbi],[VBI (inc. Teletext) decoding support with 
3703                   libzvbi (default enabled)]))
3704 AC_ARG_ENABLE(telx,
3705   AS_HELP_STRING([--enable-telx],[Teletext decoding module (conflicting with 
3706                   zvbi) (default enabled if zvbi is absent)]))
3707
3708 AS_IF( [test "${enable_zvbi}" != "no"],[
3709     PKG_CHECK_MODULES(ZVBI,
3710         zvbi-0.2 >= 0.2.25,
3711         [
3712           VLC_ADD_LIBS([zvbi],[$ZVBI_LIBS])
3713           VLC_ADD_CFLAGS([zvbi],[$ZVBI_CFLAGS])
3714           VLC_ADD_PLUGIN([zvbi])
3715           AC_DEFINE(ZVBI_COMPILED, 1, [Define if the zvbi module is built]) 
3716           AS_IF( [test "${enable_telx}" = "yes"],[
3717                   AC_MSG_WARN([The zvbi and telx modules are uncompatibles. 
3718                                Using zvbi.])
3719                   ])
3720         ],[
3721           AC_MSG_WARN(ZVBI library not found. Enabling the telx module instead)
3722         ])
3723     ])  
3724 AS_IF( [test "${enable_telx}" != "no" ],[
3725   VLC_ADD_PLUGIN([telx])
3726   ])
3727
3728 dnl
3729 dnl asa/csri subtitle rendering module
3730 dnl
3731 AC_ARG_ENABLE(csri,
3732   [  --enable-csri           Subtitle support using CSRI / asa (default disabled)])
3733 AS_IF( [test "${enable_csri}" = "yes"], [
3734   PKG_CHECK_MODULES(CSRI,
3735       csri >= 0.1.0,
3736       [
3737         VLC_ADD_LDFLAGS([csri],[$CSRI_LIBS])
3738         VLC_ADD_CFLAGS([csri],[$CSRI_CFLAGS])
3739         VLC_ADD_PLUGIN([csri])
3740       ],[
3741         AC_MSG_WARN([CSRI helper library not found])
3742       ])
3743   ])
3744
3745 dnl
3746 dnl libass subtitle rendering module
3747 dnl
3748 AC_ARG_ENABLE(libass,
3749   [  --enable-libass         Subtitle support using libass (default disabled)])
3750 AS_IF( [test "${enable_libass}" = "yes"], [
3751   PKG_CHECK_MODULES(LIBASS, libass >= 0.9.5,
3752       [
3753         VLC_ADD_LDFLAGS([libass],[$LIBASS_LIBS])
3754         VLC_ADD_CFLAGS([libass],[$LIBASS_CFLAGS])
3755         VLC_ADD_PLUGIN([libass])
3756
3757         AC_CHECK_HEADERS(fontconfig/fontconfig.h,