Partial reimplementation of encoder quant initialization more in line with derf's...
[xiph/unicode.git] / ffmpeg2theora / build.mac.sh
blob1796532544fbd2f7f30ee4e3b80ab4782186f0c6
1 #!/bin/bash
2 #build universal binary of ffmpeg2theora and package it
4 set -e
5 build_all_osx() {
6 tmp_dir=/tmp/ffmpeg2theora
7 build_dir=$tmp_dir/$arch
8 dist_dir=$tmp_dir/dist/$arch
9 mkdir -p $build_dir
10 mkdir -p $dist_dir
12 unset PKG_CONFIG_PATH
13 export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=0
14 export PKG_CONFIG_ALLOW_SYSTEM_LIBS=0
15 export PKG_CONFIG_LIBDIR=$dist_dir/lib/pkgconfig
17 ffmpeg_extra="--enable-pp --enable-gpl --enable-swscaler --disable-encoders --enable-libogg --enable-libvorbis"
18 ffmpeg_extra="$ffmpeg_extra --enable-liba52"
19 test -e $dist_dir/lib/libfaad.a && ffmpeg_extra="$ffmpeg_extra --enable-faad" && echo "building with faad"
20 echo ""
21 if [ $arch == 'ppc' ]; then
22 ffmpeg_arch="powerpc"
23 ffmpeg_extra="$ffmpeg_extra --cpu=G4"
24 else
25 ffmpeg_arch="x86_32"
26 ffmpeg_extra="$ffmpeg_extra --cpu=pentium-m"
28 export CFLAGS="-arch $arch"
29 export LDFLAGS="-arch $arch"
31 cd $build_dir
32 if [ -e ogg ]; then
33 echo "using existing $arch/libogg"
34 else
35 echo "building $arch/libogg"
36 svn co https://svn.xiph.org/trunk/ogg
37 cd ogg
38 ./autogen.sh --disable-shared --prefix=$dist_dir && make && make install
39 fi
40 export PKG_CONFIG_PATH=$build_dir/ogg:$PKG_CONFIG_PATH
42 cd $build_dir
43 package="vorbis-aotuv"
44 if [ -e $package ]; then
45 echo "using existing $arch/$package"
46 else
47 echo "building $package"
48 svn co https://svn.xiph.org/branches/vorbis-aotuv/
49 cd $package
50 ./autogen.sh --disable-shared --prefix=$dist_dir && make && make install
52 export PKG_CONFIG_PATH=$build_dir/$package:$PKG_CONFIG_PATH
54 cd $build_dir
55 package="theora"
56 if [ -e $package ]; then
57 echo "using existing $arch/$package"
58 else
59 echo "building $package"
60 svn co https://svn.xiph.org/trunk/theora
61 cd $package
62 ./autogen.sh --disable-shared --prefix=$dist_dir --host=$arch && make && make install
64 export PKG_CONFIG_PATH=$build_dir/$package:$PKG_CONFIG_PATH
66 cd $build_dir
67 package="a52dec-0.7.4"
68 if [ -e $package ]; then
69 echo "using existing $arch/$package"
70 else
71 echo "building $arch/$package"
72 tarball="http://liba52.sourceforge.net/files/$package.tar.gz"
73 test -e $package || curl $tarball > $package.tar.gz && tar xzf $package.tar.gz
74 cd $package && ./configure --disable-shared --prefix=$dist_dir && make && make install
77 cd $build_dir
78 package="ffmpeg"
79 if [ -e $package ]; then
80 echo "using existing $arch/$package"
81 else
82 echo "building $arch/$package"
83 test -e ffmpeg || svn co svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
84 cd ffmpeg
85 unset CFLAGS
86 unset LDFLAGS
87 ./configure --cross-compile $ffmpeg_extra --arch=$ffmpeg_arch \
88 --extra-ldflags="-L$dist_dir/lib -arch $arch" \
89 --extra-cflags="-I$dist_dir/include -arch $arch"
90 make
92 export PKG_CONFIG_PATH=$build_dir/ffmpeg:$PKG_CONFIG_PATH
94 echo "build $arch/ffmpeg2theora"
95 export CFLAGS="-arch $arch"
96 export LDFLAGS="-arch $arch"
97 cd $build_dir
98 test -e ffmpeg2theora || svn co https://svn.xiph.org/trunk/ffmpeg2theora
99 cd ffmpeg2theora
100 svn up
101 ./autogen.sh --prefix=$dist_dir --with-static-linking
102 make && make install
106 echo "building ffmpeg2theora"
107 echo ""
109 arch=ppc build_all_osx
110 arch=i386 build_all_osx
112 echo "building universal/ffmpeg2theora"
113 tmp_dir=/tmp/ffmpeg2theora
114 build_dir=$tmp_dir/build
115 dist_dir=$tmp_dir/dist
116 mkdir -p $dist_dir/universal/usr/local/bin
117 mkdir -p $dist_dir/universal/usr/local/share/man/man1/
118 cp $dist_dir/i386/share/man/man1/ffmpeg2theora.1 $dist_dir/universal/usr/local/share/man/man1/
119 strip $dist_dir/ppc/bin/ffmpeg2theora
120 strip $dist_dir/i386/bin/ffmpeg2theora
121 lipo -create -arch ppc $dist_dir/ppc/bin/ffmpeg2theora \
122 -arch i386 $dist_dir/i386/bin/ffmpeg2theora \
123 -output $dist_dir/universal/usr/local/bin/ffmpeg2theora
125 version=`grep AC_INIT $dist_dir/../i386/ffmpeg2theora/configure.ac | cut -f 2 -d"," | cut -f 1 -d")"`
126 sudo /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker \
127 -build -proj /tmp/ffmpeg2theora/i386/ffmpeg2theora/ffmpeg2theora.pmproj \
128 -p $dist_dir/ffmpeg2theora-$version.pkg
130 cd $dist_dir
131 zip -r ffmpeg2theora-$version.pkg.zip ffmpeg2theora-$version.pkg