3 # cross compile script for cmake
5 # initial written by Fridrich Strba
6 # refactored to debian/lenny by Ralf Habacker
8 # reported to work at least on debian/lenny
11 if test -f /usr/bin/i686-pc-mingw32-gcc; then
12 cross_cc=i686-pc-mingw32
13 elif test -f /usr/bin/i586-mingw32msvc-gcc; then
14 cross_cc=i586-mingw32msvc
16 echo "could not determine mingw cross compiler"
20 if test -d ~/$cross_cc; then
21 cross_root=~/$cross_cc
22 elif test -d /usr/$cross_cc/sys-root/mingw; then
23 cross_root=/usr/$cross_cc/sys-root/mingw
24 elif test -d /usr/$cross_cc/lib; then
25 cross_root=/usr/$cross_cc
27 echo "could not determine mingw cross compiler sdk"
34 HOST_CC=gcc; export HOST_CC;
36 if test -d $cross_root/lib/pkgconfig; then
37 PKG_CONFIG_PATH="$cross_root/lib/pkgconfig:$cross_root/share/pkgconfig"; export PKG_CONFIG_PATH;
40 if test -d "$MINGW32_CLASSPATH" || test -f "$cross_root/share/java/libgcj.jar"; then
41 CLASSPATH="$CLASSPATH:${MINGW32_CLASSPATH:-$cross_root/share/java/libgcj.jar:$cross_root/share/java/libgcj-tools.jar}"; export CLASSPATH;
44 _PREFIX="/usr/bin/$cross_cc-";
45 for i in `ls -1 ${_PREFIX}* | grep -v 'gcc-'`; do
46 x=`echo $i|sed "s,${_PREFIX},,"|sed "s,\.awk*,,"|tr "a-z+-" "A-ZX_"`;
47 declare -x $x="$i" ; export $x;
51 CC="${MINGW32_CC:-$cross_cc-gcc}"; export CC;
52 CFLAGS="${MINGW32_CFLAGS:--O2 -g -pipe -Wall -fexceptions -fno-omit-frame-pointer -fno-optimize-sibling-calls --param=ssp-buffer-size=4 -mms-bitfields}"; export CFLAGS;
53 LDFLAGS="${MINGW32_LDFLAGS:--Wl,--exclude-libs=libintl.a -Wl,--exclude-libs=libiconv.a}"; export LDFLAGS;
55 if [ -x "/usr/bin/$cross_cc-g++" ]; then
56 CXX="${MINGW32_CXX:-$cross_cc-g++}"; export CXX;
57 CXXFLAGS="${MINGW32_CXXFLAGS:--O2 -g -pipe -Wall -fexceptions -fno-omit-frame-pointer -fno-optimize-sibling-calls --param=ssp-buffer-size=4 -mms-bitfields}"; export CXXFLAGS;
60 ac_cv_prog_CXX=no; export ac_cv_prog_CXX;
61 CXXFLAGS=; export CXXFLAGS;
63 for i in `ls $cross_root/bin/*|grep -- "-config$"` ; do
64 x=`basename $i|tr "a-z+-" "A-ZX_"|sed "s,\.,,"`;
65 declare -x $x="$i" ; export $x;
69 if ! test -f "$cross_root/lib/libexpat.dll.a"; then
70 (cd /tmp; wget http://www.winkde.org/pub/kde/ports/win32/repository/win32libs/expat-2.0.1-bin.zip)
71 (cd /tmp; wget http://www.winkde.org/pub/kde/ports/win32/repository/win32libs/expat-2.0.1-lib.zip)
72 (cd $cross_root; unzip -x /tmp/expat-2.0.1-bin.zip)
73 (cd $cross_root; unzip -x /tmp/expat-2.0.1-lib.zip)
76 if test -f "$cross_root/lib/libexpat.dll.a"; then
77 xml_library=-DDBUS_USE_EXPAT=On -DLIBEXPAT_INCLUDE_DIR:PATH=$cross_root/include -DLIBEXPAT_LIBRARIES:PATH=$cross_root/lib/libexpat.dll.a
79 echo "could not find a cross compile xml libraray"
84 -DCMAKE_SYSTEM_NAME="Windows" \
85 -DCMAKE_VERBOSE_MAKEFILE=ON \
86 -DCMAKE_INSTALL_PREFIX:PATH=$cross_root \
87 -DCMAKE_INSTALL_LIBDIR:PATH=$cross_root/lib \
88 -DINCLUDE_INSTALL_DIR:PATH=$cross_root/include \
89 -DLIB_INSTALL_DIR:PATH=$cross_root/lib \
90 -DSYSCONF_INSTALL_DIR:PATH=$cross_root/etc \
91 -DSHARE_INSTALL_PREFIX:PATH=$cross_root/share \
92 -DBUILD_SHARED_LIBS:BOOL=ON \
93 -DCMAKE_C_COMPILER="/usr/bin/$cross_cc-gcc" \
94 -DCMAKE_CXX_COMPILER="/usr/bin/$cross_cc-g++" \
95 -DCMAKE_FIND_ROOT_PATH="$cross_root" \
96 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
97 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
98 -DCMAKE_CXX_COMPILER="/usr/bin/$cross_cc-g++" \
99 -DCMAKE_FIND_ROOT_PATH="$cross_root" \
100 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
101 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
103 -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \