]> git.sesse.net Git - vlc/blob - configure.in
* ALL: new module API. Makes a few things a lot simpler, and we gain
[vlc] / configure.in
1 dnl Autoconf settings for vlc
2 AC_INIT(include/main.h)
3 AC_CONFIG_HEADER(include/defs.h)
4 AC_CANONICAL_SYSTEM
5
6 CONFIGURE_LINE="$0 $*"
7
8 PACKAGE="vlc"
9 VERSION="0.5.0-cvs"
10 CODENAME="Natalya"
11
12 dnl
13 dnl  Save *FLAGS
14 dnl
15 save_CPPFLAGS="${CPPFLAGS}"
16 save_CFLAGS="${CFLAGS}"
17 save_LDFLAGS="${LDFLAGS}"
18
19 dnl
20 dnl Check for tools
21 dnl
22 AC_PROG_MAKE_SET
23 AC_PROG_CC
24 AC_PROG_CPP
25
26 dnl Find the right ranlib, even when cross-compiling
27 AC_CHECK_TOOL(RANLIB, ranlib, :)
28 AC_CHECK_TOOL(STRIP, strip, :)
29
30 dnl
31 dnl Check for GNU make
32 dnl
33 AC_PATH_PROG(GMAKE, gmake, no)
34 if test "x${GMAKE}" = "xno"; then
35   AC_CACHE_CHECK([whether GNU make is installed],
36       [ac_cv_gmake],
37       [if make --version | grep -q -i gnu; then
38          ac_cv_gmake="yes"
39        else
40          echo "This software needs you to install GNU make to compile properly."
41          echo "You can get it from http://www.gnu.org/."
42          exit
43        fi])
44   VLC_MAKE="make"
45 else
46   VLC_MAKE="gmake"
47 fi
48
49 dnl Gettext stuff
50 ALL_LINGUAS="de en_GB fr ja no ru nl pl se"
51
52 AC_DEFINE_UNQUOTED(VLC_PACKAGE, "${PACKAGE}", [Package name])
53 AC_DEFINE_UNQUOTED(VLC_VERSION, "${VERSION}", [Package version])
54 AM_GNU_GETTEXT
55
56 dnl AM_PROG_LIBTOOL
57 AC_PROG_INSTALL
58
59 dnl
60 dnl  Set default LDFLAGS
61 dnl
62 vlc_LDFLAGS="${LDFLAGS}"
63
64 dnl
65 dnl  Check the operating system
66 dnl
67 case "x${target_os}" in
68   x)
69     SYS=unknown
70     ;;
71   xlinux*)
72     SYS=linux
73     ;;
74   xbsdi*)
75     SYS=bsdi
76     save_CFLAGS="${save_CFLAGS} -pthread"; CFLAGS="${save_CFLAGS}"
77     dvd_LDFLAGS="${dvd_LDFLAGS} -ldvd"
78     vcd_LDFLAGS="${vcd_LDFLAGS} -ldvd"
79     ;;
80   x*bsd*)
81     SYS="${target_os}"
82     save_CFLAGS="${save_CFLAGS} -pthread"; CFLAGS="${save_CFLAGS}"
83     ;;
84   xdarwin*)
85     SYS=darwin
86     save_CFLAGS="${save_CFLAGS} -no-cpp-precomp"; CFLAGS="${save_CFLAGS}"
87     vlc_LDFLAGS="${vlc_LDFLAGS} -all_load"
88     ;;
89   x*mingw32*)
90     SYS=mingw32
91     AC_CHECK_TOOL(WINDRES, windres, :)
92     save_CFLAGS="${save_CFLAGS} -fnative-struct -D_OFF_T_ -D_off_t=long"; CFLAGS="${save_CFLAGS}"
93     vlc_LDFLAGS="${vlc_LDFLAGS} -mwindows -Xlinker --force-exe-suffix"
94     vlc_LDFLAGS="${vlc_LDFLAGS} -lws2_32 -lnetapi32"
95     ipv4_LDFLAGS="${ipv4_LDFLAGS} -lws2_32"
96     ipv6_LDFLAGS="${ipv6_LDFLAGS} -lws2_32"
97     http_LDFLAGS="${http_LDFLAGS} -lws2_32"
98     rc_LDFLAGS="${rc_LDFLAGS} -lws2_32"
99     ;;
100   x*nto*)
101     SYS=nto
102     x11_LDFLAGS="${x11_LDFLAGS} -lsocket"
103     xvideo_LDFLAGS="${xvideo_LDFLAGS} -lsocket"
104     ;;
105   xsolaris*)
106     SYS=solaris
107     ;;
108   xbeos)
109     SYS=beos
110     save_CFLAGS="${save_CFLAGS} -Wno-multichar -Wno-ctor-dtor-privacy -Woverloaded-virtual"; CFLAGS="${save_CFLAGS}"
111     vlc_LDFLAGS="${vlc_LDFLAGS} -lbe"
112     plugins_LDFLAGS="${plugins_LDFLAGS} -nostart"
113     beos_LDFLAGS="${beos_LDFLAGS} -lbe -lgame -lroot -ltracker"
114     ipv4_LDFLAGS="${ipv4_LDFLAGS} -lbind"
115     ;;
116   x*)
117     SYS="${target_os}"
118     ;;
119 esac
120
121 dnl Flags for plugin compilation
122 if test "x${SYS}" = "xmingw32"
123 then
124   plugins_CFLAGS="${plugins_CFLAGS} -fnative-struct"
125 else
126   plugins_CFLAGS="${plugins_CFLAGS} -fPIC"
127   plugins_LDFLAGS="${plugins_LDFLAGS} -fPIC"
128 fi
129
130 dnl The -DSYS_FOO flag
131 save_CFLAGS="${save_CFLAGS} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcdefghijklmnopqrstuvwxyz.' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`"; CFLAGS="${save_CFLAGS}"
132
133 dnl Check for system libs needed
134 AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol isatty vasprintf swab sigrelse getpwuid memalign posix_memalign gethostbyname2 atoll strndup)
135
136 AC_CHECK_FUNC(connect,,[
137   AC_CHECK_LIB(socket,connect,
138     ipv4_LDFLAGS="${ipv4_LDFLAGS} -lsocket"
139     vlc_LDFLAGS="${vlc_LDFLAGS} -lsocket"
140 )])
141 AC_CHECK_FUNC(send,,[
142   AC_CHECK_LIB(socket,send,
143     http_LDFLAGS="${http_LDFLAGS} -lsocket"
144 )])
145 AC_CHECK_FUNC(gethostbyname,,[
146   AC_CHECK_LIB(nsl,gethostbyname,ipv4_LDFLAGS="${ipv4_LDFLAGS} -lnsl")
147 ])
148 AC_CHECK_FUNC(gethostbyname,,[
149   AC_CHECK_LIB(bind,gethostbyname,ipv4_LDFLAGS="${ipv4_LDFLAGS} -lbind")
150 ])
151 have_nanosleep=0
152 AC_CHECK_FUNC(nanosleep,have_nanosleep=1,[
153   AC_CHECK_LIB(rt,nanosleep,
154     [vlc_LDFLAGS="${vlc_LDFLAGS} -lrt"; have_nanosleep=1],
155     [AC_CHECK_LIB(posix4,nanosleep,
156         [vlc_LDFLAGS="${vlc_LDFLAGS} -lposix4"; have_nanosleep=1])]
157   )
158 ])
159 if test x$have_nanosleep = x1; then
160   AC_DEFINE(HAVE_NANOSLEEP, 1,
161             Define if nanosleep is available.)
162 fi
163 # HP/UX port
164 AC_CHECK_LIB(rt,sem_init, [vlc_LDFLAGS="${vlc_LDFLAGS} -lrt"])
165
166 AC_CHECK_FUNC(inet_aton,,[
167   AC_CHECK_LIB(resolv,inet_aton,ipv4_LDFLAGS="${ipv4_LDFLAGS} -lresolv")
168 ])
169 AC_CHECK_FUNC(textdomain,,[
170   AC_CHECK_LIB(intl,textdomain,
171     vlc_LDFLAGS="${vlc_LDFLAGS} -lintl"
172     plugins_LDFLAGS="${plugins_LDFLAGS} -lintl"
173   )
174 ])
175
176 dnl Check for getopt
177 NEED_GETOPT=0
178 AC_CHECK_FUNC(getopt_long,[AC_DEFINE(HAVE_GETOPT_LONG,1,long getopt support)],
179 [ # FreeBSD has a gnugetopt library for this:
180   AC_CHECK_LIB([gnugetopt],[getopt_long],
181     [AC_DEFINE(HAVE_GETOPT_LONG,1,getopt support) vlc_LDFLAGS="${vlc_LDFLAGS} -lgnugetopt"],
182     [NEED_GETOPT=1])])
183
184 AC_TYPE_SIGNAL
185 AC_CHECK_LIB(dl,dlopen,vlc_LDFLAGS="${vlc_LDFLAGS} -ldl")
186 AC_CHECK_LIB(m,cos,
187   imdct_LDFLAGS="${imdct_LDFLAGS} -lm"
188   filter_distort_LDFLAGS="${filter_distort_LDFLAGS} -lm")
189 AC_CHECK_LIB(m,pow,
190   ffmpeg_LDFLAGS="${ffmpeg_LDFLAGS} -lm"
191   imdct_LDFLAGS="${imdct_LDFLAGS} -lm"
192   imdct3dn_LDFLAGS="${imdct3dn_LDFLAGS} -lm"
193   imdctsse_LDFLAGS="${imdctsse_LDFLAGS} -lm"
194   chroma_i420_rgb_LDFLAGS="${chroma_i420_rgb_LDFLAGS} -lm"
195 )
196
197 dnl Check for pthreads - borrowed from XMMS
198 THREAD_LIB=error
199 if test "x${THREAD_LIB}" = "xerror"; then
200   AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread")
201 fi
202 if test "x${THREAD_LIB}" = "xerror"; then
203   AC_CHECK_LIB(pthreads,main,THREAD_LIB="-lpthreads")
204 fi
205 if test "x${THREAD_LIB}" = "xerror"; then
206   AC_CHECK_LIB(c_r,main,THREAD_LIB="-lc_r")
207 fi
208 if test "x${THREAD_LIB}" = "xerror"; then
209   AC_CHECK_FUNC(pthread_mutex_lock)
210   THREAD_LIB=""
211 fi
212
213 dnl Check for cthreads under GNU/Hurd for instance
214 AC_CHECK_LIB(threads,cthread_fork,THREAD_LIB="-lthreads")
215
216 dnl Check for misc headers
217 AC_EGREP_HEADER(pthread_cond_t,pthread.h,[
218   AC_DEFINE(PTHREAD_COND_T_IN_PTHREAD_H, 1,
219             Define if <pthread.h> defines pthread_cond_t.)])
220 AC_EGREP_HEADER(pthread_once,pthread.h,[
221   AC_DEFINE(PTHREAD_ONCE_IN_PTHREAD_H, 1,
222             Define if <pthread.h> defines pthread_once.)])
223 AC_EGREP_HEADER(strncasecmp,strings.h,[
224   AC_DEFINE(STRNCASECMP_IN_STRINGS_H, 1,
225             Define if <strings.h> defines strncasecmp.)])
226
227 dnl Check for headers
228 AC_CHECK_HEADERS(stdint.h getopt.h strings.h inttypes.h sys/int_types.h)
229 AC_CHECK_HEADERS(sys/sockio.h fcntl.h sys/types.h sys/time.h sys/times.h)
230 AC_CHECK_HEADERS(dlfcn.h image.h)
231 AC_CHECK_HEADERS(arpa/inet.h net/if.h netinet/in.h sys/socket.h)
232 AC_CHECK_HEADERS(machine/param.h sys/shm.h)
233 AC_CHECK_HEADERS(linux/version.h)
234
235 AC_HEADER_TIME
236
237 dnl Mac OS X and other OSes don't have declaration for nanosleep
238 AC_EGREP_HEADER(nanosleep,time.h,[
239   AC_DEFINE(HAVE_DECL_NANOSLEEP, 1,
240             Define if <time.h> defines nanosleep.)
241 ])
242
243 dnl Make sure we have timespecs
244 AC_EGREP_HEADER(timespec,sys/time.h,[
245   AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1,
246             Define if <sys/time.h> defines struct timespec.)
247 ])
248
249 dnl Check for threads library
250 AC_CHECK_HEADERS(cthreads.h pthread.h kernel/scheduler.h kernel/OS.h)
251
252 dnl Default X headers and libraries
253 if test "x${x_includes}" = "xNONE"; then
254   x_includes="/usr/X11R6/include"
255 fi
256 if test "x${x_libraries}" = "xNONE"; then
257   x_libraries="/usr/X11R6/lib"
258 fi
259
260 dnl Check for DPMS
261 if test "x${SYS}" != "xmingw32"
262 then
263   CPPFLAGS="${save_CPPFLAGS} -I${x_includes}"
264   AC_CHECK_HEADERS(X11/extensions/dpms.h, [
265     AC_EGREP_HEADER(DPMSInfo,X11/extensions/dpms.h,[
266       AC_DEFINE(DPMSINFO_IN_DPMS_H, 1,
267                 Define if <X11/extensions/dpms.h> defines DPMSInfo.)
268     ])
269   ])
270   CPPFLAGS="${save_CPPFLAGS}"
271 fi
272
273 dnl Check for ntohl, etc.
274 AC_CACHE_CHECK([for ntohl in sys/param.h],
275     [ac_cv_c_ntohl_sys_param_h],
276     [CFLAGS="${save_CFLAGS} -Wall -Werror"
277      AC_TRY_COMPILE([#include <sys/param.h>],
278         [void foo() { int meuh; ntohl(meuh); }],
279         ac_cv_c_ntohl_sys_param_h=yes, ac_cv_c_ntohl_sys_param_h=no)])
280 if test "x${ac_cv_c_ntohl_sys_param_h}" != "xno"; then
281     AC_DEFINE(NTOHL_IN_SYS_PARAM_H, 1, Define if <sys/param.h> defines ntohl.)
282 fi
283
284 dnl Check for inline function size limit
285 AC_CACHE_CHECK([if \$CC accepts -finline-limit],
286     [ac_cv_c_inline_limit],
287     [CFLAGS="${save_CFLAGS} -finline-limit-30000"
288      AC_TRY_COMPILE([],,ac_cv_c_inline_limit=yes, ac_cv_c_inline_limit=no)])
289 if test "x${ac_cv_c_inline_limit}" != "xno"; then
290     save_CFLAGS="${save_CFLAGS} -finline-limit-30000"; CFLAGS="${save_CFLAGS}"
291 fi
292
293 dnl Check for -W or -w flags
294 AC_CACHE_CHECK([if \$CC accepts -Wall -Winline],
295     [ac_cv_c_Wall_Winline],
296     [CFLAGS="-Wall -Winline ${save_CFLAGS}"
297      AC_TRY_COMPILE([],,ac_cv_c_Wall_Winline=yes, ac_cv_c_Wall_Winline=no)])
298 if test "x${ac_cv_c_Wall_Winline}" != "xno"; then
299     save_CFLAGS="-Wall -Winline ${save_CFLAGS}"; CFLAGS="${save_CFLAGS}"
300 else
301     AC_CACHE_CHECK([if \$CC accepts -wall -winline],
302         [ac_cv_c_wall_winline],
303         [CFLAGS="-wall -winline ${save_CFLAGS}"
304          AC_TRY_COMPILE([],,ac_cv_c_wall_winline=yes, ac_cv_c_wall_winline=no)])
305     if test "x${ac_cv_c_wall_winline}" != "xno"; then
306         save_CFLAGS="-wall -winline ${save_CFLAGS}"; CFLAGS="${save_CFLAGS}"
307     fi
308 fi
309
310 dnl Check for -pipe
311 AC_CACHE_CHECK([if \$CC accepts -pipe],
312     [ac_cv_c_pipe],
313     [CFLAGS="${save_CFLAGS} -pipe"
314      AC_TRY_COMPILE([],,ac_cv_c_pipe=yes, ac_cv_c_pipe=no)])
315 if test "x${ac_cv_c_pipe}" != "xno"; then
316     save_CFLAGS="${save_CFLAGS} -pipe"; CFLAGS="${save_CFLAGS}"
317 fi
318
319 dnl Check for various optimization flags
320 AC_CACHE_CHECK([if \$CC accepts -O3],
321     [ac_cv_c_o3],
322     [CFLAGS="${save_CFLAGS} -O3"
323      AC_TRY_COMPILE([],,ac_cv_c_o3=yes, ac_cv_c_o3=no)])
324 if test "x${ac_cv_c_o3}" != "xno"; then
325     CFLAGS_OPTIM="${CFLAGS_OPTIM} -O3"
326 else
327     AC_CACHE_CHECK([if \$CC accepts -O2],
328         [ac_cv_c_o2],
329         [CFLAGS="${save_CFLAGS} -O2"
330          AC_TRY_COMPILE([],,ac_cv_c_o2=yes, ac_cv_c_o2=no)])
331     if test "x${ac_cv_c_o2}" != "xno"; then
332         CFLAGS_OPTIM="${CFLAGS_OPTIM} -O2"
333     else
334         AC_CACHE_CHECK([if \$CC accepts -O],
335             [ac_cv_c_o],
336             [CFLAGS="${save_CFLAGS} -O"
337              AC_TRY_COMPILE([],,ac_cv_c_o=yes, ac_cv_c_o=no)])
338         if test "x${ac_cv_c_o}" != "xno"; then
339             CFLAGS_OPTIM="${CFLAGS_OPTIM} -O"
340         fi
341     fi
342 fi
343
344 dnl Check for -ffast-math
345 AC_CACHE_CHECK([if \$CC accepts -ffast-math],
346     [ac_cv_c_fast_math],
347     [CFLAGS="${save_CFLAGS} -ffast-math"
348      AC_TRY_COMPILE([],,ac_cv_c_fast_math=yes, ac_cv_c_fast_math=no)])
349 if test "x${ac_cv_c_fast_math}" != "xno"; then
350     CFLAGS_OPTIM="${CFLAGS_OPTIM} -ffast-math"
351 fi
352
353 dnl Check for -funroll-loops
354 AC_CACHE_CHECK([if \$CC accepts -funroll-loops],
355     [ac_cv_c_unroll_loops],
356     [CFLAGS="${save_CFLAGS} -funroll-loops"
357      AC_TRY_COMPILE([],,ac_cv_c_unroll_loops=yes, ac_cv_c_unroll_loops=no)])
358 if test "x${ac_cv_c_unroll_loops}" != "xno"; then
359     CFLAGS_OPTIM="${CFLAGS_OPTIM} -funroll-loops"
360 fi
361
362 dnl Check for -fomit-frame-pointer
363 AC_CACHE_CHECK([if \$CC accepts -fomit-frame-pointer],
364     [ac_cv_c_omit_frame_pointer],
365     [CFLAGS="${save_CFLAGS} -fomit-frame-pointer"
366      AC_TRY_COMPILE([],,ac_cv_c_omit_frame_pointer=yes, ac_cv_c_omit_frame_pointer=no)])
367 if test "x${ac_cv_c_omit_frame_pointer}" != "xno"; then
368     CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fomit-frame-pointer"
369     # this plugin does not compile without -fomit-frame-pointer, damn gcc!
370     chroma_i420_yuy2_mmx_CFLAGS="${chroma_i420_yuy2_mmx_CFLAGS} -fomit-frame-pointer"
371 fi
372
373 dnl Check for Darwin plugin linking flags
374 AC_CACHE_CHECK([if \$CC accepts -bundle -undefined error -lcc_dynamic],
375     [ac_cv_ld_darwin],
376     [CFLAGS="${save_CFLAGS} -bundle -undefined error -lcc_dynamic"
377      AC_TRY_COMPILE([],,ac_cv_ld_darwin=yes, ac_cv_ld_darwin=no)])
378 if test "x${ac_cv_ld_darwin}" != "xno"; then
379     plugins_LDFLAGS="${plugins_LDFLAGS} -bundle -undefined error -lcc_dynamic"
380 fi
381
382 dnl Check for standard plugin linking flags
383 AC_CACHE_CHECK([if \$CC accepts -shared],
384     [ac_cv_ld_plugins],
385     [CFLAGS="${save_CFLAGS} -shared"
386      AC_TRY_COMPILE([],, ac_cv_ld_plugins=yes, ac_cv_ld_plugins=no)])
387 if test "x${ac_cv_ld_plugins}" != "xno"; then
388     plugins_LDFLAGS="${plugins_LDFLAGS} -shared"
389 fi
390         
391 dnl Check for variadic macros
392 AC_CACHE_CHECK([for variadic cpp macros],
393     [ac_cv_cpp_variadic_macros],
394     [CFLAGS="${save_CFLAGS}"
395      AC_TRY_COMPILE(
396          [#include <stdio.h>
397           #define a(b,c...) printf(b,##c)],
398          [a("foo");a("%s","bar");a("%s%s","baz","quux");],
399          ac_cv_cpp_variadic_macros=yes,
400          ac_cv_cpp_variadic_macros=no)])
401 if test "x${ac_cv_cpp_variadic_macros}" != "xno"; then
402     AC_DEFINE(HAVE_VARIADIC_MACROS, 1, Support for variadic macros)
403 fi
404
405 dnl Checks for __attribute__(aligned()) directive
406 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
407     [ac_cv_c_attribute_aligned],
408     [ac_cv_c_attribute_aligned=0
409         CFLAGS="${save_CFLAGS} -Werror"
410     for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do
411         AC_TRY_COMPILE([],
412         [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
413         [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
414     done
415         CFLAGS="${save_CFLAGS}"])
416 if test "x${ac_cv_c_attribute_aligned}" != "x0"; then
417     AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
418         [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
419 fi
420
421 dnl
422 dnl  Check the CPU
423 dnl
424 case "x${target_cpu}" in
425   x)
426     ARCH=unknown
427     ;;
428   *)
429     ARCH="${target_cpu}"
430     ;;
431 esac
432
433 dnl
434 dnl  default modules
435 dnl
436 BUILTINS="${BUILTINS} idct idctclassic motion imdct downmix mpeg_adec ac3_adec mpeg_vdec"
437 PLUGINS="${PLUGINS} dummy null rc logger mpeg_es mpeg_audio mpeg_ps mpeg_ts file udp http ipv4 memcpy lpcm_adec ac3_spdif spudec filter_deinterlace filter_invert filter_wall filter_transform filter_distort filter_clone filter_crop fx_scope chroma_i420_rgb chroma_i420_yuy2 chroma_i422_yuy2 chroma_i420_ymga"
438
439 dnl
440 dnl  Accelerated modules
441 dnl
442 MMX_MODULES="memcpymmx idctmmx motionmmx chroma_i420_rgb_mmx chroma_i420_yuy2_mmx chroma_i422_yuy2_mmx chroma_i420_ymga_mmx"
443 MMXEXT_MODULES="memcpymmxext idctmmxext motionmmxext"
444 THREEDNOW_MODULES="memcpy3dn imdct3dn downmix3dn"
445 SSE_MODULES="imdctsse downmixsse"
446 ALTIVEC_MODULES="idctaltivec motionaltivec memcpyaltivec"
447
448 AC_CACHE_CHECK([if \$CC groks MMX inline assembly],
449     [ac_cv_mmx_inline],
450     [CFLAGS="${save_CFLAGS}"
451      AC_TRY_COMPILE(,[void *p;asm volatile("packuswb %%mm1,%%mm2"::"r"(p));],
452                     ac_cv_mmx_inline=yes, ac_cv_mmx_inline=no)])
453 if test "x${ac_cv_mmx_inline}" != "xno"; then
454   ACCEL_MODULES="${ACCEL_MODULES} ${MMX_MODULES}"
455 fi
456
457 AC_CACHE_CHECK([if \$CC groks MMX EXT inline assembly],
458     [ac_cv_mmxext_inline],
459     [CFLAGS="${save_CFLAGS}"
460      AC_TRY_COMPILE(,[void *p;asm volatile("maskmovq %%mm1,%%mm2"::"r"(p));],
461                     ac_cv_mmxext_inline=yes, ac_cv_mmxext_inline=no)])
462 if test "x${ac_cv_mmxext_inline}" != "xno"; then
463   ACCEL_MODULES="${ACCEL_MODULES} ${MMXEXT_MODULES}"
464 fi
465
466 AC_CACHE_CHECK([if \$CC groks 3D Now! inline assembly],
467     [ac_cv_3dnow_inline],
468     [CFLAGS="${save_CFLAGS}"
469      AC_TRY_COMPILE(,[void *p;asm volatile("pfadd %%mm1,%%mm2"::"r"(p));],
470                     ac_cv_3dnow_inline=yes, ac_cv_3dnow_inline=no)])
471 if test "x${ac_cv_3dnow_inline}" != "xno"; then
472   AC_DEFINE(CAN_COMPILE_3DNOW, 1, Define if \$CC groks 3D Now! inline assembly.)
473   ACCEL_MODULES="${ACCEL_MODULES} ${THREEDNOW_MODULES}"
474 fi
475
476 AC_CACHE_CHECK([if \$CC groks SSE inline assembly],
477     [ac_cv_sse_inline],
478     [CFLAGS="${save_CFLAGS}"
479      AC_TRY_COMPILE(,[void *p;asm volatile("xorps %%xmm1,%%xmm2"::"r"(p));],
480                     ac_cv_sse_inline=yes, ac_cv_sse_inline=no)])
481 if test "x${ac_cv_sse_inline}" != "xno" -a "x${SYS}" != "xmingw32"; then
482   AC_DEFINE(CAN_COMPILE_SSE, 1, Define if \$CC groks SSE inline assembly.)
483   ACCEL_MODULES="${ACCEL_MODULES} ${SSE_MODULES}"
484 fi
485
486 # don't try to grok AltiVec with native mingw32 it doesn't work right now
487 # we should be able to remove this test with future versions of mingw32
488 if test "x${SYS}" != "xmingw32"; then
489 AC_CACHE_CHECK([if \$CC groks AltiVec inline assembly],
490     [ac_cv_altivec_inline],
491     [CFLAGS="${save_CFLAGS}"
492      AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
493          ac_cv_altivec_inline=yes,
494          [CFLAGS="${save_CFLAGS} -Wa,-m7400"
495           AC_TRY_COMPILE(,[asm volatile("vperm 0,1,2,3");],
496             [ac_cv_altivec_inline="-Wa,-m7400"],
497             ac_cv_altivec_inline=no)
498          ])])
499 if test "x${ac_cv_altivec_inline}" != "xno"; then
500   AC_DEFINE(CAN_COMPILE_ALTIVEC, 1, Define if \$CC groks AltiVec inline assembly.)
501   if test "x${ac_cv_altivec_inline}" != "xyes"; then
502     idctaltivec_CFLAGS="${idctaltivec_CFLAGS} ${ac_cv_altivec_inline}"
503     motionaltivec_CFLAGS="${motionaltivec_CFLAGS} ${ac_cv_altivec_inline}"
504     memcpyaltivec_CFLAGS="${memcpyaltivec_CFLAGS} ${ac_cv_altivec_inline}"
505     vlc_CFLAGS="${vlc_CFLAGS} ${ac_cv_altivec_inline}"
506   fi
507   ACCEL_MODULES="${ACCEL_MODULES} ${ALTIVEC_MODULES}"
508 fi
509
510 AC_CACHE_CHECK([if \$CC groks AltiVec C extensions],
511     [ac_cv_c_altivec],
512     [CFLAGS="${save_CFLAGS} -faltivec"
513      # Darwin test
514      AC_TRY_COMPILE(,[vec_mtvscr((vector unsigned int)(0));],
515         ac_cv_c_altivec=-faltivec, [
516         # Linux/PPC test
517         CFLAGS="${save_CFLAGS} ${idctaltivec_CFLAGS} -fvec"
518         AC_TRY_COMPILE(,[vec_mtvscr((vector unsigned int)(0));],
519             [ac_cv_c_altivec="-fvec"], ac_cv_c_altivec=no)
520         ])
521      CFLAGS="${save_CFLAGS}"])
522 if test "x${ac_cv_c_altivec}" != "xno"; then
523   AC_DEFINE(CAN_COMPILE_C_ALTIVEC, 1, Define if your compiler groks C AltiVec extensions.)
524   idctaltivec_CFLAGS="${idctaltivec_CFLAGS} ${ac_cv_c_altivec}"
525   motionaltivec_CFLAGS="${motionaltivec_CFLAGS} ${ac_cv_c_altivec}"
526   memcpyaltivec_CFLAGS="${memcpyaltivec_CFLAGS} ${ac_cv_c_altivec}"
527   vlc_CFLAGS="${vlc_CFLAGS} ${ac_cv_c_altivec}"
528   ACCEL_MODULES="${ACCEL_MODULES} ${ALTIVEC_MODULES}"
529 fi
530
531 AC_CACHE_CHECK([if linker needs -framework vecLib],
532     [ac_cv_ld_altivec],
533     [LDFLAGS="${vlc_LDFLAGS} -framework vecLib"
534      AC_TRY_LINK([],,ac_cv_ld_altivec=yes,ac_cv_ld_altivec=no)
535      LDFLAGS="${save_LDFLAGS}"
536     ])
537 if test "x${ac_cv_ld_altivec}" != "xno"; then
538   idctaltivec_LDFLAGS="${idctaltivec_LDFLAGS} -framework vecLib"
539   motionaltivec_LDFLAGS="${motionaltivec_LDFLAGS} -framework vecLib"
540   memcpyaltivec_LDFLAGS="${memcpyaltivec_LDFLAGS} -framework vecLib"
541   vlc_LDFLAGS="${vlc_LDFLAGS} -framework vecLib"
542 fi
543 fi # end if mingw32
544
545
546 AC_ARG_WITH(,[])
547 AC_ARG_WITH(,[Optimization options:])
548
549 dnl
550 dnl  Special arch tuning
551 dnl
552 AC_ARG_WITH(tuning,
553 [  --with-tuning=ARCH      enable special tuning for an architecture
554                           (default i686 on IA-32 and 750 on PPC)])
555 if test "x${with_tuning}" != "x"; then
556     TUNING="${with_tuning}"
557 else
558     if test "x${target_cpu}" = "xi686" -o "x${target_cpu}" = "xi586" -o "x${target_cpu}" = "xi486" -o "x${target_cpu}" = "xi386"; then TUNING="pentiumpro"
559     else
560         if test "x${target_cpu}" = "xpowerpc"; then TUNING="750"; fi
561     fi
562 fi
563
564 dnl
565 dnl  x86 accelerations
566 dnl
567 if test "x${target_cpu}" = "xi686" -o "x${target_cpu}" = "xi586" -o "x${target_cpu}" = "xx86" -o "x${target_cpu}" = "xi386"
568 then
569     ARCH="${ARCH} mmx"
570     PLUGINS="${PLUGINS} ${ACCEL_MODULES}"
571 fi
572
573 dnl
574 dnl  Enable/disable optimizations
575 dnl
576 AC_ARG_ENABLE(optimizations,
577 [  --disable-optimizations disable compiler optimizations (default enabled)],
578 [ if test "x${enable_optimizations}" = "xno"; then OPTIMS=0; fi ],
579 [ OPTIMS=1 ])
580
581 dnl
582 dnl  AltiVec acceleration
583 dnl
584 AC_ARG_ENABLE(altivec,
585 [  --disable-altivec       disable AltiVec optimizations (default enabled on PPC)],
586 [ if test "x${enable_altivec}" = "xyes"; then ARCH="${ARCH} altivec";
587     BUILTINS="${BUILTINS} ${ACCEL_MODULES}"; fi ],
588 [ if test "x${target_cpu}" = "xpowerpc"; then ARCH="${ARCH} altivec";
589     BUILTINS="${BUILTINS} ${ACCEL_MODULES}"; fi ])
590
591 dnl
592 dnl  Debugging mode
593 dnl
594 DEBUG=0
595 AC_ARG_ENABLE(debug,
596 [  --enable-debug          debug mode (default disabled)],
597 [ if test "x${enable_debug}" = "xyes"; then DEBUG=1; fi ])
598
599 dnl
600 dnl  Enable release-specific flags
601 dnl
602 RELEASE=0
603 AC_ARG_ENABLE(release,
604 [  --enable-release        activate extra optimizations (default disabled)],
605 [ if test "x${enable_release}" = "xyes"; then RELEASE=1; fi ],
606 [ VERSION="${VERSION}_`date +%Y-%m-%d`" ])
607
608 dnl
609 dnl  Input plugins
610 dnl
611
612 AC_ARG_WITH(,[Input plugins:])
613
614 dnl
615 dnl  DVD module: optionally check for installed libdvdcss
616 dnl
617 AC_ARG_ENABLE(dvd,
618 [  --enable-dvd            DVD input module (default enabled)])
619 if test "x${enable_dvd}" != "xno"
620 then
621   AC_ARG_WITH(dvdcss, 
622   [    --with-dvdcss=PATH    libdvdcss headers and libraries])
623   AC_ARG_WITH(dvdcss-tree, 
624   [    --with-dvdcss-tree=PATH libdvdcss tree for static linking])
625   case "x${with_dvdcss}" in
626   x|xyes)
627     if test "x${with_dvdcss_tree}" = x
628     then
629       AC_CHECK_HEADERS(dvdcss/dvdcss.h,
630         [ PLUGINS="${PLUGINS} dvd"
631           dvd_LDFLAGS="${dvd_LDFLAGS} -ldvdcss" ],
632         [ AC_MSG_WARN([libdvdcss is no longer provided with vlc; please get libdvdcss from http://www.videolan.org/libdvdcss/ and build it. Then either use --with-dvdcss=<path/where/libdvdcss/was/installed> for dynamic linking (recommended under Unix) or --with-dvdcss-tree=<path/where/libdvdcss/was/built> for static linking (recommended under BeOS, Windows, MacOS X). Alternatively you can use --disable-dvd to disable the DVD plugin.])
633           AC_MSG_ERROR([cannot find libdvdcss headers]) ])
634     else
635       AC_MSG_CHECKING(for libdvdcss.a in ${with_dvdcss_tree})
636       real_dvdcss_tree="`cd ${with_dvdcss_tree} 2>/dev/null && pwd`"
637       if test "x${real_dvdcss_tree}" = "x"
638       then
639         dnl  The given directory can't be found
640         AC_MSG_RESULT(no)
641         AC_MSG_ERROR([cannot cd to ${with_dvdcss_tree}])
642       fi
643       if test -f "${real_dvdcss_tree}/src/.libs/libdvdcss.a"
644       then
645         dnl  Use a custom libdvdcss
646         AC_MSG_RESULT(${real_dvdcss_tree}/src/.libs/libdvdcss.a)
647         BUILTINS="${BUILTINS} dvd"
648         dvd_LDFLAGS="${dvd_LDFLAGS} ${real_dvdcss_tree}/src/.libs/libdvdcss.a"
649         dvd_CFLAGS="${dvd_CFLAGS} -I${real_dvdcss_tree}/src"
650       else
651         dnl  The given libdvdcss wasn't built
652         AC_MSG_RESULT(no)
653         AC_MSG_ERROR([cannot find ${real_dvdcss_tree}/src/.libs/libdvdcss.a, make sure you compiled libdvdcss in ${with_dvdcss_tree}])
654       fi
655     fi
656   ;;
657   xno)
658     dnl  Compile without dvdcss (dlopen version, works only under Linux)
659     PLUGINS="${PLUGINS} dvd"
660     dvd_CFLAGS="${dvd_CFLAGS} -DGOD_DAMN_DMCA"
661     dvd_LDFLAGS="${dvd_LDFLAGS} -ldl"
662   ;;
663   *)
664     AC_MSG_CHECKING(for dvdcss headers in ${with_dvdcss})
665     if test -f ${with_dvdcss}/include/dvdcss/dvdcss.h
666     then
667       dnl  Use ${with_dvdcss}/include/dvdcss/dvdcss.h
668       AC_MSG_RESULT(yes)
669       PLUGINS="${PLUGINS} dvd"
670       dvd_LDFLAGS="${dvd_LDFLAGS} -L${with_dvdcss}/lib -ldvdcss"
671       dvd_CFLAGS="${dvd_CFLAGS} -I${with_dvdcss}/include"
672     else
673       dnl  No libdvdcss could be found, sorry
674       AC_MSG_RESULT(no)
675       AC_MSG_ERROR([cannot find ${with_dvdcss}/include/dvdcss/dvdcss.h])
676     fi
677   ;;
678   esac
679 fi
680
681 dnl
682 dnl dvdread module: check for libdvdread plugin
683 dnl
684 AC_ARG_ENABLE(dvdread,
685 [  --enable-dvdread        dvdread input module (default disabled)])
686 if test "x${enable_dvdread}" != "xno"
687 then
688   AC_ARG_WITH(dvdread, 
689   [    --with-dvdread=PATH   libdvdread headers and libraries])
690   if test "x${with_dvdread}" = "x"
691   then
692     test_LDFLAGS=""
693     test_CFLAGS=""
694   else
695     test_LDFLAGS="-L${with_dvdread}/lib"
696     test_CFLAGS="-I${with_dvdread}/include"
697   fi
698   CPPFLAGS="${save_CPPFLAGS} ${test_CFLAGS}"
699   AC_CHECK_HEADERS(dvdread/dvd_reader.h, [
700      AC_TRY_COMPILE([#include <dvdread/dvd_reader.h>],
701         [void foo() { int i=DVD_VIDEO_LB_LEN; }],[
702           PLUGINS="${PLUGINS} dvdread"
703           dvdread_LDFLAGS="${dvdread_LDFLAGS} ${test_LDFLAGS} -ldvdread"
704           dvdread_CFLAGS="${dvdread_CFLAGS} ${test_CFLAGS}"
705         ],[
706           if test "x${enable_dvdread}" != "x"
707           then
708             AC_MSG_ERROR([Cannot find DVD_VIDEO_LB_LEN in dvdread/dvd_reader.h, please install libdvdread version 0.9.2 or later])
709           fi
710         ])
711   ],[
712     if test "x${enable_dvdread}" != "x"
713     then
714       if test "x${with_dvdread}" != "x"
715       then
716         AC_MSG_ERROR([Cannot find dvdread/dvd_reader.h in ${with_dvdread}/include])
717       else
718         AC_MSG_ERROR([Cannot find dvdread/dvd_reader.h])
719       fi
720     fi
721   ])
722   CPPFLAGS="$save_CPPFLAGS"
723 fi
724
725 dnl
726 dnl dvdplay module: check for libdvdplay
727 dnl
728 AC_ARG_ENABLE(dvdplay,
729 [  --enable-dvdplay        dvdplay input module (default disabled)])
730 if test "x$enable_dvdplay" != "xno"
731 then
732   AC_ARG_WITH(dvdplay, 
733   [    --with-dvdplay=PATH   libdvdplay headers and libraries])
734   if test "x$with_dvdplay" = x
735   then
736     test_LDFLAGS=""
737     test_CFLAGS=""
738   else
739     test_LDFLAGS="-L${with_dvdplay}/lib"
740     test_CFLAGS="-I${with_dvdplay}/include"
741   fi
742   CPPFLAGS="$save_CPPFLAGS $test_CFLAGS"
743   AC_CHECK_HEADERS(dvdplay/dvdplay.h, [
744       PLUGINS="${PLUGINS} dvdplay"
745       dvdplay_LDFLAGS="${dvdplay_LDFLAGS} ${test_LDFLAGS} -ldvdplay -ldvdread"
746       dvdplay_CFLAGS="${dvdplay_CFLAGS} ${test_CFLAGS}"
747     ],[
748     if test "x$enable_dvdplay" != x
749     then
750       if test "x$with_dvdplay" != x
751       then
752         AC_MSG_ERROR([Cannot find dvdplay/dvdplay.h in ${with_dvdplay}/include])
753       else
754         AC_MSG_ERROR([Cannot find dvdplay/dvdplay.h])
755       fi
756     fi
757   ])
758   CPPFLAGS="${save_CPPFLAGS}"
759 fi
760
761
762 dnl
763 dnl  libdvbpsi ts demux
764 dnl
765 AC_ARG_ENABLE(dvbpsi,
766 [  --enable-dvbpsi        dvbpsi ts demux module (default disabled)])
767 if test "x${enable_dvbpsi}" != "xno"
768 then
769   AC_ARG_WITH(dvbpsi, 
770   [    --with-dvbpsi=PATH    libdvbpsi headers and libraries])
771   AC_ARG_WITH(dvbpsi,
772   [    --with-dvbpsi-tree=PATH libdvbpsi tree for static linking])
773   case "x${with_dvbpsi}" in
774   x|xyes)
775     if test "x${with_dvbpsi_tree}" = "x"
776     then
777       AC_CHECK_HEADERS(dvbpsi/dr.h,
778         [ PLUGINS="${PLUGINS} mpeg_ts_dvbpsi"
779           mpeg_ts_dvbpsi_LDFLAGS="${mpeg_ts_dvbpsi_LDFLAGS} -ldvbpsi" ], [],
780         [  AC_MSG_ERROR([cannot find libdvbpsi headers]) ])
781     else
782       AC_MSG_CHECKING(for libdvbpsi.a in ${with_dvbpsi_tree})
783       real_dvbpsi_tree="`cd ${with_dvbpsi_tree} 2>/dev/null && pwd`"
784       if test "x${real_dvbpsi_tree}" = "x"
785       then
786         dnl  The given directory can't be found
787         AC_MSG_RESULT(no)
788         AC_MSG_ERROR([cannot cd to ${with_dvbpsi_tree}])
789       fi
790       if test -f "${real_dvbpsi_tree}/src/.libs/libdvbpsi.a"
791       then
792         dnl  Use a custom libdvbpsi
793         AC_MSG_RESULT(${real_dvbpsi_tree}/src/.libs/libdvbpsi.a)
794         BUILTINS="${BUILTINS} mpeg_ts_dvbpsi"
795         mpeg_ts_dvbpsi_LDFLAGS="${mpeg_ts_dvbpsi_LDFLAGS} ${real_dvbpsi_tree}/src/.libs/libdvbpsi.a"
796         mpeg_ts_dvbpsi_CFLAGS="${mpeg_ts_dvbpsi_CFLAGS} -I${real_dvbpsi_tree}/src"
797       else
798         dnl  The given libdvbpsi wasn't built
799         AC_MSG_RESULT(no)
800         AC_MSG_ERROR([cannot find ${real_dvbpsi_tree}/src/.libs/libdvbpsi.a, make sure you compiled libdvbpsi in ${with_dvbpsi_tree}])
801       fi
802     fi
803   ;;
804   xno)
805     dnl  Compile without dvbpsi (dlopen version, works only under Linux)
806   ;;
807   *)
808     AC_MSG_CHECKING(for dvbpsi headers in ${with_dvbpsi})
809     if test "x${with_dvbpsi}" = "x"
810     then
811       test_LDFLAGS=""
812       test_CFLAGS=""
813     else
814       test_LDFLAGS="-L${with_dvbpsi}/lib"
815       test_CFLAGS="-I${with_dvbpsi}/include"
816     fi
817     CPPFLAGS="${save_CPPFLAGS} ${test_CFLAGS}"
818     AC_CHECK_HEADER([dvbpsi/dr.h],[
819       PLUGINS="${PLUGINS} mpeg_ts_dvbpsi"
820       mpeg_ts_dvbpsi_LDFLAGS="${mpeg_ts_dvbpsi_LDFLAGS} ${test_LDFLAGS} -ldvbpsi"
821       mpeg_ts_dvbpsi_CFLAGS="${mpeg_ts_dvbpsi_CFLAGS} ${test_CFLAGS}"
822       ],[
823       if test "x${enable_dvbpsi}" != "x"
824       then
825         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])
826       fi
827     ])
828     CPPFLAGS="${save_CPPFLAGS}"
829   ;;
830   esac
831 fi
832
833 dnl
834 dnl  VCD module
835 dnl
836 AC_ARG_ENABLE(vcd,
837   [  --enable-vcd            VCD support for Linux, FreeBSD and MacOS X (default enabled)])
838
839 if test "x${enable_vcd}" != "xno"
840 then
841   AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[
842     PLUGINS="${PLUGINS} vcd"
843   ])
844   
845   AC_EGREP_HEADER(ioc_toc_header ,sys/cdio.h,[
846     PLUGINS="${PLUGINS} vcd"
847     AC_DEFINE(HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H, 1, For FreeBSD VCD support)
848   ])
849   
850   if test "x${SYS}" = "xbsdi"
851   then
852     PLUGINS="${PLUGINS} vcd"
853   fi
854
855   if test "x${SYS}" = "xdarwin"
856   then
857     # No need to add vcd to PLUGINS, Darwin is already based on FreeBSD
858     vcd_LDFLAGS="${vcd_LDFLAGS} -framework IOKit -framework CoreFoundation" 
859   fi
860 fi
861
862 dnl
863 dnl  Satellite input module
864 dnl
865 AC_ARG_ENABLE(satellite,
866   [  --enable-satellite      satellite card support (default disabled)],
867   [ if test "x${enable_satellite}" = "xyes"
868     then
869       PLUGINS="${PLUGINS} satellite"
870     fi])
871
872 dnl
873 dnl  ipv6 plugin - not for QNX yet
874 dnl
875 if test "x${SYS}" != "xnto" && test "x${SYS}" != "xmingw32"
876 then
877   have_ipv6=0
878   AC_CHECK_FUNC(inet_pton,[have_ipv6=1],[
879     AC_CHECK_LIB(resolv,inet_pton,
880       [have_ipv6=1
881        ipv6_LDFLAGS="${ipv6_LDFLAGS} -lresolv"])
882   ])
883   AC_MSG_CHECKING(for sockaddr_in6 in netinet/in.h)
884   AC_EGREP_HEADER(sockaddr_in6,netinet/in.h,
885     [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); have_ipv6=0])
886   if test x$have_ipv6 = x1; then
887     PLUGINS="${PLUGINS} ipv6"
888   fi
889 fi
890 if test "x${SYS}" = "xmingw32"
891 then
892   AC_MSG_CHECKING(for getaddrinfo in ws2tcpip.h)
893   AC_EGREP_HEADER(addrinfo,ws2tcpip.h,[AC_MSG_RESULT(yes)
894     PLUGINS="${PLUGINS} ipv6"],[AC_MSG_RESULT(no)])
895 fi
896
897 dnl
898 dnl  AVI demux plugin
899 dnl
900 AC_ARG_ENABLE(avi,
901   [  --enable-avi            AVI demux module (default enabled)])
902 if test "x${enable_avi}" != "xno"
903 then
904   PLUGINS="${PLUGINS} avi"
905 fi
906
907 dnl
908 dnl  Codec plugins
909 dnl
910
911 AC_ARG_WITH(,[Codec plugins:])
912
913 dnl
914 dnl  mad plugin
915 dnl
916 AC_ARG_ENABLE(mad,
917   [  --enable-mad            libmad module (default disabled)])
918 if test "x${enable_mad}" = "xyes"
919 then
920   AC_ARG_WITH(mad,
921     [    --with-mad=PATH       path to libmad],[],[])
922   if test "x${with_mad}" != "xno" -a "x${with_mad}" != "x"
923   then
924     mad_CFLAGS="${mad_CFLAGS} -I${with_mad}/include"
925     mad_LDFLAGS="${mad_LDFLAGS} -L${with_mad}/lib"
926   fi
927
928   AC_ARG_WITH(mad-tree,
929     [    --with-mad-tree=PATH  mad tree for static linking],[],[])
930   if test "x${with_mad_tree}" != "xno" -a "x${with_mad_tree}" != "x"
931   then
932     real_mad_tree="`cd ${with_mad_tree} 2>/dev/null && pwd`"
933     if test "x${real_mad_tree}" = "x"
934     then
935       dnl  The given directory can't be found
936       AC_MSG_RESULT(no)
937       AC_MSG_ERROR([${with_mad_tree} directory doesn't exist])
938     fi
939     dnl  Use a custom libmad
940     AC_MSG_CHECKING(for mad.h in ${real_mad_tree}/libmad)
941     if test -f ${real_mad_tree}/libmad/mad.h
942     then
943       AC_MSG_RESULT(yes)
944       mad_CFLAGS="${mad_CFLAGS} -I${real_mad_tree}/libmad"
945       mad_LDFLAGS="${mad_LDFLAGS} -L${real_mad_tree}/libmad/.libs"
946       LDFLAGS="${save_LDFLAGS} ${mad_LDFLAGS}"
947       AC_CHECK_LIB(mad, mad_bit_init, [
948         BUILTINS="${BUILTINS} mad"
949         mad_LDFLAGS="${mad_LDFLAGS} -lmad"
950         ],[ AC_MSG_ERROR([the specified tree hasn't been compiled ])
951       ],[])
952       LDFLAGS="${save_LDFLAGS}"
953     else
954       AC_MSG_RESULT(no)
955       AC_MSG_ERROR([the specified tree doesn't have mad.h])
956     fi
957   else
958     CFLAGS="${save_CFLAGS} ${mad_CFLAGS}"
959     LDFLAGS="${save_LDFLAGS} ${mad_LDFLAGS}"
960     AC_CHECK_HEADERS(mad.h, ,
961       [ AC_MSG_ERROR([Cannot find development headers for libmad...]) ])
962     AC_CHECK_LIB(mad, mad_bit_init, [
963       PLUGINS="${PLUGINS} mad"
964       mad_LDFLAGS="${mad_LDFLAGS} -lmad" ],
965       [ AC_MSG_ERROR([Cannot find libmad library...]) ])
966     CFLAGS="${save_CFLAGS}"
967     LDFLAGS="${save_LDFLAGS}"
968   fi
969 fi
970
971 dnl
972 dnl  ffmpeg decoder plugin
973 dnl
974 AC_ARG_ENABLE(ffmpeg,
975 [  --enable-ffmpeg         ffmpeg codec (default disabled)])
976 if test "x${enable_ffmpeg}" = "xyes"
977 then
978   AC_ARG_WITH(ffmpeg,
979     [    --with-ffmpeg=PATH    path to ffmpeg installation],[],[])
980   if test "x${with_ffmpeg}" != "xno" -a "x${with_ffmpeg}" != "x"
981   then
982     ffmpeg_CFLAGS="${ffmpeg_CFLAGS} -I${with_ffmpeg}/include/libffmpeg"
983     ffmpeg_LDFLAGS="${ffmpeg_LDFLAGS} -L${with_ffmpeg}/lib"
984   fi
985
986   AC_ARG_WITH(ffmpeg-tree, 
987   [    --with-ffmpeg-tree=PATH ffmpeg tree for static linking])
988   if test "x${with_ffmpeg_tree}" != "x"
989   then
990     AC_MSG_CHECKING(for libavcodec.a in ${with_ffmpeg_tree})
991     real_ffmpeg_tree="`cd ${with_ffmpeg_tree} 2>/dev/null && pwd`"
992     if test "x${real_ffmpeg_tree}" = x
993     then
994       dnl  The given directory can't be found
995       AC_MSG_RESULT(no)
996       AC_MSG_ERROR([cannot cd to ${with_ffmpeg_tree}])
997     fi
998     if test -f "${real_ffmpeg_tree}/libavcodec/libavcodec.a"
999     then
1000       dnl  Use a custom libffmpeg
1001       AC_MSG_RESULT(${real_ffmpeg_tree}/libavcodec/libavcodec.a)
1002       BUILTINS="${BUILTINS} ffmpeg"
1003       ffmpeg_LDFLAGS="${ffmpeg_LDFLAGS} ${real_ffmpeg_tree}/libavcodec/libavcodec.a -lm"
1004       ffmpeg_CFLAGS="${ffmpeg_CFLAGS} -I${real_ffmpeg_tree}/libavcodec"
1005     else
1006       dnl  The given libavcodec wasn't built
1007       AC_MSG_RESULT(no)
1008       AC_MSG_ERROR([cannot find ${real_ffmpeg_tree}/libavcodec/libavcodec.a, make sure you compiled libavcodec in ${with_ffmpeg_tree}])
1009     fi
1010   else
1011     CFLAGS="${save_CFLAGS} ${ffmpeg_CFLAGS}"
1012     LDFLAGS="${save_LDFLAGS} ${ffmpeg_LDFLAGS} -lm"
1013     AC_CHECK_LIB(avcodec, avcodec_init, [
1014       BUILTINS="${BUILTINS} ffmpeg"
1015       ffmpeg_LDFLAGS="${ffmpeg_LDFLAGS} -lavcodec -lm" ],
1016       [ AC_MSG_ERROR([Cannot find libavcodec library...]) ])
1017     LDFLAGS="${save_LDFLAGS}"
1018     CFLAGS="${save_CFLAGS}"
1019   fi
1020 fi
1021
1022 dnl 
1023 dnl MP4 module 
1024 dnl 
1025 AC_ARG_ENABLE(mp4,
1026   [  --enable-mp4            MP4 demux module (default disabled)])
1027 if test "x${enable_mp4}" = "xyes"
1028 then
1029     AC_CHECK_HEADER(zlib.h,
1030         AC_CHECK_LIB(z, inflateEnd,
1031             [ PLUGINS="${PLUGINS} mp4"
1032               mp4_LDFLAGS="${mp4_LDFLAGS} -lz" ], 
1033             [ AC_MSG_ERROR([cannot find zlib library...]) ]),
1034         [  AC_MSG_ERROR([cannot find zlib header...]) ])
1035 fi
1036
1037 dnl special case for BeOS
1038 if test "x${SYS}" = "xbeos"
1039 then
1040     PLUGINS="${PLUGINS} beos"
1041 fi
1042
1043 dnl
1044 dnl  a52 AC3 decoder plugin
1045 dnl
1046 AC_ARG_ENABLE(a52,
1047   [  --enable-a52            AC3 support with liba52 (default enabled)])
1048 if test "x${enable_a52}" != "xno"
1049 then
1050   AC_ARG_WITH(a52-tree,
1051     [    --with-a52-tree=PATH  a52dec tree for static linking ],[],[])
1052   if test "x${with_a52_tree}" != "xno" -a "x${with_a52_tree}" != "x"
1053   then
1054     real_a52_tree="`cd ${with_a52_tree} 2>/dev/null && pwd`"
1055     if test "x${real_a52_tree}" = "x"
1056     then
1057       dnl  The given directory can't be found
1058       AC_MSG_RESULT(no)
1059       AC_MSG_ERROR([${with_a52_tree} directory doesn't exist])
1060     fi
1061     dnl  Use a custom a52dec
1062     AC_MSG_CHECKING(for a52.h in ${real_a52_tree}/include)
1063     if test -f ${real_a52_tree}/include/a52.h
1064     then
1065       AC_MSG_RESULT(yes)
1066       a52_CFLAGS="${a52_CFLAGS} -I${real_a52_tree}"
1067       a52_LDFLAGS="${a52_LDFLAGS} -L${real_a52_tree}/liba52/.libs"
1068       LDFLAGS="${save_LDFLAGS} ${a52_LDFLAGS}"
1069       AC_CHECK_LIB(a52, a52_free, [
1070         BUILTINS="${BUILTINS} a52"
1071         a52_LDFLAGS="${a52_LDFLAGS} -la52 -lm"
1072         a52_CFLAGS="${a52_CFLAGS} -DUSE_A52DEC_TREE"
1073         ],[
1074         if test -f ${real_a52_tree}/liba52/.libs/liba52.a
1075         then
1076           AC_MSG_ERROR([make sure you have at least a52dec-0.7.3])
1077         else
1078           AC_MSG_ERROR([the specified tree hasn't been compiled])
1079         fi
1080       ],[-lm])
1081       LDFLAGS="${save_LDFLAGS}"
1082     else
1083       AC_MSG_RESULT(no)
1084       AC_MSG_ERROR([the specified tree doesn't have a52.h])
1085     fi
1086   else dnl  no with args
1087     AC_CHECK_HEADERS(a52dec/a52.h, [
1088       AC_CHECK_LIB(a52, a52_free, [
1089         BUILTINS="${BUILTINS} a52"
1090         a52_LDFLAGS="${a52_LDFLAGS} -la52 -lm"
1091         a52_CFLAGS="${a52_CFLAGS}"
1092       ],[],[-lm])
1093     ])
1094   fi
1095 fi
1096
1097 dnl
1098 dnl  cinepak plugin
1099 dnl
1100 AC_ARG_ENABLE(cinepak,
1101   [  --enable-cinepak        Cinepak decoder (default enabled)])
1102 if test "x${enable_cinepak}" != "xno"
1103 then
1104   PLUGINS="${PLUGINS} cinepak"
1105 fi
1106
1107 dnl
1108 dnl  ogg vorbis plugin
1109 dnl
1110 AC_ARG_ENABLE(vorbis,
1111   [  --enable-vorbis         Ogg/Vorbis decoder support (default enabled)])
1112 if test "x${enable_vorbis}" != "xno"
1113 then
1114   AC_CHECK_HEADERS(ogg/ogg.h, [
1115     dnl disabled for the moment
1116     #PLUGINS="${PLUGINS} vorbis"
1117     vorbis_LDFLAGS="${vorbis_LDFLAGS} -lvorbis"
1118    ],[])
1119 fi
1120
1121 dnl
1122 dnl  Video plugins
1123 dnl
1124
1125 AC_ARG_WITH(,[Video plugins:])
1126
1127 dnl
1128 dnl  X11 module
1129 dnl  (enabled by default except on win32)
1130 dnl
1131 AC_ARG_ENABLE(x11,
1132   [  --enable-x11            X11 support (default enabled)])
1133 if test "x${enable_x11}" != "xno" &&
1134   (test "x${SYS}" != "xmingw32" || test "x${enable_x11}" = "xyes"); then
1135   CPPFLAGS="${save_CPPFLAGS} -I${x_includes}"
1136   AC_CHECK_HEADERS(X11/Xlib.h, [
1137     PLUGINS="${PLUGINS} x11"
1138     x11_LDFLAGS="${x11_LDFLAGS} -L${x_libraries} -lX11 -lXext"
1139     x11_CFLAGS="${x11_CFLAGS} -I${x_includes}"
1140   ])
1141   CPPFLAGS="${save_CPPFLAGS}"
1142 fi
1143
1144 dnl
1145 dnl  XVideo module
1146 dnl  (enabled by default except on win32)
1147 dnl
1148 AC_ARG_ENABLE(xvideo,
1149   [  --enable-xvideo         XVideo support (default enabled)])
1150 if test "x${enable_xvideo}" != "xno" &&
1151   (test "x${SYS}" != "xmingw32" || test "x${enable_xvideo}" = "xyes"); then
1152   CPPFLAGS="${save_CPPFLAGS} -I${x_includes}"
1153   AC_CHECK_HEADERS(X11/extensions/Xv.h, [
1154     CFLAGS="${save_CFLAGS} -L${x_libraries} -lX11 -lXext"
1155     AC_CHECK_LIB(Xv_pic,XvPutImage,
1156       # We have Xv_pic, that's good, we can build an xvideo.so plugin !
1157       PLUGINS="${PLUGINS} xvideo"
1158       xvideo_LDFLAGS="${xvideo_LDFLAGS} -L${x_libraries} -lX11 -lXext -lXv_pic"
1159       xvideo_CFLAGS="${xvideo_CFLAGS} -I${x_includes}",
1160       AC_CHECK_LIB(Xv,XvPutImage,
1161         # We don't have Xv_pic, but we have Xv, let's make xvideo.a as builtin
1162         PLUGINS="${PLUGINS} xvideo"
1163         xvideo_LDFLAGS="${xvideo_LDFLAGS} -L${x_libraries} -lX11 -lXext -lXv"
1164         xvideo_CFLAGS="${xvideo_CFLAGS} -I${x_includes}",
1165         # Otherwise... well, do nothing.
1166       )
1167     )
1168     CFLAGS="${save_CFLAGS}"
1169   ]
1170   CPPFLAGS="${save_CPPFLAGS}")
1171 fi
1172
1173 dnl
1174 dnl  SDL module
1175 dnl
1176 AC_ARG_ENABLE(sdl,
1177   [  --enable-sdl            SDL support (default enabled)])
1178 if test "x${enable_sdl}" != "xno"
1179 then
1180   SDL_PATH="${PATH}"
1181   AC_ARG_WITH(sdl-config-path,
1182     [    --with-sdl-config-path=PATH sdl-config path (default search in \$PATH)],
1183     [ if test "x${with_sdl_config_path}" != "xno"
1184       then
1185         SDL_PATH="${with_sdl_config_path}:${PATH}"
1186       fi ])
1187   AC_PATH_PROG(SDL12_CONFIG, sdl12-config, no, ${SDL_PATH})
1188   SDL_CONFIG="${SDL12_CONFIG}"
1189   SDL_HEADER="SDL12/SDL.h"
1190   if test "x${SDL_CONFIG}" = "xno"
1191   then
1192     AC_PATH_PROG(SDL11_CONFIG, sdl11-config, no, ${SDL_PATH})
1193     SDL_CONFIG=${SDL11_CONFIG}
1194     SDL_HEADER="SDL11/SDL.h"
1195   fi
1196   if test "x${SDL_CONFIG}" = "xno"
1197   then
1198     AC_PATH_PROG(SDL_CONFIG, sdl-config, no, ${SDL_PATH})
1199     SDL_HEADER="SDL/SDL.h"
1200   fi
1201   if test "x${SDL_CONFIG}" != "xno"
1202   then
1203     PLUGINS="${PLUGINS} sdl"
1204     sdl_CFLAGS="${sdl_CFLAGS} `${SDL_CONFIG} --cflags`"
1205     sdl_LDFLAGS="${sdl_LDFLAGS} `${SDL_CONFIG} --libs | sed 's,-rdynamic,,'`"
1206     CPPFLAGS="${save_CPPFLAGS} ${sdl_CFLAGS}"
1207     AC_CHECK_HEADERS(${SDL_HEADER}, AC_DEFINE_UNQUOTED(SDL_INCLUDE_FILE,
1208       <${SDL_HEADER}>, Indicate whether we should use SDL/SDL.h or SDL11/SDL.h),
1209       [ AC_MSG_ERROR([The development package for SDL is not installed. 
1210 Please install it and try again. Alternatively you can also configure with 
1211 --disable-sdl.])
1212       ])
1213     CPPFLAGS="${save_CPPFLAGS}"
1214     if expr 1.1.5 \> `${SDL_CONFIG} --version` >/dev/null
1215     then
1216       AC_MSG_ERROR([The development package for SDL is not installed.
1217 Please install it and try again. Alternatively you can also configure with
1218 --disable-sdl.])
1219     fi
1220   elif test "x${enable_sdl}" =  "xyes"
1221   then
1222     AC_MSG_ERROR([I couldn't find the SDL package. You can download libSDL
1223 from http://www.libsdl.org/, or configure with --disable-sdl. Have a nice day.
1224     ])
1225   fi
1226 fi
1227
1228 dnl
1229 dnl  Windows DirectX module
1230 dnl
1231 AC_ARG_ENABLE(directx,
1232   [  --enable-directx        Win32 DirectX support (default enabled on Win32)])
1233 if test "x${enable_directx}" != "xno"
1234 then
1235   if test "x${SYS}" = "xmingw32"
1236   then
1237     AC_ARG_WITH(directx, 
1238     [    --with-directx=PATH   Win32 DirectX headers])
1239     if test "x${with_directx}" = "x"
1240     then
1241       AC_CHECK_HEADERS(ddraw.h,
1242       [ PLUGINS="${PLUGINS} directx"
1243         directx_LDFLAGS="${directx_LDFLAGS} -lgdi32" ])
1244     else
1245       AC_MSG_CHECKING(for directX headers in ${with_directx})
1246       if test -f ${with_directx}/ddraw.h
1247       then
1248         PLUGINS="${PLUGINS} directx"
1249         directx_LDFLAGS="${directx_LDFLAGS} -lgdi32"
1250         directx_CFLAGS="${directx_CFLAGS} -I${with_directx}"
1251         AC_MSG_RESULT(yes)
1252       else
1253         AC_MSG_RESULT(no)
1254         AC_MSG_ERROR([Cannot find ${with_directx}/ddraw.h!])
1255       fi
1256     fi
1257   fi
1258 fi
1259
1260 dnl
1261 dnl  Linux framebuffer module
1262 dnl
1263 AC_ARG_ENABLE(fb,
1264   [  --enable-fb             Linux framebuffer support (default enabled on Linux)])
1265     if test "x${enable_fb}" != "xno"
1266     then
1267       AC_CHECK_HEADERS(linux/fb.h, [
1268         PLUGINS="${PLUGINS} fb"
1269       ])
1270     fi
1271
1272 dnl
1273 dnl  Linux MGA module
1274 dnl
1275 AC_ARG_ENABLE(mga,
1276   [  --enable-mga            Linux kernel Matrox support (default disabled)],
1277   [ if test "x${enable_mga}" = "xyes"
1278     then
1279       PLUGINS="${PLUGINS} mga xmga"
1280     fi ])
1281
1282 dnl
1283 dnl  GGI module
1284 dnl
1285 AC_ARG_ENABLE(ggi,
1286   [  --enable-ggi            GGI support (default disabled)])
1287 if test "x${enable_ggi}" = "xyes"
1288 then
1289   PLUGINS="${PLUGINS} ggi"
1290   ggi_LDFLAGS="${ggi_LDFLAGS} -lggi"
1291   AC_ARG_WITH(ggi,
1292     [    --with-ggi=PATH       path to libggi],
1293     [ if test "x${with_ggi}" != "xno" -a "x${with_ggi}" != "x"
1294       then
1295         CFLAGS_GGI="${CFLAGS_GGI} -I${with_ggi}/include"
1296         ggi_LDFLAGS="${ggi_LDFLAGS} -L${with_ggi}/lib"
1297       fi ])
1298 fi
1299
1300 dnl
1301 dnl  Glide module
1302 dnl
1303 AC_ARG_ENABLE(glide,
1304   [  --enable-glide          Glide (3dfx) support (default disabled)])
1305 if test "x${enable_glide}" = "xyes"
1306 then
1307   PLUGINS="${PLUGINS} glide"
1308   glide_LDFLAGS="${glide_LDFLAGS} -lglide2x -lm"
1309   glide_CFLAGS="${glide_CFLAGS} -I/usr/include/glide"
1310   AC_ARG_WITH(glide,
1311     [    --with-glide=PATH     path to libglide],
1312     [ if test "x${with_glide}" != "xno" -a "x${with_glide}" != "x"
1313       then
1314         glide_CFLAGS="${glide_CFLAGS} -I${with_glide}/include"
1315         glide_LDFLAGS="${glide_LDFLAGS} -L${with_glide}/lib"
1316       fi ])
1317 fi
1318
1319 dnl
1320 dnl  AA plugin
1321 dnl
1322 AC_ARG_ENABLE(aa,
1323   [  --enable-aa             aalib output (default disabled)])
1324 if test "x${enable_aa}" = "xyes"
1325 then
1326   AC_CHECK_HEADER(aalib.h,have_aa="true",have_aa="false")
1327   if test "x${have_aa}" = "xtrue"
1328   then
1329     PLUGINS="${PLUGINS} aa"
1330     aa_LDFLAGS="${aa_LDFLAGS} -laa"
1331   fi
1332 fi
1333
1334 dnl
1335 dnl  Audio plugins
1336 dnl
1337
1338 AC_ARG_WITH(,[Audio plugins:])
1339
1340 dnl
1341 dnl  OSS /dev/dsp module (enabled by default except on win32)
1342 dnl
1343 AC_ARG_ENABLE(dsp,
1344   [  --enable-dsp            Linux /dev/dsp support (enabled on Linux)])
1345
1346 if test "x${enable_dsp}" != "xno" &&
1347   (test "x${SYS}" != "xmingw32" || test "x${enable_dsp}" = "xyes")
1348 then
1349   AC_CHECK_HEADERS(soundcard.h sys/soundcard.h machine/soundcard.h, [
1350     PLUGINS="${PLUGINS} dsp"
1351     AC_CHECK_LIB(ossaudio,main,dsp_LDFLAGS="${dsp_LDFLAGS} -lossaudio")
1352   ])
1353 fi
1354
1355 dnl
1356 dnl  Esound module
1357 dnl
1358 AC_ARG_ENABLE(esd,
1359   [  --enable-esd            Esound library support (default disabled)],
1360   [if test "x${enable_esd}" = "xyes"
1361    then
1362      AC_PATH_PROG(ESD_CONFIG, esd-config, no)
1363      if test "x${ESD_CONFIG}" != "xno"
1364      then
1365        PLUGINS="${PLUGINS} esd"
1366        esd_CFLAGS="${esd_CFLAGS} `${ESD_CONFIG} --cflags`"
1367        esd_LDFLAGS="${esd_LDFLAGS} `${ESD_CONFIG} --libs`"
1368      fi
1369    fi])
1370
1371 dnl
1372 dnl  aRts module
1373 dnl
1374 AC_ARG_ENABLE(arts,
1375   [  --enable-arts           aRts sound server (default disabled)],
1376   [if test "x${enable_arts}" = "xyes"
1377    then
1378      AC_PATH_PROG(ARTS_CONFIG, artsc-config, no)
1379      if test "x${ARTS_CONFIG}" != "xno"
1380      then
1381        PLUGINS="${PLUGINS} arts"
1382        arts_CFLAGS="${arts_CFLAGS} `${ARTS_CONFIG} --cflags`"
1383        arts_LDFLAGS="${arts_LDFLAGS} `${ARTS_CONFIG} --libs `"
1384      fi
1385    fi])
1386
1387 dnl
1388 dnl  ALSA module
1389 dnl
1390 AC_ARG_ENABLE(alsa,
1391   [  --enable-alsa           ALSA sound support for Linux (default disabled)],
1392   [if test "x${enable_alsa}" = "xyes"
1393    then
1394      AC_CHECK_HEADER(alsa/asoundlib.h, AC_CHECK_LIB(asound, main, have_alsa="true", have_alsa="false"),have_alsa="false")
1395      if test "x${have_alsa}" = "xtrue"
1396      then
1397        PLUGINS="${PLUGINS} alsa"
1398        alsa_LDFLAGS="${alsa_LDFLAGS} -lasound -lm -ldl"
1399      fi
1400    fi])
1401
1402 dnl
1403 dnl  win32 waveOut plugin
1404 dnl
1405 AC_ARG_ENABLE(waveout,
1406   [  --enable-waveout        Win32 waveOut module (default enabled on Win32)])
1407 if test "x${enable_waveout}" != "xno" -a "x${SYS}" = "xmingw32"
1408   then
1409     PLUGINS="${PLUGINS} waveout"
1410     waveout_LDFLAGS="-lwinmm"
1411 fi
1412
1413 dnl
1414 dnl  Interface plugins
1415 dnl
1416
1417 AC_ARG_WITH(,[Interface plugins:])
1418
1419 dnl
1420 dnl  Gtk+ module
1421 dnl
1422 AC_ARG_ENABLE(gtk,
1423   [  --enable-gtk            Gtk+ support (default enabled)])
1424 if test "x${enable_gtk}" != "xno"
1425 then
1426   GTK_PATH="${PATH}"
1427   AC_ARG_WITH(gtk-config-path,
1428     [    --with-gtk-config-path=PATH gtk-config path (default search in \$PATH)],
1429     [ if test "x${with_gtk_config_path}" != "xno"
1430       then
1431         GTK_PATH="${with_gtk_config_path}:${PATH}"
1432       fi ])
1433   # look for gtk-config
1434   AC_PATH_PROG(GTK12_CONFIG, gtk12-config, no, ${GTK_PATH})
1435   GTK_CONFIG=${GTK12_CONFIG}
1436   if test "x${GTK_CONFIG}" = "xno"
1437   then
1438     AC_PATH_PROG(GTK_CONFIG, gtk-config, no, ${GTK_PATH})
1439   fi
1440   if test "x${GTK_CONFIG}" != "xno"
1441   then
1442     if expr 1.2.0 \> `${GTK_CONFIG} --version` >/dev/null
1443     then
1444       AC_MSG_ERROR([Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-gtk.])
1445     fi
1446     gtk_CFLAGS="${gtk_CFLAGS} `${GTK_CONFIG} --cflags gtk`"
1447     gtk_LDFLAGS="${gtk_LDFLAGS} `${GTK_CONFIG} --libs gtk | sed 's,-rdynamic,,'`"
1448     # now look for the gtk.h header
1449     CPPFLAGS="${save_CPPFLAGS} ${gtk_CFLAGS}"
1450     ac_cv_gtk_headers=yes
1451     AC_CHECK_HEADERS(gtk/gtk.h glib.h gdk/gdk.h, , [
1452       ac_cv_gtk_headers=no
1453       echo "Cannot find gtk development headers."
1454     ])
1455     if test "x${ac_cv_gtk_headers}" = "xyes"
1456     then
1457       PLUGINS="${PLUGINS} gtk"
1458       ALIASES="${ALIASES} gvlc"
1459     fi
1460     CPPFLAGS="${save_CPPFLAGS}"
1461   fi
1462 fi
1463
1464 dnl
1465 dnl  Familiar module uses Gtk+ library
1466 dnl
1467 AC_ARG_ENABLE(familiar,
1468   [  --enable-familiar       Familiar Gtk+ support (default disabled)])
1469 if test "x${enable_familiar}" = "xyes"
1470 then
1471   GTK_PATH="${PATH}"
1472   AC_ARG_WITH(gtk-config-path,
1473     [    --with-gtk-config-path=PATH gtk-config path (default search in \$PATH)],
1474     [ if test "x${with_gtk_config_path}" != "xno"
1475       then
1476         GTK_PATH="${with_gtk_config_path}:${PATH}"
1477       fi ])
1478   # look for gtk-config
1479   AC_PATH_PROG(GTK12_CONFIG, gtk12-config, no, ${GTK_PATH})
1480   GTK_CONFIG=${GTK12_CONFIG}
1481   if test "x${GTK_CONFIG}" = "xno"
1482   then
1483     AC_PATH_PROG(GTK_CONFIG, gtk-config, no, ${GTK_PATH})
1484   fi
1485   if test "x${GTK_CONFIG}" != "xno"
1486   then
1487     if expr 1.2.0 \> `${GTK_CONFIG} --version` >/dev/null
1488     then
1489       AC_MSG_ERROR([Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-familiar.])
1490     fi
1491     familiar_CFLAGS="${familiar_CFLAGS} `${GTK_CONFIG} --cflags gtk`"
1492     familiar_LDFLAGS="${familiar_LDFLAGS} `${GTK_CONFIG} --libs gtk | sed 's,-rdynamic,,'`"
1493     # now look for the gtk.h header
1494     CPPFLAGS="${save_CPPFLAGS} ${familiar_CFLAGS}"
1495     ac_cv_gtk_headers=yes
1496     AC_CHECK_HEADERS(gtk/gtk.h glib.h gdk/gdk.h, , [
1497       ac_cv_gtk_headers=no
1498       echo "Cannot find gtk development headers."
1499     ])
1500     if test "x${ac_cv_gtk_headers}" = "xyes"
1501     then
1502       PLUGINS="${PLUGINS} familiar"
1503     fi
1504     CPPFLAGS="${save_CPPFLAGS}"
1505   fi
1506 fi
1507
1508 dnl
1509 dnl  Gnome module
1510 dnl
1511 AC_ARG_ENABLE(gnome,
1512   [  --enable-gnome          Gnome interface support (default disabled)],
1513   [if test "x${enable_gnome}" = "xyes"; then
1514     # look for gnome-config
1515     AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
1516     if test -x ${GNOME_CONFIG}
1517     then
1518        gnome_CFLAGS="${gnome_CFLAGS} `${GNOME_CONFIG} --cflags gtk gnomeui`"
1519        gnome_LDFLAGS="${gnome_LDFLAGS} `${GNOME_CONFIG} --libs gnomeui | sed 's,-rdynamic,,'`"
1520     fi
1521     # now look for the gnome.h header
1522     CPPFLAGS="${save_CPPFLAGS} ${gnome_CFLAGS}"
1523     AC_CHECK_HEADERS(gnome.h, [
1524       PLUGINS="${PLUGINS} gnome"
1525       ALIASES="${ALIASES} gnome-vlc"
1526      ],[
1527       AC_MSG_ERROR([Can't find gnome headers. Please install the gnome
1528 developement tools or remove the --enable-gnome option])
1529      ])
1530     CPPFLAGS="${save_CPPFLAGS}"
1531   fi])
1532
1533 dnl
1534 dnl  Qt module
1535 dnl
1536 AC_ARG_ENABLE(qt,
1537   [  --enable-qt             Qt interface support (default disabled)],
1538   [if test "x${enable_qt}" = "xyes"; then
1539      PLUGINS="${PLUGINS} qt"
1540      ALIASES="${ALIASES} qvlc"
1541      qt_LDFLAGS="${qt_LDFLAGS} -lqt -L${QTDIR}/lib"
1542      qt_CFLAGS="${qt_CFLAGS} -I/usr/include/qt -I${QTDIR}/include"
1543      if test -x ${QTDIR}/bin/moc
1544      then
1545        MOC=${QTDIR}/bin/moc
1546      else
1547        MOC=moc
1548      fi
1549    fi])
1550
1551 dnl 
1552 dnl  KDE module
1553 dnl
1554 AC_ARG_ENABLE(kde,
1555   [  --enable-kde            KDE interface support (default disabled)],
1556   [if test "x${enable_kde}" = "xyes"; then
1557      PLUGINS="${PLUGINS} kde"
1558      ALIASES="${ALIASES} kvlc"
1559      kde_LDFLAGS="${kde_LDFLAGS} -L${KDEDIR}/lib -lkfile"
1560      kde_CFLAGS="${kde_CFLAGS} -I/usr/include/kde -I/usr/include/qt"
1561      kde_CFLAGS="${kde_CFLAGS} -I${KDEDIR}/include -I${QTDIR}/include"
1562      if test -x ${QTDIR}/bin/moc
1563      then
1564        MOC=${QTDIR}/bin/moc
1565      else
1566        MOC=moc
1567      fi
1568    fi])
1569
1570 dnl
1571 dnl  MacOS X module
1572 dnl
1573 AC_ARG_ENABLE(macosx,
1574   [  --enable-macosx         MacOS X support (default enabled on MacOS X)],
1575   [if test "x${enable_macosx}" = "xyes"
1576    then
1577      BUILTINS="${BUILTINS} macosx"
1578      macosx_LDFLAGS="${macosx_LDFLAGS} -framework CoreAudio -framework AudioToolbox -framework IOKit -framework Cocoa -framework Carbon -framework AGL -framework QuickTime -lobjc -ObjC"
1579    fi],
1580   [AC_CHECK_HEADERS(Cocoa/Cocoa.h,
1581      BUILTINS="${BUILTINS} macosx"
1582      macosx_LDFLAGS="${macosx_LDFLAGS} -framework CoreAudio -framework AudioToolbox -framework IOKit -framework Cocoa -framework Carbon -framework AGL -framework QuickTime -lobjc -ObjC"
1583    )])
1584
1585 dnl
1586 dnl  QNX RTOS module
1587 dnl
1588 AC_ARG_ENABLE(qnx,
1589   [  --enable-qnx            QNX RTOS support (default enabled on QNX RTOS)])
1590     if test "x${enable_qnx}" != "xno"
1591     then
1592       AC_CHECK_HEADERS(Ph.h, [
1593         PLUGINS="${PLUGINS} qnx"
1594         qnx_LDFLAGS="${qnx_LDFLAGS} -lasound -lph"
1595       ])
1596     fi
1597
1598 dnl
1599 dnl  Windows native interface module, built with Borland C++ Builder
1600 dnl
1601 AC_ARG_ENABLE(intfwin,
1602 [  --enable-intfwin        Win32 interface support (default disabled)],
1603 [ if test "x${enable_intfwin}" != "xno"
1604   then
1605     AC_ARG_WITH(bcbuilder, 
1606     [    --with-bcbuilder=PATH Borland C++ Builder installation path])
1607     if test "x${with_bcbuilder}" != "x"
1608     then
1609       BCBUILDER="${with_bcbuilder}"
1610     fi
1611     PLUGINS="${PLUGINS} intfwin"
1612   fi ])
1613
1614 dnl
1615 dnl  ncurses module
1616 dnl
1617 AC_ARG_ENABLE(ncurses,
1618   [  --enable-ncurses        ncurses interface support (default disabled)],
1619   [if test "x${enable_ncurses}" = "xyes"; then
1620      PLUGINS="${PLUGINS} ncurses"
1621      ncurses_LDFLAGS="${ncurses_LDFLAGS} -lncurses"
1622    fi])
1623
1624 dnl
1625 dnl  XOSD plugin
1626 dnl
1627 AC_ARG_ENABLE(xosd,
1628   [  --enable-xosd           xosd interface support (default disabled)])
1629 if test "x${enable_xosd}" = "xyes"
1630 then
1631   AC_CHECK_HEADER(xosd.h, have_xosd="true", have_xosd="false")
1632   if test "x${have_xosd}" = "xtrue"
1633   then
1634     PLUGINS="${PLUGINS} xosd"
1635     xosd_LDFLAGS="${xosd_LDFLAGS} -lxosd"
1636   fi
1637 fi
1638
1639 dnl
1640 dnl  Lirc plugin
1641 dnl
1642 AC_ARG_ENABLE(lirc,
1643   [  --enable-lirc           lirc support (default disabled)])
1644 if test "x${enable_lirc}" = "xyes"
1645 then
1646   AC_CHECK_HEADER(lirc/lirc_client.h, AC_CHECK_LIB(lirc_client, lirc_init, have_lirc="true", have_lirc="false"),have_lirc="false")
1647   if test "x${have_lirc}" = "xtrue"
1648   then
1649     PLUGINS="${PLUGINS} lirc"
1650     lirc_LDFLAGS="${lirc_LDFLAGS} -llirc_client"
1651   fi
1652 fi
1653
1654 AC_ARG_WITH(,[Misc options:])
1655
1656 dnl
1657 dnl  Endianness check, AC_C_BIGENDIAN doesn't work if we are cross-compiling
1658 dnl
1659 dnl  We give the user the opportunity to specify
1660 dnl  --with-words=big or --with-words=little ; otherwise, try to guess
1661 dnl
1662 AC_ARG_WITH(words,
1663   [  --with-words=endianness set endianness (big or little)])
1664   case "x${with_words}" in
1665     xbig)
1666       ac_cv_c_bigendian=yes
1667       ;;
1668     xlittle)
1669       ac_cv_c_bigendian=no
1670       ;;
1671     *)
1672       dnl  Try to guess endianness by matching patterns on a compiled
1673       dnl  binary, by looking for an ASCII or EBCDIC string
1674       AC_CACHE_CHECK([whether the byte order is big-endian],
1675         [ac_cv_c_bigendian],
1676         [ac_cv_c_bigendian="unknown"
1677         [cat >conftest.c <<EOF
1678         short am[] = { 0x4249, 0x4765, 0x6e44, 0x6961, 0x6e53, 0x7953, 0 };
1679         short ai[] = { 0x694c, 0x5454, 0x656c, 0x6e45, 0x6944, 0x6e61, 0 };
1680         void _a(void) { char*s = (char*)am; s = (char *)ai; }
1681         short ei[] = { 0x89D3, 0xe3e3, 0x8593, 0x95c5, 0x89c4, 0x9581, 0 };
1682         short em[] = { 0xc2c9, 0xc785, 0x95c4, 0x8981, 0x95e2, 0xa8e2, 0 };
1683         void _e(void) { char*s = (char*)em; s = (char*)ei; }
1684         int main(void) { _a(); _e(); return 0; }
1685 EOF
1686         ]
1687         if test -f conftest.c
1688         then 
1689           if ${CC-cc} -c conftest.c -o conftest.o >config.log 2>&1 \
1690               && test -f conftest.o
1691           then
1692             if test "`strings conftest.o | grep BIGenDianSyS`"
1693             then
1694               ac_cv_c_bigendian="yes"
1695             fi
1696             if test "`strings conftest.o | grep LiTTleEnDian`"
1697             then
1698               ac_cv_c_bigendian="no"
1699             fi
1700           fi
1701         fi
1702       ])
1703       if test "x${ac_cv_c_bigendian}" = "xunknown"
1704       then
1705         AC_MSG_ERROR([Could not guess endianness, please use --with-words])
1706       fi
1707       ;;
1708   esac
1709 dnl  Now we know what to use for endianness, just put it in the header
1710 if test "${ac_cv_c_bigendian}" = "yes"
1711 then
1712   AC_DEFINE(WORDS_BIGENDIAN, 1, big endian system)
1713 fi
1714
1715 dnl
1716 dnl  Profiling
1717 dnl
1718 PROFILING=0
1719
1720 GPROF=0
1721 AC_ARG_ENABLE(gprof,
1722 [  --enable-gprof          gprof profiling (default disabled)],
1723 [ if test "x${enable_gprof}" = "xyes"
1724   then
1725     GPROF=1
1726     PROFILING="gprof"
1727   fi
1728 ])
1729
1730 CPROF=0
1731 AC_ARG_ENABLE(cprof,
1732 [  --enable-cprof          cprof profiling (default disabled)],
1733 [ if test "x${enable_cprof}" = "xyes"
1734   then
1735     save_LDFLAGS="${save_LDFLAGS} -lcprof"; LDFLAGS="${save_LDFLAGS}"
1736     CPROF=1
1737     PROFILING="cprof"
1738   fi
1739 ])
1740
1741 dnl
1742 dnl  GNU portable threads
1743 dnl
1744 AC_ARG_ENABLE(pth,
1745   [  --enable-pth            GNU Pth support (default disabled)],
1746   [ if test "x${enable_pth}" = "xyes"; then
1747     AC_CHECK_LIB(pth,pth_init)
1748     AC_EGREP_HEADER(pth_init,pth.h,[
1749       AC_DEFINE(PTH_INIT_IN_PTH_H, 1,
1750                 Define if <pth.h> defines pth_init)
1751     THREAD_LIB="-lpth"
1752     fi])
1753 ])
1754
1755 dnl
1756 dnl  State Threads
1757 dnl
1758 AC_ARG_ENABLE(st,
1759   [  --enable-st             State Threads (default disabled)],
1760   [ if test "x${enable_st}" = "xyes"; then
1761     AC_CHECK_LIB(st,st_init)
1762     AC_EGREP_HEADER(st_init,st.h,[
1763       AC_DEFINE(ST_INIT_IN_ST_H, 1,
1764                 Define if <st.h> defines st_init)
1765     THREAD_LIB="-lst"
1766     fi])
1767 ])
1768
1769 vlc_LDFLAGS="${vlc_LDFLAGS} ${THREAD_LIB}"
1770 plugins_LDFLAGS="${plugins_LDFLAGS} ${THREAD_LIB}"
1771
1772 dnl
1773 dnl  Mozilla plugin
1774 dnl
1775 MOZILLA=0
1776 AC_ARG_ENABLE(mozilla,
1777   [  --enable-mozilla        build a vlc-based Mozilla plugin (default disabled)])
1778 if test "x${enable_mozilla}" = "xyes"
1779 then
1780   AC_PATH_PROG(MOZILLA_CONFIG, mozilla-config, no)
1781   if test "x${MOZILLA_CONFIG}" != "xno"
1782   then
1783     MOZILLA=1
1784     mozilla_CFLAGS="${mozilla_CFLAGS} `${MOZILLA_CONFIG} --cflags plugin java --defines | xargs`"
1785     dnl Workaround for http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=150490
1786     mozilla_LDFLAGS="${mozilla_LDFLAGS} `${MOZILLA_CONFIG} --libs | sed 's#-I\(.*\)/mozilla/\([^ ]*\)#-I\1/\2 -I\1/mozilla/\2#g'`"
1787   fi
1788 fi
1789
1790 dnl
1791 dnl  Plug-ins - this must be AT THE END
1792 dnl
1793 AC_ARG_ENABLE(plugins,
1794   [  --disable-plugins       make all plug-ins built-in (default plug-ins enabled)],
1795   [if test "x${enable_plugins}" = "xno"
1796    then
1797      BUILTINS="${BUILTINS} ${PLUGINS}"
1798      PLUGINS=
1799    fi])
1800
1801 dnl Automagically disable plug-ins if there is no system support for .so files
1802 dnl don't forget vlc-win32 still can load .so as plugins
1803 if test "x${ac_cv_header_dlfcn_h}" = "xno" -a "x${ac_cv_header_image_h}" = "xno" -a "x${SYS}" != "xmingw32"
1804 then
1805   echo "*** Your system doesn't have plug-in support. All plug-ins will be compiled"
1806   echo "as built-in"
1807   BUILTINS="${BUILTINS} ${PLUGINS}"
1808   PLUGINS=
1809 fi
1810
1811 dnl
1812 dnl  Stuff used by the program
1813 dnl
1814 AC_DEFINE_UNQUOTED(VERSION_MESSAGE, "vlc ${VERSION} ${CODENAME} Copyright 1996-2002 VideoLAN", [Simple version string])
1815 AC_DEFINE_UNQUOTED(COPYRIGHT_MESSAGE, "VideoLAN Client - version ${VERSION} ${CODENAME} - (c) 1996-2002 VideoLAN", [Copyright string])
1816 AC_DEFINE_UNQUOTED(CONFIGURE_LINE, "${CONFIGURE_LINE}", [The ./configure command line])
1817
1818 VLC_SYMBOL="`echo ${VERSION} | tr .- __`"
1819 AC_DEFINE_UNQUOTED(MODULE_SUFFIX, "__${VLC_SYMBOL}", [String suffix for module functions])
1820 AC_DEFINE_UNQUOTED(MODULE_SYMBOL, ${VLC_SYMBOL}, [Symbol suffix for module functions])
1821
1822 DATA_PATH="${ac_tool_prefix}/share/videolan"
1823 AC_SUBST(DATA_PATH)
1824 PLUGIN_PATH="${ac_tool_prefix}/share/videolan"
1825 AC_SUBST(PLUGIN_PATH)
1826
1827 dnl
1828 dnl  Restore *FLAGS
1829 dnl
1830 CPPFLAGS="${save_CPPFLAGS}"
1831 CFLAGS="${save_CFLAGS}"
1832 LDFLAGS="${save_LDFLAGS}"
1833
1834 dnl
1835 dnl  Create the vlc-config script
1836 dnl
1837 libvlc_LDFLAGS="${vlc_LDFLAGS} ${builtins_LDFLAGS}"
1838 for i in ${BUILTINS} ; do libvlc_LDFLAGS="${libvlc_LDFLAGS} ${libdir}/vlc/${i}.a `eval echo '$'{${i}_LDFLAGS}`" ; done
1839 AC_SUBST(libvlc_LDFLAGS)
1840
1841 dnl 
1842 dnl  Configuration is finished
1843 dnl
1844 AC_SUBST(SYS)
1845 AC_SUBST(ARCH)
1846 AC_SUBST(PLUGINS)
1847 AC_SUBST(BUILTINS)
1848 AC_SUBST(ALIASES)
1849 AC_SUBST(DEBUG)
1850 AC_SUBST(ASM)
1851 AC_SUBST(CPROF)
1852 AC_SUBST(GPROF)
1853 AC_SUBST(OPTIMS)
1854 AC_SUBST(TUNING)
1855 AC_SUBST(RELEASE)
1856 AC_SUBST(MOC)
1857 AC_SUBST(WINDRES)
1858 AC_SUBST(BCBUILDER)
1859 AC_SUBST(PACKAGE)
1860 AC_SUBST(VERSION)
1861 AC_SUBST(NEED_GETOPT)
1862 AC_SUBST(MOZILLA)
1863
1864 AC_SUBST(CFLAGS_OPTIM)
1865 AC_SUBST(CFLAGS_OPTIM_NODEBUG)
1866 AC_SUBST(LDFLAGS)
1867
1868 AC_SUBST(vlc_CFLAGS)
1869 AC_SUBST(plugins_CFLAGS)
1870 AC_SUBST(builtins_CFLAGS)
1871 AC_SUBST(mozilla_CFLAGS)
1872
1873 AC_SUBST(a52_CFLAGS)
1874 AC_SUBST(arts_CFLAGS)
1875 AC_SUBST(chroma_i420_yuy2_mmx_CFLAGS)
1876 AC_SUBST(dvd_CFLAGS)
1877 AC_SUBST(dvdread_CFLAGS)
1878 AC_SUBST(dvdplay_CFLAGS)
1879 AC_SUBST(mpeg_ts_dvbpsi_CFLAGS)
1880 AC_SUBST(directx_CFLAGS)
1881 AC_SUBST(esd_CFLAGS)
1882 AC_SUBST(familiar_CFLAGS)
1883 AC_SUBST(ffmpeg_CFLAGS)
1884 AC_SUBST(glide_CFLAGS)
1885 AC_SUBST(gnome_CFLAGS)
1886 AC_SUBST(gtk_CFLAGS)
1887 AC_SUBST(kde_CFLAGS)
1888 AC_SUBST(idctaltivec_CFLAGS)
1889 AC_SUBST(macosx_CFLAGS)
1890 AC_SUBST(mad_CFLAGS)
1891 AC_SUBST(memcpyaltivec_CFLAGS)
1892 AC_SUBST(motionaltivec_CFLAGS)
1893 AC_SUBST(qt_CFLAGS)
1894 AC_SUBST(sdl_CFLAGS)
1895 AC_SUBST(x11_CFLAGS)
1896 AC_SUBST(xvideo_CFLAGS)
1897
1898 AC_SUBST(vlc_LDFLAGS)
1899 AC_SUBST(plugins_LDFLAGS)
1900 AC_SUBST(builtins_LDFLAGS)
1901 AC_SUBST(mozilla_LDFLAGS)
1902
1903 AC_SUBST(a52_LDFLAGS)
1904 AC_SUBST(aa_LDFLAGS)
1905 AC_SUBST(alsa_LDFLAGS)
1906 AC_SUBST(arts_LDFLAGS)
1907 AC_SUBST(beos_LDFLAGS)
1908 AC_SUBST(chroma_i420_rgb_LDFLAGS)
1909 AC_SUBST(directx_LDFLAGS)
1910 AC_SUBST(dsp_LDFLAGS)
1911 AC_SUBST(dvd_LDFLAGS)
1912 AC_SUBST(dvdread_LDFLAGS)
1913 AC_SUBST(dvdplay_LDFLAGS)
1914 AC_SUBST(mpeg_ts_dvbpsi_LDFLAGS)
1915 AC_SUBST(esd_LDFLAGS)
1916 AC_SUBST(familiar_LDFLAGS)
1917 AC_SUBST(filter_distort_LDFLAGS)
1918 AC_SUBST(ffmpeg_LDFLAGS)
1919 AC_SUBST(mp4_LDFLAGS)
1920 AC_SUBST(ggi_LDFLAGS)
1921 AC_SUBST(glide_LDFLAGS)
1922 AC_SUBST(gnome_LDFLAGS)
1923 AC_SUBST(gtk_LDFLAGS)
1924 AC_SUBST(http_LDFLAGS)
1925 AC_SUBST(idctaltivec_LDFLAGS)
1926 AC_SUBST(imdct_LDFLAGS)
1927 AC_SUBST(imdct3dn_LDFLAGS)
1928 AC_SUBST(imdctsse_LDFLAGS)
1929 AC_SUBST(ipv4_LDFLAGS)
1930 AC_SUBST(ipv6_LDFLAGS)
1931 AC_SUBST(kde_LDFLAGS)
1932 AC_SUBST(lirc_LDFLAGS)
1933 AC_SUBST(macosx_LDFLAGS)
1934 AC_SUBST(mad_LDFLAGS)
1935 AC_SUBST(memcpyaltivec_LDFLAGS)
1936 AC_SUBST(motionaltivec_LDFLAGS)
1937 AC_SUBST(ncurses_LDFLAGS)
1938 AC_SUBST(qnx_LDFLAGS)
1939 AC_SUBST(qt_LDFLAGS)
1940 AC_SUBST(rc_LDFLAGS)
1941 AC_SUBST(sdl_LDFLAGS)
1942 AC_SUBST(vcd_LDFLAGS)
1943 AC_SUBST(vorbis_LDFLAGS)
1944 AC_SUBST(waveout_LDFLAGS)
1945 AC_SUBST(x11_LDFLAGS)
1946 AC_SUBST(xvideo_LDFLAGS)
1947 AC_SUBST(xosd_LDFLAGS)
1948
1949 AC_OUTPUT([Makefile.config Makefile.opts po/Makefile.in vlc-config])
1950 chmod a+x vlc-config
1951
1952 echo "
1953 vlc configuration
1954 --------------------
1955 vlc version           : ${VERSION}
1956 system                : ${SYS}
1957 architecture          : ${ARCH}
1958 optimizations         : ${OPTIMS}
1959 tuning                : ${TUNING}
1960 debug mode            : ${DEBUG}
1961 release               : ${RELEASE}
1962 profiling             : ${PROFILING}
1963 need builtin getopt   : ${NEED_GETOPT}
1964 built-in modules      :${BUILTINS}
1965 plug-in modules       :${PLUGINS}
1966 mozilla plugin        : ${MOZILLA}
1967 vlc aliases           :${ALIASES}
1968
1969 You may now tune Makefile.opts at your convenience, for instance to choose
1970 which modules get compiled as plugins.
1971
1972 To build vlc and its plugins, type \`${VLC_MAKE}'.
1973 "
1974