source: branches/perian-1.1/createStaticLibs.sh @ 962

Revision 962, 6.2 KB checked in by astrange, 6 years ago (diff)

Copy G3 fix from trunk and add some minor optimizations/memory bug fixes to the ffmpeg patches.

Line 
1#!/bin/sh -v
2PATH=$PATH:/usr/local/bin:/usr/bin:/sw/bin:/opt/local/bin
3buildid_ffmpeg="r`svn info ffmpeg | grep -F Revision | awk '{print $2}'`"
4
5if [ "$MACOSX_DEPLOYMENT_TARGET" = "" ]; then
6        MACOSX_DEPLOYMENT_TARGET="10.4"
7fi
8
9generalConfigureOptions="--disable-muxers --disable-encoders --disable-stripping --enable-pthreads --disable-ffmpeg --disable-network --disable-ffplay --disable-vhook --disable-ffserver"
10sdkflags="-isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -ggdb -gstabs -Dattribute_deprecated="
11
12if [ "$BUILD_STYLE" = "Development" ] ; then
13    generalConfigureOptions="$generalConfigureOptions --disable-optimizations --disable-mmx"
14fi
15
16if what /usr/bin/ld | grep -q ld64-77; then
17  no_pic=0
18else
19  no_pic=1
20fi
21
22if [ $no_pic -gt 0 ]; then
23    sdkflags="$sdkflags -mdynamic-no-pic" # ld can't handle -fno-pic on ppc
24else
25    #no-pic only on pre-leopard
26    echo "warning: Due to issues with Xcode 3.0, Perian will run very slowly! Please get the iPhone SDK or fix Patches/ffmpeg.diff!";
27    generalConfigureOptions="$generalConfigureOptions --disable-decoder=cavs --disable-decoder=vc1 --disable-decoder=wmv3 --disable-mmx --enable-shared"
28fi
29
30if [ "$CC" = "" ]; then
31        CC="gcc"
32        export CC
33fi
34
35export sdkflags
36
37OUTPUT_FILE="$BUILT_PRODUCTS_DIR/Universal/buildid"
38
39if [[ -e "$OUTPUT_FILE" ]] ; then
40    oldbuildid_ffmpeg=`cat "$OUTPUT_FILE"`
41else
42    oldbuildid_ffmpeg="buildme"
43fi
44
45QUICKBUILD="$BUILT_PRODUCTS_DIR/Universal/quickbuild"
46if [[ -e "$QUICKBUILD" ]] ; then
47    oldbuildid_ffmpeg="quick"
48    rm "$QUICKBUILD"
49fi
50
51if [[ $buildid == "r" ]] ; then
52    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."
53    exit 1;
54fi
55
56if [ `echo $ARCHS | grep -c i386` -gt 0 ] ; then
57   buildi386=1
58   if [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then
59       buildppc=1
60   else
61       buildppc=0
62   fi
63elif [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then
64   buildi386=0
65   buildppc=1
66else
67    echo "No architectures"
68    exit 0
69fi
70
71if [ -e ffmpeg/patched ] ; then
72        (cd ffmpeg && svn revert -R . && rm patched)
73fi
74
75patch -p0 < Patches/ffmpeg-h264dsp-crash.diff
76patch -p0 < Patches/ffmpeg-forceinline.diff
77patch -p0 < Patches/ffmpeg-no-interlaced.diff
78patch -p0 < Patches/ffmpeg-faltivec.diff
79patch -p0 < Patches/ffmpeg-h264-nounrollcabac.diff
80patch -p0 < Patches/ffmpeg-h264nal-valgrind-warning.diff
81touch ffmpeg/patched
82
83# if [ $no_pic -eq 0 ] ; then
84# (cd ffmpeg; patch -p1 < ../Patches/ffmpeg-pic.diff)
85# fi
86
87touch patched
88
89if [ "$buildid_ffmpeg" = "$oldbuildid_ffmpeg" ] ; then
90    echo "Static ffmpeg libs are up-to-date ; not rebuilding"
91else
92    echo "Static ffmpeg libs are out-of-date ; rebuilding"
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                export optCFlags="-mtune=nocona -fstrict-aliasing -frerun-cse-after-loop -fweb -falign-loops=16" 
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="$sdkflags -arch i386" --extra-cflags="-arch i386 $sdkflags $optCFlags" $extraConfigureOptions $generalConfigureOptions --cpu=pentium-m
119            else
120                "$SRCROOT/ffmpeg/configure" --cc=$CC --extra-cflags="$sdkflags $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                export optCFlags="-mcpu=G3 -mtune=G5 -fstrict-aliasing -funroll-loops -falign-loops=16 -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 $sdkflags $optCFlags" $extraConfigureOptions $generalConfigureOptions
149            else
150                "$SRCROOT/ffmpeg/configure" --cc=$CC --enable-cross-compile --arch=ppc  --extra-ldflags="$sdkflags -arch ppc" --extra-cflags="-faltivec -arch ppc $sdkflags $optCFlags" $extraConfigureOptions $generalConfigureOptions
151            fi
152       
153            make depend > /dev/null 2>&1 || true
154        fi
155        make -j3
156    fi
157fi
158
159#######################
160# lipo/copy shlibs
161#######################
162BUILDDIR="$BUILT_PRODUCTS_DIR/Universal"
163INTEL="$BUILT_PRODUCTS_DIR/intel"
164PPC="$BUILT_PRODUCTS_DIR/ppc"
165
166rm -rf "$BUILDDIR"
167mkdir "$BUILDDIR"
168echo $buildi386 $buildppc
169if [ $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
175else
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
188fi
189echo -n "$buildid_ffmpeg" > $OUTPUT_FILE
190
191mkdir "$SYMROOT/Universal" || true
192cp "$BUILT_PRODUCTS_DIR/Universal"/* "$SYMROOT/Universal"
193if [ "$BUILD_STYLE" = "Deployment" ] ; then
194    strip -S "$SYMROOT/Universal"/*.a
195fi
196ranlib "$SYMROOT/Universal"/*.a
Note: See TracBrowser for help on using the repository browser.