| 1 | #!/bin/sh -v |
|---|
| 2 | PATH=/usr/local/bin:/sw/bin:/opt/local/bin:/usr/bin:$PATH |
|---|
| 3 | buildid_ffmpeg="r`svn info ffmpeg | grep -F Revision | awk '{print $2}'`" |
|---|
| 4 | |
|---|
| 5 | if [ "$MACOSX_DEPLOYMENT_TARGET" = "" ]; then |
|---|
| 6 | MACOSX_DEPLOYMENT_TARGET="10.4" |
|---|
| 7 | fi |
|---|
| 8 | |
|---|
| 9 | generalConfigureOptions="--disable-muxers --disable-encoders --disable-stripping --enable-pthreads --disable-ffmpeg --disable-network --disable-ffplay --disable-ffserver" |
|---|
| 10 | cflags="-isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -g -Dattribute_deprecated= -w" |
|---|
| 11 | |
|---|
| 12 | if [ "$BUILD_STYLE" = "Development" ] ; then |
|---|
| 13 | generalConfigureOptions="$generalConfigureOptions --disable-optimizations --disable-mmx" |
|---|
| 14 | else |
|---|
| 15 | optcflags="-falign-loops=16 -fweb -fstrict-aliasing -finline-limit=1000" |
|---|
| 16 | fi |
|---|
| 17 | |
|---|
| 18 | if what /usr/bin/ld | grep -q ld64-77; then |
|---|
| 19 | no_pic=0 |
|---|
| 20 | else |
|---|
| 21 | no_pic=1 |
|---|
| 22 | fi |
|---|
| 23 | |
|---|
| 24 | if [ $no_pic -gt 0 ]; then |
|---|
| 25 | cflags="$cflags -mdynamic-no-pic" # ld can't handle -fno-pic on ppc |
|---|
| 26 | else |
|---|
| 27 | #no-pic only on pre-leopard |
|---|
| 28 | echo "warning: Due to issues with Xcode 3.0, Perian will run very slowly! Please upgrade Xcode or fix Patches/ffmpeg.diff!"; |
|---|
| 29 | generalConfigureOptions="$generalConfigureOptions --disable-decoder=cavs --disable-decoder=vc1 --disable-decoder=wmv3 --disable-mmx --enable-shared" |
|---|
| 30 | fi |
|---|
| 31 | |
|---|
| 32 | export cflags |
|---|
| 33 | |
|---|
| 34 | x86tune="generic" |
|---|
| 35 | if [ "$CC" = "" ]; then |
|---|
| 36 | if [[ -e /usr/bin/gcc-4.2 && -e /Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.2.1 ]]; then |
|---|
| 37 | CC="gcc-4.2" |
|---|
| 38 | x86tune="core2" |
|---|
| 39 | else |
|---|
| 40 | CC="gcc" |
|---|
| 41 | fi |
|---|
| 42 | export CC |
|---|
| 43 | fi |
|---|
| 44 | |
|---|
| 45 | OUTPUT_FILE="$BUILT_PRODUCTS_DIR/Universal/buildid" |
|---|
| 46 | |
|---|
| 47 | if [[ -e "$OUTPUT_FILE" ]] ; then |
|---|
| 48 | oldbuildid_ffmpeg=`cat "$OUTPUT_FILE"` |
|---|
| 49 | else |
|---|
| 50 | oldbuildid_ffmpeg="buildme" |
|---|
| 51 | fi |
|---|
| 52 | |
|---|
| 53 | QUICKBUILD="$BUILT_PRODUCTS_DIR/Universal/quickbuild" |
|---|
| 54 | if [[ -e "$QUICKBUILD" ]] ; then |
|---|
| 55 | oldbuildid_ffmpeg="quick" |
|---|
| 56 | rm "$QUICKBUILD" |
|---|
| 57 | fi |
|---|
| 58 | |
|---|
| 59 | if [[ $buildid == "r" ]] ; then |
|---|
| 60 | echo "error: you're using svk. Please ask someone to add svk support to the build system. There's a script in Adium svn that can do this." |
|---|
| 61 | exit 1; |
|---|
| 62 | fi |
|---|
| 63 | |
|---|
| 64 | if [ `echo $ARCHS | grep -c i386` -gt 0 ] ; then |
|---|
| 65 | buildi386=1 |
|---|
| 66 | if [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then |
|---|
| 67 | buildppc=1 |
|---|
| 68 | else |
|---|
| 69 | buildppc=0 |
|---|
| 70 | fi |
|---|
| 71 | elif [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then |
|---|
| 72 | buildi386=0 |
|---|
| 73 | buildppc=1 |
|---|
| 74 | else |
|---|
| 75 | echo "No architectures" |
|---|
| 76 | exit 0 |
|---|
| 77 | fi |
|---|
| 78 | |
|---|
| 79 | if [ "$buildid_ffmpeg" = "$oldbuildid_ffmpeg" ] ; then |
|---|
| 80 | echo "Static ffmpeg libs are up-to-date ; not rebuilding" |
|---|
| 81 | else |
|---|
| 82 | echo "Static ffmpeg libs are out-of-date ; rebuilding" |
|---|
| 83 | |
|---|
| 84 | if [ -e ffmpeg/patched ] ; then |
|---|
| 85 | cd ffmpeg && svn revert -R . && rm patched && cd .. |
|---|
| 86 | fi |
|---|
| 87 | |
|---|
| 88 | patch -p0 < Patches/ffmpeg-forceinline.diff |
|---|
| 89 | patch -p0 < Patches/ffmpeg-no-interlaced.diff |
|---|
| 90 | patch -p0 < Patches/ffmpeg-faltivec.diff |
|---|
| 91 | patch -p0 < Patches/ffmpeg-h264-nounrollcabac.diff |
|---|
| 92 | touch ffmpeg/patched |
|---|
| 93 | |
|---|
| 94 | echo -n "Building " |
|---|
| 95 | if [ $buildi386 -eq $buildppc ] ; then |
|---|
| 96 | echo "Universal" |
|---|
| 97 | elif [ $buildi386 -gt 0 ] ; then |
|---|
| 98 | echo "Intel-only" |
|---|
| 99 | else |
|---|
| 100 | echo "PPC-only" |
|---|
| 101 | fi |
|---|
| 102 | |
|---|
| 103 | mkdir "$BUILT_PRODUCTS_DIR" |
|---|
| 104 | ####################### |
|---|
| 105 | # Intel shlibs |
|---|
| 106 | ####################### |
|---|
| 107 | if [ $buildi386 -gt 0 ] ; then |
|---|
| 108 | BUILDDIR="$BUILT_PRODUCTS_DIR/intel" |
|---|
| 109 | mkdir "$BUILDDIR" |
|---|
| 110 | |
|---|
| 111 | if [ "$BUILD_STYLE" != "Development" ] ; then |
|---|
| 112 | optcflags="$optcflags -mtune=$x86tune -frerun-cse-after-loop" |
|---|
| 113 | fi |
|---|
| 114 | |
|---|
| 115 | cd "$BUILDDIR" |
|---|
| 116 | if [ "$oldbuildid_ffmpeg" != "quick" ] ; then |
|---|
| 117 | if [ `arch` = ppc ] ; then |
|---|
| 118 | "$SRCROOT/ffmpeg/configure" --cc=$CC --enable-cross-compile --arch=i386 --extra-ldflags="$cflags -arch i386" --extra-cflags="-arch i386 $cflags $optcflags" $extraConfigureOptions $generalConfigureOptions --cpu=pentium-m |
|---|
| 119 | else |
|---|
| 120 | "$SRCROOT/ffmpeg/configure" --cc=$CC --extra-ldflags="$cflags -arch i386" --extra-cflags="-arch i386 $cflags $optcflags" $extraConfigureOptions $generalConfigureOptions --cpu=pentium-m |
|---|
| 121 | fi |
|---|
| 122 | |
|---|
| 123 | make depend > /dev/null 2>&1 || true |
|---|
| 124 | fi |
|---|
| 125 | if [ "$BUILD_STYLE" = "Development" ] ; then |
|---|
| 126 | cd libavcodec |
|---|
| 127 | export CFLAGS="-O1 -fomit-frame-pointer -funit-at-a-time"; make h264.o cabac.o h264_parser.o motion_est.o |
|---|
| 128 | unset CFLAGS; |
|---|
| 129 | cd .. |
|---|
| 130 | fi |
|---|
| 131 | make -j3 |
|---|
| 132 | fi |
|---|
| 133 | |
|---|
| 134 | ####################### |
|---|
| 135 | # PPC shlibs |
|---|
| 136 | ####################### |
|---|
| 137 | if [ $buildppc -gt 0 ] ; then |
|---|
| 138 | BUILDDIR="$BUILT_PRODUCTS_DIR/ppc" |
|---|
| 139 | mkdir "$BUILDDIR" |
|---|
| 140 | |
|---|
| 141 | if [ "$BUILD_STYLE" != "Development" ] ; then |
|---|
| 142 | optcflags="$optcflags -mcpu=G3 -mtune=G5 -funroll-loops -mmultiple" |
|---|
| 143 | fi |
|---|
| 144 | |
|---|
| 145 | cd "$BUILDDIR" |
|---|
| 146 | if [ "$oldbuildid_ffmpeg" != "quick" ] ; then |
|---|
| 147 | if [ `arch` = ppc ] ; then |
|---|
| 148 | "$SRCROOT/ffmpeg/configure" --cc=$CC --extra-cflags="-faltivec $cflags $optcflags" $extraConfigureOptions $generalConfigureOptions |
|---|
| 149 | else |
|---|
| 150 | "$SRCROOT/ffmpeg/configure" --cc=$CC --enable-cross-compile --arch=ppc --extra-ldflags="$cflags -arch ppc" --extra-cflags="-faltivec -arch ppc $cflags $optcflags" $extraConfigureOptions $generalConfigureOptions |
|---|
| 151 | fi |
|---|
| 152 | |
|---|
| 153 | make depend > /dev/null 2>&1 || true |
|---|
| 154 | fi |
|---|
| 155 | make -j3 |
|---|
| 156 | fi |
|---|
| 157 | fi |
|---|
| 158 | |
|---|
| 159 | ####################### |
|---|
| 160 | # lipo/copy shlibs |
|---|
| 161 | ####################### |
|---|
| 162 | BUILDDIR="$BUILT_PRODUCTS_DIR/Universal" |
|---|
| 163 | INTEL="$BUILT_PRODUCTS_DIR/intel" |
|---|
| 164 | PPC="$BUILT_PRODUCTS_DIR/ppc" |
|---|
| 165 | |
|---|
| 166 | rm -rf "$BUILDDIR" |
|---|
| 167 | mkdir "$BUILDDIR" |
|---|
| 168 | echo $buildi386 $buildppc |
|---|
| 169 | if [ $buildi386 -eq $buildppc ] ; then |
|---|
| 170 | # lipo them |
|---|
| 171 | for aa in "$INTEL"/*/*.a ; do |
|---|
| 172 | echo lipo -create $aa `echo -n $aa | sed 's/intel/ppc/'` -output `echo -n $aa | sed 's/intel\/.*\//Universal\//'` |
|---|
| 173 | lipo -create $aa `echo -n $aa | sed 's/intel/ppc/'` -output `echo -n $aa | sed 's/intel\/.*\//Universal\//'` |
|---|
| 174 | done |
|---|
| 175 | else |
|---|
| 176 | if [ $buildppc -gt 0 ] ; then |
|---|
| 177 | archDir="ppc" |
|---|
| 178 | BUILDARCHDIR=$PPC |
|---|
| 179 | else |
|---|
| 180 | archDir="intel" |
|---|
| 181 | BUILDARCHDIR=$INTEL |
|---|
| 182 | fi |
|---|
| 183 | # just copy them |
|---|
| 184 | for aa in "$BUILDARCHDIR"/*/*.a ; do |
|---|
| 185 | echo cp "$aa" `echo -n $aa | sed 's/'$archDir'\/.*\//Universal\//'` |
|---|
| 186 | cp "$aa" `echo -n $aa | sed 's/'$archDir'\/.*\//Universal\//'` |
|---|
| 187 | done |
|---|
| 188 | fi |
|---|
| 189 | echo -n "$buildid_ffmpeg" > $OUTPUT_FILE |
|---|
| 190 | |
|---|
| 191 | mkdir "$SYMROOT/Universal" || true |
|---|
| 192 | cp "$BUILT_PRODUCTS_DIR/Universal"/* "$SYMROOT/Universal" |
|---|
| 193 | ranlib "$SYMROOT/Universal"/*.a |
|---|