Update to 2.0.0 tree from current Fremantle build
[opencv] / make_frameworks.sh
1 #! /bin/bash
2
3 # 2007-05-23, Mark Asbach <asbach@ient.rwth-aachen.de>
4
5 # This shell script makes use of VPATH builds and the special 'framework' Makefile target of
6 # the top level Makefile to create a universal binary framework out of native frameworks.
7 # No manual './configure && make && make install' is necessary if the framework is sufficient
8 # for you. However, Python bindings are not generated this way because of issues with 
9 # different python versions and universal binaries.
10 #
11 # If you need python wrappers and standard unix install, you should do a manual VPATH
12 # build with all the settings you like.
13 #
14 # The resulting framework is created as a Private Framework that must be copied into your
15 # application bundle by a dedicated 'Copy Files' build step. See the demo XCode project
16 # included with OpenCV and/or have a look at
17 # http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html#//apple_ref/doc/uid/20002258-106880-BAJJBIEF
18
19 # the current directory should not be configured
20 if test -e Makefile; then make distclean; fi
21
22 # (re-)create directories
23 rm -rf build_ppc build_ppc64 build_i386 build_x86_64 OpenCV.framework
24 mkdir build_ppc
25 mkdir build_i386
26 #mkdir build_ppc64
27 #mkdir build_x86_64
28
29 # find out how many parallel processes we want to use for make
30 # see http://freshmeat.net/projects/kernbench/, we use a slightly different 'optimum' guess
31 export parallel_jobs=$((2 * `sysctl -n hw.ncpu` + 1))
32
33 # this setting defines where the framework should be installed
34 export FRAMEWORK_INSTALL_PATH="@executable_path/../Frameworks"
35 #export FRAMEWORK_INSTALL_PATH="/Library/Frameworks"
36 #export FRAMEWORK_INSTALL_PATH="/Users/your_login_name_here/Library/Frameworks"
37
38 # set up a couple of additional build settings
39 export SETTINGS="CC=gcc-4.2 CXX=g++-4.2 --without-python --without-octave --disable-apps --build=`arch`"
40 #export SETTINGS="--without-python --without-octave --build=`arch`"
41 export SYSROOT="--sysroot=/Developer/SDKs/MacOSX10.5.sdk"
42 #export SYSROOT="" #--iwithsysroot=/Developer/SDKs/MacOSX10.5.sdk"
43
44 # build powerpc version
45 echo "Building ppc version of the OpenCV framework"
46 echo "============================================"
47 cd build_ppc \
48  && ../configure --host=ppc-apple-darwin9 $SETTINGS CPPFLAGS="$SYSROOT" CFLAGS="-arch ppc" CXXFLAGS="-arch ppc" LDFLAGS="$SYSROOT -arch ppc"\
49  && make -j $parallel_jobs framework FRAMEWORK_ARCH=ppc
50
51 # build powerpc 64bit version
52 #echo "Building 64bit ppc version of the OpenCV framework"
53 #echo "============================================"
54 #if test -d ../build_ppc64; then cd ../build_ppc64; fi
55 #../configure --host=ppc64-apple-darwin9 $SETTINGS --without-quicktime --without-carbon CPPFLAGS="$SYSROOT" CXXFLAGS="-arch ppc64" LDFLAGS="$SYSROOT -arch ppc64"\
56 # && make -j $parallel_jobs framework FRAMEWORK_ARCH=ppc64
57
58 # options from -O2
59 #" -fthread-jumps -fcrossjumping -foptimize-sibling-calls -fcse-follow-jumps -fcse-skip-blocks -fgcse -fgcse-lm -fexpensive-optimizations -fstrength-reduce -frerun-cse-after-loop -frerun-loop-opt -fcaller-saves -fpeephole2 -fschedule-insns -fschedule-insns2  -fsched-spec -fregmove -fdelete-null-pointer-checks -freorder-functions -funit-at-a-time -falign-functions -falign-jumps -falign-loops -falign-labels -ftree-pre"
60 # build intel version
61 echo "Building i386 version of the OpenCV framework"
62 echo "============================================="
63 if test -d ../build_i386; then cd ../build_i386; fi
64 ../configure --host=i386-apple-darwin9 $SETTINGS --enable-sse CPPFLAGS="$SYSROOT" CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="$SYSROOT -arch i386"\
65  && make -j $parallel_jobs framework FRAMEWORK_ARCH=i386
66
67 # build intel version
68 #echo "Building x86_64 version of the OpenCV framework"
69 #echo "============================================="
70 #if test -d ../build_x86_64; then cd ../build_x86_64; fi
71 #../configure --host=x86_64-apple-darwin9 $SETTINGS --without-quicktime --without-carbon CPPFLAGS="$SYSROOT" CXXFLAGS="-arch x86_64" LDFLAGS="$SYSROOT -arch x86_64"\
72 #  && make -j $parallel_jobs framework FRAMEWORK_ARCH=x86_64
73
74 # build universal version
75 echo "Creating universal Framework"
76 echo "============================================="
77 if test -d ../build_i386; then cd .. ; fi
78 cp -Rp build_ppc/OpenCV.framework ./
79 lipo -create build_ppc/OpenCV.framework/OpenCV build_i386/OpenCV.framework/OpenCV -output OpenCV.framework/Versions/B/OpenCV
80 #lipo -create build_ppc/OpenCV.framework/OpenCV build_ppc64/OpenCV.framework/OpenCV build_i386/OpenCV.framework/OpenCV build_x86_64/OpenCV.framework/OpenCV -output OpenCV.framework/Versions/A/OpenCV
81
82 # finalize
83 echo "Done!"
84 open .