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