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