]> git.sesse.net Git - vlc/blob - configure.ac
Validate the .desktop file with desktop-utils where available
[vlc] / configure.ac
1 dnl Autoconf settings for vlc
2
3 AC_COPYRIGHT([Copyright 2002-2011 the VideoLAN team])
4
5 AC_INIT(vlc, 1.2.0-git)
6 VERSION_MAJOR=1
7 VERSION_MINOR=2
8 VERSION_REVISION=0
9 VERSION_EXTRA=0
10 VERSION_DEV=git
11
12 PKGDIR="vlc"
13 AC_SUBST(PKGDIR)
14
15 CONFIGURE_LINE="`echo "$0 $ac_configure_args" | sed -e 's/\\\/\\\\\\\/g'`"
16 CODENAME="Twoflower"
17 COPYRIGHT_YEARS="1996-2011"
18
19 AC_CONFIG_SRCDIR(src/libvlc.c)
20 AC_CONFIG_AUX_DIR(autotools)
21 AC_CONFIG_MACRO_DIR(m4)
22 AC_CONFIG_LIBOBJ_DIR(compat)
23 AC_CANONICAL_BUILD
24 AC_CANONICAL_HOST
25 AC_PRESERVE_HELP_ORDER
26
27 AM_INIT_AUTOMAKE(tar-ustar color-tests)
28 AM_CONFIG_HEADER(config.h)
29
30 # Disable with "./configure --disable-silent-rules" or "make V=1"
31 AM_SILENT_RULES([yes])
32
33 dnl Too many people are not aware of maintainer mode:
34 dnl If you want to use it, you definitely know what you are doing, so
35 dnl you can specify "--disable-maintainer-mode". But if you want the default
36 dnl automake behavior, you've likely never heard of maintainer mode, so we
37 dnl can't expect you to enable it manually.
38 AS_IF([test "x${enable_maintainer_mode}" != "xno"],
39     [enable_maintainer_mode="yes"])
40 AM_MAINTAINER_MODE
41
42 dnl
43 dnl Directories
44 dnl
45 dnl vlcincludedir="\${includedir}/\${PKGDIR}"
46 dnl AC_SUBST(vlcincludedir)
47 vlcdatadir="\${datadir}/\${PKGDIR}"
48 AC_SUBST(vlcdatadir)
49 vlclibdir="\${libdir}/\${PKGDIR}"
50 AC_SUBST(vlclibdir)
51
52 dnl
53 dnl Check for tools
54 dnl
55 AC_PROG_CC_C99
56 AC_USE_SYSTEM_EXTENSIONS
57 AC_DEFINE([_FORTIFY_SOURCE], 2, [Define to 2 to get glibc warnings.])
58 AC_DEFINE([_FILE_OFFSET_BITS], 64, [Define to 64 for large files support.])
59 AC_DEFINE([_REENTRANT],, [Define to expose reentrant functions.])
60 AC_DEFINE([_THREAD_SAFE],, [Same as _REENTANT for some other OSes.])
61 AC_DEFINE([__LIBVLC__],, [Define within the LibVLC source code tree.])
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 AC_ARG_VAR([DESKTOP_FILE_VALIDATE], [Validator for desktop entry files])
81 AC_CHECK_PROGS(DESKTOP_FILE_VALIDATE, [${DESKTOP_FILE_VALIDATE} desktop-file-validate], :)
82
83 dnl Check for compiler properties
84 AC_C_CONST
85 AC_C_INLINE
86 AC_C_RESTRICT
87
88 dnl
89 dnl  Save *FLAGS
90 dnl
91 VLC_SAVE_FLAGS
92
93 dnl Extend the --help string at the current spot.
94 AC_DEFUN([EXTEND_HELP_STRING], [m4_divert_once([HELP_ENABLE], [$1])])
95
96 dnl Allow binary package maintainer to pass a custom string to avoid
97 dnl cache problem
98 AC_ARG_WITH(binary-version,
99     AS_HELP_STRING([--with-binary-version=STRING],
100          [To avoid plugins cache problem between binary version]),[],[])
101 AS_IF([test -n "${with_binary_version}"],[
102     AC_DEFINE_UNQUOTED([DISTRO_VERSION],["${with_binary_version}"],
103          [Binary specific version])
104 ])
105
106 dnl
107 dnl  Check for the contrib directory
108 dnl
109 AC_ARG_WITH(contrib,
110   [AS_HELP_STRING([--with-contrib[=DIR]],
111     [search for 3rd party libraries in DIR/include and DIR/lib])
112 ])
113 AC_MSG_CHECKING([for 3rd party libraries path])
114 AS_IF([test -z "${with_contrib}" || test "${with_contrib}" = "yes"], [
115   CONTRIB_DIR="${srcdir}/contrib/${host}"
116   AS_IF([test ! -d "${CONTRIB_DIR}"], [
117     echo "${CONTRIB_DIR} not found" >&AS_MESSAGE_LOG_FD
118     CONTRIB_DIR="${srcdir}/contrib/`$CC -dumpmachine`"
119     AS_IF([test ! -d "${CONTRIB_DIR}"], [
120       echo "${CONTRIB_DIR} not found" >&AS_MESSAGE_LOG_FD
121       CONTRIB_DIR="${srcdir}/extras/contrib/hosts/${host}"
122       AS_IF([test ! -d "${CONTRIB_DIR}"], [
123         echo "${CONTRIB_DIR} not found" >&AS_MESSAGE_LOG_FD
124         CONTRIB_DIR="${srcdir}/extras/contrib/hosts/`$CC -dumpmachine`"
125         AS_IF([test ! -d "${CONTRIB_DIR}"], [
126           echo "${CONTRIB_DIR} not found" >&AS_MESSAGE_LOG_FD
127           CONTRIB_DIR=""
128           AC_MSG_RESULT([not found])
129         ])
130       ])
131     ])
132   ])
133 ], [
134   AS_IF([test "${with_contrib}" != "no"], [
135     CONTRIB_DIR="${with_contrib}"
136   ], [
137     CONTRIB_DIR=""
138     AC_MSG_RESULT([disabled])
139   ])
140 ])
141 AS_IF([test -n "${CONTRIB_DIR}"], [
142   AS_IF([test -d "${CONTRIB_DIR}/lib"],[
143     CONTRIB_DIR=`cd "${CONTRIB_DIR}" && pwd`
144   ], [
145     echo "${CONTRIB_DIR}/lib not found" >&AS_MESSAGE_LOG_FD
146     CONTRIB_DIR=""
147     AC_MSG_RESULT([not usable])
148   ])
149
150 ])
151 AS_IF([test -n "${CONTRIB_DIR}"], [
152   AC_MSG_RESULT([${CONTRIB_DIR}])
153   export PATH=${CONTRIB_DIR}/bin:$PATH
154   CPPFLAGS="${CPPFLAGS} -I${CONTRIB_DIR}/include"
155   CPPFLAGS_save="${CPPFLAGS_save} -I${CONTRIB_DIR}/include"
156   CFLAGS="${CFLAGS} -I${CONTRIB_DIR}/include"
157   CFLAGS_save="${CFLAGS_save} -I${CONTRIB_DIR}/include"
158   CXXFLAGS="${CXXFLAGS} -I${CONTRIB_DIR}/include"
159   CXXFLAGS_save="${CXXFLAGS_save} -I${CONTRIB_DIR}/include"
160   OBJCFLAGS="${OBJCFLAGS} -I${CONTRIB_DIR}/include"
161   OBJCFLAGS_save="${OBJCFLAGS_save} -I${CONTRIB_DIR}/include"
162   AS_IF([test "$build" = "$host" -o "$PKG_CONFIG_LIBDIR"], [
163     export PKG_CONFIG_PATH="${CONTRIB_DIR}/lib/pkgconfig:$PKG_CONFIG_PATH"
164   ], [
165     export PKG_CONFIG_LIBDIR="${CONTRIB_DIR}/lib/pkgconfig"
166   ])
167   LDFLAGS="${LDFLAGS} -L${CONTRIB_DIR}/lib"
168   LDFLAGS_save="${LDFLAGS_save} -L${CONTRIB_DIR}/lib"
169
170   AS_IF([test "${SYS}" = "darwin"], [
171     export LD_LIBRARY_PATH="${CONTRIB_DIR}/lib:$LD_LIBRARY_PATH"
172     export DYLD_LIBRARY_PATH="${CONTRIB_DIR}/lib:$DYLD_LIBRARY_PATH"
173   ])
174 ], [
175   AS_IF([test -n "${with_contrib}" && test "${with_contrib}" != "no"], [
176     AC_MSG_ERROR([Third party libraries not found!])
177   ])
178 ])
179 AC_SUBST(CONTRIB_DIR)
180
181 dnl
182 dnl  Set default values
183 dnl
184 LDFLAGS_vlc="${LDFLAGS}"
185
186 dnl
187 dnl  Check the operating system
188 dnl
189 HAVE_WIN64="0"
190 case "${host_os}" in
191   "")
192     SYS=unknown
193     ;;
194   linux*)
195     SYS=linux
196     ;;
197   bsdi*)
198     SYS=bsdi
199     CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
200     VLC_ADD_LIBS([vcd cdda vcdx],[-ldvd])
201     ;;
202   *bsd*)
203     SYS="${host_os}"
204     CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
205     case "${host_os}" in
206       freebsd*)
207         CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include"
208         CPPFLAGS="${CPPFLAGS_save}"
209         LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib"
210         LDFLAGS="${LDFLAGS_save}"
211         ;;
212       openbsd*)
213         CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include -I/usr/X11R6/include"
214         CPPFLAGS="${CPPFLAGS_save}"
215         LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib -L/usr/X11R6/lib/"
216         LDFLAGS="${LDFLAGS_save}"
217         ;;
218     esac
219     ;;
220   darwin*)
221
222     dnl Force gcc "-arch" flag
223     ARCH_flag=""
224     case "${host}" in
225       i386*)
226         ARCH_flag="-arch i386"
227       ;;
228       ppc64*)
229         ARCH_flag="-arch ppc64"
230       ;;
231       ppc*)
232         ARCH_flag="-arch ppc"
233       ;;
234       x86_64*)
235         ARCH_flag="-arch x86_64"
236       ;;
237     esac
238
239     SYS=darwin
240     CFLAGS_save="${CFLAGS_save} -D_INTL_REDIRECT_MACROS ${ARCH_flag}"; CFLAGS="${CFLAGS_save}"
241     CXXFLAGS_save="${CXXFLAGS_save} -D_INTL_REDIRECT_MACROS ${ARCH_flag}"; CXXFLAGS="${CXXFLAGS_save}"
242     CPPFLAGS_save="${CPPFLAGS_save} ${ARCH_flag}"; CPPFLAGS="${CPPFLAGS_save}"
243     OBJCFLAGS_save="${OBJCFLAGS_save} -D_INTL_REDIRECT_MACROS -std=gnu99 ${ARCH_flag}"; OBJCFLAGS="${OBJCFLAGS_save}"
244     LDFLAGS_save="${LDFLAGS_save} -Wl,-headerpad_max_install_names ${ARCH_flag}"; LDFLAGS="${LDFLAGS_save}"
245     VLC_ADD_LIBS([mkv mp4 motion], [-Wl,-framework,IOKit,-framework,CoreFoundation])
246     VLC_ADD_LIBS([libvlc vlc],[-Wl,-undefined,dynamic_lookup])
247     VLC_ADD_LIBS([avcodec avformat access_avio swscale postproc i420_rgb_mmx x264],[-Wl,-read_only_relocs,suppress])
248     VLC_ADD_CFLAGS([motion],[-fconstant-cfstrings])
249     VLC_ADD_LIBS([libvlccore],[-Wl,-framework,CoreFoundation])
250     AC_ARG_ENABLE(macosx-defaults,
251       AS_HELP_STRING([--enable-macosx-defaults],[Build the default configuration on Mac OS X (default enabled)]))
252     if test "x${enable_macosx_defaults}" != "xno"
253     then
254         echo ""
255         echo "Building with Mac OS X defaults:"
256         build_dir=`pwd`
257         echo "  Assuming --prefix=${build_dir}/vlc_install_dir"
258         ac_default_prefix="${build_dir}/vlc_install_dir"
259         enable_faad="yes"
260         echo "  Assuming --enable-faad"
261         enable_flac="yes"
262         echo "  Assuming --enable-flac"
263         enable_theora="yes"
264         echo "  Assuming --enable-theora"
265         enable_shout="yes"
266         echo "  Assuming --enable-shout"
267         enable_vcdx="yes"
268         echo "  Assuming --enable-vcdx"
269         enable_caca="yes"
270         echo "  Assuming --enable-caca"
271         enable_ncurses="yes"
272         echo "  Assuming --enable-ncurses"
273         enable_twolame="yes"
274         echo "  Assuming --enable-twolame"
275         enable_realrtsp="yes"
276         echo "  Assuming --enable-realrtsp"
277         enable_libass="yes"
278         echo "  Assuming --enable-libass"
279
280         enable_skins2="no"
281         echo "  Assuming --disable-skins2"
282         enable_xcb="no"
283         echo "  Assuming --disable-xcb"
284     fi
285     dnl
286     dnl  Check for Mac OS X SDK settings
287     dnl
288     AC_ARG_WITH(macosx-sdk,
289       [AS_HELP_STRING([--with-macosx-sdk=DIR],
290         [compile using the SDK in DIR])])
291     if test "${with_macosx_sdk}" != "" ; then
292         CPP="${CPP} -isysroot ${with_macosx_sdk}"
293         CC="${CC} -isysroot ${with_macosx_sdk}"
294         CXX="${CXX} -isysroot ${with_macosx_sdk}"
295         OBJC="${OBJC} -isysroot ${with_macosx_sdk}"
296         LD="${LD} -syslibroot ${with_macosx_sdk}"
297     else
298         echo "  No desired SDK version given, falling back to 10.5"
299         CPP="${CPP} -isysroot /Developer/SDKs/MacOSX10.5.sdk"
300         CC="${CC} -isysroot /Developer/SDKs/MacOSX10.5.sdk"
301         CXX="${CXX} -isysroot /Developer/SDKs/MacOSX10.5.sdk"
302         OBJC="${OBJC} -isysroot /Developer/SDKs/MacOSX10.5.sdk"
303         LD="${LD} -syslibroot /Developer/SDKs/MacOSX10.5.sdk"
304         with_macosx_version_min="10.5"
305         echo "  Assuming --with-macosx-version-min=10.5"
306     fi
307     AC_ARG_WITH(macosx-version-min,
308       [AS_HELP_STRING([--with-macosx-version-min=VERSION],
309         [compile for MacOS X VERSION and above])])
310     if test "${with_macosx_version_min}" != "" ; then
311         CPP="${CPP} -mmacosx-version-min=${with_macosx_version_min}"
312         CC="${CC} -mmacosx-version-min=${with_macosx_version_min}"
313         CXX="${CXX} -mmacosx-version-min=${with_macosx_version_min}"
314         OBJC="${OBJC} -mmacosx-version-min=${with_macosx_version_min}"
315         LD="${LD} -macosx_version_min=${with_macosx_version_min}"
316         CFLAGS_save="${CFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; CFLAGS="${CFLAGS_save}"
317         CXXFLAGS_save="${CXXFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; CXXFLAGS="${CXXFLAGS_save}"
318         OBJCFLAGS_save="${OBJCFLAGS_save} -DMACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}"; OBJCFLAGS="${OBJCFLAGS_save}"
319         MACOSX_DEPLOYMENT_TARGET=${with_macosx_version_min}
320         export MACOSX_DEPLOYMENT_TARGET
321     fi
322     ;;
323   *mingw32* | *cygwin* | *wince* | *mingwce*)
324     AC_CHECK_TOOL(WINDRES, windres, :)
325     AC_CHECK_TOOL(OBJCOPY, objcopy, :)
326     AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows XP SP2 APIs.])
327     AC_DEFINE([_WIN32_IE], 0x0600, [Define to '0x0600' for IE 6.0 (and shell) APIs.])
328
329     case "${host_os}" in
330       *wince* | *mingwce* | *mingw32ce*)
331         SYS=mingwce
332         dnl Sadly CeGCC still needs non-wince macros
333         ;;
334       *mingw32*)
335         SYS=mingw32
336         ;;
337       *cygwin*)
338         dnl Check if we are using the mno-cygwin mode in which case we are
339         dnl actually dealing with a mingw32 compiler.
340         AC_EGREP_CPP(yes,
341             [#ifdef WIN32
342              yes
343              #endif],
344             SYS=mingw32, AC_MSG_ERROR([VLC requires -mno-cygwin]))
345         ;;
346     esac
347
348     if test "${SYS}" = "mingw32"; then
349         VLC_ADD_LIBS([libvlccore],[-lnetapi32 -lwinmm])
350         VLC_ADD_LDFLAGS([vlc],[-mwindows])
351         VLC_ADD_LIBS([win32text],[-lgdi32])
352         VLC_ADD_LIBS([cdda vcdx sdl_image vout_sdl],[-lwinmm])
353         dnl
354         dnl DEP and ASLR options
355         dnl
356         AC_ARG_WITH(peflags,
357           [AS_HELP_STRING([--with-peflags],
358             [use peflags (default enabled on Windows)])])
359         if test "${with_peflags}" != "no" ; then
360           AC_PATH_TOOL(PEFLAGS, peflags, :)
361         fi
362         AC_CHECK_PROGS(U2D, [unix2dos todos], unix2dos)
363         ac_default_prefix="`pwd`/_win32"
364         DESTDIR="`pwd`/_win32/"
365
366         dnl
367         dnl NSIS Installer prefix and WIN64
368         dnl
369         case "${host}" in
370             amd64*|i686-w64*|x86_64*)
371                 HAVE_WIN64="1"
372                 PROGRAMFILES="PROGRAMFILES64"
373             ;;
374             *)
375                 PROGRAMFILES="PROGRAMFILES"
376             ;;
377         esac
378         AC_SUBST(PROGRAMFILES)
379
380     fi
381     if test "${SYS}" = "mingwce"; then
382         VLC_ADD_LIBS([libvlccore],[-lmmtimer])
383         AC_CHECK_PROGS(U2D, [unix2dos todos], unix2dos)
384         ac_default_prefix="`pwd`/_wince"
385         DESTDIR="`pwd`/_wince/"
386     fi
387     ;;
388   *nto*)
389     SYS=nto
390     ;;
391   solaris*)
392     SYS=solaris
393     ;;
394   hpux*)
395     SYS=hpux
396     ;;
397   symbian*)
398     SYS=symbian
399     ;;
400   *os2*)
401     SYS=os2
402     LDFLAGS_save="${LDFLAGS_save} -Zomf -Zbin-files -Zargs-wild"; LDFLAGS="${LDFLAGS_save}"
403     ;;
404   *)
405     SYS="${host_os}"
406     ;;
407 esac
408 AM_CONDITIONAL(HAVE_DARWIN,  test "${SYS}" = "darwin")
409 AM_CONDITIONAL(HAVE_LINUX,   test "${SYS}" = "linux")
410 AM_CONDITIONAL(HAVE_OS2,     test "${SYS}" = "os2")
411 AM_CONDITIONAL(HAVE_WIN32,   test "${SYS}" = "mingw32")
412 AM_CONDITIONAL(HAVE_WIN64,   test "${HAVE_WIN64}" = "1")
413 AM_CONDITIONAL(HAVE_WINCE,   test "${SYS}" = "mingwce")
414 AM_CONDITIONAL(HAVE_SYMBIAN, test "${SYS}" = "symbian")
415 AM_CONDITIONAL(USE_PEFLAGS,  test "${with_peflags}" = "yes")
416
417 dnl
418 dnl Sadly autoconf doesn't think about testing foo.exe when ask to test
419 dnl for program foo on win32
420
421 case "${build_os}" in
422     cygwin|msys)
423         ac_executable_extensions=".exe"
424     ;;
425     *)
426     ;;
427 esac
428
429 dnl Android is linux, but a bit different
430 AS_IF([test "$SYS" = linux],[
431     AC_MSG_CHECKING([for an Android system])
432     AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
433         [[#ifndef __ANDROID__
434          # error Not Android
435          #endif
436         ]],[[;]])
437     ],[
438       HAVE_ANDROID="1"
439       AC_MSG_RESULT([yes])
440     ],[
441       AC_MSG_RESULT([no])
442     ])
443 ])
444 AM_CONDITIONAL(HAVE_ANDROID, test "${HAVE_ANDROID}" = "1")
445
446 dnl
447 dnl  Libtool
448 dnl  It's very bad, but our former custom system was worst
449 dnl  -- Courmisch
450 dnl
451
452 dnl override platform specific check for dependent libraries
453 dnl otherwise libtool linking of shared libraries will
454 dnl fail on anything other than pass_all.
455 AC_CACHE_VAL(lt_cv_deplibs_check_method,
456     [lt_cv_deplibs_check_method=pass_all])
457
458 LT_INIT([dlopen win32-dll shared disable-static])
459 LT_LANG([C++])
460 LT_LANG([Windows Resource])
461
462 m4_undefine([AC_DEPLIBS_CHECK_METHOD])
463 m4_defun([AC_DEPLIBS_CHECK_METHOD],[])
464
465 lt_cv_deplibs_check_method=pass_all
466
467 AS_IF([test "${enable_shared}" = "no" -a "${enable_vlc}" != "no"], [
468   AC_MSG_ERROR([VLC is based on plugins. Shared libraries cannot be disabled.])
469 ])
470
471 dnl
472 dnl Gettext stuff
473 dnl
474 AM_GNU_GETTEXT_VERSION([0.18.1])
475 AM_GNU_GETTEXT([external])
476
477 dnl
478 dnl Iconv stuff
479 dnl
480 AM_ICONV
481
482 dnl Check for broken versions of mingw-runtime compatability library
483 AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"], [
484     AC_MSG_CHECKING(for broken mingw-runtime)
485     AC_PREPROC_IFELSE([AC_LANG_SOURCE([
486 #include <_mingw.h>
487 #if (__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION < 15)
488 #ifndef __MINGW64_VERSION_MAJOR
489 # error Attempting to use mingw-runtime with broken vsnprintf support
490 #endif
491 #endif
492     ])], [
493         AC_MSG_RESULT([ok])
494     ], [
495         AC_MSG_RESULT([present])
496         AC_MSG_ERROR([LibVLC requires mingw-runtime version 3.15 or higher!])
497     ])
498     dnl force use of mingw provided c99 *printf over msvcrt
499     CPPFLAGS="${CPPFLAGS} -D__USE_MINGW_ANSI_STDIO=1"
500     CPPFLAGS_save="${CPPFLAGS_save} -D__USE_MINGW_ANSI_STDIO=1"
501 ])
502
503 dnl Check for the need to include the mingwex lib for mingw32
504 if test "${SYS}" = "mingw32" ; then
505     AC_CHECK_LIB(mingwex,opendir,
506         AC_CHECK_LIB(mingw32,opendir,,
507             [VLC_ADD_LIBS([libvlccore],[-lmingwex])])
508     )
509 fi
510
511 dnl Check for fnative-struct or mms-bitfields support for mingw32
512 if test "${SYS}" = "mingw32" ; then
513     AC_CACHE_CHECK([if \$CC accepts -mms-bitfields],
514         [ac_cv_c_mms_bitfields],
515         [CFLAGS="${CFLAGS_save} -mms-bitfields"
516          AC_TRY_COMPILE([],,ac_cv_c_mms_bitfields=yes, ac_cv_c_mms_bitfields=no)])
517     if test "${ac_cv_c_mms_bitfields}" != "no"; then
518         CFLAGS_save="${CFLAGS_save} -mms-bitfields";
519         CXXFLAGS_save="${CXXFLAGS_save} -mms-bitfields";
520     else
521         AC_CACHE_CHECK([if \$CC accepts -fnative-struct],
522             [ac_cv_c_fnative_struct],
523             [CFLAGS="${CFLAGS_save} -fnative-struct"
524              AC_TRY_COMPILE([],,ac_cv_c_fnative_struct=yes, ac_cv_c_fnative_struct=no)])
525         if test "${ac_cv_c_fnative_struct}" != "no"; then
526             CFLAGS_save="${CFLAGS_save} -fnative-struct";
527             CXXFLAGS_save="${CXXFLAGS_save} -fnative-struct";
528         fi
529     fi
530
531     CFLAGS="${CFLAGS_save}"; CXXFLAGS="${CXXFLAGS_save}"
532 fi
533
534 dnl
535 dnl Buggy glibc prevention. Purposedly not cached.
536 dnl See sourceware.org bugs 5058 and 5443.
537 dnl Ubuntu alone has 20 bug numbers for this...
538 dnl
539 AC_MSG_CHECKING(for buggy GNU/libc versions)
540 AC_PREPROC_IFELSE([AC_LANG_SOURCE([
541 #include <limits.h>
542 #if defined (__GLIBC__) && (__GLIBC__ == 2) \
543   && (__GLIBC_MINOR__ >= 5) && (__GLIBC_MINOR__ <= 7)
544 # error GNU/libc with dcgettext killer bug!
545 #endif
546 ])], [
547   AC_MSG_RESULT([not present])
548 ], [
549   AC_MSG_RESULT([found])
550   AS_IF([test "x${enable_nls}" != "xno"], [
551     AC_MSG_ERROR([Buggy GNU/libc (version 2.5 - 2.7) present. VLC would crash; there is no viable
552 work-around for this. Check with your distribution vendor on how to update the
553 glibc run-time. Alternatively, build with --disable-nls.])
554   ], [
555     AC_DEFINE(DISABLE_BUGGY_GLIBC_CHECK, 1, [Disables runtime check for buggy glibc.])
556   ])
557 ])
558
559 dnl Plugin compilation stuff
560
561 VLC_LIBRARY_SUFFIX
562
563 dnl Check for system libs needed
564 need_libc=false
565
566 dnl Check for usual libc functions
567 AC_CHECK_DECLS([nanosleep],,,[#include <time.h>])
568 AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r if_nameindex if_nametoindex isatty lstat memalign mmap openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp uselocale])
569 AC_REPLACE_FUNCS([asprintf atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r lldiv localtime_r nrand48 rewind setenv strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy vasprintf])
570 AC_CHECK_FUNCS(fdatasync,,
571   [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
572 ])
573
574 # Windows CE doesn't have strcoll()
575 AC_FUNC_STRCOLL
576
577 dnl Check for non-standard system calls
578 AC_CHECK_FUNCS([accept4 pipe2 eventfd vmsplice sched_getaffinity])
579
580 AH_BOTTOM([#include <vlc_fixups.h>])
581
582 dnl Check for poll
583 AC_SEARCH_LIBS(poll, [poll], [
584   AC_DEFINE(HAVE_POLL, 1, [Define to 1 if the OS has poll().])
585 ], [
586   AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"], [
587     AC_MSG_ERROR([poll() is required.])
588   ])
589 ])
590
591 dnl Check for struct pollfd
592 AC_CHECK_TYPES([struct pollfd],,,
593 [#include <sys/types.h>
594 #if HAVE_POLL
595 # include <poll.h>
596 #elif defined (WIN32)
597 # include <winsock2.h>
598 #endif
599 ])
600
601 dnl Check for connect
602 LIBS_save="$LIBS"
603 SOCKET_LIBS=""
604 AC_SEARCH_LIBS(connect, [socket], [
605   AS_IF([test "$ac_cv_search_connect" != "none required"], [
606     SOCKET_LIBS="$ac_cv_search_connect"
607   ])
608 ], [
609   AS_IF([test "${SYS}" = "mingw32"], [
610     SOCKET_LIBS="-lws2_32"
611   ])
612   AS_IF([test "${SYS}" = "mingwce"], [
613     SOCKET_LIBS="-lws2"
614   ])
615 ])
616 LIBS="$LIBS_save"
617 AS_IF([test -n "$SOCKET_LIBS"], [
618   VLC_ADD_LIBS([access_http access_mms access_udp access_tcp access_ftp access_rtmp access_output_udp access_output_shout sap stream_out_select stream_out_standard stream_out_rtp stream_out_raop vod_rtsp access_realrtsp rtp oldrc netsync gnutls flac ts audioscrobbler lua remoteosd zvbi audiobargraph_a netsync],[${SOCKET_LIBS}])
619 ])
620 AC_SUBST(SOCKET_LIBS)
621
622 dnl Check for socklen_t
623 AH_TEMPLATE(socklen_t, [Define to `int' if <sys/socket.h> does not define.])
624 AC_CACHE_CHECK([for socklen_t in sys/socket.h],
625 ac_cv_type_socklen_t,
626 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
627 [#include <sys/types.h>
628 #ifdef WIN32
629 # include <winsock2.h>
630 # include <ws2tcpip.h>
631 #else
632 # include <sys/socket.h>
633 #endif]], [[socklen_t len; len = 0;]])],
634 ac_cv_type_socklen_t=yes,
635 ac_cv_type_socklen_t=no)])
636 AS_IF([test "$ac_cv_type_socklen_t" = no],
637  [AC_DEFINE(socklen_t, int)])
638
639 dnl Check for struct sockaddr_storage
640 AH_TEMPLATE(sockaddr_storage, [Define to `sockaddr' if <sys/socket.h> does not define.])
641 AH_TEMPLATE(ss_family, [Define to `sa_family' if <sys/socket.h> does not define.])
642 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_struct_sockaddr_storage,
643   [AC_TRY_COMPILE(
644     [#include <sys/types.h>
645      #if defined( UNDER_CE )
646      # include <winsock2.h>
647      #elif defined( WIN32 )
648      # include <winsock2.h>
649      #else
650      # include <sys/socket.h>
651      #endif], [struct sockaddr_storage addr;],
652      ac_cv_struct_sockaddr_storage=yes,
653      ac_cv_struct_sockaddr_storage=no)])
654 AS_IF([test "${ac_cv_struct_sockaddr_storage}" = no], [
655   AC_DEFINE(sockaddr_storage, sockaddr)
656   AC_DEFINE(ss_family, sa_family)
657 ])
658
659 dnl getaddrinfo, getnameinfo and gai_strerror check
660 dnl  -lnsl and -lsocket are needed on Solaris;
661 dnl  we purposedly make the test fail on Windows
662 LIBS_save="${LIBS}"
663 AC_SEARCH_LIBS([getaddrinfo], [nsl],,, [${SOCKET_LIBS}])
664 LIBS="${LIBS_save}"
665
666 AC_CHECK_FUNCS(inet_aton,,[
667   AC_CHECK_LIB(resolv,inet_aton,[
668     VLC_ADD_LIBS([libvlccore],[-lresolv])
669   ])
670 ])
671
672 dnl FreeBSD has a gnugetopt library for this:
673 GNUGETOPT_LIBS=""
674 AC_CHECK_FUNC(getopt_long,, [
675   AC_CHECK_LIB([gnugetopt],[getopt_long], [
676     GNUGETOPT_LIBS="-lgnugetopt"
677   ])
678 ])
679 AC_SUBST(GNUGETOPT_LIBS)
680
681 AC_CHECK_LIB(m,cos,[
682   VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mod mpc dmo quicktime realvideo qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x264],[-lm])
683   LIBM="-lm"
684 ], [
685   LIBM=""
686 ])
687 AC_SUBST(LIBM)
688
689 AC_CHECK_LIB(m,lrintf, [
690   AC_DEFINE(HAVE_LRINTF, 1, [Define to 1 if you have the lrintf function])
691   VLC_ADD_LIBS([skins2],[-lm])
692 ])
693
694 dnl Check for dynamic plugins
695 LIBDL=""
696 have_dynamic_objects="no"
697 LIBS_save="$LIBS"
698 AC_SEARCH_LIBS(dlopen, [dl svld], [
699   AS_IF([test "$ac_cv_search_dlopen" != "none required"], [
700     LIBDL="$ac_cv_search_dlopen"
701   ])
702   have_dynamic_objects="yes"
703 ])
704 LIBS="$LIBS_save"
705
706 # Windows
707 AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"], [
708   LIBDL=""
709   have_dynamic_objects="yes" #assume we can use shared objects
710 ])
711
712 test "${enable_shared}" = "no" && have_dynamic_objects=no
713
714 AS_IF([test "${have_dynamic_objects}" != "no"], [
715   AC_DEFINE(HAVE_DYNAMIC_PLUGINS, 1,
716             [Define to 1 if dynamic plugins are supported.])
717 ], [
718   dnl Clear $LIBDL so as not to break linking
719   LIBDL=""
720 ])
721 AM_CONDITIONAL(HAVE_DYNAMIC_PLUGINS, [test "${have_dynamic_objects}" != "no"])
722
723 AC_SUBST(LIBDL)
724 VLC_ADD_LIBS([realvideo lua],[$LIBDL])
725
726 dnl Check for thread library
727 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
728   dnl Check for pthreads - borrowed from XMMS
729   THREAD_LIB=error
730   if test "${THREAD_LIB}" = "error"; then
731     AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread")
732   fi
733   if test "${THREAD_LIB}" = "error"; then
734     AC_CHECK_LIB(pthreads,main,THREAD_LIB="-lpthreads")
735   fi
736   if test "${THREAD_LIB}" = "error"; then
737     AC_CHECK_LIB(c_r,main,THREAD_LIB="-lc_r")
738   fi
739   if test "${THREAD_LIB}" = "error"; then
740     AC_CHECK_FUNCS(pthread_mutex_lock)
741     THREAD_LIB=""
742   fi
743
744   VLC_ADD_LIBS([libvlccore libvlc vlc plugin],[${THREAD_LIB}])
745
746   AC_CHECK_LIB(rt, clock_nanosleep, [
747     VLC_ADD_LIBS([libvlccore],[-lrt])
748   ], [
749     AC_CHECK_FUNC(nanosleep,,[
750       AC_CHECK_LIB(rt,nanosleep, [
751         VLC_ADD_LIBS([libvlccore],[-lrt])
752       ], [
753         AC_CHECK_LIB(posix4,nanosleep, [
754           VLC_ADD_LIBS([libvlccore],[-lposix4])
755         ])
756       ])
757     ])
758     dnl HP/UX port
759     AC_CHECK_LIB(rt,sem_init, [VLC_ADD_LIBS([libvlccore],[-lrt])])
760   ])
761 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
762
763 dnl Check for misc headers
764 AC_MSG_CHECKING(for strncasecmp in strings.h)
765 AC_EGREP_HEADER(strncasecmp,strings.h,[
766   AC_MSG_RESULT(yes)
767   AC_DEFINE(STRNCASECMP_IN_STRINGS_H, 1,
768             Define if <strings.h> defines strncasecmp.)],[
769   AC_MSG_RESULT(no)])
770
771 dnl Check for headers
772 AC_CHECK_HEADERS([search.h])
773 AC_CHECK_HEADERS(getopt.h strings.h locale.h xlocale.h)
774 AC_CHECK_HEADERS(fcntl.h sys/time.h sys/ioctl.h sys/stat.h)
775 AC_CHECK_HEADERS([arpa/inet.h netinet/in.h netinet/udplite.h sys/eventfd.h])
776 AC_CHECK_HEADERS([net/if.h], [], [],
777   [
778     #include <sys/types.h>
779     #include <sys/socket.h>
780   ])
781 AC_CHECK_HEADERS([sys/mount.h], [], [],
782   [
783     #include <sys/param.h>
784   ])
785
786 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
787   AC_CHECK_HEADERS(machine/param.h sys/shm.h)
788   AC_CHECK_HEADERS([linux/version.h linux/dccp.h scsi/scsi.h linux/magic.h])
789   AC_CHECK_HEADERS(syslog.h)
790 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
791
792 dnl LP64 and LLP64 architectures had better define ssize_t by themselves...
793 AH_TEMPLATE(ssize_t, [Define to `int' if <stddef.h> does not define.])
794 AC_CHECK_TYPE(ssize_t,, [
795   AC_DEFINE(ssize_t, int)
796 ])
797
798 dnl Check for threads library
799 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
800   AC_CHECK_HEADERS(pthread.h)
801 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
802
803 dnl It seems that autoconf detects pkg-config only during the first
804 dnl PKG_CHECK_MODULES from configure.ac - which makes sense. But in our case,
805 dnl it is nested within a conditional block, so it was not working right.
806 dnl Make PKG_CONFIG_PATH precious so that it appears in the help and get saved
807 AC_ARG_VAR(PKG_CONFIG_PATH,
808        [Paths where to find .pc not at the default location])
809 PKG_PROG_PKG_CONFIG()
810
811 dnl On some OS we need static linking
812 AS_IF([test -n "${PKG_CONFIG}" ],[
813     AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce" -o "${SYS}" = "darwin" -o "${SYS}" = "os2" ],[
814         PKG_CONFIG="${PKG_CONFIG} --static"
815     ])
816 ])
817
818
819 dnl
820 dnl Check for zlib.h and -lz along with system -lminizip if available
821 dnl
822 AC_CHECK_HEADERS(zlib.h, [ have_zlib=yes ], [ have_zlib=no ])
823 AM_CONDITIONAL(HAVE_ZLIB, [ test "${have_zlib}" = "yes" ])
824 if test "${have_zlib}" = "yes"
825 then
826   VLC_ADD_LIBS([access_http mp4 skins2 sap mkv unzip zip],[-lz])
827   PKG_CHECK_MODULES([MINIZIP], [minizip] , [ have_minizip=yes ], [
828     AC_CHECK_HEADERS([unzip.h], [
829       have_minizip=yes
830       MINIZIP_LIBS="-lminizip -lz"
831     ], [
832       have_minizip=no
833       MINIZIP_CFLAGS="-I\\\${top_srcdir}/modules/access/zip/unzip"
834       MINIZIP_LIBS="\\\${top_builddir}/modules/access/zip/unzip/libunzip.la"
835     ])
836   ])
837   VLC_ADD_CPPFLAGS([skins2],[$MINIZIP_CFLAGS])
838   VLC_ADD_LIBS([skins2],[$MINIZIP_LIBS])
839 fi
840 AM_CONDITIONAL(HAVE_MINIZIP, [ test "${have_minizip}" = "yes" ])
841
842
843 dnl Manual switch for UTF-8
844 AC_ARG_ENABLE(non-utf8,
845   [AS_HELP_STRING([--enable-non-utf8],
846     [support legacy non-UTF-8 systems (default disabled)])],, [
847   AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce" -o "${SYS}" = "os2"], [
848     enable_non_utf8="no"
849   ])
850 ])
851 AS_IF([test "${enable_non_utf8}" != "no"], [
852   AC_DEFINE([ASSUME_UTF8], [1],
853             [Define to 1 if the operating system uses UTF-8 internally])
854 ])
855
856
857 dnl Check for dbus
858 AC_ARG_ENABLE(dbus,
859   [AS_HELP_STRING([--enable-dbus],
860     [compile D-Bus message bus support (default enabled)])])
861 case "${SYS}" in
862     linux*|*bsd*)
863 if test "${enable_dbus}" != "no" -a "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
864 then
865   dnl api stable dbus
866   PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0.0,
867     [ AC_DEFINE( HAVE_DBUS, 1, [Define if you have the D-BUS library] )
868       VLC_ADD_LIBS([libvlccore],[$DBUS_LIBS])
869       VLC_ADD_CFLAGS([libvlccore],[$DBUS_CFLAGS])
870       dnl Check for dbus control interface
871         AC_ARG_ENABLE(dbus-control,
872           [AS_HELP_STRING([--disable-dbus-control],
873             [D-Bus control interface (default enabled)])])
874         if test "${enable_dbus_control}" != "no"
875         then
876           VLC_ADD_PLUGIN([dbus])
877           VLC_ADD_LIBS([dbus],[$DBUS_LIBS])
878           VLC_ADD_CFLAGS([dbus],[$DBUS_CFLAGS])
879         fi
880       dnl Check for Telepathy
881         AC_ARG_ENABLE(telepathy,
882           AS_HELP_STRING([--enable-telepathy],[Telepathy Presence plugin through DBus(default enabled)]))
883         if test "${enable_telepathy}" != "no"; then
884           VLC_ADD_PLUGIN([telepathy])
885           VLC_ADD_LIBS([telepathy],[$DBUS_LIBS])
886           VLC_ADD_CFLAGS([telepathy],[$DBUS_CFLAGS])
887         fi
888         dnl Power Management Inhibiter
889         VLC_ADD_PLUGIN([inhibit])
890         VLC_ADD_LIBS([inhibit],[$DBUS_LIBS])
891         VLC_ADD_CFLAGS([inhibit],[$DBUS_CFLAGS])
892     ],
893     [AC_MSG_ERROR([Couldn't find DBus >= 1.0.0, install libdbus-dev ?])]
894   )
895 fi
896 ;;
897 esac
898
899 dnl Check for ntohl, etc.
900 AC_CACHE_CHECK([for ntohl in sys/param.h],
901     [ac_cv_c_ntohl_sys_param_h],
902     [CFLAGS="${CFLAGS_save} -Wall -Werror"
903      AC_TRY_COMPILE([#include <sys/param.h>],
904         [int meuh; ntohl(meuh);],
905         ac_cv_c_ntohl_sys_param_h=yes, ac_cv_c_ntohl_sys_param_h=no)])
906 if test "${ac_cv_c_ntohl_sys_param_h}" != "no"; then
907     AC_DEFINE(NTOHL_IN_SYS_PARAM_H, 1, Define if <sys/param.h> defines ntohl.)
908 fi
909
910 EXTEND_HELP_STRING([Optimization options:])
911 VLC_RESTORE_FLAGS
912 dnl
913 dnl  Compiler warnings
914 dnl
915
916 RDC_PROG_CC_WFLAGS([all extra sign-compare undef pointer-arith bad-function-cast write-strings missing-prototypes volatile-register-var error-implicit-function-declaration])
917 RDC_PROG_CC_FLAGS([-pipe])
918 AC_LANG_PUSH([C++])
919 RDC_PROG_CXX_WFLAGS([all extra sign-compare undef pointer-arith volatile-register-var])
920 AC_LANG_POP([C++])
921
922 dnl
923 dnl  Debugging mode
924 dnl
925 AC_ARG_ENABLE(debug,
926   [AS_HELP_STRING([--enable-debug],
927     [build with run-time assertions (default disabled)])],,
928   [enable_debug="no"])
929 AH_TEMPLATE(NDEBUG,
930             [Define to 1 if debug code should NOT be compiled])
931 AS_IF([test "${enable_debug}" != "no"], [
932   AC_CHECK_HEADERS([valgrind/valgrind.h])
933 ], [
934   AC_DEFINE(NDEBUG)
935 ])
936
937 dnl
938 dnl  Profiling
939 dnl
940 AC_ARG_ENABLE(gprof,
941   [AS_HELP_STRING([--enable-gprof],[profile with gprof (default disabled)])],,
942   [enable_gprof="no"])
943 AS_IF([test "${enable_gprof}" != "no"], [
944   CFLAGS="${CFLAGS} -pg"
945   CXXFLAGS="${CXXFLAGS} -pg"
946   OBJCFLAGS="${OBJCFLAGS} -pg"
947   LDFLAGS="${LDFLAGS} -pg"
948 ])
949
950 AC_ARG_ENABLE(cprof,
951   [AS_HELP_STRING([--enable-cprof],[profile with cprof (default disabled)])],,
952   [enable_cprof="no"])
953 AS_IF([test "${enable_gprof}" != "no"], [
954   CFLAGS="${CFLAGS} -finstrument-functions"
955   CXXFLAGS="${CXXFLAGS} -finstrument-functions"
956   OBJCFLAGS="${OBJCFLAGS} -finstrument-functions"
957   LDFLAGS="${LDFLAGS} -finstrument-functions"
958 ])
959
960 dnl
961 dnl  Test coverage
962 dnl
963 AC_ARG_ENABLE(coverage,
964   [AS_HELP_STRING([--enable-coverage],
965     [build for test coverage (default disabled)])],,
966   [enable_coverage="no"])
967 AS_IF([test "${enable_coverage}" != "no"], [
968   CFLAGS="-fprofile-arcs -ftest-coverage ${CFLAGS}"
969   CXXFLAGS="-fprofile-arcs -ftest-coverage ${CXXFLAGS}"
970   LDFLAGS="-lgcov ${LDFLAGS}"
971 ])
972
973 VLC_SAVE_FLAGS
974
975 AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"], [
976   AC_CACHE_CHECK([if $CC accepts -fvisibility=hidden],
977                  [ac_cv_c_visibility_hidden], [
978     CFLAGS="${CFLAGS_save} -fvisibility=hidden"
979     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
980       ac_cv_c_visibility_hidden=yes
981     ], [
982       ac_cv_c_visibility_hidden=no
983     ])
984   ])
985   AS_IF([test "${ac_cv_c_visibility_hidden}" != "no"], [
986     VLC_RESTORE_FLAGS
987     CFLAGS="${CFLAGS} -fvisibility=hidden"
988     CXXFLAGS="${CXXFLAGS} -fvisibility=hidden"
989     OBJCFLAGS="${OBJCFLAGS} -fvisibility=hidden"
990     VLC_SAVE_FLAGS
991   ])
992 ])
993
994
995 dnl
996 dnl  Enable/disable optimizations
997 dnl
998 AC_ARG_ENABLE(optimizations,
999   [AS_HELP_STRING([--disable-optimizations],
1000     [disable compiler optimizations (default enabled)])],,
1001   [enable_optimizations="yes"])
1002 AS_IF([test "${enable_optimizations}" != "no"], [
1003   enable_optimizations="speed"
1004 ])
1005
1006 dnl Check for various optimization flags
1007 AS_IF([test "${enable_optimizations}" != "no"], [
1008
1009   C_O=""
1010   dnl -O4 and -O3 only in production builds
1011   AS_IF([test "{enable_debug}" = "no"], [
1012     AC_CACHE_CHECK([if $CC accepts -O4], [ac_cv_c_o4], [
1013       CFLAGS="${CFLAGS_save} -O4"
1014       AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
1015         ac_cv_c_o4=yes
1016       ], [
1017         ac_cv_c_o4=no
1018       ])
1019     ])
1020     AS_IF([test "${ac_cv_c_o4}" != "no"], [
1021       C_O="-O4"
1022     ], [
1023       AC_CACHE_CHECK([if $CC accepts -O3],  [ac_cv_c_o3], [
1024         CFLAGS="${CFLAGS_save} -O3"
1025         AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
1026           ac_cv_c_o3=yes
1027         ], [
1028           ac_cv_c_o3=no
1029         ])
1030       ])
1031       AS_IF([test "${ac_cv_c_o3}" != "no"], [
1032         C_O="-O3"
1033       ])
1034     ])
1035   ])
1036
1037   VLC_RESTORE_FLAGS
1038   CFLAGS="${CFLAGS} ${C_O}"
1039   CXXFLAGS="${CXXFLAGS} ${C_O}"
1040   OBJCFLAGS="${OBJCFLAGS} ${C_O}"
1041   VLC_SAVE_FLAGS
1042
1043   dnl Check for -ffast-math
1044   AC_CACHE_CHECK([if $CC accepts -ffast-math], [ac_cv_c_fast_math], [
1045     CFLAGS="${CFLAGS_save} -ffast-math"
1046     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
1047       ac_cv_c_fast_math=yes
1048     ], [
1049       ac_cv_c_fast_math=no
1050     ])
1051   ])
1052   AS_IF([test "${ac_cv_c_fast_math}" != "no"], [
1053     VLC_RESTORE_FLAGS
1054     CFLAGS="${CFLAGS} -ffast-math"
1055     CXXFLAGS="${CXXFLAGS} -ffast-math"
1056     OBJCFLAGS="${OBJCFLAGS} -ffast-math"
1057     VLC_SAVE_FLAGS
1058   ])
1059
1060   dnl Check for -funroll-loops
1061   AC_CACHE_CHECK([if $CC accepts -funroll-loops], [ac_cv_c_unroll_loops], [
1062     CFLAGS="${CFLAGS_save} -funroll-loops"
1063     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
1064       ac_cv_c_unroll_loops=yes
1065     ], [
1066       ac_cv_c_unroll_loops=no
1067     ])
1068   ])
1069   AS_IF([test "${ac_cv_c_unroll_loops}" != "no"], [
1070     VLC_RESTORE_FLAGS
1071     CFLAGS="${CFLAGS} -funroll-loops"
1072     CXXFLAGS="${CXXFLAGS} -funroll-loops"
1073     OBJCFLAGS="${OBJCFLAGS} -funroll-loops"
1074     VLC_SAVE_FLAGS
1075   ])
1076
1077   AS_IF([test "$enable_debug" = "no"], [
1078     dnl Check for -fomit-frame-pointer
1079     AC_CACHE_CHECK([if $CC accepts -fomit-frame-pointer],
1080       [ac_cv_c_omit_frame_pointer], [
1081       CFLAGS="${CFLAGS_save} -fomit-frame-pointer"
1082       AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
1083         ac_cv_c_omit_frame_pointer=yes
1084       ], [
1085         ac_cv_c_omit_frame_pointer=no
1086       ])
1087     ])
1088     AS_IF([test "${ac_cv_c_omit_frame_pointer}" != "no"], [
1089       VLC_RESTORE_FLAGS
1090       AS_IF([test "${SYS}" != "darwin"], [
1091         CFLAGS="${CFLAGS} -fomit-frame-pointer"
1092         CXXFLAGS="${CXXFLAGS} -fomit-frame-pointer"
1093       ], [
1094         dnl On darwin we explicitely disable it.
1095         CFLAGS="${CFLAGS} -fno-omit-frame-pointer"
1096         CXXFLAGS="${CXXFLAGS} -fno-omit-frame-pointer"
1097         OBJCFLAGS="${OBJCFLAGS} -fno-omit-frame-pointer"
1098       ])
1099       VLC_SAVE_FLAGS
1100     ])
1101   ])
1102 ])
1103
1104 dnl Check for Darwin plugin linking flags
1105 AS_IF([test "${SYS}" = "darwin"], [
1106   AC_CACHE_CHECK([if $CC accepts -bundle -undefined error],
1107     [ac_cv_ld_darwin], [
1108     CFLAGS="${CFLAGS_save} -bundle -undefined error"
1109     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
1110       ac_cv_ld_darwin=yes
1111     ], [
1112       ac_cv_ld_darwin=no
1113     ])
1114   ])
1115   AS_IF([test "${ac_cv_ld_darwin}" != "no"], [
1116     VLC_ADD_LDFLAGS([plugin],[-bundle -undefined error])
1117   ])
1118 ])
1119
1120 dnl Checks for __attribute__(aligned()) directive
1121 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
1122     [ac_cv_c_attribute_aligned],
1123     [ac_cv_c_attribute_aligned=0
1124         CFLAGS="${CFLAGS_save} -Werror"
1125     for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do
1126         AC_TRY_COMPILE([],
1127         [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
1128         [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
1129     done
1130         CFLAGS="${CFLAGS_save}"])
1131 if test "${ac_cv_c_attribute_aligned}" != "0"; then
1132     AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
1133         [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
1134 fi
1135
1136 dnl Check for __attribute__((packed))
1137 AC_CACHE_CHECK([for __attribute__((packed))],
1138   [ac_cv_c_attribute_packed],
1139   [ac_cv_c_attribute_packed=no
1140    AC_TRY_COMPILE(, [struct __attribute__((__packed__)) foo { int a; } b; (void)b;],
1141                     [ac_cv_c_attribute_packed=yes])])
1142 if test "${ac_cv_c_attribute_packed}" != "no"; then
1143   AC_DEFINE(HAVE_ATTRIBUTE_PACKED, 1, Support for __attribute__((packed)) for structs)
1144 fi
1145
1146 dnl
1147 dnl  Check the CPU
1148 dnl
1149 case "${host_cpu}" in
1150   "")
1151     ARCH=unknown
1152     ;;
1153   *)
1154     ARCH="${host_cpu}"
1155     ;;
1156 esac
1157
1158 dnl Check for backtrace() support
1159 AC_CHECK_HEADERS(execinfo.h)
1160 AC_CHECK_FUNCS(backtrace)
1161
1162 dnl
1163 dnl  default modules
1164 dnl
1165 ALIASES="${ALIASES} cvlc rvlc"
1166
1167 dnl
1168 dnl Some plugins aren't useful on some platforms
1169 dnl
1170 if test "${SYS}" = "os2"; then
1171     VLC_ADD_PLUGIN([dynamicoverlay])
1172 elif test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
1173     VLC_ADD_PLUGIN([dynamicoverlay access_shm])
1174 elif test "${SYS}" != "mingwce"; then
1175     VLC_ADD_PLUGIN([access_smb dmo globalhotkeys])
1176     VLC_ADD_LIBS([dmo],[-lole32 -luuid])
1177 fi
1178 if test "${SYS}" = "darwin"; then
1179     VLC_ADD_LIBS([quartztext],[-Wl,-framework,ApplicationServices])
1180 fi
1181
1182 dnl
1183 dnl  Accelerated modules
1184 dnl
1185
1186 dnl  Check for fully working MMX intrinsics
1187 dnl  We need support for -mmmx, we need <mmintrin.h>, and we also need a
1188 dnl  working compiler (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23963)
1189 AC_ARG_ENABLE(mmx,
1190   [AS_HELP_STRING([--disable-mmx],
1191     [disable MMX optimizations (default auto)])],,[
1192   case "${host_cpu}" in
1193     i?86|x86_64)
1194       enable_mmx="yes"
1195       ;;
1196     *)
1197       enable_mmx="no"
1198       ;;
1199   esac
1200 ])
1201 have_mmx="no"
1202 have_mmxext="no"
1203 AS_IF([test "${enable_mmx}" != "no"], [
1204   ARCH="${ARCH} mmx"
1205
1206   AC_CACHE_CHECK([if $CC groks MMX intrinsics],
1207     [ac_cv_c_mmx_intrinsics],
1208     [CFLAGS="${CFLAGS_save} -O -mmmx"
1209      AC_TRY_COMPILE([#include <mmintrin.h>
1210                      #include <stdint.h>
1211                      uint64_t frobzor;],
1212                     [__m64 a, b, c;
1213                      a = b = c = (__m64)frobzor;
1214                      a = _mm_slli_pi16(a, 3);
1215                      a = _mm_adds_pi16(a, b);
1216                      c = _mm_srli_pi16(c, 8);
1217                      c = _mm_slli_pi16(c, 3);
1218                      b = _mm_adds_pi16(b, c);
1219                      a = _mm_unpacklo_pi8(a, b);
1220                      frobzor = (uint64_t)a;],
1221                     [ac_cv_c_mmx_intrinsics=yes],
1222                     [ac_cv_c_mmx_intrinsics=no])])
1223   AS_IF([test "${ac_cv_c_mmx_intrinsics}" != "no"], [
1224     AC_DEFINE(HAVE_MMX_INTRINSICS, 1,
1225               [Define to 1 if MMX intrinsics are available.])
1226   ])
1227
1228   AC_CACHE_CHECK([if $CC groks MMX inline assembly],
1229     [ac_cv_mmx_inline],
1230     [CFLAGS="${CFLAGS_save}"
1231      AC_TRY_COMPILE(,[void *p;asm volatile("packuswb %%mm1,%%mm2"::"r"(p));],
1232                     ac_cv_mmx_inline=yes, ac_cv_mmx_inline=no)])
1233   AS_IF([test "${ac_cv_mmx_inline}" != "no"], [
1234     AC_DEFINE(CAN_COMPILE_MMX, 1,
1235               [Define to 1 inline MMX assembly is available.])
1236     have_mmx="yes"
1237   ])
1238
1239   AC_CACHE_CHECK([if $CC groks MMX EXT inline assembly],
1240     [ac_cv_mmxext_inline],
1241     [CFLAGS="${CFLAGS_save}"
1242      AC_TRY_COMPILE(,[void *p;asm volatile("maskmovq %%mm1,%%mm2"::"r"(p));],
1243                     ac_cv_mmxext_inline=yes, ac_cv_mmxext_inline=no)])
1244   AS_IF([test "${ac_cv_mmxext_inline}" != "no"], [
1245     AC_DEFINE(CAN_COMPILE_MMXEXT, 1,
1246               [Define to 1 if MMX EXT inline assembly is available.])
1247     have_mmxext="yes"
1248   ])
1249 ])
1250 AM_CONDITIONAL([HAVE_MMX], [test "${have_mmx}" = "yes"])
1251 AM_CONDITIONAL([HAVE_MMXEXT], [test "${have_mmxext}" = "yes"])
1252
1253 dnl  Check for fully workin SSE2 intrinsics
1254 dnl  We need support for -mmmx, we need <emmintrin.h>, and we also need a
1255 dnl  working compiler (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23963)
1256 AC_ARG_ENABLE(sse,
1257   [AS_HELP_STRING([--disable-sse],
1258     [disable SSE (1-4) optimizations (default auto)])],, [
1259   case "${host_cpu}" in
1260     i?86|x86_64)
1261       enable_sse=yes
1262       ;;
1263     *)
1264       enable_sse=no
1265       ;;
1266   esac
1267 ])
1268 have_sse2="no"
1269 AS_IF([test "${enable_sse}" != "no"], [
1270   ARCH="${ARCH} sse sse2"
1271
1272   AC_CACHE_CHECK([if $CC groks SSE2 intrinsics],
1273     [ac_cv_c_sse2_intrinsics],
1274     [CFLAGS="${CFLAGS_save} -O -msse2"
1275      AC_TRY_COMPILE([#include <emmintrin.h>
1276                      #include <stdint.h>
1277                      uint64_t frobzor;],
1278                     [__m128i a, b, c;
1279                      a = b = c = _mm_set1_epi64((__m64)frobzor);
1280                      a = _mm_slli_epi16(a, 3);
1281                      a = _mm_adds_epi16(a, b);
1282                      c = _mm_srli_epi16(c, 8);
1283                      c = _mm_slli_epi16(c, 3);
1284                      b = _mm_adds_epi16(b, c);
1285                      a = _mm_unpacklo_epi8(a, b);
1286                      frobzor = (uint64_t)_mm_movepi64_pi64(a);],
1287                     [ac_cv_c_sse2_intrinsics=yes],
1288                     [ac_cv_c_sse2_intrinsics=no])])
1289   AS_IF([test "${ac_cv_c_sse2_intrinsics}" != "no"], [
1290     AC_DEFINE(HAVE_SSE2_INTRINSICS, 1,
1291               [Define to 1 if SSE2 intrinsics are available.])
1292   ])
1293
1294   AC_CACHE_CHECK([if $CC groks SSE inline assembly],
1295     [ac_cv_sse_inline],
1296     [CFLAGS="${CFLAGS_save}"
1297      AC_TRY_COMPILE(,[void *p;asm volatile("xorps %%xmm1,%%xmm2"::"r"(p));],
1298                     ac_cv_sse_inline=yes, ac_cv_sse_inline=no)])
1299   AS_IF([test "${ac_cv_sse_inline}" != "no" -a "${SYS}" != "solaris"], [
1300     AC_DEFINE(CAN_COMPILE_SSE, 1,
1301               [Define to 1 if SSE inline assembly is available.])
1302   ])
1303
1304   AC_CACHE_CHECK([if $CC groks SSE2 inline assembly],
1305     [ac_cv_sse2_inline],
1306     [CFLAGS="${CFLAGS_save}"
1307      AC_TRY_COMPILE(,[void *p;asm volatile("punpckhqdq %%xmm1,%%xmm2"::"r"(p));],
1308                     ac_cv_sse2_inline=yes, ac_cv_sse2_inline=no)])
1309   AS_IF([test "${ac_cv_sse2_inline}" != "no" -a "${SYS}" != "solaris"], [
1310     AC_DEFINE(CAN_COMPILE_SSE2, 1,
1311               [Define to 1 if SSE2 inline assembly is available.])
1312     have_sse2="yes"
1313   ])
1314
1315   # SSE3
1316   AC_CACHE_CHECK([if $CC groks SSE3 inline assembly],
1317     [ac_cv_sse3_inline],
1318     [CFLAGS="${CFLAGS_save}"
1319      AC_TRY_COMPILE(,[void *p;asm volatile("movsldup %%xmm1,%%xmm0"::"r"(p));],
1320                     ac_cv_sse3_inline=yes, ac_cv_sse3_inline=no)])
1321   AS_IF([test "${ac_cv_sse3_inline}" != "no"], [
1322     AC_DEFINE(CAN_COMPILE_SSE3, 1,
1323               [Define to 1 if SSE3 inline assembly is available.]) ])
1324   # SSSE3
1325   AC_CACHE_CHECK([if $CC groks SSSE3 inline assembly],
1326     [ac_cv_ssse3_inline],
1327     [CFLAGS="${CFLAGS_save}"
1328      AC_TRY_COMPILE(,[void *p;asm volatile("pabsw %%xmm0,%%xmm0"::"r"(p));],
1329                     ac_cv_ssse3_inline=yes, ac_cv_ssse3_inline=no)])
1330   AS_IF([test "${ac_cv_ssse3_inline}" != "no"], [
1331     AC_DEFINE(CAN_COMPILE_SSSE3, 1,
1332               [Define to 1 if SSSE3 inline assembly is available.]) ])
1333
1334   # SSE4.1
1335   AC_CACHE_CHECK([if $CC groks SSE4.1 inline assembly],
1336     [ac_cv_sse4_1_inline],
1337     [CFLAGS="${CFLAGS_save}"
1338      AC_TRY_COMPILE(,[void *p;asm volatile("pmaxsb %%xmm1,%%xmm0"::"r"(p));],
1339                     ac_cv_sse4_1_inline=yes, ac_cv_sse4_1_inline=no)])
1340   AS_IF([test "${ac_cv_sse4_1_inline}" != "no"], [
1341     AC_DEFINE(CAN_COMPILE_SSE4_1, 1,
1342               [Define to 1 if SSE4_1 inline assembly is available.]) ])
1343
1344   # SSE4.2
1345   AC_CACHE_CHECK([if $CC groks SSE4.2 inline assembly],
1346     [ac_cv_sse4_2_inline],
1347     [CFLAGS="${CFLAGS_save}"
1348      AC_TRY_COMPILE(,[void *p;asm volatile("pcmpgtq %%xmm1,%%xmm0"::"r"(p));],
1349                     ac_cv_sse4_2_inline=yes, ac_cv_sse4_2_inline=no)])
1350   AS_IF([test "${ac_cv_sse4_2_inline}" != "no"], [
1351     AC_DEFINE(CAN_COMPILE_SSE4_2, 1,
1352               [Define to 1 if SSE4_2 inline assembly is available.]) ])
1353
1354   # SSE4A
1355   AC_CACHE_CHECK([if $CC groks SSE4A inline assembly],
1356     [ac_cv_sse4a_inline],
1357     [CFLAGS="${CFLAGS_save}"
1358      AC_TRY_COMPILE(,[void *p;asm volatile("insertq %%xmm1,%%xmm0"::"r"(p));],
1359                     ac_cv_sse4a_inline=yes, ac_cv_sse4a_inline=no)])
1360   AS_IF([test "${ac_cv_sse4a_inline}" != "no"], [
1361     AC_DEFINE(CAN_COMPILE_SSE4A, 1,
1362               [Define to 1 if SSE4A inline assembly is available.]) ])
1363 ])
1364 AM_CONDITIONAL([HAVE_SSE2], [test "$have_sse2" = "yes"])
1365
1366 have_3dnow="no"
1367 AC_CACHE_CHECK([if $CC groks 3D Now! inline assembly],
1368     [ac_cv_3dnow_inline],
1369     [CFLAGS="${CFLAGS_save}"
1370      AC_TRY_COMPILE(,[void *p;asm volatile("pfadd %%mm1,%%mm2"::"r"(p));],
1371                     ac_cv_3dnow_inline=yes, ac_cv_3dnow_inline=no)])
1372 AS_IF([test "${ac_cv_3dnow_inline}" != "no"], [
1373   AC_DEFINE(CAN_COMPILE_3DNOW, 1,
1374             [Define to 1 if 3D Now! inline assembly is available.])
1375   have_3dnow="yes"
1376 ])
1377 AM_CONDITIONAL([HAVE_3DNOW], [test "$have_3dnow" = "yes"])
1378
1379
1380 AC_ARG_ENABLE(neon,
1381   [AS_HELP_STRING([--disable-neon],
1382     [disable NEON optimizations (default auto)])],, [
1383   AS_IF([test "${host_cpu}" = "arm"], [enable_neon="yes"] ,[enable_neon="no"])
1384 ])
1385 AS_IF([test "${enable_neon}" != "no"], [
1386   AC_CACHE_CHECK([if $CC groks NEON inline assembly], [ac_cv_neon_inline], [
1387     CFLAGS="${CFLAGS_save} -mfpu=neon"
1388     AC_COMPILE_IFELSE([
1389       AC_LANG_PROGRAM(,[[
1390 asm volatile("vqmovun.s64 d0, q1":::"d0");
1391 asm volatile("ssat r0, #1, r0":::"r0"); /* assume ARMv6 */
1392 ]])
1393     ], [
1394       ac_cv_neon_inline="-mfpu=neon"
1395     ], [
1396       ac_cv_neon_inline="no"
1397     ])
1398     CFLAGS="${CFLAGS_save}"
1399   ])
1400   AS_IF([test "$ac_cv_neon_inline" != "no"], [
1401     NEON_CFLAGS="$ac_cv_neon_inline"
1402     AC_DEFINE([CAN_COMPILE_NEON], 1,
1403       [Define to 1 if NEON (and ARMv6) assembly is available with NEON_CFLAGS.])
1404   ])
1405 ], [
1406   ac_cv_neon_inline="no"
1407 ])
1408 AC_SUBST(NEON_CFLAGS)
1409 AM_CONDITIONAL(HAVE_NEON, [test "${ac_cv_neon_inline}" != "no"])
1410
1411
1412 AC_ARG_ENABLE(altivec,
1413   [AS_HELP_STRING([--disable-altivec],
1414     [disable AltiVec optimizations (default auto)])],, [
1415   AS_IF([test "${host_cpu}" = "powerpc"],
1416         [enable_altivec=yes], [enable_altivec=no])
1417 ])
1418 have_altivec="no"
1419 AS_IF([test "${enable_altivec}" = "yes"], [
1420   ARCH="${ARCH} altivec";
1421   AC_CACHE_CHECK([if $CC groks AltiVec inline assembly],
1422     [ac_cv_altivec_inline],
1423     [CFLAGS="${CFLAGS_save}"
1424      AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
1425          ac_cv_altivec_inline="yes",
1426          [CFLAGS="${CFLAGS_save} -Wa,-m7400"
1427           AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
1428             [ac_cv_altivec_inline="-Wa,-m7400"],
1429             ac_cv_altivec_inline=no)
1430          ])])
1431   AS_IF([test "${ac_cv_altivec_inline}" != "no"], [
1432     AC_DEFINE(CAN_COMPILE_ALTIVEC, 1,
1433               [Define to 1 if AltiVec inline assembly is available.])
1434     AS_IF([test "${ac_cv_altivec_inline}" != "yes"], [
1435       VLC_ADD_CFLAGS([memcpyaltivec],[${ac_cv_altivec_inline}])
1436       VLC_ADD_CFLAGS([i420_yuy2_altivec],[${ac_cv_altivec_inline}])
1437       VLC_ADD_CFLAGS([libvlccore],[${ac_cv_altivec_inline}])
1438     ])
1439     have_altivec="yes"
1440   ])
1441
1442 dnl The AltiVec C extensions
1443 dnl
1444 dnl There are several possible cases:
1445 dnl - OS X PPC, gcc 4.x: use -mpim-altivec -force_cpusubtype_ALL, don't
1446 dnl                      need <altivec.h>
1447 dnl - OS X PPC, gcc 3.x: need -faltivec, don't need <altivec.h>
1448 dnl - Linux PPC, gcc 3.4, 4.x: need <altivec.h> which requires -maltivec
1449 dnl - Linux PPC, gcc 3.3: need <altivec.h> and -maltivec -mabi=altivec
1450 dnl - Linux PPC, gcc 3.x: need <altivec.h> and -fvec
1451 dnl - Others: test should fail
1452   AC_CACHE_CHECK([if \$CC groks AltiVec C extensions],
1453   [ac_cv_c_altivec],
1454   [# OS X/PPC test (gcc 4.x)
1455    CFLAGS="${CFLAGS_save} -mpim-altivec -force_cpusubtype_ALL"
1456    AC_TRY_COMPILE([vector unsigned char foo;],
1457      [vec_ld(0, (unsigned char *)0);],
1458      [ac_cv_c_altivec="-mpim-altivec -force_cpusubtype_ALL"],
1459      [# OS X/PPC test (gcc 3.x)
1460       CFLAGS="${CFLAGS_save} -faltivec"
1461       AC_TRY_COMPILE([vector unsigned char foo;],
1462         [vec_ld(1 * sizeof(vector float), (unsigned char *)0);],
1463         [ac_cv_c_altivec="-faltivec"],
1464         dnl Below this are the Linux tests
1465         [# Linux/PPC test (gcc 4.x)
1466          CFLAGS="${CFLAGS_save} -maltivec"
1467          AC_TRY_COMPILE([#include <altivec.h>],
1468            [vec_ld(0, (unsigned char *)0);],
1469            [ac_cv_c_altivec="-maltivec"],
1470            [# Linux/PPC test (gcc 3.3)
1471             CFLAGS="${CFLAGS_save} -maltivec -mabi=altivec"
1472             AC_TRY_COMPILE([#include <altivec.h>],
1473               [vec_ld(0, (unsigned char *)0);],
1474               [ac_cv_c_altivec=""
1475                ac_cv_c_altivec_abi="-maltivec -mabi=altivec"],
1476               [# Linux/PPC test (gcc 3.3)
1477                CFLAGS="${CFLAGS_save} -fvec"
1478                AC_TRY_COMPILE([#include <altivec.h>],
1479                  [vec_ld(0, (unsigned char *)0);],
1480                  [ac_cv_c_altivec="-fvec"],
1481                  [ac_cv_c_altivec=no])
1482               ])
1483            ])
1484         ])
1485      ])
1486    CFLAGS="${CFLAGS_save}"
1487   ])
1488   AS_IF([test "${ac_cv_c_altivec}" != "no"], [
1489     CPPFLAGS="${CPPFLAGS_save} ${ac_cv_c_altivec}"
1490   ])
1491
1492   AC_CHECK_HEADERS(altivec.h)
1493   CPPFLAGS="${CPPFLAGS_save}"
1494
1495   AS_IF([test "${ac_cv_c_altivec}" != "no"], [
1496     AC_DEFINE(CAN_COMPILE_C_ALTIVEC, 1,
1497               [Define to 1 if C AltiVec extensions are available.])
1498     VLC_ADD_CFLAGS([libvlccore],[${ac_cv_c_altivec}])
1499     VLC_ADD_CFLAGS([i420_yuy2_altivec memcpyaltivec deinterlace],[${ac_cv_c_altivec} ${ac_cv_c_altivec_abi}])
1500     have_altivec="yes"
1501   ])
1502
1503   AC_CACHE_CHECK([if linker needs -framework vecLib],
1504     [ac_cv_ld_altivec],
1505     [LDFLAGS="${LDFLAGS_vlc} -Wl,-framework,vecLib"
1506      AC_TRY_LINK([],,ac_cv_ld_altivec=yes,ac_cv_ld_altivec=no)
1507      LDFLAGS="${LDFLAGS_save}"
1508     ])
1509   AS_IF([test "${ac_cv_ld_altivec}" != "no"], [
1510     VLC_ADD_LIBS([libvlccore memcpyaltivec],[-Wl,-framework,vecLib])
1511   ])
1512 ])
1513 AM_CONDITIONAL([HAVE_ALTIVEC], [test "$have_altivec" = "yes"])
1514
1515 dnl
1516 dnl  Special arch tuning
1517 dnl
1518 AC_ARG_WITH(tuning,
1519   [AS_HELP_STRING([--with-tuning=ARCH],
1520     [tune compilation for an architecture (default varies)])])
1521 if test -n "${with_tuning}"; then
1522     if test "${with_tuning}" != "no"; then
1523         CFLAGS_TUNING="-mtune=${with_tuning}"
1524     fi
1525 else
1526     if test "${SYS}" = "darwin" -a "${host_cpu}" = "i686"; then
1527         CFLAGS_TUNING="-march=prescott -mtune=generic"
1528     elif test "${SYS}" = "darwin" -a "${host_cpu}" = "x86_64"; then
1529         CFLAGS_TUNING="-march=core2 -mtune=core2"
1530     elif test "${host_cpu}" = "i686" -o "${host_cpu}" = "i586" -o "${host_cpu}" = "i486" -o "${host_cpu}" = "i386"; then
1531         CFLAGS_TUNING="-mtune=pentium2"
1532     elif test "${host_cpu}" = "x86_64"; then
1533         CFLAGS_TUNING="-mtune=athlon64"
1534     elif test "${host_cpu}" = "powerpc"; then
1535         CFLAGS_TUNING="-mtune=G4";
1536     fi
1537 fi
1538
1539 dnl NOTE: this can't be cached cleanly
1540 AS_IF([test "${CFLAGS_TUNING}"],
1541    [CFLAGS_save="${CFLAGS}"
1542     CFLAGS="${CFLAGS} ${CFLAGS_TUNING}"
1543
1544     AC_MSG_CHECKING([whether $CC accepts ${CFLAGS_TUNING}])
1545     AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
1546                       [tuning="yes"],
1547                       [CFLAGS_TUNING=""; tuning="no"
1548                        AS_IF([test "${with_tuning}"],
1549                              [AC_MSG_ERROR([requested tuning not supported])])])
1550
1551     AC_MSG_RESULT([$tuning])
1552     CFLAGS="${CFLAGS_save}"
1553 ])
1554
1555 dnl
1556 dnl  Memory usage
1557 dnl
1558 AC_ARG_ENABLE(optimize-memory,
1559   [AS_HELP_STRING([--enable-optimize-memory],
1560     [optimize memory usage over performance])])
1561 if test "${enable_optimize_memory}" = "yes"; then
1562   AC_DEFINE(OPTIMIZE_MEMORY, 1, Define if you want to optimize memory usage over performance)
1563 fi
1564
1565 dnl
1566 dnl Allow running as root (useful for people running on embedded platforms)
1567 dnl
1568 AC_ARG_ENABLE(run-as-root,
1569   [AS_HELP_STRING([--enable-run-as-root],
1570     [allow running VLC as root (default disabled)])])
1571 AS_IF([test "${enable_run_as_root}" = "yes"],[
1572     AC_DEFINE(ALLOW_RUN_AS_ROOT, 1,
1573               [Define to 1 to allow running VLC as root (uid 0).])
1574 ])
1575
1576 dnl
1577 dnl Stream output
1578 dnl
1579 AC_ARG_ENABLE(sout,
1580   [AS_HELP_STRING([--disable-sout],
1581     [disable streaming output (default enabled)])])
1582 AS_IF([test "${enable_sout}" != "no"], [
1583   AC_DEFINE(ENABLE_SOUT, 1, [Define to 1 for stream output support.])
1584 ])
1585 AM_CONDITIONAL(ENABLE_SOUT, [test "${enable_sout}" != "no"])
1586
1587 dnl Lua modules
1588 AC_ARG_ENABLE(lua,
1589   [AS_HELP_STRING([--disable-lua],
1590     [disable LUA scripting support (default enabled)])])
1591 if test "${enable_lua}" != "no"
1592 then
1593   PKG_CHECK_MODULES(LUA, lua5.1,
1594     [ have_lua=yes ],
1595     [
1596     AC_MSG_WARN([lua5.1 not found, trying lua >= 5.1 instead])
1597     PKG_CHECK_MODULES(LUA, lua >= 5.1,
1598       [ have_lua=yes ],
1599       [
1600         have_lua=yes
1601         AC_CHECK_HEADERS([lua.h lauxlib.h lualib.h],
1602           [],
1603           [ have_lua=no ] )
1604         AC_CHECK_LIB(  lua5.1 , luaL_newstate,
1605           [LUA_LIBS="-llua5.1"],
1606           AC_CHECK_LIB( lua51 , luaL_newstate,
1607             [LUA_LIBS="-llua51"],
1608             AC_CHECK_LIB( lua , luaL_newstate,
1609               [LUA_LIBS="-llua"],
1610               [ have_lua=no
1611               ], [-lm])
1612           )
1613         )
1614       ])
1615     ])
1616   if test "x${have_lua}" = "xyes" ;  then
1617      VLC_ADD_LIBS([lua],[$LUA_LIBS])
1618      VLC_ADD_CFLAGS([lua],[$LUA_CFLAGS])
1619   else
1620       AC_MSG_ERROR([Could not find lua. Lua is needed for some interfaces (rc, telnet, http) as well as many other custom scripts. Use --disable-lua to ignore this error.])
1621   fi
1622   AC_ARG_VAR([LUAC], [LUA byte compiler])
1623   AC_PATH_PROGS(LUAC,[${LUAC} luac], [false])
1624   AS_IF([test "${LUAC}" = "false"], [
1625     AC_MSG_ERROR([Could not find the LUA byte compiler.])
1626   ])
1627 fi
1628 AM_CONDITIONAL(BUILD_LUA, [test "${have_lua}" = "yes"])
1629
1630
1631 dnl
1632 dnl HTTP daemon
1633 dnl
1634 AC_ARG_ENABLE(httpd,
1635   [AS_HELP_STRING([--disable-httpd],
1636     [disable the built-in HTTP server (default enabled)])])
1637 if test "${enable_httpd}" != "no"
1638 then
1639   AC_DEFINE(ENABLE_HTTPD, 1, Define if you want the HTTP dameon support)
1640 fi
1641 AM_CONDITIONAL(BUILD_HTTPD, [test "${enable_httpd}" != "no"])
1642
1643
1644 dnl
1645 dnl VideoLAN manager
1646 dnl
1647 AC_ARG_ENABLE(vlm,
1648   [AS_HELP_STRING([--disable-vlm],
1649     [disable the stream manager (default enabled)])],,
1650   [enable_vlm="${enable_sout}"])
1651 AS_IF([test "${enable_vlm}" != "no"], [
1652   AS_IF([test "${enable_sout}" = "no"], [
1653     AC_MSG_ERROR([VLM requires the stream output. Do not use --disable-sout.])
1654   ])
1655   AC_DEFINE(ENABLE_VLM, 1, [Define if you want the VideoLAN manager support])
1656 ])
1657 AM_CONDITIONAL([ENABLE_VLM], [test "${enable_vlm}" != "no"])
1658
1659
1660 dnl
1661 dnl  ipv6 support
1662 dnl
1663 have_ipv6=no
1664 AC_CHECK_FUNCS(inet_pton,[have_ipv6=yes],[
1665   AC_CHECK_LIB(nsl,inet_pton, [have_ipv6=yes])
1666 ])
1667
1668 AS_IF([test "${have_ipv6}" = "yes"], [
1669   AC_DEFINE(HAVE_INET_PTON, 1, [Define to 1 if you have inet_pton().])])
1670
1671
1672 AC_CHECK_FUNCS(inet_ntop,[
1673   AC_DEFINE(HAVE_INET_NTOP, 1, [Define to 1 if you have inet_ntop().])])
1674
1675
1676 dnl
1677 dnl  Input plugins
1678 dnl
1679
1680 EXTEND_HELP_STRING([Input plugins:])
1681
1682 dnl
1683 dnl libproxy support
1684 dnl
1685 AC_ARG_ENABLE(libproxy,
1686   [AS_HELP_STRING([--enable-libproxy],[support libproxy (default auto)])])
1687 AS_IF([test "${enable_libproxy}" != "no"], [
1688   PKG_CHECK_MODULES(LIBPROXY, libproxy-1.0, [
1689     AC_DEFINE(HAVE_LIBPROXY, 1, [Define if libproxy is available])
1690     VLC_ADD_CFLAGS([access_http],[$LIBPROXY_CFLAGS])
1691     VLC_ADD_LIBS([access_http],[$LIBPROXY_LIBS])
1692   ], [
1693     AS_IF([test "x${enable_libproxy}" != "x"], [
1694       AC_MSG_ERROR([libproxy could not be found on your system])
1695     ])
1696   ])
1697 ])
1698
1699 dnl
1700 dnl  live555 input
1701 dnl
1702 AC_ARG_ENABLE(live555,
1703   [AS_HELP_STRING([--enable-live555],
1704     [enable RTSP input through live555 (default enabled)])])
1705 AC_ARG_WITH(live555-tree,
1706   [AS_HELP_STRING([--with-live555-tree=PATH],
1707     [live555 tree for static linking])])
1708 if test "${enable_live555}" != "no"; then
1709
1710   dnl
1711   dnl test for --with-live555-tree
1712   dnl
1713   if test -z "${with_live555_tree}" -a "${CXX}" != ""; then
1714     AC_LANG_PUSH(C++)
1715     CPPFLAGS_save="${CPPFLAGS}"
1716     if test -z "${CONTRIB_DIR}"; then
1717         CPPFLAGS_live555="-I/usr/include/liveMedia -I/usr/include/groupsock -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment"
1718     else
1719         CPPFLAGS_live555="-I${CONTRIB_DIR}/include/liveMedia -I${CONTRIB_DIR}/include/groupsock -I${CONTRIB_DIR}/include/BasicUsageEnvironment -I${CONTRIB_DIR}/include/UsageEnvironment"
1720     fi
1721     if test "${SYS}" = "solaris"; then
1722       CPPFLAGS_live555="${CPPFLAGS_live555} -DSOLARIS"
1723     fi
1724     CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_live555}"
1725
1726     AC_CHECK_HEADERS(liveMedia_version.hh, [
1727       AC_MSG_CHECKING(for liveMedia version >= 1275091200 )
1728       AC_EGREP_CPP(yes,
1729         [#include <liveMedia_version.hh>
1730          #ifdef LIVEMEDIA_LIBRARY_VERSION_INT
1731          #if LIVEMEDIA_LIBRARY_VERSION_INT < 1275091200
1732          yes
1733          #endif
1734          #endif],
1735         [AC_MSG_RESULT([no])
1736           AC_MSG_WARN([The installed liveMedia version is too old:
1737 Version 2010.05.29 or later is required to proceed.
1738 You can get an updated one from http://www.live555.com/liveMedia .])
1739           AS_IF([test "${enable_live555}" = "yes"], [
1740             AC_MSG_ERROR([Update live555 or pass --disable-live555 to disable the plugin.])
1741           ])
1742         ],[
1743           AC_MSG_RESULT([yes])
1744           other_libs="-lgroupsock -lBasicUsageEnvironment -lUsageEnvironment"
1745           other_libs_pic="-lgroupsock_pic -lBasicUsageEnvironment_pic -lUsageEnvironment_pic"
1746           if test "${SYS}" = "mingw32"; then
1747             # add ws2_32 for closesocket, select, recv
1748             other_libs="$other_libs -lws2_32"
1749           elif test "${SYS}" = "mingwce"; then
1750             # add ws2 for closesocket, select, recv
1751             other_libs="$other_libs -lws2"
1752           fi
1753
1754           dnl We need to check for pic because live555 don't provide shared libs
1755           dnl and we want to build a plugins so we need -fPIC on some arch.
1756           VLC_ADD_CXXFLAGS([live555], [${CPPFLAGS_live555}])
1757           AC_CHECK_LIB(liveMedia_pic, main, [
1758             VLC_ADD_PLUGIN([live555])
1759             VLC_ADD_LIBS([live555], [-lliveMedia_pic ${other_libs_pic}])
1760           ],[
1761             AC_CHECK_LIB(liveMedia, main, [
1762             VLC_ADD_PLUGIN([live555])
1763             VLC_ADD_LIBS([live555], [-lliveMedia ${other_libs}])
1764           ],[],[${other_libs}]) ],[${other_libs_pic}])
1765
1766           CPPFLAGS="${CPPFLAGS_save}"
1767           AC_LANG_POP(C++)
1768         ])
1769       ])
1770   else
1771     AC_MSG_CHECKING(for liveMedia/libliveMedia.a in ${with_live555_tree})
1772     real_live555_tree="`cd ${with_live555_tree} 2>/dev/null && pwd`"
1773     if test -z "${real_live555_tree}"; then
1774       dnl  The given directory can't be found
1775       AC_MSG_RESULT(no)
1776       AC_MSG_ERROR([cannot cd to ${with_live555_tree}])
1777     fi
1778     if test -f "${real_live555_tree}/liveMedia/libliveMedia.a"; then
1779       AC_MSG_RESULT(${real_live555_tree}/liveMedia/libliveMedia.a)
1780
1781       AC_CHECK_HEADERS(${real_live555_tree}/liveMedia/include/liveMedia_version.hh,[
1782         AC_MSG_CHECKING(for liveMedia version >= 1275091200 )
1783         AC_EGREP_CPP(yes,
1784           [#include "${real_live555_tree}/liveMedia/include/liveMedia_version.hh"
1785            #ifdef LIVEMEDIA_LIBRARY_VERSION_INT
1786            #if LIVEMEDIA_LIBRARY_VERSION_INT < 1275091200
1787            yes
1788            #endif
1789            #endif],
1790           [AC_MSG_RESULT([no])
1791            AC_MSG_ERROR([Your version of liveMedia is too old: you may get a more recent one from http://www.live555.com/liveMedia.
1792 lternatively you can use --disable-live555 to disable the liveMedia plugin.])
1793         ],[
1794        AC_MSG_RESULT([yes])
1795        ])
1796       ])
1797
1798       VLC_ADD_PLUGIN([live555])
1799
1800       if test "${SYS}" = "mingw32"; then
1801         # add ws2_32 for closesocket, select, recv
1802         VLC_ADD_LIBS([live555],[-lws2_32])
1803       fi
1804
1805       VLC_ADD_LIBS([live555],[-L${real_live555_tree}/UsageEnvironment -lUsageEnvironment])
1806       VLC_ADD_LIBS([live555],[-L${real_live555_tree}/BasicUsageEnvironment -lBasicUsageEnvironment])
1807       VLC_ADD_LIBS([live555],[-L${real_live555_tree}/groupsock -lgroupsock])
1808       VLC_ADD_LIBS([live555],[-L${real_live555_tree}/liveMedia -lliveMedia])
1809
1810       VLC_ADD_CXXFLAGS([live555],[-I${real_live555_tree}/BasicUsageEnvironment/include])
1811       VLC_ADD_CXXFLAGS([live555],[-I${real_live555_tree}/groupsock/include])
1812       VLC_ADD_CXXFLAGS([live555],[-I${real_live555_tree}/liveMedia/include])
1813       VLC_ADD_CXXFLAGS([live555],[-I${real_live555_tree}/UsageEnvironment/include ])
1814       if test "${SYS}" = "solaris"; then
1815         VLC_ADD_CXXFLAGS([live555],[-DSOLARIS])
1816       fi
1817     else
1818       dnl  The given live555 wasn't built
1819         AC_MSG_RESULT(no)
1820       if test "${enable_live555}" = "yes"; then
1821         AC_MSG_ERROR([cannot find ${real_live555_tree}/liveMedia/libliveMedia.a, make sure you compiled live555 in ${with_live555_tree}])
1822       fi
1823     fi
1824   fi
1825 fi
1826
1827 dnl
1828 dnl - special access module for dc1394 input
1829 dnl - dv module: digital video module check for libraw1394
1830 dnl - linsys modules: access module check for libzvbi
1831 dnl
1832 PKG_ENABLE_MODULES_VLC([DC1394], [], [libraw1394 >= 2.0.1 libdc1394-2 >= 2.1.0], [dc1394 access module], [auto])
1833 PKG_ENABLE_MODULES_VLC([DV], [access_dv], [libraw1394 >= 2.0.1 libavc1394 >= 0.5.3], [DV input module], [auto])
1834
1835 AC_ARG_ENABLE(linsys,
1836   [AS_HELP_STRING([--enable-linsys],
1837     [Linux Linear Systems Ltd. SDI and HD-SDI input cards (default enabled)])])
1838 if test "$SYS" = "linux" -a "${enable_linsys}" != "no"; then
1839   VLC_ADD_PLUGIN([linsys_hdsdi])
1840   PKG_CHECK_MODULES(LINSYS_SDI, zvbi-0.2 >= 0.2.28,
1841     [ VLC_ADD_LIBS([linsys_sdi],[$LINSYS_SDI_LIBS])
1842       VLC_ADD_CFLAGS([linsys_sdi],[$LINSYS_SDI_CFLAGS])
1843       VLC_ADD_PLUGIN([linsys_sdi]) ],
1844     [AC_MSG_WARN([Could not find zvbi >= 0.2.28, install libzvbi-dev ?])]
1845   )
1846 fi
1847
1848 dnl
1849 dnl dvdread module: check for libdvdread
1850 dnl
1851 dnl prepend -ldvdcss on OS that need it
1852 AS_CASE(["${SYS}"], [mingw32|darwin], [VLC_ADD_LIBS([dvdread], [-ldvdcss])])
1853 PKG_ENABLE_MODULES_VLC([DVDREAD], [], [dvdread], [dvdread input module], [auto])
1854
1855 dnl
1856 dnl libdvdnav plugin
1857 dnl
1858 AC_ARG_ENABLE(dvdnav,
1859   [AS_HELP_STRING([--disable-dvdnav],
1860     [disable DVD navigation with libdvdnav (default auto)])])
1861 if test "${enable_dvdnav}" != "no"
1862 then
1863   dnl prepend -ldvdcss on OS that need it
1864   AS_CASE(["${SYS}"], [mingw32|darwin], [VLC_ADD_LIBS([dvdnav], [-ldvdcss])])
1865
1866   PKG_CHECK_MODULES(DVDNAV, dvdnav, [
1867     VLC_ADD_PLUGIN([dvdnav])
1868     VLC_ADD_CFLAGS([dvdnav],[${DVDNAV_CFLAGS}])
1869     VLC_ADD_LIBS([dvdnav],[${DVDNAV_LIBS}])
1870     AC_CHECK_LIB(dvdnav, dvdnav_get_video_resolution,
1871       AC_DEFINE(HAVE_DVDNAV_GET_VIDEO_RESOLUTION, 1, [Define if you have dvdnav_get_video_resolution.]),
1872         [], [${LIBS_dvdnav}])
1873     AC_CHECK_LIB(dvdnav, dvdnav_describe_title_chapters,
1874       AC_DEFINE(HAVE_DVDNAV_DESCRIBE_TITLE_CHAPTERS, 1, [Define if you have dvdnav_describe_title_chapters.]),
1875         [], [${LIBS_dvdnav}])],
1876       [AC_MSG_WARN(dvdnav library not found)])
1877 fi
1878
1879 dnl
1880 dnl  Windows DirectShow access module
1881 dnl
1882 AC_ARG_ENABLE(dshow,
1883   [AS_HELP_STRING([--disable-dshow],
1884     [support DirectShow (default auto)])])
1885 if test "${enable_dshow}" != "no"
1886 then
1887   if test "${SYS}" = "mingw32"
1888   then
1889     AC_LANG_PUSH(C++)
1890       AC_CHECK_HEADERS(dshow.h,
1891       [ VLC_ADD_PLUGIN([dshow])
1892         VLC_ADD_CXXFLAGS([dshow],[])
1893         VLC_ADD_LIBS([dshow],[-lole32 -loleaut32 -luuid]) ])
1894     AC_LANG_POP(C++)
1895   fi
1896 fi
1897
1898 dnl
1899 dnl  Blu-ray Disc Support with libbluray
1900 dnl
1901 PKG_ENABLE_MODULES_VLC([BLURAY], [libbluray], [libbluray >= 0.2 libxml-2.0 >= 2.6 ], (libbluray for Blu-ray disc support ) )
1902
1903 dnl
1904 dnl  OpenCV wrapper and example filters
1905 dnl
1906 PKG_ENABLE_MODULES_VLC([OPENCV], [opencv_example opencv_wrapper], [opencv], (OpenCV (computer vision) filter), [off])
1907
1908
1909 dnl
1910 dnl  libsmbclient plugin
1911 dnl
1912 AC_ARG_ENABLE(smb,
1913   [AS_HELP_STRING([--disable-smb], [disable SMB/CIFS support (default auto)])])
1914 if test "${enable_smb}" != "no"; then
1915   AC_CHECK_HEADERS(libsmbclient.h,
1916     [ VLC_ADD_PLUGIN([access_smb])
1917       VLC_ADD_LIBS([access_smb],[-lsmbclient]) ],
1918     [ if test -n "${enable_smb}"; then
1919         AC_MSG_ERROR([cannot find libsmbclient headers])
1920      fi ])
1921 fi
1922
1923
1924 dnl
1925 dnl sftp access support
1926 dnl
1927 AC_ARG_ENABLE(sftp,
1928   [AS_HELP_STRING([--enable-sftp],
1929     [support SFTP file transfer via libssh2 (default disabled)])])
1930 if test "${enable_sftp}" = "yes"; then
1931   AC_CHECK_HEADERS(libssh2.h, [
1932     VLC_ADD_PLUGIN([access_sftp])
1933     VLC_ADD_LIBS([access_sftp], [-lssh2])
1934   ])
1935 fi
1936
1937 dnl
1938 dnl  Video4Linux 2
1939 dnl
1940 AC_ARG_ENABLE(libv4l2, [AS_HELP_STRING([--disable-libv4l2],
1941   [disable userspace V4L2 library (default auto)])])
1942 AC_ARG_ENABLE(pvr, [AS_HELP_STRING([--enable-pvr],
1943   [support PVR V4L2 cards (default disabled)])])
1944 have_v4l2="no"
1945 AC_CHECK_HEADERS([linux/videodev2.h sys/videoio.h], [
1946   have_v4l2="yes"
1947 ])
1948 AS_IF([test "$have_v4l2" = "yes"], [
1949   AS_IF([test "${enable_libv4l2}" != "no"], [
1950     PKG_CHECK_MODULES(LIBV4L2, libv4l2, [
1951       AC_DEFINE(HAVE_LIBV4L2, 1, [Define to 1 if libv4l2 is available])
1952     ], [
1953       AC_MSG_WARN([${LIBV4L2_PKG_ERRORS}])
1954     ])
1955   ])
1956   AS_IF([test "${enable_pvr}" = "yes"], [
1957     VLC_ADD_PLUGIN([pvr])
1958   ])
1959 ])
1960 AM_CONDITIONAL(HAVE_V4L2, [test "${have_v4l2}" != "no"])
1961
1962 dnl
1963 dnl special access module for Blackmagic SDI cards
1964 dnl
1965 AC_ARG_ENABLE(decklink,
1966   [AS_HELP_STRING([--disable-decklink],
1967     [disable Blackmagic DeckLink SDI input (default auto)])])
1968 AC_ARG_WITH(decklink_sdk,
1969   [AS_HELP_STRING[--with-decklink-sdk=DIR],
1970     [                        location of Blackmagic DeckLink SDI SDK])])
1971 if test "${enable_decklink}" != "no"
1972 then
1973   if test "${with_decklink_sdk}" != "no" -a -n "${with_decklink_sdk}"
1974   then
1975     VLC_ADD_CPPFLAGS([decklink],[-I${with_decklink_sdk}/include])
1976   fi
1977   CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_decklink}"
1978   AC_LANG_PUSH(C++)
1979   AC_CHECK_HEADERS(DeckLinkAPIDispatch.cpp, [
1980     VLC_ADD_PLUGIN([decklink])
1981   ],[AC_MSG_WARN(Blackmagic DeckLink SDI include files not found, decklink disabled)])
1982   AC_LANG_POP(C++)
1983   CPPFLAGS="${CPPFLAGS_save}"
1984 fi
1985
1986
1987 dnl
1988 dnl  gnomeVFS access module
1989 dnl
1990 PKG_ENABLE_MODULES_VLC([GNOMEVFS], [access_gnomevfs], [gnome-vfs-2.0], [GnomeVFS access module], [auto])
1991
1992 dnl
1993 dnl  VCDX modules
1994 dnl
1995 AC_ARG_ENABLE(vcdx,
1996   [AS_HELP_STRING([--enable-vcdx],
1997     [navigate VCD with libvcdinfo (default disabled)])])
1998 if test "${enable_vcdx}" = "yes"
1999 then
2000     PKG_CHECK_MODULES(LIBCDIO, [libcdio >= 0.78.2 libiso9660 >= 0.72],
2001       [VLC_ADD_LIBS([vcdx],[$LIBCDIO_LIBS])
2002          VLC_ADD_CFLAGS([vcdx],[$LIBCDIO_CFLAGS])],
2003         [AC_MSG_ERROR([vcdx plugin requires libcdio >= 0.78.2 and libiso9660 >= 0.72])])
2004     PKG_CHECK_MODULES(LIBVCDINFO, libvcdinfo >= 0.7.22,
2005         [VLC_ADD_LIBS([vcdx],[$LIBVCDINFO_LIBS])
2006          VLC_ADD_CFLAGS([vcdx],[$LIBVCDINFO_CFLAGS])],
2007       [AC_MSG_ERROR([vcdx plugin requires libvcdinfo library >= 0.7.22])])
2008         VLC_ADD_PLUGIN([vcdx])
2009 fi
2010
2011 dnl
2012 dnl  Built-in CD-DA and VCD module
2013 dnl
2014 AC_ARG_ENABLE(vcd,
2015   [AS_HELP_STRING([--disable-vcd],
2016     [disable built-in VCD and CD-DA support (default enabled)])])
2017
2018 AC_ARG_ENABLE(libcddb,
2019   [AS_HELP_STRING([--disable-libcddb],
2020     [disable CDDB for Audio CD (default enabled)])])
2021
2022 if test "${enable_vcd}" != "no"
2023 then
2024   AC_MSG_CHECKING(for cdrom_msf0 in linux/cdrom.h)
2025   AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[
2026     AC_MSG_RESULT(yes)
2027     VLC_ADD_PLUGIN([vcd cdda])
2028   ],[
2029     AC_MSG_RESULT(no)
2030   ])
2031
2032   AC_MSG_CHECKING(for scsireq in sys/scsiio.h)
2033   AC_EGREP_HEADER(scsireq,sys/scsiio.h,[
2034     AC_MSG_RESULT(yes)
2035     VLC_ADD_PLUGIN([vcd cdda])
2036     AC_DEFINE(HAVE_SCSIREQ_IN_SYS_SCSIIO_H, 1, For NetBSD VCD support)
2037   ],[
2038     AC_MSG_RESULT(no)
2039   ])
2040
2041   AC_MSG_CHECKING(for ioc_toc_header in sys/cdio.h)
2042   AC_EGREP_HEADER(ioc_toc_header ,sys/cdio.h,[
2043     AC_MSG_RESULT(yes)
2044     VLC_ADD_PLUGIN([vcd cdda])
2045     AC_DEFINE(HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H, 1, For FreeBSD VCD support)
2046   ],[
2047     AC_MSG_RESULT(no)
2048   ])
2049
2050   if test "${SYS}" = "bsdi" -o "${SYS}" = "mingw32"
2051   then
2052     VLC_ADD_PLUGIN([vcd cdda])
2053   fi
2054
2055   if test "${SYS}" = "darwin"
2056   then
2057     VLC_ADD_PLUGIN([vcd cdda])
2058     VLC_ADD_LIBS([vcd vcdx cdda],[-Wl,-framework,IOKit,-framework,CoreFoundation])
2059     VLC_ADD_LIBS([vcdx cdda],[-liconv])
2060   fi
2061
2062   if test "$enable_libcddb" != "no"; then
2063     PKG_CHECK_MODULES(LIBCDDB, libcddb >= 0.9.5, [
2064       HAVE_LIBCDDB=yes
2065       AC_DEFINE(HAVE_LIBCDDB, 1, [Define this if you have libcddb installed])
2066       VLC_ADD_LIBS([cdda],[$LIBCDDB_LIBS])
2067       VLC_ADD_CFLAGS([cdda],[$LIBCDDB_CFLAGS])
2068       ],:
2069       [AC_MSG_WARN(new enough libcddb not found. CDDB access disabled)
2070       HAVE_LIBCDDB=no])
2071   fi
2072 fi
2073
2074 dnl
2075 dnl Linux DVB
2076 dnl
2077 AC_CACHE_CHECK([for Linux DVB version 5], [ac_cv_linux_s2api], [
2078   AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
2079 [#include <linux/dvb/version.h>
2080 #if (DVB_API_VERSION < 5)
2081 EXPLODE
2082 #endif]])], [
2083   ac_cv_linux_s2api=yes
2084 ], [
2085   ac_cv_linux_s2api=no
2086 ])])
2087 AM_CONDITIONAL([HAVE_LINUX_DVB], [test "$ac_cv_linux_s2api" = "yes"])
2088
2089 dnl
2090 dnl  Screen capture module
2091 dnl
2092 AC_ARG_ENABLE(screen,
2093   [AS_HELP_STRING([--enable-screen],
2094     [disable screen capture (default enabled)])])
2095 if test "${enable_screen}" != "no"; then
2096   if test "${SYS}" = "darwin"; then
2097     AC_CHECK_HEADERS(OpenGL/gl.h, [
2098       AC_CHECK_HEADERS(ApplicationServices/ApplicationServices.h, [
2099         VLC_ADD_PLUGIN([screen])
2100         VLC_ADD_LIBS([screen],[-Wl,-framework,OpenGL,-framework,ApplicationServices])
2101       ])
2102     ])
2103   elif test "${SYS}" = "mingw32"; then
2104     VLC_ADD_PLUGIN([screen])
2105     VLC_ADD_LIBS([screen],[-lgdi32])
2106   elif test "${SYS}" = "mingwce"; then
2107     CPPFLAGS="${CPPFLAGS_save}"
2108   fi
2109 fi
2110
2111 dnl
2112 dnl  Real RTSP plugin
2113 dnl
2114 AC_ARG_ENABLE(realrtsp,
2115   [  --enable-realrtsp       Real RTSP module (default disabled)])
2116 if test "${enable_realrtsp}" = "yes"; then
2117   VLC_ADD_PLUGIN([access_realrtsp])
2118 fi
2119
2120 dnl
2121 dnl MacOS eyeTV
2122 AC_ARG_ENABLE(macosx-eyetv,
2123   [  --enable-macosx-eyetv   Mac OS X EyeTV (TNT Tuner) module (default enabled on Mac OS X)])
2124 if test "x${enable_macosx_eyetv}" != "xno" &&
2125   (test "${SYS}" = "darwin" || test "${enable_macosx_eyetv}" = "yes")
2126 then
2127   VLC_ADD_LIBS([access_eyetv], [-Wl,-framework,Foundation])
2128   VLC_ADD_PLUGIN([access_eyetv])
2129 fi
2130
2131 dnl
2132 dnl QTCapture
2133 AC_ARG_ENABLE(macosx-qtcapture,
2134   [  --enable-macosx-qtcapture Mac OS X qtcapture (iSight) module (default enabled on Mac OS X)])
2135 if test "x${enable_macosx_qtcapture}" != "xno" &&
2136   (test "${SYS}" = "darwin" || test "${enable_macosx_qtcapture}" = "yes")
2137 then
2138   VLC_ADD_LIBS([qtcapture], [-Wl,-framework,Cocoa])
2139   VLC_ADD_LIBS([qtcapture], [-Wl,-framework,QTKit])
2140   VLC_ADD_LIBS([qtcapture], [-Wl,-framework,CoreAudio])
2141   VLC_ADD_LIBS([qtcapture], [-Wl,-framework,QuartzCore])
2142   VLC_ADD_LIBS([qtcapture], [-Wl,-framework,CoreVideo])
2143   VLC_ADD_PLUGIN([qtcapture])
2144 fi
2145
2146
2147 dnl
2148 dnl  Demux plugins
2149 dnl
2150
2151 EXTEND_HELP_STRING([Mux/Demux plugins:])
2152
2153 dnl
2154 dnl  libdvbpsi check for ts mux/demux
2155 dnl
2156 have_dvbpsi="no"
2157 PKG_WITH_MODULES([DVBPSI], [libdvbpsi], [have_dvbpsi="yes"])
2158 AM_CONDITIONAL(HAVE_DVBPSI, [test "${have_dvbpsi}" = "yes"])
2159
2160
2161 dnl
2162 dnl  GME demux plugin
2163 dnl
2164 AC_ARG_ENABLE(gme,
2165   [AS_HELP_STRING([--enable-gme],
2166     [use Game Music Emu (default auto)])])
2167 AS_IF([test "${enable_gme}" != "no"], [
2168   AC_CHECK_HEADER([gme/gme.h], [
2169     VLC_ADD_LIBS([gme], [-lgme])
2170     VLC_ADD_PLUGIN([gme])
2171   ], [
2172     AS_IF([test "x${enable_gme}" != "x"], [
2173       AC_MSG_ERROR([GME cannot be found. Please install the development files.])
2174     ])
2175   ])
2176 ])
2177
2178
2179 dnl
2180 dnl  SIDPlay plugin
2181 dnl
2182 AC_ARG_ENABLE(sid,
2183     [AS_HELP_STRING([--enable-sid],[C64 sid demux support (default auto)])])
2184 AS_IF([test "${enable_sid}" != "no"], [
2185     PKG_CHECK_MODULES(SID, [libsidplay2], [
2186         AC_LANG_PUSH(C++)
2187         oldCPPFLAGS="$CPPFLAGS"
2188         CPPFLAGS="$CPPFLAGS $SID_CFLAGS"
2189         AC_CHECK_HEADER([sidplay/builders/resid.h], [
2190             VLC_ADD_PLUGIN([sid])
2191             VLC_ADD_CFLAGS([sid], [$SID_CFLAGS])
2192             VLC_ADD_LIBS([sid], [$SID_LIBS] [-lresid-builder])
2193         ], [
2194             AS_IF([test "x${enable_sid}" = "xyes"],
2195                 [AC_MSG_ERROR(Library libresid-builder needed for sid was not found)],
2196                 [AC_MSG_WARN(Library libresid-builder needed for sid was not found)]
2197                 )
2198         ])
2199         CPPFLAGS="$oldCPPFLAGS"
2200         AC_LANG_POP(C++)
2201     ], [
2202         AS_IF([test "x${enable_sid}" = "xyes"],
2203             [AC_MSG_ERROR(Library libsidplay2 needed for sid was not found)],
2204             [AC_MSG_WARN(Library libsidplay2 needed for sid was not found)]
2205             )
2206     ])
2207 ])
2208
2209
2210 dnl
2211 dnl  ogg demux plugin
2212 dnl
2213 PKG_ENABLE_MODULES_VLC([OGG], [], [ogg >= 1.0], [Ogg demux support], [auto])
2214 if test "${enable_sout}" != "no"; then
2215     PKG_ENABLE_MODULES_VLC([MUX_OGG], [], [ogg >= 1.0], [Ogg mux support], [auto])
2216 dnl Check for libshout
2217     PKG_ENABLE_MODULES_VLC([SHOUT], [access_output_shout], [shout >= 2.1], [libshout output plugin], [auto])
2218 fi
2219
2220 dnl
2221 dnl  matroska demux plugin
2222 dnl
2223 AC_ARG_ENABLE(mkv,
2224   [AS_HELP_STRING([--disable-mkv],
2225     [do not use libmatroska (default auto)])])
2226 if test "${enable_mkv}" != "no" -a "${CXX}" != ""; then
2227   AC_LANG_PUSH(C++)
2228   AC_CHECK_HEADERS(ebml/EbmlVersion.h, [
2229     AC_MSG_CHECKING(for libebml version >= 1.0.0)
2230     AC_EGREP_CPP(yes,
2231       [#include <ebml/EbmlVersion.h>
2232        #ifdef LIBEBML_VERSION
2233        #if LIBEBML_VERSION >= 0x010000
2234        yes
2235        #endif
2236        #endif],
2237       [AC_MSG_RESULT([yes])
2238         AC_CHECK_HEADERS(matroska/KaxVersion.h, [
2239           AC_MSG_CHECKING(for libmatroska version >= 1.0.0)
2240           AC_EGREP_CPP(yes,
2241             [#include <matroska/KaxVersion.h>
2242              #ifdef LIBMATROSKA_VERSION
2243              #if LIBMATROSKA_VERSION >= 0x010000
2244              yes
2245              #endif
2246              #endif],
2247             [AC_MSG_RESULT([yes])
2248               AC_CHECK_HEADERS(matroska/KaxAttachments.h)
2249               VLC_ADD_CXXFLAGS([mkv],[])
2250               if test "${SYS}" = "darwin"; then
2251                 VLC_ADD_CXXFLAGS([mkv],[-O1])
2252               fi
2253               AC_CHECK_LIB(ebml_pic, main, [
2254                 VLC_ADD_PLUGIN([mkv])
2255                 VLC_ADD_LIBS([mkv],[-lmatroska -lebml_pic])
2256               ],[
2257                 AC_CHECK_LIB(ebml, main, [
2258                   VLC_ADD_PLUGIN([mkv])
2259                   VLC_ADD_LIBS([mkv],[-lmatroska -lebml])
2260                 ])
2261               ])
2262             ], [
2263               AC_MSG_RESULT([no])
2264               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.])
2265           ])
2266         ])
2267       ],
2268       [AC_MSG_RESULT([no])
2269         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.])
2270     ])
2271   ])
2272   AC_LANG_POP(C++)
2273 fi
2274
2275 dnl
2276 dnl  modplug demux plugin
2277 dnl
2278 AC_ARG_ENABLE(mod,
2279   [AS_HELP_STRING([--disable-mod],
2280     [do not use libmodplug (default auto)])])
2281 if test "${enable_mod}" != "no" ; then
2282     PKG_CHECK_MODULES(LIBMODPLUG, [libmodplug >= 0.8.4 libmodplug != 0.8.8], [
2283           VLC_ADD_PLUGIN([mod])
2284           VLC_ADD_CXXFLAGS([mod],[$LIBMODPLUG_CFLAGS])
2285           VLC_ADD_LIBS([mod],[$LIBMODPLUG_LIBS])
2286     ],[
2287        AS_IF([test x"${enable_mod}" = "xyes"],
2288          [AC_MSG_ERROR(libmodplug not found or a broken version (0.8.8.0) was found!)],
2289          [AC_MSG_WARN(libmodplug not found or a broken version (0.8.8.0) was found!)])
2290     ])
2291 fi
2292
2293 dnl
2294 dnl  mpc demux plugin
2295 dnl
2296 AC_ARG_ENABLE(mpc,
2297   [AS_HELP_STRING([--disable-mpc], [do not use libmpcdec (default auto)])])
2298 if test "${enable_mpc}" != "no"
2299 then
2300   AC_CHECK_HEADERS([mpc/mpcdec.h], [
2301     VLC_ADD_PLUGIN([mpc])
2302     VLC_ADD_LIBS([mpc],[-lmpcdec])],
2303     [AC_CHECK_HEADERS([mpcdec/mpcdec.h], [
2304     VLC_ADD_PLUGIN([mpc])
2305     VLC_ADD_LIBS([mpc],[-lmpcdec])])])
2306 fi
2307
2308 dnl
2309 dnl  Codec plugins
2310 dnl
2311
2312 EXTEND_HELP_STRING([Codec plugins:])
2313
2314 dnl
2315 dnl wmafixed plugin
2316 dnl
2317 AC_ARG_ENABLE(wma-fixed,
2318   [  --enable-wma-fixed      libwma-fixed module (default disabled)])
2319 if test "${enable_wma_fixed}" = "yes"
2320 then
2321   VLC_ADD_PLUGIN([wma_fixed])
2322 fi
2323
2324 dnl
2325 dnl shine fixed point mp3 encoder
2326 dnl
2327 AC_ARG_ENABLE(shine,
2328   [  --enable-shine          shine mp3 encoding module (default disabled)])
2329 if test "${enable_shine}" = "yes"
2330 then
2331   VLC_ADD_PLUGIN([shine])
2332 fi
2333
2334 dnl
2335 dnl openmax il codec plugin
2336 dnl
2337 AC_ARG_ENABLE(omxil,
2338   [  --enable-omxil          openmax il codec module (default disabled)])
2339 if test "${enable_omxil}" = "yes"
2340 then
2341   VLC_ADD_PLUGIN([omxil])
2342   VLC_ADD_LIBS([omxil], [$LIBDL])
2343 fi
2344
2345 dnl
2346 dnl iomx codec plugin
2347 dnl
2348 AC_ARG_ENABLE(iomx,
2349   [  --enable-iomx           iomx codec module (default disabled)])
2350 if test "${enable_iomx}" = "yes"
2351 then
2352   CPPFLAGS_save="${CPPFLAGS}"
2353   CPPFLAGS="${CPPFLAGS} -I${srcdir}/modules/codec/omxil" # For the OMX headers
2354   AC_LANG_PUSH([C++])
2355   AC_CHECK_HEADER(media/stagefright/OMXClient.h, [
2356     VLC_ADD_PLUGIN([iomx])
2357     VLC_ADD_CXXFLAGS([iomx], [-fno-exceptions -fno-rtti])
2358     VLC_ADD_LIBS([iomx], [-lstagefright -lmedia -lutils -lbinder])
2359   ], [
2360     AC_MSG_ERROR("Could not find IOMX headers")
2361   ])
2362   AC_LANG_POP([C++])
2363   CPPFLAGS="${CPPFLAGS_save}"
2364 fi
2365
2366 dnl
2367 dnl CrystalHD codec plugin
2368 dnl
2369 AC_ARG_ENABLE(crystalhd,
2370   [  --enable-crystalhd      crystalhd codec plugin (default auto)])
2371 if test "${enable_crystalhd}" != "no"; then
2372     AC_CHECK_HEADER(libcrystalhd/libcrystalhd_if.h, [
2373       VLC_ADD_PLUGIN([crystalhd])
2374       VLC_ADD_LIBS([crystalhd], [-lcrystalhd])
2375     ],[
2376       if test "${SYS}" = "mingw32" ; then
2377         AC_CHECK_HEADERS(libcrystalhd/bc_dts_defs.h, [
2378           VLC_ADD_PLUGIN([crystalhd])
2379           AC_CHECK_HEADERS(libcrystalhd/bc_drv_if.h, [
2380             VLC_ADD_LIBS([crystalhd], [-lbcmDIL])
2381             ])
2382         ],[
2383           AS_IF([test x"${enable_crystalhd}" = "xyes"],
2384                 [AC_MSG_ERROR("Could not find CrystalHD development headers")],
2385                 [AC_MSG_WARN("Could not find CrystalHD development headers")])
2386         ],[#define __LINUX_USER__
2387                #include <libcrystalhd/bc_dts_types.h>
2388         ])
2389       fi
2390     ],[
2391        #include <libcrystalhd/bc_dts_types.h>
2392       ])
2393 fi
2394
2395 dnl
2396 dnl  mad plugin
2397 dnl
2398 AC_ARG_ENABLE(mad,
2399   [  --enable-mad            libmad module (default enabled)])
2400 if test "${enable_mad}" != "no"
2401 then
2402   AC_ARG_WITH(mad,
2403     [  --with-mad=PATH         path to libmad],[],[])
2404   if test "${with_mad}" != "no" -a -n "${with_mad}"
2405   then
2406     VLC_ADD_CPPFLAGS([mpgatofixed32],[-I${with_mad}/include])
2407     VLC_ADD_LIBS([mpgatofixed32],[-L${with_mad}/lib])
2408   fi
2409
2410   AC_ARG_WITH(mad-tree,
2411     [  --with-mad-tree=PATH    mad tree for static linking],[],[])
2412   if test "${with_mad_tree}" != "no" -a -n "${with_mad_tree}"
2413   then
2414     real_mad_tree="`cd ${with_mad_tree} 2>/dev/null && pwd`"
2415     if test -z "${real_mad_tree}"
2416     then
2417       dnl  The given directory can't be found
2418       AC_MSG_RESULT(no)
2419       AC_MSG_ERROR([${with_mad_tree} directory doesn't exist])
2420     fi
2421     dnl  Use a custom libmad
2422     AC_MSG_CHECKING(for mad.h in ${real_mad_tree})
2423     if test -f ${real_mad_tree}/mad.h
2424     then
2425       AC_MSG_RESULT(yes)
2426       VLC_ADD_CPPFLAGS([mpgatofixed32],[-I${real_mad_tree}])
2427       VLC_ADD_LIBS([mpgatofixed32],[-L${real_mad_tree}/.libs])
2428       LDFLAGS="${LDFLAGS_save} ${LIBS_mpgatofixed32}"
2429       AC_CHECK_LIB(mad, mad_bit_init, [
2430         VLC_ADD_PLUGIN([mpgatofixed32])
2431         VLC_ADD_LIBS([mpgatofixed32],[-lmad])
2432         ],[ AC_MSG_ERROR([the specified tree hasn't been compiled ])
2433       ],[])
2434       LDFLAGS="${LDFLAGS_save}"
2435     else
2436       AC_MSG_RESULT(no)
2437       AC_MSG_ERROR([the specified tree doesn't have mad.h])
2438     fi
2439   else
2440     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_mpgatofixed32}"
2441     LDFLAGS="${LDFLAGS_save} ${LIBS_mpgatofixed32}"
2442     AC_CHECK_HEADERS(mad.h, ,
2443       [ 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.]) ])
2444     AC_CHECK_LIB(mad, mad_bit_init, [
2445       VLC_ADD_PLUGIN([mpgatofixed32])
2446       VLC_ADD_LIBS([mpgatofixed32],[-lmad])],
2447       [ AC_MSG_ERROR([Cannot find libmad library...]) ])
2448     CPPFLAGS="${CPPFLAGS_save}"
2449     LDFLAGS="${LDFLAGS_save}"
2450   fi
2451 fi
2452
2453
2454 AC_ARG_ENABLE(merge-ffmpeg,
2455 [  --enable-merge-ffmpeg   merge FFmpeg-based plugins (default disabled)],, [
2456   enable_merge_ffmpeg="no"
2457 ])
2458 AM_CONDITIONAL([MERGE_FFMPEG], [test "$enable_merge_ffmpeg" != "no"])
2459
2460 AC_CACHE_CHECK([if linker supports -Bsymbolic],
2461   [ac_cv_ld_bsymbolic],
2462   [LDFLAGS="${LDFLAGS_vlc} -Wl,-Bsymbolic"
2463     AC_TRY_LINK([],,ac_cv_ld_bsymbolic=yes,ac_cv_ld_bsymbolic=no)
2464     LDFLAGS="${LDFLAGS_save}"
2465   ])
2466
2467 dnl
2468 dnl  avcodec decoder/encoder plugin
2469 dnl
2470 AC_ARG_ENABLE(avcodec,
2471 [  --enable-avcodec        libavcodec codec (default enabled)])
2472 AS_IF([test "${enable_avcodec}" != "no"], [
2473   PKG_CHECK_MODULES(AVCODEC,[libavcodec >= 52.25.0 libavutil],
2474     [
2475       VLC_SAVE_FLAGS
2476       CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}"
2477       CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}"
2478       AC_CHECK_HEADERS(libavcodec/avcodec.h)
2479       AC_CHECK_HEADERS(libavutil/avutil.h)
2480       VLC_ADD_PLUGIN([avcodec])
2481       VLC_ADD_LIBS([avcodec],[$AVCODEC_LIBS])
2482       AS_IF([test "${ac_cv_ld_bsymbolic}" != "no"], [
2483         VLC_ADD_LIBS([avcodec],[-Wl,-Bsymbolic])
2484       ])
2485       VLC_ADD_CFLAGS([avcodec],[$AVCODEC_CFLAGS])
2486       VLC_RESTORE_FLAGS
2487       have_avcodec="yes"
2488     ],[
2489       AC_MSG_ERROR([Could not find libavcodec or libavutil. Use --disable-avcodec to ignore this error.])
2490   ])
2491 ], [
2492   have_avcodec="no"
2493 ])
2494
2495 dnl
2496 dnl libva needs avcodec
2497 dnl
2498 AC_ARG_ENABLE(libva,
2499   [  --enable-libva          VAAPI GPU decoding support (libVA) (default auto)])
2500
2501 AS_IF([test "${enable_libva}" != "no"], [
2502   AS_IF([test "x${have_avcodec}" = "xyes"], [
2503     PKG_CHECK_MODULES(LIBVA, [libva libva-x11],
2504       [
2505         VLC_SAVE_FLAGS
2506         CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}"
2507         CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}"
2508         AC_CHECK_HEADERS(libavcodec/vaapi.h, [
2509            VLC_ADD_LIBS([avcodec],[$LIBVA_LIBS ${X_LIBS} ${X_PRE_LIBS} -lX11])
2510            VLC_ADD_CFLAGS([avcodec],[$LIBVA_CFLAGS ${X_CFLAGS}])
2511            AC_DEFINE(HAVE_AVCODEC_VAAPI, 1, [Define if avcodec has to be built with VAAPI support.])
2512            echo "VAAPI acceleration activated"
2513         ],[
2514     AS_IF([test "${enable_libva}" = "yes"],
2515           [AC_MSG_ERROR([libva is present but libavcodec/vaapi.h is missing])],
2516               [AC_MSG_WARN([libva is present but libavcodec/vaapi.h is missing ])])
2517         ])
2518         VLC_RESTORE_FLAGS
2519       ],[
2520     AS_IF([test "${enable_libva}" = "yes"],
2521               [AC_MSG_ERROR([Could not find required libva.])],
2522               [AC_MSG_WARN([libva not found  ])])
2523       ])
2524   ],[
2525     AS_IF([test "x${enable_libva}" != "x"], [
2526       AC_MSG_ERROR([--enable-libva and --disable-avcodec options are mutually exclusive.])
2527     ])
2528   ])
2529 ])
2530
2531 dnl
2532 dnl dxva2 needs avcodec
2533 dnl
2534 AC_ARG_ENABLE(dxva2,
2535   [  --enable-dxva2          DxVA2 GPU decoding support (default auto)])
2536
2537 AS_IF([test "${enable_dxva2}" != "no"], [
2538   if test "${SYS}" = "mingw32"; then
2539   AS_IF([test "x${have_avcodec}" = "xyes"], [
2540     AC_CHECK_HEADERS(dxva2api.h,
2541       [
2542         AC_CHECK_HEADERS(libavcodec/dxva2.h, [
2543            VLC_ADD_LIBS([avcodec],[-lole32 -lshlwapi -luuid])
2544            AC_DEFINE(HAVE_AVCODEC_DXVA2, 1, [Define if avcodec has to be built with DxVA2 support.])
2545            echo "DxVA2 acceleration activated"
2546         ],[
2547     AS_IF([test "${enable_dxva2}" = "yes"],
2548           [AC_MSG_ERROR([dxva2 is present but libavcodec/dxva2.h is missing])],
2549               [AC_MSG_WARN([dxva2 is present but libavcodec/dxva2.h is missing ])])
2550         ])
2551       ],[
2552     AS_IF([test "${enable_dxva2}" = "yes"],
2553               [AC_MSG_ERROR([Could not find required dxva2api.h])],
2554               [AC_MSG_WARN([dxva2api.h not found])])
2555       ])
2556   ],[
2557     AS_IF([test "x${enable_dxva2}" != "x"], [
2558       AC_MSG_ERROR([--enable-dxva2 and --disable-avcodec options are mutually exclusive.])
2559     ])
2560   ])
2561   fi
2562 ])
2563
2564
2565 dnl
2566 dnl stream_out switcher needs libavcodec
2567 dnl
2568 AC_ARG_ENABLE(switcher,
2569   [  --enable-switcher       Stream-out switcher plugin (default disabled)])
2570 AS_IF([test "${enable_switcher}" = "yes"], [
2571   AS_IF([test "x${have_avcodec}" = "xyes"], [
2572     VLC_ADD_PLUGIN([stream_out_switcher])
2573     VLC_ADD_LIBS([stream_out_switcher],[$AVCODEC_LIBS $AVUTIL_LIBS])
2574     VLC_ADD_CFLAGS([stream_out_switcher],[$AVCODEC_CFLAGS $AVUTIL_CFLAGS])
2575   ],[AC_MSG_ERROR([Stream_out switcher depends on avcodec])
2576   ])
2577 ])
2578
2579
2580 dnl
2581 dnl  avformat demuxer/muxer plugin
2582 dnl
2583
2584 AC_ARG_ENABLE(avformat,
2585 [  --enable-avformat       libavformat containers (default enabled)],, [
2586   enable_avformat="${have_avcodec}"
2587 ])
2588 if test "${enable_avformat}" != "no"
2589 then
2590   PKG_CHECK_MODULES(AVFORMAT,[libavformat > 52.30.0 libavcodec libavutil],
2591     [
2592       VLC_SAVE_FLAGS
2593       CPPFLAGS="${CPPFLAGS} ${AVFORMAT_CFLAGS}"
2594       CFLAGS="${CFLAGS} ${AVFORMAT_CFLAGS}"
2595       AC_CHECK_HEADERS(libavformat/avformat.h libavformat/avio.h)
2596       AC_CHECK_HEADERS(libavutil/avutil.h)
2597       AS_IF([test "$enable_merge_ffmpeg" = "no"], [
2598         VLC_ADD_PLUGIN([avformat access_avio])
2599         VLC_ADD_LIBS([avformat access_avio],[$AVFORMAT_LIBS $AVUTIL_LIBS])
2600         VLC_ADD_CFLAGS([avformat access_avio],[$AVFORMAT_CFLAGS $AVUTIL_CFLAGS])
2601         AS_IF([test "${ac_cv_ld_bsymbolic}" != "no"], [
2602           VLC_ADD_LIBS([avformat access_avio],[-Wl,-Bsymbolic])
2603         ])
2604       ], [
2605         VLC_ADD_LIBS([avcodec],[$AVFORMAT_LIBS $AVUTIL_LIBS])
2606         VLC_ADD_CFLAGS([avcodec],[$AVFORMAT_CFLAGS $AVUTIL_CFLAGS])
2607       ])
2608       VLC_RESTORE_FLAGS
2609     ],[
2610       AC_MSG_ERROR([Could not find libavformat or libavutil. Use --disable-avformat to ignore this error.])
2611   ])
2612 fi
2613
2614 dnl
2615 dnl  swscale image scaling and conversion plugin
2616 dnl
2617
2618 AC_ARG_ENABLE(swscale,
2619   AS_HELP_STRING([--enable-swscale],[libswscale image scaling and conversion
2620           (default enabled)]))
2621 if test "${enable_swscale}" != "no"
2622 then
2623   PKG_CHECK_MODULES(SWSCALE,[libswscale],
2624     [
2625       VLC_SAVE_FLAGS
2626       CPPFLAGS="${CPPFLAGS} ${SWSCALE_CFLAGS}"
2627       CFLAGS="${CFLAGS} ${SWSCALE_CFLAGS}"
2628       AC_CHECK_HEADERS(libswscale/swscale.h)
2629       VLC_ADD_PLUGIN([swscale])
2630       VLC_ADD_LIBS([swscale],[$SWSCALE_LIBS])
2631       VLC_ADD_CFLAGS([swscale],[$SWSCALE_CFLAGS])
2632       AS_IF([test "${ac_cv_ld_bsymbolic}" != "no"], [
2633         VLC_ADD_LIBS([swscale],[-Wl,-Bsymbolic])
2634       ])
2635       VLC_RESTORE_FLAGS
2636     ],[
2637       AC_MSG_ERROR([Could not find libswscale. Use --disable-swscale to ignore this error. Proper software scaling and some video chroma conversion will be missing.])
2638   ])
2639 fi
2640
2641 dnl
2642 dnl  postproc plugin
2643 dnl
2644
2645 AC_ARG_ENABLE(postproc,
2646 [  --enable-postproc       libpostproc image post-processing (default enabled)])
2647 if test "${enable_postproc}" != "no"
2648 then
2649   PKG_CHECK_MODULES(POSTPROC,[libpostproc libavutil],
2650     [
2651       VLC_SAVE_FLAGS
2652       CPPFLAGS="${CPPFLAGS} ${POSTPROC_CFLAGS}"
2653       CFLAGS="${CFLAGS} ${POSTPROC_CFLAGS}"
2654       AC_CHECK_HEADERS(postproc/postprocess.h)
2655       VLC_ADD_PLUGIN([postproc])
2656       VLC_ADD_LIBS([postproc],[$POSTPROC_LIBS $AVUTIL_LIBS])
2657       VLC_ADD_CFLAGS([postproc],[$POSTPROC_CFLAGS $AVUTIL_CFLAGS])
2658       VLC_RESTORE_FLAGS
2659     ],[
2660       AC_MSG_ERROR([Could not find libpostproc. Use --disable-postproc to ignore this error.])
2661   ])
2662 fi
2663
2664 dnl
2665 dnl  faad decoder plugin
2666 dnl
2667 AC_ARG_ENABLE(faad,
2668 [  --enable-faad           faad codec (default disabled)])
2669 if test "${enable_faad}" = "yes"
2670 then
2671   AC_ARG_WITH(faad-tree,
2672   [  --with-faad-tree=PATH   faad tree for static linking])
2673   if test -n "${with_faad_tree}"
2674   then
2675     AC_MSG_CHECKING(for libfaad.a in ${with_faad_tree})
2676     real_faad_tree="`cd ${with_faad_tree} 2>/dev/null && pwd`"
2677     if test -z "${real_faad_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_faad_tree}])
2682     fi
2683     if test -f "${real_faad_tree}/libfaad/.libs/libfaad.a"
2684     then
2685       dnl  Use a custom faad
2686       AC_MSG_RESULT(${real_faad_tree}/libfaad/.libs/libfaad.a)
2687       VLC_ADD_PLUGIN([faad])
2688       VLC_ADD_LIBS([faad],[${real_faad_tree}/libfaad/.libs/libfaad.a])
2689       VLC_ADD_CPPFLAGS([faad],[-I${real_faad_tree}/include])
2690     else
2691       dnl  The given libfaad wasn't built
2692       AC_MSG_RESULT(no)
2693       AC_MSG_ERROR([cannot find ${real_faad_tree}/libfaad/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}])
2694     fi
2695   else
2696     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_faad}"
2697     LDFLAGS="${LDFLAGS_save} ${LIBS_faad}"
2698     AC_CHECK_HEADERS(faad.h, ,
2699       [ AC_MSG_ERROR([Cannot find development headers for libfaad...]) ])
2700     AC_CHECK_LIB(faad, faacDecOpen, [
2701       VLC_ADD_PLUGIN([faad])
2702       VLC_ADD_LIBS([faad],[-lfaad]) ],
2703       AC_CHECK_LIB(faad, NeAACDecOpen, [
2704         VLC_ADD_PLUGIN([faad])
2705         VLC_ADD_LIBS([faad],[-lfaad]) ],
2706         [ AC_MSG_ERROR([Cannot find libfaad library...]) ]))
2707     LDFLAGS="${LDFLAGS_save}"
2708     CPPFLAGS="${CPPFLAGS_save}"
2709   fi
2710 fi
2711
2712 dnl
2713 dnl twolame encoder plugin
2714 dnl
2715 PKG_ENABLE_MODULES_VLC([TWOLAME], [], [twolame], [MPEG Audio Layer 2 encoder], [auto], [], [], [ -DLIBTWOLAME_STATIC])
2716
2717 dnl
2718 dnl  QuickTime plugin
2719 dnl
2720 AC_ARG_ENABLE(quicktime,
2721   [  --enable-quicktime      QuickTime module (deprecated)])
2722 if test "${enable_quicktime}" = "yes"; then
2723   if test "${SYS}" = "mingw32"; then
2724     VLC_ADD_PLUGIN([quicktime])
2725   else
2726   AC_CHECK_HEADERS(QuickTime/QuickTime.h,
2727     [ VLC_ADD_PLUGIN([quicktime])
2728       VLC_ADD_LIBS([quicktime],[-Wl,-framework,QuickTime,-framework,Carbon])
2729     ], [ AC_MSG_ERROR([cannot find QuickTime headers]) ])
2730   fi
2731 fi
2732
2733 dnl
2734 dnl  Real plugin
2735 dnl
2736 AC_ARG_ENABLE(real,
2737   [  --enable-real           Real video decoder module (default disabled)])
2738 if test "${enable_real}" = "yes"; then
2739   VLC_ADD_PLUGIN([realvideo])
2740 fi
2741
2742 dnl
2743 dnl A52/AC3 decoder plugin
2744 dnl
2745 AC_ARG_ENABLE(a52,
2746   [  --enable-a52            A/52 support with liba52 (default enabled)])
2747 if test "${enable_a52}" != "no"
2748 then
2749   AC_ARG_WITH(a52,
2750     [  --with-a52=PATH         a52 headers and libraries])
2751   AC_ARG_WITH(a52-tree,
2752     [  --with-a52-tree=PATH    a52dec tree for static linking ],[],[])
2753   if test "${with_a52_tree}" != "no" -a -n "${with_a52_tree}"
2754   then
2755     real_a52_tree="`cd ${with_a52_tree} 2>/dev/null && pwd`"
2756     if test -z "${real_a52_tree}"
2757     then
2758       dnl  The given directory can't be found
2759       AC_MSG_RESULT(no)
2760       AC_MSG_ERROR([${with_a52_tree} directory doesn't exist])
2761     fi
2762     dnl  Use a custom a52dec
2763     AC_MSG_CHECKING(for a52.h in ${real_a52_tree}/include)
2764     if test -f ${real_a52_tree}/include/a52.h
2765     then
2766       AC_MSG_RESULT(yes)
2767       VLC_ADD_CPPFLAGS([a52tofloat32],[-I${real_a52_tree}])
2768       VLC_ADD_LIBS([a52tofloat32],[-L${real_a52_tree}/liba52/.libs])
2769       LDFLAGS="${LDFLAGS_save} ${LIBS_a52tofloat32}"
2770       AC_CHECK_LIB(a52, a52_free, [
2771         VLC_ADD_PLUGIN([a52tofloat32])
2772         VLC_ADD_CPPFLAGS([a52tofloat32],[-DUSE_A52DEC_TREE])
2773         VLC_ADD_LIBS([a52tofloat32],[-la52])
2774         ],[
2775         if test -f ${real_a52_tree}/liba52/.libs/liba52.a
2776         then
2777           AC_MSG_ERROR([make sure you have at least a52dec-0.7.3 ($real_a52_tree)])
2778         else
2779           AC_MSG_ERROR([the specified tree hasn't been compiled])
2780         fi
2781       ])
2782       LDFLAGS="${LDFLAGS_save}"
2783     else
2784       AC_MSG_RESULT(no)
2785       AC_MSG_ERROR([the specified tree doesn't have a52.h])
2786     fi
2787   else
2788     if test -z "${with_a52}"
2789     then
2790       LDFLAGS_test=""
2791       CPPFLAGS_test=""
2792     else
2793       LDFLAGS_test="-L${with_a52}/lib"
2794       CPPFLAGS_test="-I${with_a52}/include"
2795     fi
2796     CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_test} ${CPPFLAGS_a52tofloat32}"
2797     LDFLAGS="${LDFLAGS_save} ${LDFLAGS_test} ${LIBS_a52tofloat32}"
2798     AC_CHECK_HEADERS(a52dec/a52.h, [
2799       AC_CHECK_LIB(a52, a52_free, [
2800         VLC_ADD_PLUGIN([a52tofloat32])
2801         VLC_ADD_LIBS([a52tofloat32],[${LDFLAGS_test} -la52])
2802         VLC_ADD_CPPFLAGS([a52tofloat32],[${CPPFLAGS_test}])
2803       ],[
2804         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.])
2805         ])
2806     ],[
2807       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.])
2808     ])
2809     CPPFLAGS="${CPPFLAGS_save}"
2810     LDFLAGS="${LDFLAGS_save}"
2811   fi
2812 fi
2813
2814 AC_ARG_WITH(a52-fixed,
2815       [  --with-a52-fixed        specify if liba52 has been compiled with fixed point support],
2816       [
2817         VLC_ADD_CPPFLAGS([a52tofloat32],[-DLIBA52_FIXED]) ])
2818
2819 dnl
2820 dnl DTS Coherent Acoustics decoder plugin
2821 dnl
2822 PKG_ENABLE_MODULES_VLC([DCA], [dtstofloat32], [libdca >= 0.0.5], [DTS Coherent Acoustics support with libdca], [auto])
2823
2824 dnl
2825 dnl  Flac plugin
2826 dnl
2827 PKG_ENABLE_MODULES_VLC([FLAC], [], [flac], [libflac decoder/encoder support], [auto])
2828
2829 dnl
2830 dnl  Libmpeg2 plugin
2831 dnl
2832 PKG_ENABLE_MODULES_VLC([LIBMPEG2], [], [libmpeg2 > 0.3.2], [libmpeg2 decoder support], [auto])
2833
2834 dnl
2835 dnl  Vorbis plugin
2836 dnl
2837 PKG_ENABLE_MODULES_VLC([VORBIS], [], [ogg vorbis >= 1.1 vorbisenc >= 1.1], [Vorbis decoder and encoder], [auto])
2838
2839 dnl
2840 dnl  Tremor plugin
2841 dnl
2842 AC_ARG_ENABLE(tremor,
2843   [  --enable-tremor         Tremor decoder support (default disabled)])
2844 if test "${enable_tremor}" = "yes"
2845 then
2846   AC_CHECK_HEADERS(tremor/ivorbiscodec.h, [
2847     VLC_ADD_PLUGIN([tremor])
2848     VLC_ADD_LIBS([tremor],[-lvorbisidec -logg])
2849    ],[])
2850 fi
2851
2852 dnl
2853 dnl  Speex plugin
2854 dnl
2855 PKG_ENABLE_MODULES_VLC([SPEEX], [], [ogg speex >= 1.0.5], [Speex decoder support], [auto])
2856
2857 dnl
2858 dnl  theora decoder plugin
2859 dnl
2860 PKG_ENABLE_MODULES_VLC([THEORA], [], [ogg theora >= 1.0], [experimental theora codec], [auto])
2861
2862 dnl
2863 dnl  dirac encoder plugin
2864 dnl
2865 PKG_ENABLE_MODULES_VLC([DIRAC], [], [dirac >= 0.10.0], [dirac encoder], [auto])
2866
2867 dnl
2868 dnl  schroedinger decoder plugin (for dirac format video)
2869 dnl
2870 PKG_ENABLE_MODULES_VLC([SCHROEDINGER], [], [schroedinger-1.0 >= 1.0.10], [dirac decoder and encoder using schroedinger], [auto])
2871
2872 dnl
2873 dnl  PNG decoder module
2874 dnl
2875 AC_ARG_ENABLE(png,
2876   [  --enable-png            PNG support (default enabled)])
2877 if test "${enable_png}" != "no"; then
2878 AC_CHECK_HEADERS(png.h, [
2879   LDFLAGS="${LDFLAGS_save} -lz"
2880   AC_CHECK_LIB(png, png_set_rows, [
2881     VLC_ADD_LIBS([png],[-lpng -lz -lm])
2882     VLC_ADD_PLUGIN([png osdmenu osd_parser])],
2883     [],[-lz])
2884     LDFLAGS="${LDFLAGS_save}"
2885   ])
2886 fi
2887 AM_CONDITIONAL(BUILD_OSDMENU, [test "${enable_png}" != "no"])
2888
2889 dnl
2890 dnl H264 encoder plugin (using libx264)
2891 dnl
2892 AC_ARG_ENABLE(x264,
2893   [  --enable-x264           H264 encoding support with libx264 (default enabled)])
2894 if test "${enable_x264}" != "no"; then
2895   AC_ARG_WITH(x264-tree,
2896     [  --with-x264-tree=PATH   x264 tree for static linking ],[],[])
2897   if test "${with_x264_tree}" != "no" -a -n "${with_x264_tree}"
2898   then
2899     real_x264_tree="`cd ${with_x264_tree} 2>/dev/null && pwd`"
2900     if test -z "${real_x264_tree}"
2901     then
2902       dnl  The given directory can't be found
2903       AC_MSG_RESULT(no)
2904       AC_MSG_ERROR([${with_x264_tree} directory doesn't exist])
2905     fi
2906     dnl  Use a custom libx264
2907     AC_MSG_CHECKING(for x264.h in ${real_x264_tree})
2908     if test -f ${real_x264_tree}/x264.h
2909     then
2910       AC_MSG_RESULT(yes)
2911       VLC_ADD_CPPFLAGS([x264],[-I${real_x264_tree}])
2912       VLC_ADD_LIBS([x264],[-L${real_x264_tree}])
2913       PKG_CHECK_MODULES(X264,x264, [
2914         VLC_ADD_PLUGIN([x264])
2915         VLC_ADD_LIBS([x264],[${X264_LIBS}])
2916         VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}])
2917         if echo ${X264_LIBS} |grep -q 'pthreadGC2'; then
2918           VLC_ADD_CFLAGS([x264], [-DPTW32_STATIC_LIB])
2919         fi
2920       ],[
2921         AC_MSG_ERROR([the specified tree hasn't been compiled])
2922       ])
2923       LDFLAGS="${LDFLAGS_save}"
2924     else
2925       AC_MSG_RESULT(no)
2926       AC_MSG_ERROR([the specified tree doesn't have x264.h])
2927     fi
2928   else
2929       PKG_CHECK_MODULES(X264,x264 >= 0.86, [
2930         VLC_ADD_PLUGIN([x264])
2931         VLC_ADD_LDFLAGS([x264],[${X264_LIBS}])
2932
2933         AS_IF([test "${ac_cv_ld_bsymbolic}" != "no"], [
2934           VLC_ADD_LIBS([x264],[-Wl,-Bsymbolic])
2935         ])
2936
2937         VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}])
2938         if echo ${X264_LIBS} |grep -q 'pthreadGC2'; then
2939           VLC_ADD_CFLAGS([x264], [-DPTW32_STATIC_LIB])
2940         fi
2941       ],[
2942         if test "${enable_x264}" = "yes"; then
2943             AC_MSG_ERROR([Could not find libx264 >= 0.86 on your system: you may get it from http://www.videolan.org/x264.html])
2944           fi
2945       ])
2946     LDFLAGS="${LDFLAGS_save}"
2947   fi
2948 fi
2949
2950 dnl
2951 dnl libfluidsynth (MIDI synthetizer) plugin
2952 dnl
2953 PKG_ENABLE_MODULES_VLC([FLUIDSYNTH], [], [fluidsynth], [MIDI synthetiser with libfluidsynth], [auto])
2954
2955 dnl
2956 dnl Teletext Modules
2957 dnl vbi decoder plugin (using libzbvi)
2958 dnl telx module
2959 dnl uncompatible
2960 dnl
2961 AC_ARG_ENABLE(zvbi,
2962   AS_HELP_STRING([--enable-zvbi],[VBI (inc. Teletext) decoding support with
2963                   libzvbi (default enabled)]))
2964 AC_ARG_ENABLE(telx,
2965   AS_HELP_STRING([--enable-telx],[Teletext decoding module (conflicting with
2966                   zvbi) (default enabled if zvbi is absent)]))
2967
2968 AS_IF( [test "${enable_zvbi}" != "no"],[
2969     PKG_CHECK_MODULES(ZVBI,
2970         zvbi-0.2 >= 0.2.28,
2971         [
2972           VLC_ADD_LIBS([zvbi],[$ZVBI_LIBS])
2973           if test "${SYS}" = "mingw32"; then
2974               VLC_ADD_LIBS([zvbi],[ -lpthreadGC2])
2975           fi
2976           VLC_ADD_CFLAGS([zvbi],[$ZVBI_CFLAGS])
2977           VLC_ADD_PLUGIN([zvbi])
2978           AC_DEFINE(ZVBI_COMPILED, 1, [Define if the zvbi module is built])
2979           AS_IF( [test "${enable_telx}" = "yes"],[
2980                   AC_MSG_WARN([The zvbi and telx modules are uncompatibles.
2981                                Using zvbi.])
2982                   ])
2983         ],[
2984           AC_MSG_WARN(ZVBI library not found. Enabling the telx module instead)
2985         ])
2986     ])
2987 AS_IF( [test "${enable_telx}" != "no" ],[
2988   VLC_ADD_PLUGIN([telx])
2989   ])
2990
2991 dnl
2992 dnl libass subtitle rendering module
2993 dnl
2994 AC_ARG_ENABLE(libass,
2995   [  --enable-libass         Subtitle support using libass (default enabled)])
2996 AS_IF( [test "${enable_libass}" != "no"], [
2997   PKG_CHECK_MODULES(LIBASS, libass >= 0.9.8,
2998       [
2999         VLC_ADD_LIBS([libass],[$LIBASS_LIBS])
3000         VLC_ADD_CFLAGS([libass],[$LIBASS_CFLAGS])
3001         VLC_ADD_PLUGIN([libass])
3002
3003         AC_CHECK_HEADERS(fontconfig/fontconfig.h,
3004           [VLC_ADD_CPPFLAGS([libass],[-DHAVE_FONTCONFIG])
3005            VLC_ADD_LIBS([libass],[-lfontconfig])
3006        ])
3007       ],[
3008         AC_MSG_WARN([LIBASS library not found])
3009       ])
3010   ])
3011
3012 dnl
3013 dnl  kate decoder plugin
3014 dnl
3015 PKG_ENABLE_MODULES_VLC([KATE], [], [kate >= 0.3.0], [kate codec], [auto])
3016
3017 dnl
3018 dnl  tiger rendering for kate decoder plugin
3019 dnl
3020 AC_ARG_ENABLE(tiger,
3021 [  --enable-tiger          Tiger rendering library for Kate streams (default auto)])
3022 AS_IF([test "${enable_tiger}" != "no"], [
3023   PKG_CHECK_MODULES(TIGER,[tiger >= 0.3.1], [
3024       AC_DEFINE(HAVE_TIGER, 1, [Define if libtiger is available.])
3025       VLC_ADD_CFLAGS([kate],[$TIGER_CFLAGS])
3026       VLC_ADD_LIBS([kate],[$TIGER_LIBS]) ],[
3027         AS_IF([test "x${enable_tiger}" != "x"], [
3028           AC_MSG_ERROR([libtiger does not appear to be installed on your system.])
3029         ])
3030   ])
3031 ])
3032
3033
3034 dnl
3035 dnl  Video plugins
3036 dnl
3037
3038 EXTEND_HELP_STRING([Video plugins:])
3039
3040 dnl
3041 dnl  Xlib
3042 dnl
3043
3044 AC_PATH_XTRA()
3045 AC_CHECK_HEADERS(X11/Xlib.h)
3046
3047 dnl
3048 dnl  X C Bindings modules
3049 dnl
3050 AC_ARG_ENABLE(xcb,
3051   [  --enable-xcb            X11 support with XCB (default enabled)],, [
3052   AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce" -a "${SYS}" != "darwin" -a "${SYS}" != "symbian"], [
3053     enable_xcb="yes"
3054   ], [
3055     enable_xcb="no"
3056   ])
3057 ])
3058 AC_ARG_ENABLE(xvideo,
3059   [  --enable-xvideo         XVideo support (default enabled)],, [
3060     enable_xvideo="$enable_xcb"
3061 ])
3062
3063 have_xcb="no"
3064 AS_IF([test "${enable_xcb}" != "no"], [
3065   dnl libxcb
3066   PKG_CHECK_MODULES(XCB, [xcb >= 1.6])
3067   have_xcb="yes"
3068   PKG_CHECK_MODULES(XCB_SHM, [xcb-shm])
3069   PKG_CHECK_MODULES(XCB_COMPOSITE, [xcb-composite])
3070
3071   AS_IF([test "${enable_xvideo}" != "no"], [
3072     PKG_CHECK_MODULES(XCB_XV, [xcb-xv >= 1.1.90.1], [
3073       VLC_ADD_PLUGIN([xcb_xv])
3074     ])
3075   ])
3076
3077   PKG_CHECK_MODULES(XCB_RANDR, [xcb-randr >= 1.3], [
3078     VLC_ADD_PLUGIN([panoramix])
3079     VLC_ADD_LIBS([panoramix],[${XCB_RANDR_LIBS} ${XCB_LIBS}])
3080     VLC_ADD_CFLAGS([panoramix],[${XCB_RANDR_CFLAGS} ${XCB_CFLAGS}])
3081   ], [
3082     AC_MSG_WARN([libxcb-randr not found. Panoramix filter will not be supported.])
3083   ])
3084
3085   dnl xcb-utils
3086   PKG_CHECK_MODULES(XCB_KEYSYMS, [xcb-keysyms >= 0.3.4], [
3087     PKG_CHECK_MODULES(XPROTO, [xproto])
3088     VLC_ADD_PLUGIN([globalhotkeys])
3089     VLC_ADD_CFLAGS([globalhotkeys], [${XCB_KEYSYMS_CFLAGS} ${XCB_CFLAGS}])
3090     VLC_ADD_LIBS([globalhotkeys], [${XCB_KEYSYMS_LIBS} ${XCB_LIBS}])
3091     VLC_ADD_CFLAGS([xcb_window], [-DHAVE_XCB_KEYSYMS])
3092   ], [
3093     AC_MSG_WARN([libxcb-keysyms (0.3.4 or later) not found. Hotkeys will not work.])
3094   ])
3095 ])
3096 AM_CONDITIONAL([HAVE_XCB], [test "${have_xcb}" = "yes"])
3097
3098 AC_ARG_ENABLE(glx,
3099   [  --enable-glx            X11 OpenGL (GLX) support (default enabled)],, [
3100   enable_glx="$enable_xcb"
3101 ])
3102 AS_IF([test "${enable_glx}" != "no"], [
3103   PKG_CHECK_MODULES(XLIB_XCB, [x11-xcb])
3104   PKG_CHECK_MODULES(GL, [gl],, [
3105     AC_CHECK_HEADER([GL/gl.h], [
3106       GL_CFLAGS=""
3107       GL_LIBS="-lGL"
3108     ], [
3109       AC_MSG_ERROR([GLX (libGL) cannot be found. If you do not need OpenGL with X11, use --disable-glx.])
3110     ])
3111   ])
3112   VLC_ADD_PLUGIN([xcb_glx])
3113 ])
3114
3115 dnl
3116 dnl  OpenGL
3117 dnl
3118 PKG_ENABLE_MODULES_VLC([GL], [], [gl], [OpenGL support], [auto])
3119 PKG_ENABLE_MODULES_VLC([GLES1], [], [glesv1_cm], [OpenGL ES v1 support], [auto])
3120 PKG_ENABLE_MODULES_VLC([GLES2], [], [glesv2], [OpenGL ES v2 support], [auto])
3121 PKG_ENABLE_MODULES_VLC([EGL], [], [egl], [EGL support], [auto])
3122
3123 dnl
3124 dnl  SDL module
3125 dnl
3126 AC_ARG_ENABLE(sdl,
3127   [  --enable-sdl            SDL support (default enabled)])
3128 AC_ARG_ENABLE(sdl-image,
3129   [  --enable-sdl-image      SDL image support (default enabled)])
3130 if test "${enable_sdl}" != "no"
3131 then
3132    PKG_CHECK_MODULES(SDL, [sdl >= 1.2.10], [
3133       # SDL on Darwin is heavily patched and can only run SDL_image
3134       if test "${SYS}" != "darwin"; then
3135         VLC_ADD_PLUGIN([vout_sdl])
3136       fi
3137       if test "${SYS}" != "mingw32" -a "${SYS}" != "os2"; then
3138         VLC_ADD_LIBS([vout_sdl],[${X_LIBS} ${X_PRE_LIBS} -lX11])
3139       fi
3140       VLC_ADD_CFLAGS([vout_sdl],[${SDL_CFLAGS}])
3141       VLC_ADD_LIBS([vout_sdl],[${SDL_LIBS}])
3142
3143       # SDL_image
3144       AS_IF([ test "${enable_sdl_image}" != "no"],[
3145         PKG_CHECK_MODULES(SDL_IMAGE, [SDL_image >= 1.2.10], [
3146           VLC_ADD_PLUGIN([sdl_image])
3147           VLC_ADD_LIBS([sdl_image],[${SDL_IMAGE_LIBS}])
3148           VLC_ADD_CFLAGS([sdl_image], [${SDL_IMAGE_CFLAGS}])],
3149           [ AC_MSG_WARN([The development package for SDL_image is not installed.
3150     You should install it alongside your SDL package.])
3151           ])
3152       ])
3153    ],[
3154      AC_MSG_WARN([The development package for SDL is not present or too old.
3155                   You need 1.2.10. Alternatively you can also configure with
3156                   --disable-sdl.])
3157    ])
3158 fi
3159
3160
3161 dnl
3162 dnl Mac Vout
3163 AC_ARG_ENABLE(macosx-vout,
3164   [  --enable-macosx-vout    Mac OS X video output module (default enabled on Mac OS X)])
3165 if test "x${enable_macosx_vout}" != "xno" &&
3166   (test "${SYS}" = "darwin" || test "${enable_macosx_vout}" = "yes")
3167 then
3168   VLC_ADD_LIBS([vout_macosx],[-Wl,-framework,Cocoa])
3169   VLC_ADD_LIBS([vout_macosx],[-Wl,-framework,OpenGL])
3170   VLC_ADD_PLUGIN([vout_macosx])
3171 fi
3172
3173
3174 dnl
3175 dnl  freetype module
3176 dnl
3177 AC_ARG_ENABLE(freetype,
3178   [  --enable-freetype       freetype support   (default auto)])
3179 AC_ARG_ENABLE(fribidi,
3180   [  --enable-fribidi        fribidi support    (default auto)])
3181 AC_ARG_ENABLE(fontconfig,
3182   [  --enable-fontconfig     fontconfig support (default auto)])
3183
3184 if test "${enable_freetype}" != "no"; then
3185    PKG_CHECK_MODULES(FREETYPE, freetype2, [
3186       have_freetype=yes
3187       VLC_ADD_PLUGIN([freetype])
3188       VLC_ADD_CPPFLAGS([freetype skins2],[${FREETYPE_CFLAGS}])
3189       if test "${SYS}" = "mingw32"; then
3190         VLC_ADD_LIBS([freetype],[-liconv -lz])
3191       fi
3192       VLC_ADD_LIBS([freetype skins2],[${FREETYPE_LIBS}])
3193
3194       AC_CHECK_HEADERS(Carbon/Carbon.h,
3195                        [VLC_ADD_LIBS([freetype],[-Wl,-framework,Carbon])])
3196
3197       dnl fontconfig support
3198       if test "${SYS}" != "mingw32"; then
3199           if test "${enable_fontconfig}" != "no"; then
3200             AC_CHECK_HEADERS(fontconfig/fontconfig.h, [
3201               VLC_ADD_CPPFLAGS([freetype],[-DHAVE_FONTCONFIG])
3202               VLC_ADD_LIBS([freetype],[-lfontconfig])
3203             ],[AC_MSG_WARN([library fontconfig not found. Styles will be disabled in freetype])])
3204           fi
3205       else
3206           VLC_ADD_LIBS([freetype],[-lgdi32])
3207       fi
3208
3209       dnl fribidi support
3210       if test "${enable_fribidi}" != "no"; then
3211         PKG_CHECK_MODULES(FRIBIDI, fribidi, [
3212           VLC_ADD_CPPFLAGS([freetype skins2], [${FRIBIDI_CFLAGS} -DHAVE_FRIBIDI])
3213           VLC_ADD_LIBS([freetype skins2], [${FRIBIDI_LIBS}])
3214         ],[AC_MSG_WARN([library fribidi not found. Bidirectional support will be disabled in freetype])])
3215       fi
3216
3217   ],[
3218   have_freetype=no
3219   AS_IF([ test "${enable_freetype}" = "yes"],[
3220     AC_MSG_ERROR([Freetype2 package cannot be detected. Install Freetype2 development or configure with --disable-freetype.])
3221     ])
3222   ])
3223 fi
3224
3225
3226 dnl
3227 dnl  QuartzText vout module (iOS/Mac OS)
3228 dnl
3229 AC_ARG_ENABLE(macosx-quartztext,
3230   [  --enable-macosx-quartztext   Mac OS X quartz text module (default enabled on Mac OS X)])
3231 if test "x${enable_macosx_quartztext}" != "xno" &&
3232   (test "${SYS}" = "darwin" || test "${enable_macosx_quartztext}" = "yes")
3233 then
3234   VLC_ADD_PLUGIN([quartztext])
3235   VLC_ADD_LIBS([quartztext],[-Wl,-framework,ApplicationServices])
3236 fi
3237
3238 dnl
3239 dnl  SVG module
3240 dnl
3241 PKG_ENABLE_MODULES_VLC([SVG], [], [librsvg-2.0 >= 2.9.0], [SVG rendering library],[auto])
3242
3243 dnl
3244 dnl  android surface module
3245 dnl
3246 AC_ARG_ENABLE(android-surface,
3247   [  --enable-android-surface   Android Surface video output module (default disabled)])
3248 if test "${enable_android_surface}" = "yes"; then
3249   if test "${HAVE_ANDROID}" = "1"; then
3250      VLC_ADD_PLUGIN([android_surface])
3251      VLC_ADD_LDFLAGS([android_surface], [-ldl])
3252   fi
3253 fi
3254
3255
3256 dnl
3257 dnl  iOS vout module
3258 dnl
3259 AC_ARG_ENABLE(ios-vout,
3260   [  --enable-ios-vout    iOS video output module (default disabled)])
3261 if test "${enable_ios_vout}" = "yes"
3262 then
3263   VLC_ADD_PLUGIN([vout_ios])
3264   VLC_ADD_CFLAGS([vout_ios], [-DUSE_OPENGL_ES=1])
3265   VLC_ADD_LIBS([vout_ios], [-Wl,-framework,OpenGLES,-framework,QuartzCore,-framework,UIKit,-framework,Foundation])
3266 fi
3267
3268 dnl
3269 dnl  Windows DirectX module
3270 dnl
3271
3272 if test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"
3273 then
3274   VLC_ADD_PLUGIN([panoramix])
3275 fi
3276
3277 AC_ARG_ENABLE(directx,
3278   [  --enable-directx        Win32 DirectX support (default enabled on Win32)])
3279 if test "${enable_directx}" != "no"; then
3280   if test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"; then
3281       dnl DDraw
3282       AC_CHECK_HEADERS(ddraw.h,
3283       [ VLC_ADD_PLUGIN([directx aout_directx])
3284         VLC_ADD_LIBS([directx],[-luser32 -lgdi32])
3285       ],[AC_MSG_ERROR([Cannot find DirectX headers!])]
3286       )
3287
3288       dnl OpenGL
3289       AC_CHECK_HEADERS(GL/glext.h,
3290       [ VLC_ADD_PLUGIN([glwin32])
3291         VLC_ADD_LIBS([glwin32],[-lopengl32 -lgdi32])
3292       ],[],[
3293         #include <GL/gl.h>
3294       ])
3295
3296       dnl Direct3D
3297       AC_CHECK_HEADERS(d3d9.h,
3298       [ VLC_ADD_PLUGIN([direct3d])
3299         VLC_ADD_LIBS([direct3d],[-lgdi32])
3300       ])
3301       VLC_ADD_LIBS([direct3d directx glwin32],[-lole32])
3302   fi
3303 fi
3304
3305 dnl
3306 dnl  Windows Direct2D plugin
3307 dnl
3308 AC_ARG_ENABLE(direct2d,
3309   [  --enable-direct2d       Win7/VistaPU Direct2D support (default auto on Win32)],, [
3310   AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"], [
3311     enable_direct2d="no"
3312   ])
3313 ])
3314 AS_IF([test "${enable_direct2d}" != "no"], [
3315   AC_CHECK_HEADERS(d2d1.h, [
3316     VLC_ADD_PLUGIN([direct2d])
3317     VLC_ADD_LIBS([direct2d],[-lgdi32 -lole32])
3318   ], [
3319     AC_MSG_WARN([Cannot find Direct2D headers!])
3320   ])
3321 ])
3322
3323 dnl
3324 dnl  win32 GDI plugin
3325 dnl
3326 AC_ARG_ENABLE(wingdi,
3327   [  --enable-wingdi         Win32 GDI module (default enabled on Win32)])
3328 if test "${enable_wingdi}" != "no"; then
3329   if test "${SYS}" = "mingw32"; then
3330     VLC_ADD_PLUGIN([wingdi])
3331     VLC_ADD_LIBS([wingdi],[-lgdi32 -lole32])
3332   fi
3333   if test "${SYS}" = "mingwce"; then
3334     VLC_ADD_PLUGIN([wingdi wingapi])
3335     VLC_ADD_LIBS([wingdi],[-laygshell])
3336     VLC_ADD_LIBS([wingapi],[-laygshell])
3337   fi
3338 fi
3339
3340
3341 dnl
3342 dnl  Linux framebuffer module
3343 dnl
3344 AC_CHECK_HEADER([linux/fb.h], [
3345   VLC_ADD_PLUGIN([fb])
3346 ])
3347
3348
3349 dnl
3350 dnl  DirectFB module
3351 dnl  try to find using: 1 - given location; 2 - directfb-config; 3 - pkg-config
3352 dnl  TODO: support for static linking
3353 dnl
3354 AC_ARG_ENABLE(directfb,
3355   [  --enable-directfb       DirectFB support (default disabled)])
3356 AC_ARG_WITH(directfb,
3357   [  --with-directfb=PATH    path to DirectFB headers and libraries])
3358
3359 if test "${enable_directfb}" = "yes"; then
3360     have_directfb="false"
3361     CPPFLAGS_mydirectfb=
3362     LIBS_mydirectfb=
3363     if test "${with_directfb}" != "no" -a -n "${with_directfb}"; then
3364         dnl Trying the given location
3365         CPPFLAGS_save="${CPPFLAGS}"
3366         LIBS_save="${LIBS}"
3367
3368         CPPFLAGS_new="-I${with_directfb}/include -D_REENTRANT -D_GNU_SOURCE"
3369         LIBS_new="-L${with_directfb}/lib/fusion/.libs/ -L${with_directfb}/lib/direct/.libs/"
3370         LIBS_new="${LIBS_new} -L${with_directfb}/src/.libs/"
3371
3372         CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_new}"
3373         LIBS="${LIBS} ${LIBS_new}"
3374
3375         dnl FIXME: too obscure
3376         AC_CHECK_HEADER([directfb.h], [
3377             AC_CHECK_LIB([direct],[direct_initialize], [
3378                 AC_CHECK_LIB([fusion], [fusion_enter], [
3379                     AC_CHECK_LIB([directfb], [DirectFBInit], have_directfb="true", have_directfb="false")
3380                 ], have_directfb="false")
3381             ], have_directfb="false")
3382         ], have_directfb="false")
3383
3384         dnl Restore flags
3385         CPPFLAGS="${CPPFLAGS_save}"
3386         LIBS="${LIBS_save}"
3387
3388         if test "${have_directfb}" = "true"; then
3389             LIBS_mydirectfb="${LIBS_new} -lz $LIBDL -ldirectfb -lfusion -ldirect -lpthread"
3390             CPPFLAGS_mydirectfb="${CPPFLAGS_new}"
3391         fi
3392     else
3393         dnl Look for directfb-config
3394         AC_PATH_PROG(DIRECTFB_CONFIG, directfb-config, no, ${PATH})
3395         if test "${DIRECTFB_CONFIG}" != "no"; then
3396             CPPFLAGS_mydirectfb="`${DIRECTFB_CONFIG} --cflags`"
3397             LIBS_mydirectfb="`${DIRECTFB_CONFIG} --libs`"
3398             have_directfb="true"
3399         else
3400             dnl Trying with pkg-config
3401             PKG_CHECK_MODULES(DIRECTFB, directfb, [
3402                 CPPFLAGS_mydirectfb="${DIRECTFB_CFLAGS}"
3403                 LIBS_mydirectfb="${DIRECTFB_LIBS}"
3404                 have_directfb="true"
3405                 ], [have_directfb="false"])
3406         fi
3407     fi
3408     if test "${have_directfb}" = "true"; then
3409         VLC_ADD_PLUGIN([directfb])
3410         VLC_ADD_CPPFLAGS([directfb],[${CPPFLAGS_mydirectfb}])
3411         VLC_ADD_LIBS([directfb],[${LIBS_mydirectfb}])
3412     else
3413         AC_MSG_ERROR([cannot find directfb headers and/or libraries ])
3414     fi
3415 fi
3416
3417 dnl
3418 dnl  AA plugin
3419 dnl
3420 AC_ARG_ENABLE(aa,
3421   [  --enable-aa             aalib output (default disabled)])
3422 if test "${enable_aa}" = "yes"
3423 then
3424   AC_CHECK_HEADER(aalib.h,have_aa="true",have_aa="false")
3425   if test "${have_aa}" = "true"
3426   then
3427     VLC_ADD_PLUGIN([aa])
3428     VLC_ADD_LIBS([aa],[-laa])
3429     if test "${SYS}" != "mingw32"; then
3430       VLC_ADD_LIBS([aa],[${X_LIBS} ${X_PRE_LIBS} -lX11])
3431     fi
3432   fi
3433 fi
3434
3435 dnl
3436 dnl  libcaca plugin
3437 dnl
3438 PKG_ENABLE_MODULES_VLC([CACA], [], [caca >= 0.99.beta14], [libcaca output],[auto])
3439
3440 dnl
3441 dnl  Audio plugins
3442 dnl
3443
3444 EXTEND_HELP_STRING([Audio plugins:])
3445
3446 dnl
3447 dnl  Pulseaudio module
3448 dnl
3449 AC_ARG_ENABLE(pulse,
3450   [AS_HELP_STRING([--enable-pulse],
3451     [use the PulseAudio client library (default auto)])])
3452 have_pulse="no"
3453 AS_IF([test "${enable_pulse}" != "no"], [
3454   PKG_CHECK_MODULES([PULSE], [libpulse >= 0.9.22], [
3455     have_pulse="yes"
3456   ], [
3457     PKG_CHECK_MODULES([PULSE], [libpulse >= 0.9.16], [
3458       AS_IF([test "${no_x}" != "yes"], [
3459         have_pulse="yes"
3460         PULSE_LIBS="$PULSE_LIBS ${X_LIBS} ${X_PRE_LIBS} -lX11"
3461       ], [
3462         AS_IF([test "${enable_pulse}" = "yes"], [
3463           AC_MSG_ERROR([Xlib is required with PulseAudio pre-0.9.22 versions
3464 (see http://www.pulseaudio.org/ticket/799 for further reference).])
3465         ])
3466       ])
3467     ], [
3468       AS_IF([test "x${enable_pulse}" != "x"], [
3469         AC_MSG_ERROR([$PULSE_PKG_ERRORS. PulseAudio 0.9.22 or later required.])
3470       ])
3471     ])
3472   ])
3473 ])
3474 AM_CONDITIONAL([HAVE_PULSE], [test "${have_pulse}" = "yes"])
3475
3476 dnl
3477 dnl  ALSA module
3478 dnl
3479 AC_ARG_ENABLE(alsa,
3480   [AS_HELP_STRING([--enable-alsa],
3481     [support the Advanced Linux Sound Architecture (default auto)])],, [
3482   AS_IF([test "$SYS" = "linux" -a "${have_pulse}" = "no"], [
3483     enable_alsa="yes"
3484   ])
3485 ])
3486 have_alsa="no"
3487 AS_IF([test "${enable_alsa}" != "no"], [
3488   PKG_CHECK_MODULES([ALSA], [alsa >= 1.0.16], [
3489     have_alsa="yes"
3490   ], [
3491     AS_IF([test "x${enable_alsa}" != "x"], [
3492       AC_MSG_ERROR([$ALSA_PKG_ERRORS. alsa-lib 1.0.16 or later required.])
3493     ])
3494   ])
3495 ])
3496 AM_CONDITIONAL([HAVE_ALSA], [test "${have_alsa}" = "yes"])
3497
3498 dnl
3499 dnl  Open Sound System module
3500 dnl
3501 AC_ARG_ENABLE(oss,
3502   [AS_HELP_STRING([--enable-oss],
3503     [support the Open Sound System OSS (default enabled on BSD)])],, [
3504   AS_IF([test "$SYS" = "mingw32" -o "$SYS" = "mingwce" -o "$SYS" = "linux"], [
3505     enable_oss="no"
3506   ])
3507 ])
3508 have_oss="no"
3509 OSS_LIBS=""
3510 AS_IF([test "$enable_oss" != "no"], [
3511   AC_CHECK_HEADERS([soundcard.h sys/soundcard.h], [
3512     have_oss="yes"
3513     AC_CHECK_LIB(ossaudio, main, [
3514       OSS_LIBS="-lossaudio"
3515     ])
3516   ])
3517 ])
3518 AC_SUBST(OSS_LIBS)
3519 AM_CONDITIONAL([HAVE_OSS], [test "${have_oss}" = "yes"])
3520
3521 dnl
3522 dnl  Portaudio module
3523 dnl
3524 PKG_ENABLE_MODULES_VLC([PORTAUDIO], [], [portaudio-2.0], [Portaudio library support], [auto])
3525
3526 dnl
3527 dnl  win32 waveOut plugin
3528 dnl
3529 AC_ARG_ENABLE(waveout,
3530   [  --enable-waveout        Win32 waveOut module (default enabled on Win32)])
3531 if test "${enable_waveout}" != "no"; then
3532   if test "${SYS}" = "mingw32"; then
3533     VLC_ADD_PLUGIN([waveout])
3534     VLC_ADD_LIBS([waveout],[-lwinmm])
3535   fi
3536   if test "${SYS}" = "mingwce"; then
3537     VLC_ADD_PLUGIN([waveout])
3538   fi
3539 fi
3540
3541 dnl
3542 dnl  CoreAudio plugin
3543 dnl
3544 AC_ARG_ENABLE(macosx-audio,
3545   [  --enable-macosx-audio   Mac OS X audio module (default enabled on MacOS X)])
3546 if test "x${enable_macosx_audio}" != "xno" &&
3547   (test "${SYS}" = "darwin" || test "${enable_macosx_audio}" = "yes")
3548 then
3549   AC_CHECK_HEADERS(CoreAudio/CoreAudio.h,
3550     [ VLC_ADD_PLUGIN([auhal])
3551       VLC_ADD_LIBS([auhal],[-Wl,-framework,CoreAudio,-framework,AudioUnit,-framework,AudioToolbox,-framework,Carbon])
3552     ], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
3553 fi
3554
3555 dnl
3556 dnl  AudioQueue plugin
3557 dnl
3558 AC_ARG_ENABLE(audioqueue,
3559   [  --enable-audioqueue     AudioQueue audio module (default disabled)])
3560 if test "${enable_audioqueue}" = "yes"
3561 then
3562   VLC_ADD_PLUGIN([audioqueue])
3563   VLC_ADD_LIBS([audioqueue], [-Wl,-framework,AudioToolbox,-framework,CoreFoundation])
3564 fi
3565
3566 dnl
3567 dnl  JACK modules
3568 dnl
3569 PKG_ENABLE_MODULES_VLC([JACK], [jack access_jack], [jack], [JACK audio I/O modules],[auto])
3570
3571 dnl
3572 dnl  OpenSLES Android
3573 dnl
3574 AC_ARG_ENABLE(opensles,
3575   [  --enable-opensles       Android OpenSL ES audio module (default disabled)])
3576 if test "${HAVE_ANDROID}" = "1"; then
3577   if test "${enable_opensles}" = "yes"; then
3578       AC_CHECK_HEADERS(SLES/OpenSLES.h,
3579         [ VLC_ADD_PLUGIN([opensles_android]) ],
3580         [ AC_MSG_ERROR([cannot find OpenSLES headers])] )
3581   fi
3582 fi
3583
3584 dnl
3585 dnl libsamplerate plugin
3586 dnl
3587 PKG_ENABLE_MODULES_VLC([SAMPLERATE], [], [samplerate], [Resampler with libsamplerate], [auto])
3588
3589 dnl
3590 dnl  Interface plugins
3591 dnl
3592
3593 EXTEND_HELP_STRING([Interface plugins:])
3594
3595 dnl
3596 dnl Skins2 module
3597 dnl
3598 AC_ARG_ENABLE(skins2,
3599   [AS_HELP_STRING([--enable-skins2], [skins interface module (default auto)])])
3600 AS_IF([test "${enable_skins2}" != "no"], [
3601   have_skins_deps="yes"
3602   AS_IF([test "${SYS}" = "mingw32"], [
3603     VLC_ADD_CPPFLAGS([skins2],[-U_OFF_T_ -U_off_t -Imodules/gui/skins2 -DWIN32_SKINS])
3604     VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
3605     VLC_ADD_LIBS([skins2],[-loleaut32 -lwinspool -lwinmm -lshell32 -ladvapi32 -lwsock32 -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32  -lmsimg32 -luser32])
3606
3607   ], [test "${SYS}" = "darwin"], [
3608     VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 -DMACOSX_SKINS])
3609     VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
3610     VLC_ADD_LIBS([skins2],[-Wl,-framework,Carbon])
3611
3612   ], [
3613     PKG_CHECK_MODULES([XPM], [xpm],, [have_skins_deps="no"])
3614     PKG_CHECK_MODULES([XINERAMA], [xinerama],, [have_skins_deps="no"])
3615     PKG_CHECK_MODULES([XEXT], [xext],, [have_skins_deps="no"])
3616     VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 ${X_CFLAGS} ${XEXT_CFLAGS} ${XPM_CFLAGS} -DX11_SKINS])
3617     VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
3618     VLC_ADD_LIBS([skins2],[${X_LIBS} ${X_PRE_LIBS} ${XEXT_LIBS} ${XPM_LIBS} ${XINERAMA_LIBS} -lX11])
3619
3620   ])
3621   AS_IF([test "${have_freetype}" != "yes"], [
3622     have_skins_deps="no"
3623   ])
3624
3625   AS_IF([test "${have_skins_deps}" = "no"], [
3626     AS_IF([test "x${enable_skins2}" = "x"], [
3627       AC_MSG_WARN([Skins2 interface disabled due to missing dependencies.])
3628     ], [
3629       AC_MSG_ERROR([Skins2 interface requires FreeType, libxpm, libxext and libxinerama])
3630     ])
3631     enable_skins2="no"
3632   ], [
3633     VLC_ADD_PLUGIN([skins2])
3634     ALIASES="${ALIASES} svlc"
3635   ])
3636 ])
3637 AM_CONDITIONAL(BUILD_SKINS, [test "${enable_skins2}" = "yes"])
3638
3639 AC_ARG_ENABLE(libtar,
3640   [  --enable-libtar         libtar support for skins2 (default auto)])
3641 AS_IF([test "${enable_skins2}" = "yes" && test "${enable_libtar}" != "no"], [
3642   AC_CHECK_HEADERS(libtar.h, [
3643     VLC_ADD_LIBS([skins2],[-ltar])
3644   ])
3645 ])
3646
3647 dnl
3648 dnl Hildon UI
3649 dnl
3650 AC_ARG_ENABLE(hildon,
3651   [  --enable-hildon         Hildon touchscreen UI (default disabled)])
3652 AS_IF([test "${enable_hildon}" = "yes"], [
3653   PKG_CHECK_MODULES(HILDON, [hildon-1], [
3654     PKG_CHECK_MODULES(HILDON_FM, hildon-fm-2, [
3655       VLC_ADD_CFLAGS([hildon],[${HILDON_FM_CFLAGS} -DHAVE_HILDON_FM])
3656       VLC_ADD_LIBS([hildon],[${HILDON_FM_LIBS}])
3657     ], [
3658       AC_MSG_WARN(hildon-fm-2 not found)
3659     ])
3660     VLC_ADD_CFLAGS([hildon],[${HILDON_CFLAGS} ${X_CFLAGS}])
3661     VLC_ADD_LIBS([hildon],[${HILDON_LIBS} ${X_LIBS} ${X_PRE_LIBS} -lX11])
3662     VLC_ADD_PLUGIN([hildon])
3663     ALIASES="${ALIASES} mvlc"
3664   ], [
3665     AS_IF([test "${enable_hildon}" = "yes"],[
3666       AC_MSG_ERROR([Hildon libraries not found])
3667     ])
3668     enable_hildon="no"
3669   ])
3670 ])
3671 AM_CONDITIONAL(BUILD_HILDON, [test "${enable_hildon}" = "yes"])
3672
3673 dnl
3674 dnl QT 4
3675 dnl
3676 AC_ARG_ENABLE(qt4,
3677   [  --enable-qt4            Qt 4 support (default enabled) ],, [
3678   AS_IF([test "${SYS}" = "darwin"], [enable_qt4=no])
3679 ])
3680 AS_IF([test "${enable_qt4}" != "no"], [
3681   PKG_CHECK_MODULES(QT4, [QtCore QtGui >= 4.6.0], [
3682     VLC_ADD_PLUGIN([qt4])
3683     VLC_ADD_LIBS([qt4],[${QT4_LIBS}])
3684     VLC_ADD_CXXFLAGS([qt4],[${QT4_CFLAGS}])
3685     ALIASES="${ALIASES} qvlc"
3686
3687     AC_LANG_PUSH([C++])
3688     CPPFLAGS_save="${CPPFLAGS}"
3689
3690     AC_MSG_CHECKING([whether Qt uses X11])
3691     CPPFLAGS="${CPPFLAGS} ${QT4_CFLAGS}"
3692     AC_PREPROC_IFELSE([AC_LANG_SOURCE([
3693 #include <QWidget>
3694 #if !defined (Q_WS_X11)
3695 # error Fail
3696 #endif
3697     ])], [
3698       AC_MSG_RESULT([yes])
3699       VLC_ADD_LIBS([qt4],[${X_LIBS} ${X_PRE_LIBS} -lX11])
3700       VLC_ADD_CXXFLAGS([qt4],[${X_CFLAGS}])
3701     ], [
3702       AC_MSG_RESULT([no])
3703     ])
3704
3705     CPPFLAGS="${CPPFLAGS_save}"
3706     AC_LANG_POP([C++])
3707
3708     AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"], [
3709         VLC_ADD_LIBS([qt4],[-lole32])
3710     ])
3711     AS_IF([test "${SYS}" = "darwin" ],[
3712          VLC_ADD_LIBS([qt4], [-Wl,-framework,Cocoa])
3713     ])
3714     AC_PATH_PROGS(MOC, [moc-qt4 moc], moc,`eval $PKG_CONFIG --variable=exec_prefix QtCore`/bin)
3715     AC_PATH_PROG(RCC, rcc, rcc,`eval $PKG_CONFIG --variable=exec_prefix QtCore`/bin)
3716     AC_PATH_PROGS(UIC, [uic-qt4 uic], uic,`eval $PKG_CONFIG --variable=exec_prefix QtCore`/bin)
3717   ], [
3718     AS_IF([test "${enable_qt4}" = "yes"],[
3719       AC_MSG_ERROR([Qt 4 library not found])
3720     ],[
3721       AC_MSG_WARN([Qt 4 library not found])
3722     ])
3723     enable_qt4="no"
3724   ])
3725 ])
3726 AM_CONDITIONAL(ENABLE_QT4, [test "x$enable_qt4" != "xno"])
3727
3728 dnl
3729 dnl Simple test for skins2 dependency
3730 dnl
3731 AS_IF([test "${enable_skins2}" != "no" && test "x$enable_qt4" = "xno"], [
3732   AC_MSG_ERROR([The skins2 module depends on a the Qt4 development package. Without it you won't be able to open any dialog box from the interface, which makes the skins2 interface rather useless. Install the Qt4 development package or alternatively you can also configure with: --disable-qt4 --disable-skins2.])
3733 ])
3734
3735 dnl
3736 dnl  MacOS X gui module
3737 dnl
3738 AC_ARG_ENABLE(macosx,
3739   [  --enable-macosx         Mac OS X gui support (default enabled on Mac OS X)])
3740 if test "x${enable_macosx}" != "xno" &&
3741 (test "${SYS}" = "darwin" || test "${enable_macosx}" = "yes")
3742 then
3743   VLC_ADD_LIBS([macosx minimal_macosx],[-Wl,-framework,Cocoa])
3744   VLC_ADD_LIBS([macosx minimal_macosx],[-Wl,-framework,OpenGL])
3745   VLC_ADD_LIBS([macosx minimal_macosx],            [-Wl,-framework,Carbon])
3746   VLC_ADD_LIBS([macosx minimal_macosx],            [-Wl,-framework,CoreServices])
3747   VLC_ADD_LIBS([macosx minimal_macosx],            [-Wl,-framework,AGL])
3748   VLC_ADD_LIBS([macosx],                           [-Wl,-framework,QTKit])
3749   VLC_ADD_LIBS([macosx],                           [-Wl,-framework,IOKit])
3750   VLC_ADD_LIBS([macosx],                           [-F${CONTRIB_DIR}/Sparkle -Wl,-framework,Sparkle])
3751   VLC_ADD_OBJCFLAGS([macosx],                         [-F${CONTRIB_DIR}/Sparkle])
3752   VLC_ADD_LIBS([macosx],                           [-F${CONTRIB_DIR}/BGHUDAppKit -Wl,-framework,BGHUDAppKit])
3753   VLC_ADD_OBJCFLAGS([macosx],                         [-F${CONTRIB_DIR}/BGHUDAppKit])
3754   dnl For bug report
3755   VLC_ADD_LIBS([macosx],                           [-Wl,-framework,AddressBook])
3756   VLC_ADD_LIBS([macosx],                           [-Wl,-framework,WebKit])
3757   VLC_ADD_OBJCFLAGS([macosx minimal_macosx], [-fobjc-exceptions] )
3758
3759   VLC_ADD_PLUGIN([macosx minimal_macosx])
3760 fi
3761
3762 dnl
3763 dnl  MacOS X dialor provider
3764 dnl
3765 AC_ARG_ENABLE(macosx-dialog-provider,
3766   [  --enable-macosx-dialog-provider Mac OS X dialog module (default enabled on Mac OS X)])
3767 if test "x${enable_macosx_dialog_provider}" != "xno" &&
3768   (test "${SYS}" = "darwin" || test "${enable_macosx_dialog_provider}" = "yes")
3769 then
3770   VLC_ADD_LIBS([macosx_dialog_provider],[-Wl,-framework,Cocoa])
3771   VLC_ADD_PLUGIN([macosx_dialog_provider])
3772 fi
3773
3774 dnl
3775 dnl  ncurses module
3776 dnl
3777 AC_ARG_ENABLE(ncurses,
3778   [  --disable-ncurses       ncurses interface support (default disabled)],
3779   [if test "${enable_ncurses}" != "no"; then
3780     AC_CHECK_HEADER(ncurses.h,
3781       [AC_CHECK_LIB(ncursesw, mvprintw,
3782         [VLC_ADD_PLUGIN([ncurses])
3783         VLC_ADD_LIBS([ncurses],[-lncursesw])
3784         ALIASES="${ALIASES} nvlc"
3785         AC_CHECK_LIB(ncursesw, tgetent, [],
3786           AC_CHECK_LIB(tinfow, tgetent, [VLC_ADD_LIBS([ncurses],[-ltinfow])],
3787             [AC_CHECK_LIB(tinfo, tgetent, [VLC_ADD_LIBS([ncurses],[-ltinfo])],
3788               [AS_IF([test "${enable_ncurses}" = "yes"],
3789                 [AC_MSG_ERROR([tgetent not found in ncursesw tinfow tinfo]
3790                )])])
3791             ]
3792           )
3793         )
3794         ],
3795           [AS_IF([test "${enable_ncurses}" = "yes"], [
3796             AC_MSG_ERROR([libncursesw not found])])]
3797         )],
3798         [AS_IF([test "${enable_ncurses}" = "yes"], [
3799           AC_MSG_ERROR([ncurses.h not found])])]
3800         )
3801   fi]
3802 )
3803
3804 dnl
3805 dnl  XOSD plugin
3806 dnl
3807 AC_ARG_ENABLE(xosd,
3808   [  --enable-xosd           xosd interface support (default disabled)])
3809 if test "${enable_xosd}" = "yes"
3810 then
3811   AC_CHECK_HEADERS(xosd.h,
3812     AC_CHECK_LIB(xosd, xosd_set_horizontal_offset, [
3813       VLC_ADD_PLUGIN([xosd])
3814       VLC_ADD_LIBS([xosd],[-lxosd])
3815     ])
3816   )
3817 fi
3818
3819 dnl
3820 dnl Framebuffer (overlay) plugin
3821 dnl
3822 AC_ARG_ENABLE(fbosd,
3823   [  --enable-fbosd          fbosd interface support (default disabled)])
3824 if test "${enable_fbosd}" = "yes"
3825 then
3826   AC_CHECK_HEADERS(linux/fb.h, [
3827     VLC_ADD_PLUGIN([fbosd])
3828  ])
3829 fi
3830
3831 dnl
3832 dnl  Lirc plugin
3833 dnl
3834 AC_ARG_ENABLE(lirc,
3835   [  --enable-lirc           lirc support (default disabled)])
3836 if test "${enable_lirc}" = "yes"
3837 then
3838   AC_CHECK_HEADER(lirc/lirc_client.h, AC_CHECK_LIB(lirc_client, lirc_init, have_lirc="true", have_lirc="false"),have_lirc="false")
3839   if test "${have_lirc}" = "true"
3840   then
3841     VLC_ADD_PLUGIN([lirc])
3842     VLC_ADD_LIBS([lirc],[-llirc_client])
3843   fi
3844 fi
3845
3846 EXTEND_HELP_STRING([Visualisations and Video filter plugins:])
3847 dnl
3848 dnl Visualisation plugin
3849 dnl
3850 AC_ARG_ENABLE(visual,
3851   [  --enable-visual         visualisation plugin (default enabled)])
3852 if test "${enable_visual}" != "no"
3853 then
3854     VLC_ADD_PLUGIN([visual])
3855 fi
3856
3857 dnl
3858 dnl  goom visualization plugin
3859 dnl
3860 PKG_ENABLE_MODULES_VLC([GOOM], [], [libgoom2], [goom visualization plugin], [auto])
3861
3862 dnl
3863 dnl libprojectM visualization plugin
3864 dnl
3865 AC_ARG_ENABLE(projectm,
3866   [  --enable-projectm       projectM visualization plugin (default enabled)])
3867 AS_IF([test "${enable_projectm}" != "no"],
3868   [
3869     PKG_CHECK_MODULES(PROJECTM, libprojectM,
3870     [
3871       VLC_ADD_PLUGIN([projectm])
3872       VLC_ADD_CXXFLAGS([projectm],[$PROJECTM_CFLAGS])
3873       VLC_ADD_LIBS([projectm],[$PROJECTM_LIBS])
3874       PKG_CHECK_MODULES(PROJECTM2, [libprojectM >= 2.0.0],
3875         [ AC_DEFINE([HAVE_PROJECTM2], 1, [Define to 1 if using libprojectM 2.x]) ],
3876         [ AC_MSG_WARN( [Using libprojectM version 1] )
3877       ])
3878     ],[
3879       AC_MSG_WARN([libprojectM library not found])
3880     ])
3881   ])
3882
3883 dnl
3884 dnl  AtmoLight (homemade Philips Ambilight clone)
3885 dnl
3886 AC_ARG_ENABLE(atmo,
3887 AS_HELP_STRING([--disable-atmo],[AtmoLight (homemade Philips Ambilight clone)
3888                 (default enabled)]),, [enable_atmo="yes"])
3889 AS_IF([test "${enable_atmo}" != no], [
3890   AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "linux"], [
3891     AC_LANG_PUSH(C++)
3892     VLC_ADD_PLUGIN([atmo])
3893     AC_LANG_POP(C++)
3894   ])
3895 ])
3896
3897 EXTEND_HELP_STRING([Service Discovery plugins:])
3898 dnl
3899 dnl  Bonjour services discovery
3900 PKG_ENABLE_MODULES_VLC([BONJOUR], [], [avahi-client >= 0.6], [Bonjour services discovery], [auto])
3901
3902 dnl
3903 dnl  libudev services discovery
3904 PKG_ENABLE_MODULES_VLC([UDEV], [], [libudev >= 142], [Linux udev services discovery], [auto])
3905
3906 dnl
3907 dnl MTP devices services discovery
3908 PKG_ENABLE_MODULES_VLC([MTP], [mtp access_mtp], [libmtp >= 1.0.0], [MTP devices support], [auto])
3909
3910 dnl
3911 dnl UPnP Plugin (Intel SDK)
3912 dnl
3913 PKG_ENABLE_MODULES_VLC([UPNP], [upnp], [libupnp], [Intel UPNP SDK],[auto])
3914 VLC_ADD_CXXFLAGS([upnp],[${UPNP_CFLAGS}])
3915
3916 EXTEND_HELP_STRING([Misc options:])
3917
3918 dnl
3919 dnl  libxml2 module
3920 dnl
3921 PKG_ENABLE_MODULES_VLC([LIBXML2], [xml], [libxml-2.0 >= 2.5], [libxml2 support],[auto])
3922
3923
3924 dnl
3925 dnl libgcrypt
3926 dnl
3927 AC_ARG_ENABLE(libgcrypt,
3928   [  --disable-libgcrypt     gcrypt support (default enabled)])
3929 AS_IF([test "${enable_libgcrypt}" != "no"], [
3930   AC_CHECK_DECL([GCRYCTL_SET_THREAD_CBS], [
3931     libgcrypt-config --version >/dev/null || \
3932         AC_MSG_ERROR([gcrypt.h present but libgcrypt-config could not be found])
3933     AC_CHECK_LIB(gcrypt, gcry_control, [
3934       have_libgcrypt="yes"
3935       GCRYPT_CFLAGS="`libgcrypt-config --cflags`"
3936       GCRYPT_LIBS="`libgcrypt-config --libs`"
3937     ], [
3938       AC_MSG_ERROR([libgcrypt not found. Install libgcrypt or use --disable-libgcrypt. Have a nice day.])
3939     ], [`libgcrypt-config --libs`])
3940   ], [
3941     AC_MSG_ERROR([libgcrypt version 1.1.94 or higher not found. Install libgcrypt or use --disable-libgcrypt. Have a nice day.])
3942   ], [#include <gcrypt.h>]
3943   )
3944 ])
3945
3946 if test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"; then
3947   AS_IF([test "${have_libgcrypt}" = "yes"],[
3948     VLC_ADD_LIBS([rtp stream_out_rtp], [${GCRYPT_LIBS}])
3949   ])
3950 fi
3951 AC_SUBST(GCRYPT_CFLAGS)
3952 AC_SUBST(GCRYPT_LIBS)
3953 AM_CONDITIONAL([HAVE_GCRYPT], [test "${have_libgcrypt}" = "yes"])
3954
3955 dnl
3956 dnl TLS/SSL
3957 dnl
3958 AC_ARG_ENABLE(gnutls,
3959   [  --enable-gnutls         GNU TLS TLS/SSL support (default enabled)])
3960
3961 AS_IF([test "${have_libgcrypt}" != "yes"], [
3962   AS_IF([test "${enable_gnutls}" = "yes"], [
3963     AC_MSG_ERROR([--enable-gnutls and --disable-libgcrypt are mutually exclusive.])
3964   ])
3965   enable_gnutls="no"
3966 ])
3967 AS_IF([test "${enable_gnutls}" != "no"], [
3968   PKG_CHECK_MODULES(GNUTLS, [gnutls >= 2.0.0], [
3969     VLC_ADD_PLUGIN([gnutls])
3970     VLC_ADD_CFLAGS([gnutls], [$GNUTLS_CFLAGS])
3971     AS_IF([test "${SYS}" = "mingw32"], [
3972       dnl pkg-config --libs gnutls omits these
3973       VLC_ADD_LIBS([gnutls], [-lz ${LTLIBINTL} -lcrypt32])
3974     ])
3975     VLC_ADD_LIBS([gnutls], [${GCRYPT_LIBS}])
3976     VLC_ADD_CFLAGS([gnutls], [${GCRYPT_CFLAGS}])
3977     VLC_ADD_LIBS([gnutls], [$GNUTLS_LIBS])
3978   ], [
3979     AS_IF([test "${enable_gnutls}" = "yes"], [
3980       AC_MSG_ERROR([GNU TLS not present or too old (version 2.0.0 required)])
3981     ])
3982   ])
3983 ])
3984
3985
3986 dnl
3987 dnl RemoteOSD plugin (VNC client as video filter)
3988 dnl
3989 AC_MSG_CHECKING([whether to enable the RemoteOSD plugin])
3990 AS_IF([test "${have_libgcrypt}" = "yes"],[
3991   AC_MSG_RESULT(yes)
3992   VLC_ADD_PLUGIN([remoteosd])
3993   VLC_ADD_LIBS([remoteosd], ${GCRYPT_LIBS})
3994   VLC_ADD_CFLAGS([remoteosd], ${GCRYPT_CFLAGS})
3995 ], [
3996   AC_MSG_RESULT(no)
3997   AC_MSG_WARN([libgcrypt support required for RemoteOSD plugin])
3998 ])
3999
4000
4001 dnl
4002 dnl RAOP plugin
4003 dnl
4004 AC_MSG_CHECKING([whether to enable the RAOP plugin])
4005 AS_IF([test "${have_libgcrypt}" = "yes"], [
4006   AC_MSG_RESULT(yes)
4007   VLC_ADD_PLUGIN([stream_out_raop])
4008   VLC_ADD_LIBS([stream_out_raop], [${GCRYPT_LIBS} -lgpg-error])
4009   VLC_ADD_CFLAGS([stream_out_raop], [${GCRYPT_CFLAGS}])
4010 ], [
4011   AC_MSG_RESULT(no)
4012   AC_MSG_WARN([libgcrypt support required for RAOP plugin])
4013 ])
4014
4015
4016 dnl
4017 dnl Nokia MCE plugin (Maemo screen unblanking)
4018 dnl
4019 PKG_CHECK_MODULES([MCE], [dbus-1 mce], [VLC_ADD_PLUGIN([mce])], [true])
4020
4021
4022 AS_IF([test -f "/etc/maemo_version"], [
4023   AC_DEFINE([HAVE_MAEMO], 1, [Define to 1 if building for the Maemo platform.])
4024 ])
4025
4026
4027 dnl
4028 dnl Taglib plugin
4029 dnl
4030 AC_ARG_ENABLE(taglib,
4031   [AS_HELP_STRING([--disable-taglib],
4032     [do not use TagLib (default enabled)])])
4033 AS_IF([test "${enable_taglib}" != "no"], [
4034   PKG_CHECK_MODULES(TAGLIB, taglib >= 1.5, [
4035     VLC_ADD_PLUGIN([taglib])
4036     VLC_ADD_LIBS([taglib],[$TAGLIB_LIBS -lz])
4037     VLC_ADD_CXXFLAGS([taglib],[$TAGLIB_CFLAGS])
4038   ], [
4039     AC_MSG_WARN(TagLib library not found)])
4040 ])
4041
4042
4043 dnl
4044 dnl update checking system
4045 dnl
4046 AC_ARG_ENABLE(update-check,
4047   [  --enable-update-check   update checking system (default disabled)])
4048 if test "${enable_update_check}" = "yes"
4049 then
4050   if test "${have_libgcrypt}" != "yes"
4051   then
4052     AC_MSG_ERROR([libgcrypt is required for update checking system])
4053   fi
4054   VLC_ADD_LIBS([libvlccore], [${GCRYPT_LIBS}])
4055   VLC_ADD_CFLAGS([libvlccore], [${GCRYPT_CFLAGS}])
4056   AC_DEFINE([UPDATE_CHECK], 1, [Define if you want to use the VLC update mechanism])
4057 fi
4058
4059 dnl
4060 dnl Growl notification plugin
4061 dnl
4062 AC_ARG_ENABLE(growl,
4063   [  --enable-growl          growl notification plugin (default disabled)],,
4064   [enable_growl=no])
4065 AS_IF([test "${enable_growl}" != "no"], [
4066     AC_CHECK_HEADERS(${CONTRIB_DIR}/Growl/Growl.framework/Versions/A/Headers/GrowlDefines.h, [
4067       VLC_ADD_PLUGIN([growl])
4068       VLC_ADD_LIBS([growl], [-F${CONTRIB_DIR}/Growl -Wl,-framework,Growl,-framework,CoreFoundation])
4069       VLC_ADD_OBJCFLAGS([growl], [-F${CONTRIB_DIR}/Growl])
4070       VLC_ADD_OBJCFLAGS([growl], [-fobjc-exceptions] )
4071     ])
4072   ]
4073 )
4074
4075 dnl
4076 dnl Libnotify notification plugin
4077 dnl
4078 PKG_ENABLE_MODULES_VLC([NOTIFY], [], [libnotify gtk+-2.0], [libnotify notification], [auto])
4079
4080 dnl
4081 dnl media library
4082 dnl
4083 AC_ARG_ENABLE(media-library,
4084     [  --enable-media-library  media library (default disabled)])
4085 AS_IF([test "${enable_media_library}" = "yes"], [
4086   AC_DEFINE([MEDIA_LIBRARY], 1, [Define if you want to use the VLC media library])
4087   VLC_ADD_CPPFLAGS([qt4],"-DMEDIA_LIBRARY")
4088   VLC_ADD_PLUGIN([media_library])
4089
4090 dnl
4091 dnl SQLite
4092 dnl
4093   AS_IF([test "${SYS}" != "darwin"], [
4094     PKG_ENABLE_MODULES_VLC([SQLITE], [], [sqlite3 >= 3.6.0], [sqlite3], [auto])
4095   ], [
4096     AS_IF([test "${enable_sqlite}" != "no"], [
4097       AC_CHECK_HEADERS(sqlite3.h, [
4098         VLC_ADD_PLUGIN([sqlite])
4099         VLC_ADD_LIBS([sqlite], [-lsqlite3])
4100       ], [
4101         AC_MSG_ERROR([sqlite3 is required for the media library])
4102       ])
4103     ])
4104   ])
4105 ])
4106
4107
4108 dnl
4109 dnl  Endianness check
4110 dnl
4111 AC_C_BIGENDIAN
4112 AS_IF([test "${ac_cv_c_bigendian}" = "yes"], [
4113   DEFS_BIGENDIAN="-DWORDS_BIGENDIAN=1"
4114 ], [
4115   DEFS_BIGENDIAN=""
4116 ])
4117 AC_SUBST(DEFS_BIGENDIAN)
4118
4119 dnl
4120 dnl Where to install KDE solid .desktop
4121 dnl
4122 AC_ARG_VAR([KDE4_CONFIG], [kde4-config utility])
4123 AS_IF([test "x$KDE4_CONFIG" = "x"], [
4124   KDE4_CONFIG="kde4-config"
4125 ])
4126
4127 AC_ARG_WITH(kde-solid,
4128   AS_HELP_STRING([--with-kde-solid=PATH],
4129                  [KDE Solid actions directory (auto)]),, [
4130
4131 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce" ; then
4132   with_kde_solid="yes"
4133 fi
4134 ])
4135 soliddatadir=""
4136 AS_IF([test "${with_kde_solid}" != "no"], [
4137   AS_IF([test "${with_kde_solid}" = "yes"], [
4138     kde4datadir="`${KDE4_CONFIG} --install data`"
4139     AS_IF([test "x$kde4datadir" = "x"], [kde4datadir='${datadir}/kde4/apps'])
4140     soliddatadir="${kde4datadir}/solid/actions"
4141   ], [
4142     soliddatadir="${with_kde_solid}"
4143   ])
4144 ])
4145 AC_SUBST(soliddatadir)
4146 AM_CONDITIONAL(KDE_SOLID, [test "x${soliddatadir}" != "x"])
4147
4148 dnl
4149 dnl  DLL loader copied from MPlayer copied from somewhere else (WINE ?)
4150 dnl
4151 loader=false
4152 AC_ARG_ENABLE(loader,
4153   AS_HELP_STRING([--enable-loader],[build DLL loader for ELF i386 platforms
4154           (default disabled)]))
4155 AM_CONDITIONAL(LOADER, [test "${enable_loader}" = "yes"])
4156 AS_IF([test "${enable_loader}" = "yes"],
4157   [ VLC_ADD_PLUGIN([dmo])
4158     VLC_ADD_CPPFLAGS([dmo quicktime realvideo],[-I\\\${top_srcdir}/modules/codec/loader])
4159     VLC_ADD_LIBS([dmo quicktime realvideo],[\\\${top_builddir}/modules/codec/loader/libloader.la])
4160     VLC_ADD_CPPFLAGS([realvideo], [-DLOADER])
4161     VLC_ADD_LIBS([dmo quicktime], [-lpthread])
4162   ])
4163
4164 EXTEND_HELP_STRING([Components:])
4165
4166 dnl
4167 dnl  the VLC binary
4168 dnl
4169 AC_ARG_ENABLE(vlc,
4170   [  --enable-vlc            build the VLC media player (default enabled)])
4171 AM_CONDITIONAL(BUILD_VLC, [test "${enable_vlc}" != "no"])
4172
4173 AC_ARG_ENABLE(macosx-vlc-app,
4174   [  --enable-macosx-vlc-app build the VLC media player (default enabled on Mac OS X)])
4175 AM_CONDITIONAL(BUILD_MACOSX_VLC_APP, [test "${enable_macosx_vlc_app}" != "no" &&
4176     (test "${SYS}" = "darwin" || test "${enable_macosx_vlc_app}" = "yes") ])
4177
4178
4179 dnl
4180 dnl Pic and shared libvlc stuff
4181 dnl
4182 AS_IF([test "${SYS}" = "mingw32"], [
4183   FILE_LIBVLCCORE_DLL="!define LIBVLCCORE_DLL libvlccore.dll"
4184   FILE_LIBVLC_DLL="!define LIBVLC_DLL libvlc.dll"
4185 ])
4186
4187 dnl
4188 dnl  Stuff used by the program
4189 dnl
4190 VERSION_MESSAGE="${VERSION} ${CODENAME}"
4191 COPYRIGHT_MESSAGE="Copyright © ${COPYRIGHT_YEARS} the VideoLAN team"
4192 AC_DEFINE_UNQUOTED(VERSION_MESSAGE, "${VERSION_MESSAGE}", [Simple version string])
4193 AC_DEFINE_UNQUOTED(COPYRIGHT_MESSAGE, "${COPYRIGHT_MESSAGE}", [Copyright string])
4194 AC_DEFINE_UNQUOTED(COPYRIGHT_YEARS, "${COPYRIGHT_YEARS}", [The copyright years])
4195 AC_DEFINE_UNQUOTED(CONFIGURE_LINE, "${CONFIGURE_LINE}", [The ./configure command line])
4196 AC_DEFINE_UNQUOTED(PACKAGE_VERSION_MAJOR,${VERSION_MAJOR}, [version major number])
4197 AC_DEFINE_UNQUOTED(PACKAGE_VERSION_MINOR,${VERSION_MINOR}, [version minor number])
4198 AC_DEFINE_UNQUOTED(PACKAGE_VERSION_REVISION,${VERSION_REVISION}, [version revision number])
4199 AC_DEFINE_UNQUOTED(PACKAGE_VERSION_EXTRA,${VERSION_EXTRA}, [version extra number])
4200 AC_DEFINE_UNQUOTED(PACKAGE_VERSION_DEV,"${VERSION_DEV}", [version development string])
4201 AC_SUBST(COPYRIGHT_MESSAGE)
4202 AC_SUBST(VERSION_MESSAGE)
4203 AC_SUBST(VERSION_MAJOR)
4204 AC_SUBST(VERSION_MINOR)
4205 AC_SUBST(VERSION_REVISION)
4206 AC_SUBST(VERSION_EXTRA)
4207 AC_SUBST(COPYRIGHT_YEARS)
4208 AC_DEFINE_UNQUOTED(VLC_COMPILE_BY, "`whoami`", [user who ran configure])
4209 AC_DEFINE_UNQUOTED(VLC_COMPILE_HOST, "`hostname -f 2>/dev/null || hostname`", [host which ran configure])
4210 AC_DEFINE_UNQUOTED(VLC_COMPILER, "`$CC -v 2>&1 | tail -n 1`", [compiler])
4211 dnl
4212 dnl  Handle substvars that use $(top_srcdir)
4213 dnl
4214 CPPFLAGS_save="-I\$(top_srcdir)/include -I\$(top_builddir)/include ${CPPFLAGS_save}"
4215
4216 dnl
4217 dnl  Restore *FLAGS
4218 dnl
4219 VLC_RESTORE_FLAGS
4220
4221 dnl
4222 dnl Sort the modules list
4223 dnl
4224 PLUGINS=$( (for i in `echo $PLUGINS`; do echo $i; done)|sort|xargs )
4225
4226 dnl
4227 dnl  Configuration is finished
4228 dnl
4229 AC_SUBST(SYS)
4230 AC_SUBST(ARCH)
4231 AC_SUBST(ALIASES)
4232 AC_SUBST(ASM)
4233 AC_SUBST(MOC)
4234 AC_SUBST(RCC)
4235 AC_SUBST(UIC)
4236 AC_SUBST(WINDRES)
4237 AC_SUBST(WINE_SDK_PATH)
4238 AC_SUBST(LIBEXT)
4239 AC_SUBST(AM_CPPFLAGS)
4240 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
4241 AC_SUBST(FILE_LIBVLCCORE_DLL)
4242 AC_SUBST(FILE_LIBVLC_DLL)
4243
4244 AC_CONFIG_FILES([
4245   Makefile
4246   doc/Makefile
4247   modules/Makefile
4248   m4/Makefile
4249   po/Makefile.in
4250   share/Makefile
4251   compat/Makefile
4252   src/Makefile
4253   src/test/Makefile
4254   lib/Makefile
4255   bin/Makefile
4256   test/Makefile
4257   modules/access/Makefile
4258   modules/access/bd/Makefile
4259   modules/access/dshow/Makefile
4260   modules/access/mms/Makefile
4261   modules/access/rtp/Makefile
4262   modules/access/rtsp/Makefile
4263   modules/access/vcd/Makefile
4264   modules/access/vcdx/Makefile
4265   modules/access/screen/Makefile
4266   modules/access/zip/Makefile
4267   modules/access/zip/unzip/Makefile
4268   modules/access_output/Makefile
4269   modules/audio_filter/Makefile
4270   modules/audio_mixer/Makefile
4271   modules/audio_output/Makefile
4272   modules/codec/Makefile
4273   modules/codec/avcodec/Makefile
4274   modules/codec/dmo/Makefile
4275   modules/codec/loader/Makefile
4276   modules/codec/omxil/Makefile
4277   modules/codec/shine/Makefile
4278   modules/codec/spudec/Makefile
4279   modules/codec/wmafixed/Makefile
4280   modules/control/Makefile
4281   modules/control/dbus/Makefile
4282   modules/control/globalhotkeys/Makefile
4283   modules/demux/Makefile
4284   modules/demux/asf/Makefile
4285   modules/demux/avformat/Makefile
4286   modules/demux/avi/Makefile
4287   modules/demux/mkv/Makefile
4288   modules/demux/mp4/Makefile
4289   modules/demux/mpeg/Makefile
4290   modules/demux/playlist/Makefile
4291   modules/gui/Makefile
4292   modules/gui/macosx/Makefile
4293   modules/gui/hildon/Makefile
4294   modules/gui/minimal_macosx/Makefile
4295   modules/gui/macosx_dialog_provider/Makefile
4296   modules/gui/qt4/Makefile
4297   modules/gui/skins2/Makefile
4298   modules/lua/Makefile
4299   modules/meta_engine/Makefile
4300   modules/misc/Makefile
4301   modules/misc/playlist/Makefile
4302   modules/misc/osd/Makefile
4303   modules/misc/stats/Makefile
4304   modules/media_library/Makefile
4305   modules/mux/Makefile
4306   modules/mux/mpeg/Makefile
4307   modules/notify/Makefile
4308   modules/packetizer/Makefile
4309   modules/services_discovery/Makefile
4310   modules/stream_filter/Makefile
4311   modules/stream_out/Makefile
4312   modules/stream_out/transcode/Makefile
4313   modules/text_renderer/Makefile
4314   modules/video_chroma/Makefile
4315   modules/video_filter/Makefile
4316   modules/video_filter/dynamicoverlay/Makefile
4317   modules/video_output/Makefile
4318   modules/video_output/msw/Makefile
4319   modules/visualization/Makefile
4320   modules/visualization/visual/Makefile
4321   modules/mmx/Makefile
4322   modules/mmxext/Makefile
4323   modules/3dnow/Makefile
4324   modules/sse2/Makefile
4325   modules/altivec/Makefile
4326   modules/arm_neon/Makefile
4327 ])
4328
4329 AM_COND_IF([HAVE_WIN32], [
4330   AC_CONFIG_FILES([
4331     extras/package/win32/spad.nsi
4332     extras/package/win32/vlc.win32.nsi
4333   ])
4334 ])
4335
4336 AM_COND_IF([HAVE_DARWIN], [
4337   AC_CONFIG_FILES([
4338     extras/package/macosx/Info.plist
4339     extras/package/macosx/Resources/English.lproj/InfoPlist.strings
4340   ])
4341 ])
4342
4343 dnl Generate makefiles
4344 AC_OUTPUT
4345
4346 /bin/echo -n "Enabled modules: ${PLUGINS}"
4347
4348 dnl Do we have to use make or gmake ?
4349 USE_MAKE_OR_GMAKE=`case "${SYS}" in openbsd*) echo "gmake";; *) echo "make";; esac`
4350 dnl Shortcut to nice compile message
4351 rm -f compile
4352 if test -n $SHELL; then
4353   SHELL=${CONFIG_SHELL-/bin/sh}
4354 fi
4355 echo '#! '$SHELL >compile
4356 echo rm -f .error\$\$ >>compile
4357 echo ERROR=0 >>compile
4358 echo export PATH=$PATH LANG=C >>compile
4359 echo "($USE_MAKE_OR_GMAKE V=1 \$@ 2>&1 || touch .error\$\$)| \\" >>compile
4360 echo '`sed -ne "s/^top_srcdir *= *//p" < Makefile`/extras/buildsystem/make.pl' >>compile
4361 echo test -f .error\$\$ \&\& ERROR=1 >>compile
4362 echo rm -f .error\$\$ >>compile
4363 echo exit \$ERROR >>compile
4364 chmod a+x compile
4365
4366 printf "
4367 libvlc configuration
4368 --------------------
4369 version               : ${VERSION}
4370 system                : ${SYS}
4371 architecture          : ${ARCH}
4372 build flavour         : "
4373 test "${enable_optimizations}" != "no" && printf ${enable_optimizations}
4374 echo ""
4375 if test "${enable_vlc}" != "no"; then
4376 echo "vlc aliases           :${ALIASES}"
4377 else
4378 echo "build vlc executable  : no"
4379 fi
4380 echo "
4381 To build vlc and its plugins, type \`./compile' or \`$USE_MAKE_OR_GMAKE'."