Silence silent build a bit more.
[platform/upstream/dbus.git] / cmake / cross-compile.sh
1 #!/bin/sh
2 #
3 #  cross compile script for cmake
4
5 # initial written by Fridrich Strba
6 # refactored to debian/lenny by Ralf Habacker
7 #
8 #  reported to work at least on debian/lenny 
9
10
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
15 else
16     echo "could not determine mingw cross compiler"
17     exit 1
18 fi
19
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
26 else
27     echo "could not determine mingw cross compiler sdk"
28     exit 1
29 fi
30
31 # make cmake happy 
32 export TEMP=/tmp
33
34 HOST_CC=gcc; export HOST_CC;
35
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;
38 fi 
39
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;
42 fi
43
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;
48 done;
49 unset _PREFIX;
50
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;
54
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;
58 else
59     CXX=; export CXX;
60     ac_cv_prog_CXX=no; export ac_cv_prog_CXX;
61     CXXFLAGS=; export CXXFLAGS;
62 fi;
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;
66 done;
67 unset x i ;
68
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)
74 fi 
75
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 
78 else
79     echo "could not find a cross compile xml libraray"
80     exit 1
81 fi
82
83 cmake \
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 \
102     $xml_library \
103     -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
104     $*
105