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