Created
June 16, 2011 12:52
-
-
Save rcarlsen/1029171 to your computer and use it in GitHub Desktop.
Script for building an iOS FAT binary from a typical configure/make project. (tesseract-ocr)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# build_fat.sh | |
# | |
# Created by Robert Carlsen on 15.07.2009. Updated 24.9.2010 | |
# build an arm / i386 lib of standard linux project | |
# | |
# initially configured for tesseract-ocr v2.0.4 | |
# updated for tesseract prerelease v3 | |
outdir=outdir | |
mkdir -p $outdir/arm $outdir/i386 | |
libdirs=( api ccutil ccmain ccstruct classify cutil dict image textord training viewer wordrec ) | |
libs=( api ccutil main ccstruct classify cutil dict image textord training viewer wordrec ) | |
count=${#libdirs[@]} | |
make distclean | |
unset CPPFLAGS CFLAGS LDFLAGS CPP CXX CC CXXFLAGS DEVROOT SDKROOT LD | |
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer | |
export SDKROOT=$DEVROOT/SDKs/iPhoneOS4.1.sdk | |
export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=3.0 -I$SDKROOT/usr/include/" | |
export CPPFLAGS="$CFLAGS" | |
export CXXFLAGS="$CFLAGS" | |
export LDFLAGS="-L$SDKROOT/usr/lib/" | |
export LD="$DEVROOT/usr/bin/ld" | |
export CPP="$DEVROOT/usr/bin/cpp-4.2" | |
export CXX="$DEVROOT/usr/bin/g++-4.2" | |
export CC="$DEVROOT/usr/bin/gcc-4.2" | |
./configure --host=arm-apple-darwin | |
make -j3 | |
index=0 | |
while [ "$index" -lt "$count" ] | |
do | |
cp ${libdirs[index]}/.libs/libtesseract_${libs[index]}.a $outdir/arm/libtesseract_${libs[index]}_armv6.a | |
((index++)) | |
done | |
make distclean | |
unset CPPFLAGS CFLAGS LDFLAGS CPP CXX CC CXXFLAGS DEVROOT SDKROOT LD | |
export DEVROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer | |
export SDKROOT=$DEVROOT/SDKs/iPhoneSimulator4.1.sdk | |
export CFLAGS="-arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=3.0 -I$SDKROOT/usr/include/" | |
export CPPFLAGS="$CFLAGS" | |
export CXXFLAGS="$CFLAGS" | |
export LDFLAGS="-L$SDKROOT/usr/lib/" | |
export LD="$DEVROOT/usr/bin/ld" | |
export CPP="$DEVROOT/usr/bin/cpp-4.2" | |
export CXX="$DEVROOT/usr/bin/g++-4.2" | |
export CC="$DEVROOT/usr/bin/gcc-4.2" | |
./configure | |
make -j3 | |
index=0 | |
while [ "$index" -lt "$count" ] | |
do | |
cp ${libdirs[index]}/.libs/libtesseract_${libs[index]}.a $outdir/i386/libtesseract_${libs[index]}_i386.a | |
((index++)) | |
done | |
# are the fat libs making the bundle too big? | |
index=0 | |
while [ "$index" -lt "$count" ] | |
do | |
/usr/bin/lipo -arch armv6 $outdir/arm/libtesseract_${libs[index]}_armv6.a -arch i386 $outdir/i386/libtesseract_${libs[index]}_i386.a -create -output $outdir/libtesseract_${libs[index]}.a | |
((index++)) | |
done | |
unset CPPFLAGS CFLAGS LDFLAGS CPP CXX CC CXXFLAGS DEVROOT SDKROOT |
Thanks for that catch...my apologies for the headache.
…On Jun 22, 2011, at 14:11, ***@***.*** wrote:
NOTE: in the above script you'll want to replace '-isysroot$SDKROOT' with '-isysroot $SDKROOT' (minus the single quotes). This caused me hours of frustration, hope it helps someone else save some time.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1029171
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: in the above script you'll want to replace '-isysroot$SDKROOT' with '-isysroot $SDKROOT' (minus the single quotes). Essentially adding a space after -isysroot. This caused me hours of frustration, hope it helps someone else save some time.