1. lame

./configure \
    --disable-shared --enable-static \
    --enable-nasm \
    --disable-analyzer-hooks --disable-brhist --disable-decoder --disable-frontend \
    --with-pic

FFmpeg looks for lame.h as lame/lame.h but the uninstalled lame-3.98.4 does not
have the lame directory so go into lame-3.98.4/include and "ln -s . lame" on
Linux and Mac OS X or "mklink /d lame ." on Windows.

Windows notes:
    - As an alternative to configure and a subsequent make, use:
      make -f Makefile.unix HAVE_NASM=YES NOUNIXCMD=NO UNAME=MSDOS
      Unfortunately, it may not work.
    - Before make, open Makefile, libmp3lame/Makefile and
      libmp3lame/i386/Makefile and make sure that the path to nasm.exe is
      correct (e.g. have NASM=nasm and nasm.exe on the PATH);
    - When building the x64 library on Windows x64, add
      --build=x86_64-w64-mingw32 to the configure line. When building the x64
      library on Windows x86, add --build=i686-pc-mingw32 and
      --host=x86_64-w64-mingw32.
    - If a script outputs errors mentioning \r, it may need dos2unix conversion.

2. x264

- Windows

Download yasm for Windows (32-bit or 64-bit) at
http://www.tortall.net/projects/yasm/wiki/Download and make it available in the
PATH.

When building the x64 library on Windows x86, add --host=x86_64-w64-mingw32 to
the configure line.

./configure --enable-win32thread
make

- FreeBSD

patch -Np1 -i x264-01-freebsd.patch
./configure --enable-pic
gmake

- Linux, Mac OS X

./configure --enable-pic
make

3. ffmpeg

patch -Np1 -i ffmpeg-01-libavcodec_libx264.c-zero_latency.patch
patch -Np1 -i ffmpeg-02-libavcodec_libx264.c-rtp_payload_size.patch

./configure \
  --enable-static --disable-shared --shlibdir=. \
  --disable-debug \
  --disable-everything --disable-network \
  --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver \
  --enable-libmp3lame --enable-encoder=libmp3lame \
  --enable-decoder=h263 --enable-encoder=h263p --enable-parser=h263 \
  --enable-libx264 --enable-gpl \
  --enable-decoder=h264 --enable-encoder=libx264 --enable-parser=h264 \
  --enable-filter=buffer --enable-filter=hflip --enable-filter=scale --enable-filter=nullsink \
  --extra-cflags="-I$MP3LAME_HOME/include -I$X264_HOME" \
  --extra-ldflags="-L$MP3LAME_HOME/libmp3lame -L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME"

- Windows

x86:
Add --target-os=mingw32, --enable-memalign-hack, --disable-pthreads and
--enable-w32threads.

x64:
Add --arch=amd64 and --enable-cross-compile to the configure line used for x86.

mingw32-make

- Linux, FreeBSD

Add --enable-pic and --enable-pthreads.

- Mac OS X 

Note: Remove from the configure script the option to add -mdynamic-no-pic unless
building for the i386 architecture. For i386, remove "--enable-pic" from the
following command.

./configure \
  --enable-pic \
  --enable-static --disable-shared --shlibdir=. \
  --disable-encoders --disable-decoders --disable-muxers --disable-demuxers \
  --disable-parsers --disable-bsfs --disable-protocols --disable-devices \
  --disable-network \
  --enable-libx264 --enable-gpl --enable-parser=h264 --enable-encoder=libx264 \
  --enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 \
  --enable-parser=h263 --enable-encoder=h263p \
  --enable-decoder=h263 --enable-muxer=h263 --enable-demuxer=h263 \
  --enable-libmp3lame --enable-encoder=libmp3lame \
  --extra-ldflags="-fPIC -L$MP3LAME_HOME/libmp3lame/.libs -L$X264_HOME" --extra-cflags="-fPIC -I$MP3LAME_HOME/include -I$X264_HOME" \
  --disable-debug \
  --disable-ffserver --disable-ffprobe --disable-ffplay --disable-ffmpeg \
  --enable-pthreads

4. libffmpeg

Define the environment variable JAVA_HOME so that the JNI headers can be found.
Change the current directory to src\native and run "ant ffmpeg" passing it
values for the ffmpeg, lame and x264 properties which specify the paths to the
homes of the development trees of the respective libraries.
