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