#!/bin/sh
if [ $# == 1 ];then
	OUTPUT=$1
else
	OUTPUT=output
fi
PWD=$pwd
RISCV_BASE=../../../../work
RISCV_TOOLCHAIN=${RISCV_BASE}/buildroot_initramfs/host
RISCV_SYSROOT=${RISCV_TOOLCHAIN}/riscv64-buildroot-linux-gnu/sysroot

export PATH=${RISCV_TOOLCHAIN}/bin:$PATH
export LD_LIBRARY_PATH=${RISCV_SYSROOT}/lib:$LD_LIBRARY_PATH
export ARCH=riscv
export SUBARCH=riscv
export CROSS_COMPILE_PREFIX=${RISCV_TOOLCHAIN}/bin/riscv64-buildroot-linux-gnu-
export SYSROOT=$RISCV_SYSROOT

PREFIX=$OUTPUT
ADDI_CFLAGS=""

echo "start config ffmpeg $ARCH"
./configure --target-os=linux      \
        --prefix=$PREFIX       \
        --arch=$ARCH           \
        --disable-x86asm       \
        --disable-asm          \
        --disable-ffplay       \
        --disable-ffprobe      \
        --disable-doc          \
        --disable-symver       \
        --disable-decoders     \
        --disable-encoders     \
        --disable-protocols    \
        --disable-filters      \
        --enable-protocol=file \
        --enable-protocol=data \
        --enable-bsf=h264_mp4toannexb\
        --enable-bsf=hevc_mp4toannexb\
        --disable-outdevs      \
        --disable-indevs       \
        --enable-cross-compile \
	--enable-zlib          \
        --cross-prefix=$CROSS_COMPILE_PREFIX\
        --sysroot=$SYSROOT     \
        --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
        --extra-ldflags="$ADDI_LDFLAGS"

echo "config finished $ARCH"

echo "NOW,you can make && make install to $PREFIX."
