-
-
Save vhbit/874549 to your computer and use it in GitHub Desktop.
OpenCV iPhone
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
################################################################################ | |
# This script will create universal binaries for OpenCV library for | |
# iOS-based devices (iPhone, iPad, iPod, etc). | |
# As output you obtain debug/release static libraries and include headers. | |
# | |
# This script was written by Eugene Khvedchenya | |
# And distributed under GPL license | |
# My site, where you can get support: http://computer-vision-talks.com | |
################################################################################ | |
if [ $# -ne 2 ] | |
then | |
echo "Error in $0 - Invalid Argument Count" | |
echo "Syntax: $0 [OpenCV source directory] [Build destination directory]" | |
echo "If the destination directory already exists, it will be overwritten!" | |
exit | |
fi | |
# Absolute path to the source code directory. | |
D=`dirname "$1"` | |
B=`basename "$1"` | |
SRC="`cd \"$D\" 2>/dev/null && pwd || echo \"$D\"`/$B" | |
# Absolute path to the build directory. | |
D=`dirname "$2"` | |
B=`basename "$2"` | |
BUILD="`cd \"$D\" 2>/dev/null && pwd || echo \"$D\"`/$B" | |
INTERMEDIATE=$BUILD/tmp | |
INSTALL_DIR=$INTERMEDIATE/install | |
echo "OpenCV source :" $SRC | |
echo "Build directory :" $BUILD | |
echo "Intermediate dir:" $INTERMEDIATE | |
################################################################################ | |
# Clear the old build and recompile the new one. | |
rm -rf $BUILD | |
mkdir -p $INTERMEDIATE | |
cd $INTERMEDIATE | |
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ | |
-DENABLE_SSE=NO \ | |
-DENABLE_SSE2=NO \ | |
-DBUILD_TESTS=OFF \ | |
-DBUILD_SHARED_LIBS=NO \ | |
-DBUILD_EXAMPLES=NO \ | |
-DWITH_EIGEN2=NO \ | |
-DWITH_PVAPI=NO \ | |
-DWITH_OPENEXR=NO \ | |
-DWITH_QT=NO \ | |
-DWITH_QUICKTIME=NO \ | |
-DOPENCV_BUILD_3RDPARTY_LIBS=YES \ | |
-G Xcode $SRC | |
################################################################################ | |
# Let's b everything: | |
cd $INTERMEDIATE | |
################################################################################ | |
echo "Building iphone armv6 release configuration" | |
xcodebuild -sdk iphoneos -configuration Release ARCHS="armv6" > /dev/null | |
mkdir -p $BUILD/lib/release-iphoneos-armv6 | |
mv $INTERMEDIATE/lib/Release/*.a $BUILD/lib/release-iphoneos-armv6 | |
mv $INTERMEDIATE/3rdparty/lib/Release/*.a $BUILD/lib/release-iphoneos-armv6 | |
################################################################################# | |
echo "Building iphone armv6 debug configuration" | |
xcodebuild -sdk iphoneos -configuration Debug ARCHS="armv6" > /dev/null | |
mkdir -p $BUILD/lib/debug-iphoneos-armv6 | |
mv $INTERMEDIATE/lib/Debug/*.a $BUILD/lib/debug-iphoneos-armv6 | |
mv $INTERMEDIATE/3rdparty/lib/Debug/*.a $BUILD/lib/debug-iphoneos-armv6 | |
################################################################################ | |
echo "Building iphone release configuration" | |
xcodebuild -sdk iphoneos -configuration Release ARCHS="armv7" > build.out | |
mkdir -p $BUILD/lib/release-iphoneos | |
mv $INTERMEDIATE/lib/Release/*.a $BUILD/lib/release-iphoneos | |
mv $INTERMEDIATE/3rdparty/lib/Release/*.a $BUILD/lib/release-iphoneos | |
################################################################################ | |
echo "Building iphone debug configuration" | |
xcodebuild -sdk iphoneos -configuration Debug ARCHS="armv7" > /dev/null | |
mkdir -p $BUILD/lib/debug-iphoneos | |
mv $INTERMEDIATE/lib/Debug/*.a $BUILD/lib/debug-iphoneos | |
mv $INTERMEDIATE/3rdparty/lib/Debug/*.a $BUILD/lib/debug-iphoneos | |
################################################################################ | |
echo "Building iphone simulator release configuration" | |
xcodebuild -sdk iphonesimulator -configuration Release ARCHS="i386" > /dev/null | |
mkdir -p $BUILD/lib/Release-iphonesimulator | |
mv $INTERMEDIATE/lib/Release/*.a $BUILD/lib/release-iphonesimulator | |
mv $INTERMEDIATE/3rdparty/lib/Release/*.a $BUILD/lib/release-iphonesimulator | |
################################################################################ | |
echo "Building iphone simulator debug configuration" | |
xcodebuild -sdk iphonesimulator -configuration Debug ARCHS="i386" > /dev/null | |
mkdir -p $BUILD/lib/debug-iphonesimulator | |
mv $INTERMEDIATE/lib/Debug/*.a $BUILD/lib/debug-iphonesimulator | |
mv $INTERMEDIATE/3rdparty/lib/Debug/*.a $BUILD/lib/debug-iphonesimulator | |
################################################################################ | |
# Make universal binaries for release INTERMEDIATE: | |
# mkdir -p $BUILD/lib/release-universal | |
# | |
for FILE in `ls $BUILD/lib/release-iphoneos` | |
do | |
lipo $BUILD/lib/release-iphoneos/$FILE \ | |
-arch armv6 $BUILD/lib/release-iphoneos-armv6/$FILE \ | |
-arch i386 $BUILD/lib/release-iphonesimulator/$FILE \ | |
-create -output $BUILD/lib/release-universal/$FILE | |
done | |
# | |
# ################################################################################ | |
# # Make universal binaries for debug INTERMEDIATE: | |
# mkdir -p $BUILD/lib/debug-universal | |
# | |
for FILE in `ls $BUILD/lib/debug-iphoneos` | |
do | |
lipo $BUILD/lib/debug-iphoneos/$FILE \ | |
-arch armv6 $BUILD/lib/debug-iphoneos-armv6/$FILE \ | |
-arch i386 $BUILD/lib/debug-iphonesimulator/$FILE \ | |
-create -output $BUILD/lib/debug-universal/$FILE | |
done | |
################################################################################ | |
# Now we will do some tricks to get OpenCV headers: | |
# This command will build opencv INSTALL target, which will | |
# copy headers to the $BUILD/include directory. | |
#echo "Getting OpenCV headers" | |
#mkdir $BUILD/include | |
#xcodebuild -sdk macosx -configuration Release -target install > /dev/null | |
#mv $INSTALL_DIR/include/* $BUILD/include | |
# | |
#rm -rf $INTERMEDIATE | |
#echo "All is done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment