#!/bin/sh

# ffmpeg-config

prefix="/usr"
exec_prefix="/usr/bin"
version="0.cvs20060329-3bpo1"

include_dir="/usr/include/ffmpeg"
lib_dir="/usr/lib"

link_libs=""

usage()
{
    cat <<EOF
Usage: ffmpeg-config [OPTIONS]
Options:
    [--prefix]
    [--cflags]
    [--libs [avcodec] [avformat] [postproc]]
    [--plugin-libs [avcodec] [avformat] [postproc]]
    [--version]
EOF
    exit $1
}

if test $# -eq 0; then
    usage 1 1>&2
fi

while test $# -gt 0; do
	case $1 in
    --prefix)
	    echo_prefix=yes
	    ;;

	--cflags)
	    echo_cflags=yes
	    ;;
        
	--libs | --plugin-libs)
	    echo_libs=yes
	    ;;

	--version)
	    echo_version=yes
	    ;;

	avcodec|avformat|postproc)
	    if test "$echo_libs" = "yes"; then
		link_libs="$link_libs -l$1"
		if test "$1" != "avcodec"; then
		    link_libs="$link_libs -lavcodec"
		fi
		link_libs="$link_libs -lavutil"
	    else
		usage 1 1>&2
	    fi
	    ;;

	*)
	    usage 1 1>&2
	    ;;
    esac
  shift
done

if test "$echo_prefix" = "yes"; then
    echo $prefix
fi

cflags="-I$include_dir"
link_libs="$link_libs -lvorbis -lvorbisenc -ltheora -logg -ldts -la52 -lraw1394 -ldc1394_control -lgsm -lz -lm"

if test "$lib_dir" != "/usr/lib"; then
    libs="-L$lib_dir"
else
    libs=""
fi

if test "$echo_cflags" = "yes"; then
    echo $cflags
fi

if test "$echo_libs" = "yes"; then
    echo $libs $link_libs
fi

if test "$echo_version" = "yes"; then
    echo $version
fi
