]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/build-cross-mingw-w64
Tweak fix MySQL quoting again :-(
[bacula/bacula] / bacula / src / win32 / build-cross-mingw-w64
1 #!/bin/bash -e
2 #
3 # Script to help build the mingw cross compile tool chain for Win64
4 #  This typically needs a lot of hand tweaking to get everything to
5 #  work.  We build this only on Ubuntu Hardy, and it is unlikely
6 #  to work on any other Linux version without significant changes
7 #  to the patch files...  You are on your own here.
8 #
9 HST=x86_64-pc-linux
10 TGT=x86_64-pc-mingw32
11 RT=mingw-w64
12 # Directory where cross-tools directory will be placed
13 TOPDIR=../../..
14 # Cross tools directory name under TOPDIR
15 CROSSTOOLS=cross-tools
16 cwd=`pwd`
17
18 cd ${TOPDIR}
19 # Make TOPDIR absolute
20 TOPDIR=`pwd`
21 TOPDIR=${DEPKGS:-${TOPDIR}}
22
23 mkdir -p ${TOPDIR}/cross-tools
24 cd ${TOPDIR}/cross-tools
25 echo "Buiding in ${TOPDIR}/cross-tools"
26 PF=`pwd`/$RT
27 BD=`pwd`/build
28 SRC=`pwd`/source
29 cd -
30 DIRS="$SRC $PF $PF/$TGT $BD $BD/binutils $BD/binutils/build-$HST $BD/gcc-svn $BD/gcc-svn/build-$HST $BD/mingw $BD/mingw/build-$HST"
31 baseopts="--prefix=$PF --with-sysroot=$PF --target=$TGT"
32 j="-j3"
33
34 #Option defaults
35 build="true"
36 update="true"
37 out=/dev/null
38
39 binutilsver=binutils-2.19
40 dlbinutils=http://ftp.gnu.org/gnu/binutils/$binutilsver.tar.bz2
41 gccver=gcc-4.3.2
42 dlgcc=http://ftp.gnu.org/gnu/gcc/$gccver/$gccver.tar.bz2
43 mingwver=mingw-w64-snapshot-20081115
44 dlmingw64=http://garr.dl.sourceforge.net/sourceforge/mingw-w64/$mingwver.tar.bz2
45 #Third part packages
46 gmpver=gmp-4.2.4
47 gmp=ftp://ftp.gnu.org/gnu/gmp/${gmpver}.tar.bz2
48 mpfrver=mpfr-2.3.2
49 mpfr=http://www.mpfr.org/mpfr-current/${mpfrver}.tar.bz2
50 url=http://www.bacula.org/cross-tools
51
52 echo "Check sources"
53 mkdir -p $SRC
54 cd $SRC
55
56 for i in $binutilsver $gccver $mpfrver $gmpver $mingwver
57 do
58     if [ ! -f $i.tar.bz2 ]; then
59         echo "Download $i"
60         wget $url/$i.tar.bz2
61     fi
62 done
63
64 tar xf $mingwver.tar.bz2
65 mv trunk/mingw-* .
66 tar cfj mingw-w64-crt.tar.bz2 mingw-w64-crt
67 tar cfj mingw-w64-headers.tar.bz2 mingw-w64-headers
68 rm -rf mingw-w64-crt mingw-w64-headers trunk
69
70 if [ $update = "true" ]; then
71   echo "Creating directory tree:"
72   echo "$PF -- sysroot directory tree"
73   echo "$BD -- build directory tree"
74   echo ""
75
76   for i in $DIRS; do
77     [ -d $i ] && echo "Warning: $i preexisting, skipping directory creation" || mkdir $i
78   done
79   [ -h $PF/mingw ] || ln -s $TGT $PF/mingw
80
81   echo "Downloading binutils.." && cd $BD/binutils
82   rm -rf binutils
83   tar xf $SRC/binutils-2.19.tar.bz2
84   mv binutils-* src
85
86   echo "Downloading gcc.." && cd $BD/gcc-svn
87 #  svn -q checkout svn://gcc.gnu.org/svn/gcc/trunk gcc -r $gccrev
88   rm -rf gcc
89   tar xf $SRC/gcc-4.3.2.tar.bz2
90   mv gcc-* gcc
91
92   echo "Downloading additional required libraries for gcc.."
93   cd gcc
94   rm -rf gmp
95   tar xf $SRC/gmp-4.2.4.tar.bz2
96   mv gmp-* gmp
97
98   rm -rf mpfr
99   tar xf $SRC/mpfr-2.3.2.tar.bz2
100   mv mpfr-* mpfr
101   cd ..
102
103   echo "Downloading crt and headers.."
104   cd $BD/mingw
105   tar xf $SRC/mingw-w64-headers.tar.bz2
106   tar xf $SRC/mingw-w64-crt.tar.bz2
107   cp -prf mingw-w64-headers/include $PF/$TGT/include
108
109   echo "Root setup complete."
110 fi
111
112 if [ $build = "true" ]; then
113   echo "Compiling binutils.." && cd $BD/binutils/build-$HST
114   ../src/configure $baseopts > $out && make -s $j > $out && make install > $out || exit 1
115
116   echo "Compiling bootstrap gcc.." && cd $BD/gcc-svn/build-$HST
117   ../gcc/configure $baseopts > $out && make -s $j all-gcc > $out && make install-gcc > $out || exit 1
118   export PATH=$PF/bin:$PATH
119
120   echo "Compiling crt.." && cd $BD/mingw/build-$HST
121   ../mingw-w64-crt/configure --prefix=$PF --with-sysroot=$PF --host=$TGT > $out && make -s $j > $out && make install > $out || exit 1
122
123   echo "Compiling full gcc.." && cd $BD/gcc-svn/build-$HST
124   make -s $j > $out && make install > $out || exit 1
125
126   cd $PF
127   echo "Done building."
128 fi
129
130 cd $PF/bin
131 for i in x86_64-pc-mingw32-*
132 do
133     ln -s $i ${i##x86_64-pc-}
134 done