Advertisement
Guest User

zaaghad

a guest
Feb 20th, 2009
1,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.90 KB | None | 0 0
  1. #! /bin/bash
  2. # 2009-02-20, Igor Stepura <igor.stepura@gmail.com>
  3. # Script to build universal ARM/i386 OpenCV private framework using iPhone SDK
  4. # Based on make_frameworks.sh by Mark Asbach <asbach@ient.rwth-aachen.de>
  5. # and script from here http://lambdajive.wordpress.com/2008/12/20/cross-compiling-for-iphone/
  6.  
  7. # Tested to build with OpenCV 1.1pre1
  8. # (http://sourceforge.net/project/showfiles.php?group_id=22870&package_id=16948&release_id=634504)
  9.  
  10.  
  11. #You will need modified Makefile.in (http://pastebin.com/f35b8b20e) for this script to work properly
  12. #see http://zaaghad.blogspot.com/2009/02/universal-i386arm-opencv-framework-for.html for details
  13.  
  14. if test -x Makefile; then make distclean; fi
  15.  
  16. # (re-)create directories                                                                                                                                                                                        
  17. rm -rf build_ppc build_i386 build_iphoneos OpenCV.framework
  18.  
  19. mkdir build_ppc
  20. mkdir build_i386
  21. mkdir build_iphoneos
  22.  
  23. export parallel_jobs=$((2 * `sysctl -n hw.ncpu` + 1))
  24.  
  25. export FRAMEWORK_INSTALL_PATH="@executable_path/Frameworks"                                                                                                                                                  
  26. export FRAMEWORK_NAME=OpenCV
  27. export FRAMEWORK_VERSION=A
  28. export FRAMEWORK_CURRENT_VERSION=1.1
  29. export FRAMEWORK_COMPAT_VERSION=1.1
  30.  
  31. export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
  32. export SDK_VER=2.2
  33. export SDK=$DEVROOT/SDKs/iPhoneOS$SDK_VER.sdk
  34.  
  35.  
  36.  
  37. # build powerpc version
  38.  
  39. #Uncomment these lines if you need ppc version of framework
  40.  
  41. ##echo "Building ppc version of the OpenCV framework"
  42. ##echo "============================================"
  43. ##cd build_ppc && ../configure --build=`arch` --host="powerpc-apple-darwin8" CXXFLAGS="-arch ppc" --without-python --without-swig --disable-apps && make -j $parallel_jobs framework FRAMEWORK_ARCH=ppc
  44.  
  45. ##cd build_ppc
  46.  
  47.                                                                              
  48.  
  49. # build intel version                                                                                                                                                                                            
  50. echo "Building i386 version of the OpenCV framework"
  51. echo "============================================="
  52. if test -d build_i386; then cd build_i386; fi
  53. ../configure --build=`arch` --host="i686-apple-darwin8" CXXFLAGS="-arch i386"\
  54.  --enable-static \
  55.  --disable-shared \
  56.  --without-gtk  \
  57.   --without-imageio --without-quicktime --without-carbon --without-python --without-swig --disable-apps\
  58.  && make -j $parallel_jobs\
  59.  framework FRAMEWORK_ARCH=i386  FRAMEWORK_LIBTOOL=libtool
  60.  
  61. # build arm version                                                                                                                                                                                              
  62. echo "Building iPhoneOS arm version of the OpenCV framework"
  63. echo "============================================="
  64. if test -d ../build_iphoneos; then cd ../build_iphoneos; fi
  65. ../configure \
  66.  --disable-shared \
  67.   --enable-static \
  68.   --host=arm-apple-darwin9 --target=arm-apple-darwin9 \
  69.   --without-imageio  --without-carbon  --without-quicktime --without-python --without-gtk --without-swig --disable-apps \
  70.  CC=$DEVROOT/usr/bin/gcc-4.0 \
  71.  LD=$DEVROOT/usr/bin/ld \
  72.  CPP=$DEVROOT/usr/bin/cpp \
  73.  CXXCPP=$DEVROOT/usr/bin/cpp \
  74.  CXX=$DEVROOT/usr/bin/arm-apple-darwin9-g++-4.0.1\
  75.  AR=$DEVROOT/usr/bin/ar \
  76.  RANLIB=$DEVROOT/usr/bin/ranlib \
  77.  NM=$DEVROOT/usr/bin/nm \
  78.  CFLAGS="-arch armv6 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -gdwarf-2 -mthumb -miphoneos-version-min=2.0 -I/Library/iPhone/include -isysroot $SDK" \
  79.  LDFLAGS="-arch armv6 -pipe -std=c99 -gdwarf-2 -mthumb -isysroot $SDK -L$SDK/usr/lib" \
  80.  CXXFLAGS="-arch armv6 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -gdwarf-2 -mthumb -miphoneos-version-min=2.0 -I/Library/iPhone/include -isysroot $SDK"  \
  81. && make -j $parallel_jobs framework FRAMEWORK_ARCH=armv6 FRAMEWORK_LIBTOOL=$DEVROOT/usr/bin/libtool
  82.  
  83.  
  84. # build universal version                                                                                                                                                                                        
  85. echo "Creating universal Framework"
  86. echo "============================================="
  87. if test -d ../build_i386; then cd .. ; fi
  88. cp -Rp build_i386/OpenCV.framework ./
  89. $DEVROOT/usr/bin/lipo -create -arch armv6 build_iphoneos/OpenCV.framework/OpenCV\
  90.                -arch i386 build_i386/OpenCV.framework/OpenCV\
  91.  -output OpenCV.framework/Versions/A/OpenCV
  92.  
  93.  
  94. # finalize                                                                                                                                                                                                      
  95. echo "Done!"
  96. open .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement