dnl 'autoconf' input file for the LBL/UCB vic tool
dnl $Header$ (LBL)

AC_INIT(main.cpp)

V_PROG="vic"
V_ALL="$V_PROG"
V_SHM="-DUSE_SHM"
V_PATH=`pwd`
V_OBJ=""
V_LIB=""
V_CODEC_LIB=""
V_DEFINE=""

#ARCH DETECTION
v_ARCH=""
arch=`uname -m`
case "$arch" in
  i386|i486|i586|i686|i86pc|BePC)
    V_ARCH="ARCH_X86"
  ;;
  x86_64|amd64)
    V_ARCH="ARCH_X86_64"
  ;;
  "Power Macintosh"|ppc|ppc64|powerpc)
    V_ARCH="ARCH_PPC"
    case "$target" in (*darwin*) V_DEFINE="$V_DEFINE -DSYS_DARWIN";; esac
    ppc_conf="--disable-altivec"
    ppc_tune="-mcpu=G3"
    echo test1
    if sysctl hw.vectorunit 2>/dev/null | grep "hw.vectorunit: 1" >/dev/null 2>&1; then
    echo testa
    	ppc_conf=""
    	ppc_tune="-mcpu=G4 -mtune=G4"
    fi
  ;;
esac

echo "Architecture             $V_ARCH"


builtin(include, configure.in.head)

#XXX
V_STATIC="-static"
V_LIB_GRABBER=""
V_INCLUDE_GRABBER=""
V_OBJ_GRABBER=""
V_LIB_XIL=""
V_OBJ_XIL=""
V_LIB_FFMPEG=""
V_LIB_X264=""

AC_ARG_WITH(aix-shm,	--with-aix-shm=path	specify a pathname for the AIX shm X extension library file, lib=$withval, lib="")
if test "$lib" != "" ; then
	if test ! -r $lib ; then
		echo "'$lib' does not exist"
		exit 1
	fi
	V_LIB_AIXSHM=$lib
else
	V_LIB_AIXSHM=""
fi

AC_ARG_WITH(qcam,	--with-qcam=dir     specify directory with qcam.h for Connectix QuickCam device driver, qcamdir=$withval, qcamdir="")
if test "$qcamdir" != "" -a ! -r $qcamdir/qcam.h ; then
	echo "'$dir/qcam.h' does not exist"
	exit 1
fi

AC_ARG_ENABLE(gpl,	--enable-gpl	Enable or disable  use of gpl functionality - H264 MPEG4 Swscale, gpl="yes", gpl="no")
if test "$gpl" = "yes" ; then
  V_DEFINE="$V_DEFINE -DHAVE_SWSCALE"
  V_OBJ="$V_OBJ codec/packetbuffer.o codec/databuffer.o \
    codec/ffmpeg_codec.o codec/encoder-mpeg4.o codec/decoder-mpeg4.o \
    codec/x264encoder.o codec/encoder-h264.o codec/decoder-h264.o \
    codec/rtp_h264_depayloader.o render/color-swscale.o video/deinterlace.o"
else
  V_OBJ="$V_OBJ render/color-true.o  render/color-hi.o"
fi

AC_ARG_ENABLE(ffmpeg-co,	--disable-ffmpeg-co	Enable or disable ffmpeg svn checkout, ffmpegco="no", ffmpegco="yes")
if test "$ffmpegco" = "yes" ; then
  if test "$gpl" = "yes" ; then
   #if test ! -r "ffmpeg" ; then
     echo "checking out HEAD of ffmpeg from  svn://svn.mplayerhq.hu/ffmpeg/trunk..."
     #echo "checking out r7110 (and 21687 of libswscale) of ffmpeg from  svn://svn.mplayerhq.hu/ffmpeg/trunk..."
     svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
     #svn checkout -r 7110 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
     #svn checkout -r 21687 svn://svn.mplayerhq.hu/mplayer/trunk/libswscale  ffmpeg/libswscale
     echo "Configuring ffmpeg..."
     cd ffmpeg; ./configure --prefix=$V_PATH/ffmpeg $ppc_conf --enable-gpl --enable-swscale --enable-postproc; cd ..
   #fi
   V_INCLUDE="$V_INCLUDE -Iffmpeg/include -Iffmpeg"
   V_CODEC_LIB="$V_CODEC_LIB ffmpeg/libavcodec/libavcodec.a ffmpeg/libavutil/libavutil.a ffmpeg/libswscale/libswscale.a ffmpeg/libpostproc/libpostproc.a"
  else 
    echo "ffmpeg not available without --enable-gpl"
  fi
fi

AC_ARG_ENABLE(x264-co,        --disable-x264-co      Enable or disable x264 svn checkout, x264co="no", x264co="yes")
if test "$x264co" = "yes" ; then
  if test "$gpl" = "yes" ; then
   if test ! -r "x264" ; then
     X264_SNAP="x264-snapshot-20070413-2245"
     echo "Downloading ${X264_SNAP} (r650) of x264 from videolan.org ..."
     #svn checkout -r 650 svn://svn.videolan.org/x264/trunk x264
     curl -s http://downloads.videolan.org/pub/videolan/x264/snapshots/${X264_SNAP}.tar.bz2 | tar xfj - && ln -s ${X264_SNAP} x264
     echo "Configuring x264..."
     cd x264; ./configure --prefix=$V_PATH/x264; cd ..
   fi
   V_INCLUDE="$V_INCLUDE -Ix264/include"
   V_CODEC_LIB="$V_CODEC_LIB x264/lib/libx264.a"
  else 
    echo "x264 not available without --enable-gpl"
  fi
fi

AC_ARG_WITH(ffmpeginc,       --with-ffmpeginc=dir     specify the prefix directory of ffmpeg header, ffmpeginc=$withval, ffmpeginc="")
AC_ARG_WITH(ffmpeglib,       --with-ffmpeglib=dir     specify the directory of ffmpeg library, ffmpeglib=$withval, ffmpeglib="")

if test "$gpl" = "yes" ; then
  if test "$ffmpegco" != "yes"; then

	if test "$ffmpeginc" != "" ; then
	   if test ! -r $ffmpeginc/ffmpeg/avcodec.h ; then
	        echo "Error! you need to have $ffmpeginc/ffmpeg/avcodec.h around"
	        exit 1
	   elif test ! -r $ffmpeginc/ffmpeg/avutil.h ; then
	        echo "Error! you need to have $ffmpeginc/ffmpeg/avutil.h around"
	        exit 1
	   elif test ! -r $ffmpeginc/ffmpeg/swscale.h ; then
	        echo "Error! you need to have $ffmpeginc/ffmpeg/swscale.h around"
	        exit 1
	   fi
	   echo "checking for FFmpeg headers...yes"
	   V_INCLUDE="$V_INCLUDE -I$ffmpeginc"
	
	else

	   AC_CHECK_HEADER(ffmpeg/avcodec.h, [], [
        	echo "Error! you need to have avcodec.h around."
	        exit -1
	   ])
	   AC_CHECK_HEADER(ffmpeg/avutil.h, [], [
	        echo "Error! you need to have avutil.h around."
	        exit -1
	   ])
	   AC_CHECK_HEADER(ffmpeg/swscale.h, [], [
	        echo "Error! you need to have swscale.h around."
	        exit -1
	   ])
	fi

	if test "$ffmpeglib" != "" ; then
	   if test ! -r $ffmpeglib/libavcodec.a ; then
		echo "Error! you need to have $ffmpeglib/libavcodec.a around"
	   elif test ! -r $ffmpeglib/libavutil.a ; then
	        echo "Error! you need to have $ffmpeglib/libavutil.a around"
	   elif test ! -r $ffmpeglib/libswscale.a ; then
	        echo "Error! you need to have $ffmpeglib/libswscale.a around"
           elif test ! -r $ffmpeglib/libpostproc.a ; then
                echo "Error! you need to have $ffmpeglib/libpostproc.a around"
           fi
	   
	   V_LIB_FFMPEG="-L$ffmpeglib -lavcodec -lavutil -lswscale -lpostproc"
	else
	   AC_CHECK_LIB(avcodec, main, [], [
	        echo "Error! you need to have libavcodec around."
	        exit -1
	   ])
	   AC_CHECK_LIB(avutil, main, [], [
	        echo "Error! you need to have libavutil around."
	        exit -1
	   ])
	   AC_CHECK_LIB(swscale, main, [], [
	        echo "Error! you need to have libswscale around."
	        exit -1
	   ])

           AC_CHECK_LIB(postproc, main, [], [
                echo "Error! you need to have libpostproc around."
                exit -1
           ])

	   V_LIB_FFMPEG="-lavcodec -lavutil -lswscale -lpostproc"
	fi
  fi 
fi

AC_ARG_WITH(x264inc,       --with-x264inc=dir     specify the directory of x264 header, x264inc=$withval, x264inc="")
AC_ARG_WITH(x264lib,       --with-x264lib=dir     specify the directory of x264 library, x264lib=$withval, x264lib="")
if test "$gpl" = "yes" ; then
  if test "$x264co" != "yes" ; then
	if test "$x264inc" != "" ; then
	   if test ! -r $x264inc/x264.h ; then
	        echo "Error! you need to have $x264inc/x264.h around."
	        exit 1
	   fi
	   V_INCLUDE="$V_INCLUDE -I$x264inc"
	elif test ! -r /usr/local/include/x264.h -a ! -r /usr/include/x264.h ; then
	        echo "Error! you need to have x264.h around."
	        exit 1
	else
	   echo "checking for x264.h...yes"
	fi

	if test "$x264lib" != "" ; then
	   if test ! -r $x264lib/libx264.a ; then
	        echo "Error! you need to have $x264lib/libx264.a around"
		exit 1
	   fi
	   V_LIB_X264="-L$x264lib -lx264"
	else
	   AC_CHECK_LIB(x264, main, [], [
	        echo "Error! you need to have libx264 around."
	        exit -1
	   ])
	   V_LIB_X264="-lx264"
	fi
 fi
fi

V_CPUDETECT=""
AC_ARG_ENABLE(cpudetect, --disable-cpudetect     Enable or disable runtime cpu detection, cpudetect="no", cpudetect="yes")
if test "$gpl" = "yes" ; then
 if test "$cpudetect" = "yes"; then
    echo "using CPU runtime detection..."
    V_CPUDETECT="-DRUNTIME_CPUDETECT"
    V_CPUDETECT_OBJ="cpu/cpudetect.o cpu/cpuid.o"
 fi
 else 
   echo "No runtime cputect without --enable-gpl"
fi

V_H261AS=""
dnl h261 as (arbitrary size) 
AC_ARG_ENABLE(h261as, --disable-h261as         Enable or disable the h261as codec (default: enabled), h261as=no, h261as=yes)
if test "$h261as" = "yes"; then
   V_OBJ="$V_OBJ codec/p64/p64as.o codec/decoder-h261as.o codec/encoder-h261as.o"
   V_H261AS="-DUSE_H261AS"
fi

V_DV=""
dnl dv decoding support
AC_ARG_ENABLE(dvdecode, --enable-dvdecode       Enable or disable dv decoding (default: disabled), dvdecode=yes, dvdecode=no)
if test "$dvdecode" = "yes"; then
   AC_CHECK_LIB([dv], [main], [], [
      echo "Error! libdv not available. Please install libdv."
      exit 1
      ])
   AC_CHECK_HEADERS([libdv/dv.h], [], [
      echo "Error! libdv/dv.h not found. Please install libdv developer package."
      exit 1
      ])
   V_OBJ="$V_OBJ codec/decoder-dv.o"
   V_DV="-DUSE_DVDECODER"
   V_LIB="$V_LIB -ldv"
fi

dnl xvideo rendering support
V_XV=""
AC_ARG_ENABLE(xvideo, --enable-xvideo		Enable or disable Xvideo rendering (default: disabled), xvideo=yes, xvideo=no)
if test "$xvideo" = "yes"; then

   dnl Look for the PIC library first, Debian requires it.
   AC_CHECK_LIB(Xv_pic, XvQueryExtension,
                 HAVE_XVIDEO="yes", HAVE_XVIDEO="no",
                 -lXext)
   if test $HAVE_XVIDEO = "yes"; then
	V_LIB="$V_LIB -lXv_pic"
        V_XV="-DHAVE_XVIDEO"
        V_OBJ="$V_OBJ render/xvideo.o"
   else
   dnl try again using something else if we didn't find it first

   	AC_CHECK_LIB(Xv, XvQueryExtension,
                HAVE_XVIDEO="yes", HAVE_XVIDEO="no",
                -lXext)

   	if test $HAVE_XVIDEO = "yes"; then
       	    V_XV="-DHAVE_XVIDEO"
       	    V_LIB="$V_LIB -lXv"
            V_OBJ="$V_OBJ render/xvideo.o"
   	fi
   fi

   if test $HAVE_XVIDEO = "yes"; then
   	AC_CHECK_HEADERS([X11/extensions/Xvlib.h], [], [
      	echo "Error! \"X11/extensions/Xvlib.h\" not found. Please install \"libxv-dev\" package."
      		exit 1
      	])
   fi
fi

dnl lots of hairy special cases for detecting which frame capture
dnl support to compile in

AC_ARG_ENABLE(v4l2old,	--enable-v4l2old    Enable or disable old Video4Linux2 grabber (default: disabled), v4l2old=yes, v4l2old=no)
if test "$v4l2old" = "yes" ; then
                V_OBJ_GRABBER="$V_OBJ_GRABBER video/grabber-v4l2-old.o"
		echo "Using old Linux grabber-v4l2"
elif test -r /usr/include/linux/videodev.h ; then
        AC_CHECK_HEADER(libv4lconvert.h,
        [V_DEFINE="$V_DEFINE -DHAVE_LIBV4L"
         V_LIB_GRABBER="$V_LIB_GRABBER -lv4l1 -lv4l2"],
        [V_OBJ_GRABBER="$V_OBJ_GRABBER  video/tinyjpeg.o video/jidctflt.o"])
        if test -r /usr/include/linux/videodev2.h  ; then
                V_OBJ_GRABBER="$V_OBJ_GRABBER video/grabber-v4l2.o video/grabber-video4linux.o"
		echo "Using Linux Grabbers: Video4Linux2 and Video4Linux1"
        else
                V_OBJ_GRABBER="$V_OBJ_GRABBER video/grabber-video4linux.o"
		echo "Using Linux Grabber: Video4Linux1"
        fi
fi

if test -r /usr/lib/libvl.so ; then
	V_LIB_GRABBER="$V_LIB_GRABBER -lvl -ldmedia"
	V_OBJ_GRABBER="video/grabber-vl.o video/output-vl.o $V_OBJ_GRABBER"
	if test -r /usr/include/dmedia/cl_cosmo.h  ; then
		V_LIB_GRABBER="$V_LIB_GRABBER -lcl"
		V_OBJ_GRABBER="video/grabber-cosmo.o $V_OBJ_GRABBER"
	fi		
fi
if test -r /usr/lib/libsvideo.a ; then
	V_LIB_GRABBER="$V_LIB_GRABBER -lsvideo"
	V_OBJ_GRABBER="video/grabber-svideo.o $V_OBJ_GRABBER"
fi

AC_ARG_ENABLE(XvGrabber,--enable-XvGrabber    Enable or disable old XvGrabber (default: disabled), XvGrabber=yes, XvGrabber=no)
if test -r /usr/lib/libXv.a -a "$XvGrabber" = "yes" ; then
	V_LIB_GRABBER="$V_LIB_GRABBER -lXv"
	V_DEFINE="$V_DEFINE -DXV_PSEUDO8"
	V_OBJ_GRABBER="video/grabber-xv.o $V_OBJ_GRABBER"
fi
if test -r /usr/lpp/parallax/lib/libXvid.a ; then
    V_LIB_GRABBER="$V_LIB_GRABBER -L/usr/lpp/parallax/lib -lXvid -lXv"
    V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I/usr/lpp/parallax/include"
    V_OBJ_GRABBER="video/grabber-plx.o video/assistor-plx.o $V_OBJ_GRABBER"
fi
if test -r /usr/lpp/UMS6000/lib/libUMSobj.a ; then
	V_LIB_GRABBER="$V_LIB_GRABBER -L/usr/lpp/UMS6000/lib -lUMSobj"
	V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I/usr/lpp/UMS6000/include"
	V_DEFINE="$V_DEFINE -DSUNRISE"
	V_OBJ_GRABBER="video/grabber-sunrise.o video/output-sunrise.o $V_OBJ_GRABBER"
fi

if test -r /usr/include/machine/ioctl_meteor.h ; then
	V_OBJ_GRABBER="video/grabber-meteor.o $V_OBJ_GRABBER"
fi

AC_ARG_ENABLE(Linux1394Grabber,--enable-Linux1394Grabber    Enable or disable Linux1394XvGrabber (default: disabled), Linux1394Grabber=yes, Linux1394Grabber=no)
if test -r /usr/include/libdc1394/dc1394_control.h -a -r /usr/include/libraw1394/raw1394.h -a "$Linux1394Grabber" = "yes"; then
      V_OBJ_GRABBER="$V_OBJ_GRABBER video/grabber-linux1394.o"
      V_LIB_GRABBER="$V_LIB_GRABBER -lraw1394 -ldc1394_control"
fi

#if test -r /usr/local/lib/libspigot.a -a ${PORTOBJFORMAT} != elf; then
if test -r /usr/local/lib/libspigot.a ; then
	V_OBJ_GRABBER="video/grabber-spigot.o $V_OBJ_GRABBER"
	V_LIB_GRABBER="$V_LIB_GRABBER -lspigot"
	V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I/usr/local/include"
fi

if test "$qcamdir" != "" ; then
	V_OBJ_GRABBER="video/grabber-qcam.o $V_OBJ_GRABBER"
	V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I$qcamdir"
	V_DEFINE="$V_DEFINE -DQCAMDEV -DQCAMDOTH=qcam.h"
elif test -r /usr/local/lib/libqcam.a ; then
	V_OBJ_GRABBER="video/grabber-qcam.o $V_OBJ_GRABBER"
	V_LIB_GRABBER="$V_LIB_GRABBER -lqcam"
	V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I/usr/local/include"
	V_DEFINE="$V_DEFINE -DQCAMLIB"
elif test -r /dev/qcam0 ; then
	V_OBJ_GRABBER="video/grabber-qcam.o $V_OBJ_GRABBER"
	V_DEFINE="$V_DEFINE -DQCAMDEV"
fi
vpix_dir=/usr/src/local/vfc-1.0
vpix_lib=$vpix_dir/vfc_lib
if test -d /import/VideoPix ; then
	vpix_dir=/import/VideoPix
	vpic_lib=$vpix_dir/lib
fi
if test -d $vpix_dir ; then
	V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I$vpix_dir/sys -I$vpix_lib"
	V_LIB_GRABBER="$V_LIB_GRABBER $vpix_lib/libvfc.a"
	V_DEFINE="$V_DEFINE -DVIDEOPIX"
	V_OBJ_GRABBER="video/grabber-vpix.o $V_OBJ_GRABBER"
fi
places="/usr/src/local/vigrapix/lib \
	/opt/VIGRAvigrapix/lib"
for dir in $places; do
	if test -d $dir ; then
		V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I$dir"
		V_LIB_GRABBER="$V_LIB_GRABBER $dir/libvigrapix.a"
		V_OBJ_GRABBER="video/grabber-vigra.o $V_OBJ_GRABBER"
    		break
	fi
done

d=/opt/MMACslv
if test -d $d ; then
	V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I$d/include"
	V_LIB_GRABBER="$V_LIB_GRABBER $d/lib/libslv.a -lintl"
	V_OBJ_GRABBER="video/grabber-slv.o $V_OBJ_GRABBER"
fi

d=/usr/include/mme
if test -d $d ; then
	V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I$d"
	V_LIB_GRABBER="$V_LIB_GRABBER -lmme"
	V_OBJ_GRABBER="video/grabber-mme.o $V_OBJ_GRABBER"
fi

places="/opt/parallax \
	/usr/src/local/parallax \
	/usr/local/parallax \
	/usr/local/parallax/components/Xclients_sun4.ow3_1.18 \
	/usr/src/local/parallax/components/Xclients_sun4.ow3_1.18"
for dir in $places; do
	if test -d $dir/include ; then
		V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I$dir/include"
		V_LIB_GRABBER="$V_LIB_GRABBER -L$dir/lib -lXext -lXvid"
		V_OBJ_GRABBER="video/grabber-plx.o video/assistor-plx.o $V_OBJ_GRABBER"
    		break
	fi
done


case "$target" in 
*-dec-*)
	jv_dir=jv2
	V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I$jv_dir"
	V_LIB_GRABBER="$V_LIB_GRABBER $jv_dir/jvdriverint.o"
	V_OBJ_GRABBER="video/assistor-jv.o video/grabber-jv.o $V_OBJ_GRABBER"
	if test "$target_os" = ultrix4.3 ; then
		#XXX rtip code currently broken
		#V_DEFINE="$V_DEFINE -DRTIP"
		#V_LIB="$V_LIB lib.ultrix/librcap.a"
		#V_INCLUDE="$V_INCLUDE -Ircap-include"
		#XXX
		#V_OBJ_GRABBER="$V_OBJ_GRABBER net-rtip.o"
		echo no rtip support 
	fi
	;;
sparc-sun-solaris*)
	V_STATIC=""
	have_xil=no
	xil_dir=/usr/openwin
	if test -d $xil_dir ; then
		if test ! -d $xil_dir/include/xil ; then
			echo "You don't have the XIL developer's kit!"
			echo "Building without XIL support..."
		else
			echo "Using XIL developer's kit (Found in: $xil_dir/include/xil)"
			have_xil=yes
		fi
	fi
	SYSINC="-I"
	if test $CC = gcc ; then
		V_DEFINE="$V_DEFINE -mv8 -msupersparc"
		SYSINC="-isystem "
	elif  test -z "$enable_debug" ; then
		V_CCOPT="-xO2";
	fi
	if test $ipv6 = yes; then
		V_DEFINE="$V_DEFINE -D__svr4__ -DSolaris -DHAVE_IPV6 -DSOLARIS7_IPV6"
	else
		V_DEFINE="$V_DEFINE -D__svr4__ -DSolaris"
	fi
	OPSYS=solaris
	if test -f video/grabber-rtvc.cpp || test -f video/grabber-rtvc.o ; then
		V_OBJ_GRABBER="video/grabber-rtvc.o $V_OBJ_GRABBER"
		if test "$have_xil" = yes ; then
			V_ALL="$V_PROG $V_PROG.xil"
			V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER $SYSINC$xil_dir/include -DSUNXIL_WARNING_DISABLE"
			V_LIB_XIL="-L$xil_dir/lib -R\"$xil_dir/lib:/opt/SUNWo1kp/lib:/opt/MMACo1k/lib\" -lxil"
			V_OBJ_XIL="video/grabber-xil.o codec/framer-h261hw.o codec/framer-cellb.o video/assistor-xil.o" 
		fi
	elif test "$have_xil" = yes ; then
		V_OBJ_XIL="video/grabber-xil.o codec/framer-h261hw.o codec/framer-cellb.o video/assistor-xil.o"
		V_INCLUDE_GRABBER="$V_INCLUDE_GRABBER -I$xil_dir/include"
		V_LIB_GRABBER="$V_LIB_GRABBER -L$xil_dir/lib -R\"$xil_dir/lib:/opt/SUNWo1kp/lib:/opt/MMACo1k/lib\" -lxil "
	fi
	;;
sparc-sun-sunos*)
	V_DEFINE="$V_DEFINE -DNEED_SUNOS_PROTOS -DSunOS"
	;;
*-sgi-irix*)
	V_DEFINE="$V_DEFINE -D_BSD_SIGNALS -DIRIX"
	OPSYS=irix
	if test "$target_os" = irix6.2 ; then
		V_DEFINE="$V_DEFINE -DIRIX6_2 -DSIGARGS=__sigargs"
	fi
	V_TARCMD="tar cfL"
	V_SHELL="SHELL = /bin/sh"
	if test $CC != gcc ; then
		V_DEFINE="$V_DEFINE -signed -g3"
		CC="cc -Dinline="
		if test "$target_os" = irix5.2 ; then
			CC="$CC -xansi -D__STDC__"
		fi
		CXX="CC +p -float -woff 3262 -DSGI_COMPAT"
	else
		CXX=$CC	
	fi
	V_STATIC=""
	;;
*-*-bsdi1*)
	V_SHM=""
	V_TARCMD="tar cfL"
	;;
*-*-bsdi2.0*)
	V_SHM=""
	V_TARCMD="tar cfL"
	;;
*-*-bsdi*)
	# bsdi2.1 added sys-v shared memory support but their implementation
	# is broken so we have to turn it off.  If they ever fix libipc,
	# the following line should be deleted.
	V_SHM=""
	V_TARCMD="tar cfL"
	V_CCOPT="-O2 -m486"
	V_LIB="$V_LIB -lipc"
	;;
*-*-netbsd*)
	V_TARCMD="tar -h -c -f"
	V_LIB="$V_LIB -L/usr/local/lib"
	;;
*-*-freebsd*)
	V_STATIC=""
	if test $ipv6 = yes; then
		V_DEFINE="$V_DEFINE -DFreeBSD -DHAVE_IPV6"
		V_LIB="$V_LIB -L/usr/local/v6/lib"
	else
		V_DEFINE="$V_DEFINE -DFreeBSD"
	fi
	OPSYS=freebsd
	;;
*-*-hpux*)
	V_CCOPT="-O -DHPUX"
	OPSYS=hpux
	;;
*-*-aix3*)
	V_STATIC=""
	V_DEFINE="$V_DEFINE -DSIGARGS=int -DHPUX"
	if test "$V_LIB_AIXSHM" != "" ; then
		V_LIB="$V_LIB $V_LIB_AIXSHM"
	else
		V_SHM=""
	fi
	CXX="xlC -+"
	;;
*-*-aix4*)
	V_STATIC=""
	V_DEFINE="$V_DEFINE -DSIGARGS=int -D_AIX41"
	if test "$V_LIB_AIXSHM" != "" ; then
		V_LIB="$V_LIB $V_LIB_AIXSHM"
	else
		V_SHM=""
	fi
	CXX="xlC -+"
	;;
armv4l-*-linux)
	V_STATIC=""
	V_BROKEN_OBJ=
	CC=arm-linux-gcc
	CPP=arm-linux-g++
	AR=arm-linux-ar
	RANLIB=arm-linux-ranlib
	if test $ipv6 = yes; then
		V_DEFINE="$V_DEFINE -DLinux -DHAVE_IPV6 -DLINUX_IPV6"
	else
		V_DEFINE="$V_DEFINE -DLinux"
	fi
	OPSYS=linux
	;;
*-*-linux*)
	V_STATIC=""
	V_BROKEN_OBJ=
	if test $ipv6 = yes; then
		V_DEFINE="$V_DEFINE -DLinux -DHAVE_IPV6 -DLINUX_IPV6"
	else
		V_DEFINE="$V_DEFINE -DLinux"
	fi
	OPSYS=linux
        ;;
*darwin*)
        V_SHM=""
        V_STATIC=""
        V_BROKEN_OBJ=
        V_DEFINE="$V_DEFINE -DHAVE_IPV6 -DHAVE_FAST_INT"
        V_LIB="$V_LIB -framework Carbon -framework QuickTime"
        if test "$target_cpu" = powerpc; then
            V_CCOPT="-O2 $ppc_tune"
        fi
        OPSYS=macosx
        ;;
esac

case "$target" in
   *-*-darwin*)
        V_OBJ_GRABBER="$V_OBJ_GRABBER video/grabber-macosx.o"
        ;;
   *)
        V_OBJ_GRABBER="$V_OBJ_GRABBER video/grabber-x11.o"
        ;;
esac

dnl Optimisation in H261 decoder needs to be turned off for GCC 2.96 

if test $CC = gcc ; then
     echo $ac_n "checking version of GCC""... $ac_c"
     GCC_version=`$CC --version`
     echo "$GCC_version"
     if test "$GCC_version" = 2.96 ; then
           echo "Turning off optimisation for dct code"
           V_CCOPT_H261="";
     fi
fi

if test -f codec/encoder-bvc.cpp ; then
	V_OBJ="$V_OBJ codec/encoder-bvc.o codec/decoder-bvc.o"
fi

AC_SUBST(V_LIB_FFMPEG)
AC_SUBST(V_LIB_X264)
AC_SUBST(V_INCLUDE_GRABBER)
AC_SUBST(V_LIB_GRABBER)
AC_SUBST(V_OBJ_GRABBER)
AC_SUBST(V_LIB_XIL)
AC_SUBST(V_OBJ_XIL)
AC_SUBST(V_OBJ)
AC_SUBST(V_LIB)
AC_SUBST(V_CODEC_LIB)
AC_SUBST(V_CPUDETECT_OBJ)

V_DEFINE="$V_DEFINE $V_SHM $V_H261AS $V_DV $V_XV $V_CPUDETECT -D$V_ARCH"

builtin(include, configure.in.tail)
