source: trunk/createStaticLibs.sh @ 844

Revision 844, 5.7 KB checked in by astrange, 6 years ago (diff)

Fix building

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 -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    generalConfigureOptions="$generalConfigureOptions --disable-decoder=cavs --disable-decoder=vc1 --disable-decoder=wmv3 --enable-shared"
27fi
28       
29export sdkflags
30
31OUTPUT_FILE="$BUILT_PRODUCTS_DIR/Universal/buildid"
32
33if [[ -e "$OUTPUT_FILE" ]] ; then
34    oldbuildid_ffmpeg=`cat "$OUTPUT_FILE"`
35else
36    oldbuildid_ffmpeg="buildme"
37fi
38
39QUICKBUILD="$BUILT_PRODUCTS_DIR/Universal/quickbuild"
40if [[ -e "$QUICKBUILD" ]] ; then
41    oldbuildid_ffmpeg="quick"
42    rm "$QUICKBUILD"
43fi
44
45if [[ $buildid == "r" ]] ; then
46    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."
47    exit 1;
48fi
49
50if [ `echo $ARCHS | grep -c i386` -gt 0 ] ; then
51   buildi386=1
52   if [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then
53       buildppc=1
54   else
55       buildppc=0
56   fi
57elif [ `echo $ARCHS | grep -c ppc` -gt 0 ] ; then
58   buildi386=0
59   buildppc=1
60else
61    echo "No architectures"
62    exit 0
63fi
64
65if [ -e ffmpeg/patched ] ; then
66        (cd ffmpeg && svn revert -R . && rm patched)
67fi
68
69if [ $no_pic -eq 0 ] ; then
70 (cd ffmpeg; patch -p1 < ../Patches/ffmpeg-pic.diff)
71fi
72
73touch patched
74
75if [ "$buildid_ffmpeg" = "$oldbuildid_ffmpeg" ] ; then
76    echo "Static ffmpeg libs are up-to-date ; not rebuilding"
77else
78    echo "Static ffmpeg libs are out-of-date ; rebuilding"
79   
80    echo -n "Building "
81    if [ $buildi386 -eq $buildppc ] ; then
82        echo "Universal"
83    elif [ $buildi386 -gt 0 ] ; then
84        echo "Intel-only"
85    else
86        echo "PPC-only"
87    fi
88   
89    mkdir "$BUILT_PRODUCTS_DIR"
90    #######################
91    # Intel shlibs
92    #######################
93    if [ $buildi386 -gt 0 ] ; then
94        BUILDDIR="$BUILT_PRODUCTS_DIR/intel"
95        mkdir "$BUILDDIR"
96
97                if [ "$BUILD_STYLE" != "Development" ] ; then
98                export optCFlags="-mtune=nocona -fstrict-aliasing -frerun-cse-after-loop -fweb -falign-loops=16" 
99        fi
100
101        cd "$BUILDDIR"
102        if [ "$oldbuildid_ffmpeg" != "quick" ] ; then
103            if [ `arch` = ppc ] ; then
104                "$SRCROOT/ffmpeg/configure" --enable-cross-compile --arch=i386 --extra-ldflags='-arch i386' --extra-cflags='-arch i386 $sdkflags $optCFlags' $extraConfigureOptions $generalConfigureOptions --cpu=pentium-m
105            else
106                "$SRCROOT/ffmpeg/configure" --extra-cflags='$sdkflags $optCFlags' $extraConfigureOptions $generalConfigureOptions --cpu=pentium-m
107            fi
108       
109            make depend > /dev/null 2>&1 || true
110        fi
111        if [ "$BUILD_STYLE" = "Development" ] ; then
112            cd libavcodec
113            export CFLAGS="-O1 -fomit-frame-pointer -funit-at-a-time"; make h264.o cabac.o h264_parser.o motion_est.o
114            unset CFLAGS;
115            cd ..
116        fi
117        make -j3
118    fi
119   
120    #######################
121    # PPC shlibs
122    #######################
123    if [ $buildppc -gt 0 ] ; then
124        BUILDDIR="$BUILT_PRODUCTS_DIR/ppc"
125        mkdir "$BUILDDIR"
126
127                if [ "$BUILD_STYLE" != "Development" ] ; then
128                export optCFlags="-mcpu=G3 -mtune=G5 -fstrict-aliasing -funroll-loops -falign-loops=16 -mmultiple"
129        fi
130   
131        cd "$BUILDDIR"
132        if [ "$oldbuildid_ffmpeg" != "quick" ] ; then
133            if [ `arch` = ppc ] ; then
134                "$SRCROOT/ffmpeg/configure" --extra-cflags='-faltivec $sdkflags $optCFlags' $extraConfigureOptions $generalConfigureOptions
135            else
136                "$SRCROOT/ffmpeg/configure" --enable-cross-compile --arch=ppc  --extra-ldflags='-arch ppc' --extra-cflags='-faltivec -arch ppc $sdkflags $optCFlags' $extraConfigureOptions $generalConfigureOptions
137            fi
138       
139            make depend > /dev/null 2>&1 || true
140        fi
141        make -j3
142    fi
143fi
144
145#######################
146# lipo/copy shlibs
147#######################
148BUILDDIR="$BUILT_PRODUCTS_DIR/Universal"
149INTEL="$BUILT_PRODUCTS_DIR/intel"
150PPC="$BUILT_PRODUCTS_DIR/ppc"
151
152rm -rf "$BUILDDIR"
153mkdir "$BUILDDIR"
154echo $buildi386 $buildppc
155if [ $buildi386 -eq $buildppc ] ; then
156    # lipo them
157    for aa in "$INTEL"/*/*.a ; do
158        echo lipo -create $aa `echo -n $aa | sed 's/intel/ppc/'` -output `echo -n $aa | sed 's/intel\/.*\//Universal\//'`
159        lipo -create $aa `echo -n $aa | sed 's/intel/ppc/'` -output `echo -n $aa | sed 's/intel\/.*\//Universal\//'`
160    done
161else
162    if [ $buildppc -gt 0 ] ; then
163        archDir="ppc"
164        BUILDARCHDIR=$PPC
165    else
166        archDir="intel"
167        BUILDARCHDIR=$INTEL
168    fi
169    # just copy them
170    for aa in "$BUILDARCHDIR"/*/*.a ; do
171        echo cp "$aa" `echo -n $aa | sed 's/'$archDir'\/.*\//Universal\//'`
172        cp "$aa" `echo -n $aa | sed 's/'$archDir'\/.*\//Universal\//'`
173    done
174fi
175echo -n "$buildid_ffmpeg" > $OUTPUT_FILE
176
177mkdir "$SYMROOT/Universal" || true
178cp "$BUILT_PRODUCTS_DIR/Universal"/* "$SYMROOT/Universal"
179if [ "$BUILD_STYLE" = "Deployment" ] ; then
180    strip -S "$SYMROOT/Universal"/*.a
181fi
182ranlib "$SYMROOT/Universal"/*.a
Note: See TracBrowser for help on using the repository browser.