| 1 | #!/bin/sh -v |
|---|
| 2 | PATH=/usr/local/bin:/sw/bin:/opt/local/bin:/usr/bin:$PWD/Binaries:$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 --disable-amd3dnow --enable-runtime-cpudetect --enable-pthreads --disable-ffmpeg --disable-network --disable-ffplay --disable-ffserver" |
|---|
| 10 | cflags="-isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -Dattribute_deprecated= -w -D__DARWIN_UNIX03=0" |
|---|
| 11 | |
|---|
| 12 | if [ "$BUILD_STYLE" = "Development" ] ; then |
|---|
| 13 | generalConfigureOptions="$generalConfigureOptions --disable-optimizations --disable-mmx" |
|---|
| 14 | buildid_ffmpeg="${buildid_ffmpeg}Dev" |
|---|
| 15 | else |
|---|
| 16 | optcflags="-falign-loops=16 -fweb -fstrict-aliasing -finline-limit=1000 -freorder-blocks" |
|---|
| 17 | buildid_ffmpeg="${buildid_ffmpeg}Dep" |
|---|
| 18 | fi |
|---|
| 19 | |
|---|
| 20 | if what /usr/bin/ld | grep -q ld64-77; then |
|---|
| 21 | echo "Xcode 3.1 is required to build Perian"; |
|---|
| 22 | exit 1 |
|---|
| 23 | fi |
|---|
| 24 | |
|---|
| 25 | x86tune="generic" |
|---|
| 26 | x86flags="" |
|---|
| 27 | |
|---|
| 28 | if [ -e /usr/bin/gcc-4.2 ]; then |
|---|
| 29 | CC="gcc-4.2" |
|---|
| 30 | x86tune="core2" |
|---|
| 31 | x86flags="--param max-completely-peel-times=2" |
|---|
| 32 | fi |
|---|
| 33 | |
|---|
| 34 | BUILD_ID_FILE="$BUILT_PRODUCTS_DIR/Universal/buildid" |
|---|
| 35 | |
|---|
| 36 | if [[ -e "$BUILD_ID_FILE" ]] ; then |
|---|
| 37 | oldbuildid_ffmpeg=`cat "$BUILD_ID_FILE"` |
|---|
| 38 | else |
|---|
| 39 | oldbuildid_ffmpeg="buildme" |
|---|
| 40 | fi |
|---|
| 41 | |
|---|
| 42 | QUICKBUILD="$BUILT_PRODUCTS_DIR/Universal/quickbuild" |
|---|
| 43 | if [[ -e "$QUICKBUILD" ]] ; then |
|---|
| 44 | oldbuildid_ffmpeg="quick" |
|---|
| 45 | rm "$QUICKBUILD" |
|---|
| 46 | fi |
|---|
| 47 | |
|---|
| 48 | if [[ $buildid == "r" ]] ; then |
|---|
| 49 | 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." |
|---|
| 50 | exit 1; |
|---|
| 51 | fi |
|---|
| 52 | |
|---|
| 53 | if [ `echo $ARCHS | grep -c i386` -gt 0 ] ; then |
|---|
| 54 | buildi386=1 |
|---|
| 55 | if [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then |
|---|
| 56 | buildppc=1 |
|---|
| 57 | else |
|---|
| 58 | buildppc=0 |
|---|
| 59 | fi |
|---|
| 60 | elif [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then |
|---|
| 61 | buildi386=0 |
|---|
| 62 | buildppc=1 |
|---|
| 63 | else |
|---|
| 64 | echo "No architectures" |
|---|
| 65 | exit 0 |
|---|
| 66 | fi |
|---|
| 67 | |
|---|
| 68 | if [ "$buildid_ffmpeg" = "$oldbuildid_ffmpeg" ] ; then |
|---|
| 69 | echo "Static ffmpeg libs are up-to-date ; not rebuilding" |
|---|
| 70 | else |
|---|
| 71 | echo "Static ffmpeg libs are out-of-date ; rebuilding" |
|---|
| 72 | |
|---|
| 73 | if [ -e ffmpeg/patched ] ; then |
|---|
| 74 | cd ffmpeg && svn revert -R . && rm patched && cd .. |
|---|
| 75 | fi |
|---|
| 76 | |
|---|
| 77 | patch -p0 < Patches/ffmpeg-forceinline.diff |
|---|
| 78 | patch -p0 < Patches/ffmpeg-no-interlaced.diff |
|---|
| 79 | patch -p0 < Patches/ffmpeg-faltivec.diff |
|---|
| 80 | patch -p0 < Patches/ffmpeg-h264-nounrollcabac.diff |
|---|
| 81 | patch -p0 < Patches/ffmpeg-no-h264-warning.diff |
|---|
| 82 | patch -p0 < Patches/ffmpeg-bgr24-huffyuv.diff |
|---|
| 83 | touch ffmpeg/patched |
|---|
| 84 | |
|---|
| 85 | echo -n "Building " |
|---|
| 86 | if [ $buildi386 -eq $buildppc ] ; then |
|---|
| 87 | echo "Universal" |
|---|
| 88 | elif [ $buildi386 -gt 0 ] ; then |
|---|
| 89 | echo "Intel-only" |
|---|
| 90 | else |
|---|
| 91 | echo "PPC-only" |
|---|
| 92 | fi |
|---|
| 93 | |
|---|
| 94 | mkdir -p "$BUILT_PRODUCTS_DIR" |
|---|
| 95 | ####################### |
|---|
| 96 | # Intel shlibs |
|---|
| 97 | ####################### |
|---|
| 98 | if [ $buildi386 -gt 0 ] ; then |
|---|
| 99 | BUILDDIR="$BUILT_PRODUCTS_DIR/intel" |
|---|
| 100 | mkdir -p "$BUILDDIR" |
|---|
| 101 | |
|---|
| 102 | if [ "$BUILD_STYLE" != "Development" ] ; then |
|---|
| 103 | optcflags="$optcflags -mtune=$x86tune $x86flags -frerun-cse-after-loop -mdynamic-no-pic" |
|---|
| 104 | fi |
|---|
| 105 | |
|---|
| 106 | cd "$BUILDDIR" |
|---|
| 107 | if [ "$oldbuildid_ffmpeg" != "quick" ] ; then |
|---|
| 108 | if [ `arch` = ppc ] ; then |
|---|
| 109 | "$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 |
|---|
| 110 | else |
|---|
| 111 | "$SRCROOT/ffmpeg/configure" --cc=$CC --extra-ldflags="$cflags -arch i386" --extra-cflags="-arch i386 $cflags $optcflags" $extraConfigureOptions $generalConfigureOptions --cpu=pentium-m |
|---|
| 112 | fi |
|---|
| 113 | |
|---|
| 114 | make depend > /dev/null 2>&1 || true |
|---|
| 115 | fi |
|---|
| 116 | if [ "$BUILD_STYLE" = "Development" ] ; then |
|---|
| 117 | cd libavcodec |
|---|
| 118 | export CFLAGS="-O1 -fomit-frame-pointer -funit-at-a-time"; make h264.o cabac.o h264_parser.o motion_est.o |
|---|
| 119 | unset CFLAGS; |
|---|
| 120 | cd .. |
|---|
| 121 | fi |
|---|
| 122 | |
|---|
| 123 | make -j3 |
|---|
| 124 | fi |
|---|
| 125 | |
|---|
| 126 | ####################### |
|---|
| 127 | # PPC shlibs |
|---|
| 128 | ####################### |
|---|
| 129 | if [ $buildppc -gt 0 ] ; then |
|---|
| 130 | BUILDDIR="$BUILT_PRODUCTS_DIR/ppc" |
|---|
| 131 | mkdir -p "$BUILDDIR" |
|---|
| 132 | |
|---|
| 133 | if [ "$BUILD_STYLE" != "Development" ] ; then |
|---|
| 134 | optcflags="$optcflags -mcpu=G3 -mtune=G5 -funroll-loops -mmultiple" |
|---|
| 135 | fi |
|---|
| 136 | |
|---|
| 137 | cd "$BUILDDIR" |
|---|
| 138 | if [ "$oldbuildid_ffmpeg" != "quick" ] ; then |
|---|
| 139 | if [ `arch` = ppc ] ; then |
|---|
| 140 | "$SRCROOT/ffmpeg/configure" --cc=$CC --extra-cflags="-faltivec $cflags $optcflags" $extraConfigureOptions $generalConfigureOptions |
|---|
| 141 | else |
|---|
| 142 | "$SRCROOT/ffmpeg/configure" --cc=$CC --enable-cross-compile --arch=ppc --extra-ldflags="$cflags -arch ppc" --extra-cflags="-faltivec -arch ppc $cflags $optcflags" $extraConfigureOptions $generalConfigureOptions |
|---|
| 143 | fi |
|---|
| 144 | |
|---|
| 145 | make depend > /dev/null 2>&1 || true |
|---|
| 146 | fi |
|---|
| 147 | make -j3 |
|---|
| 148 | fi |
|---|
| 149 | |
|---|
| 150 | ####################### |
|---|
| 151 | # lipo/copy shlibs |
|---|
| 152 | ####################### |
|---|
| 153 | BUILDDIR="$BUILT_PRODUCTS_DIR/Universal" |
|---|
| 154 | INTEL="$BUILT_PRODUCTS_DIR/intel" |
|---|
| 155 | PPC="$BUILT_PRODUCTS_DIR/ppc" |
|---|
| 156 | |
|---|
| 157 | rm -rf "$BUILDDIR" |
|---|
| 158 | mkdir "$BUILDDIR" |
|---|
| 159 | echo $buildi386 $buildppc |
|---|
| 160 | if [ $buildi386 -eq $buildppc ] ; then |
|---|
| 161 | # lipo them |
|---|
| 162 | for aa in "$INTEL"/*/*.a ; do |
|---|
| 163 | echo lipo -create -arch i386 $aa -arch ppc `echo -n $aa | sed 's/intel/ppc/'` -output `echo -n $aa | sed 's/intel\/.*\//Universal\//'` |
|---|
| 164 | lipo -create -arch i386 $aa -arch ppc `echo -n $aa | sed 's/intel/ppc/'` -output `echo -n $aa | sed 's/intel\/.*\//Universal\//'` |
|---|
| 165 | done |
|---|
| 166 | else |
|---|
| 167 | if [ $buildppc -gt 0 ] ; then |
|---|
| 168 | archDir="ppc" |
|---|
| 169 | BUILDARCHDIR=$PPC |
|---|
| 170 | else |
|---|
| 171 | archDir="intel" |
|---|
| 172 | BUILDARCHDIR=$INTEL |
|---|
| 173 | fi |
|---|
| 174 | # just copy them |
|---|
| 175 | for aa in "$BUILDARCHDIR"/*/*.a ; do |
|---|
| 176 | echo cp "$aa" `echo -n $aa | sed 's/'$archDir'\/.*\//Universal\//'` |
|---|
| 177 | cp "$aa" `echo -n $aa | sed 's/'$archDir'\/.*\//Universal\//'` |
|---|
| 178 | done |
|---|
| 179 | fi |
|---|
| 180 | echo -n "$buildid_ffmpeg" > $BUILD_ID_FILE |
|---|
| 181 | fi |
|---|
| 182 | |
|---|
| 183 | FINAL_BUILD_ID_FILE="$SYMROOT/Universal/buildid" |
|---|
| 184 | if [[ -e "$FINAL_BUILD_ID_FILE" ]] ; then |
|---|
| 185 | oldbuildid_ffmpeg=`cat "$FINAL_BUILD_ID_FILE"` |
|---|
| 186 | else |
|---|
| 187 | oldbuildid_ffmpeg="buildme" |
|---|
| 188 | fi |
|---|
| 189 | |
|---|
| 190 | if [ "$buildid_ffmpeg" = "$oldbuildid_ffmpeg" ] ; then |
|---|
| 191 | echo "Final static ffmpeg libs are up-to-date ; not copying" |
|---|
| 192 | else |
|---|
| 193 | mkdir -p "$SYMROOT/Universal" |
|---|
| 194 | cp "$BUILT_PRODUCTS_DIR/Universal"/* "$SYMROOT/Universal" |
|---|
| 195 | ranlib "$SYMROOT/Universal"/*.a |
|---|
| 196 | fi |
|---|