source: trunk/createStaticLibs.sh @ 1132

Revision 1132, 6.8 KB checked in by astrange, 5 years ago (diff)

Fixup r1131 and r1129.

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