#!/bin/sh

# this script need to be run in ffmpeg directory in msys2 shell (msys2_shell.bat) that is
# executed in "VS2015 x64 Native Tools Command Prompt"

set -e
set -x

# add zlib library and header to find zlib (required for png encoder)
export INCLUDE="$INCLUDE;"
export LIB="$LIB;"


./configure --toolchain=msvc \
  --prefix="../build/" \
  --bindir="../build/bin/" \
  --build-suffix=-nimble \
  --disable-static     \
  --enable-shared      \
  --enable-pic         \
  --disable-decoders   \
  --enable-decoder=aac,pcm_alaw,pcm_mulaw,mp2,h264,mpeg2video,mp3,png,mjpeg,tiff,gif,bmp,libspeex \
  --disable-encoders   \
  --enable-encoder=aac,png \
  --disable-muxers     \
  --disable-demuxers   \
  --enable-demuxer=mov,image2,gif,mp3  \
  --disable-parsers    \
  --disable-bsfs       \
  --disable-protocols  \
  --enable-protocol=file  \
  --disable-indevs     \
  --disable-outdevs    \
  --enable-filters     \
  --disable-ffserver   \
  --disable-ffmpeg     \
  --disable-ffprobe    \
  --disable-ffplay     \
  --enable-libspeex    \
  --disable-dxva2      \
  --disable-manpages
 #--enable-libmfx      \
 #--disable-stripping --enable-debug=3 --disable-optimizations  \

# remove HAVE_UNISTD_H definition as zlib incorrectly considers header
# available even if it is defined to 0
sed -i -e 's/#define HAVE_UNISTD_H 0//' config.h

make -j 4
make install

