source: trunk/createStaticLibs.sh @ 1198

Revision 1198, 6.3 KB checked in by astrange, 5 years ago (diff)

Import patch to fix the alpha in HuffYUV locally.

Haven't managed to finish it for mainline yet.
Fixes #439.

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 -D__DARWIN_UNIX03=0"
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    echo "Xcode 3.1 is required to build Perian";
22    exit 1
23fi
24
25x86tune="generic"
26x86flags=""
27
28if [ -e /usr/bin/gcc-4.2 ]; then
29        CC="gcc-4.2"
30        x86tune="core2"
31        x86flags="--param max-completely-peel-times=2"
32fi
33
34BUILD_ID_FILE="$BUILT_PRODUCTS_DIR/Universal/buildid"
35
36if [[ -e "$BUILD_ID_FILE" ]] ; then
37    oldbuildid_ffmpeg=`cat "$BUILD_ID_FILE"`
38else
39    oldbuildid_ffmpeg="buildme"
40fi
41
42QUICKBUILD="$BUILT_PRODUCTS_DIR/Universal/quickbuild"
43if [[ -e "$QUICKBUILD" ]] ; then
44    oldbuildid_ffmpeg="quick"
45    rm "$QUICKBUILD"
46fi
47
48if [[ $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;
51fi
52
53if [ `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
60elif [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then
61   buildi386=0
62   buildppc=1
63else
64    echo "No architectures"
65    exit 0
66fi
67
68if [ "$buildid_ffmpeg" = "$oldbuildid_ffmpeg" ] ; then
69    echo "Static ffmpeg libs are up-to-date ; not rebuilding"
70else
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
181fi
182
183FINAL_BUILD_ID_FILE="$SYMROOT/Universal/buildid"
184if [[ -e "$FINAL_BUILD_ID_FILE" ]] ; then
185    oldbuildid_ffmpeg=`cat "$FINAL_BUILD_ID_FILE"`
186else
187    oldbuildid_ffmpeg="buildme"
188fi
189
190if [ "$buildid_ffmpeg" = "$oldbuildid_ffmpeg" ] ; then
191    echo "Final static ffmpeg libs are up-to-date ; not copying"
192else
193        mkdir -p "$SYMROOT/Universal"
194        cp "$BUILT_PRODUCTS_DIR/Universal"/* "$SYMROOT/Universal"
195        ranlib "$SYMROOT/Universal"/*.a
196fi
Note: See TracBrowser for help on using the repository browser.