]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/build-cross-mingw-w64
Change old get_Jobxxx to getJobxxx
[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 mkdir -p ../../../cross-tools
13 cd ../../../cross-tools
14 PF=`pwd`/$RT
15 BD=`pwd`/build
16 SRC=`pwd`/source
17 cd -
18 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"
19 baseopts="--prefix=$PF --with-sysroot=$PF --target=$TGT"
20 j="-j3"
21
22 #Option defaults
23 build="true"
24 update="true"
25 out=/dev/null
26
27 binutilsver=binutils-2.19
28 dlbinutils=http://ftp.gnu.org/gnu/binutils/$binutilsver.tar.bz2
29 gccver=gcc-4.3.2
30 dlgcc=http://ftp.gnu.org/gnu/gcc/$gccver/$gccver.tar.bz2
31 mingwver=mingw-w64-snapshot-20081115
32 dlmingw64=http://garr.dl.sourceforge.net/sourceforge/mingw-w64/$mingwver.tar.bz2
33 #Third part packages
34 gmpver=gmp-4.2.4
35 gmp=ftp://ftp.gnu.org/gnu/gmp/${gmpver}.tar.bz2
36 mpfrver=mpfr-2.3.2
37 mpfr=http://www.mpfr.org/mpfr-current/${mpfrver}.tar.bz2
38 url=http://www.bacula.org/cross-tools
39
40 echo "Check sources"
41 mkdir -p $SRC
42 cd $SRC
43
44 for i in $binutilsver $gccver $mpfrver $gmpver $mingwver
45 do
46     if [ ! -f $i.tar.bz2 ]; then
47         echo "Download $i"
48         wget $url/$i.tar.bz2
49     fi
50 done
51
52 tar xf $mingwver.tar.bz2
53 mv trunk/mingw-* .
54 tar cfj mingw-w64-crt.tar.bz2 mingw-w64-crt
55 tar cfj mingw-w64-headers.tar.bz2 mingw-w64-headers
56 rm -rf mingw-w64-crt mingw-w64-headers trunk
57
58 if [ $update = "true" ]; then
59   echo "Creating directory tree:"
60   echo "$PF -- sysroot directory tree"
61   echo "$BD -- build directory tree"
62   echo ""
63
64   for i in $DIRS; do
65     [ -d $i ] && echo "Warning: $i preexisting, skipping directory creation" || mkdir $i
66   done
67   [ -h $PF/mingw ] || ln -s $TGT $PF/mingw
68
69   echo "Downloading binutils.." && cd $BD/binutils
70   rm -rf binutils
71   tar xf $SRC/binutils-2.19.tar.bz2
72   mv binutils-* src
73
74   echo "Downloading gcc.." && cd $BD/gcc-svn
75 #  svn -q checkout svn://gcc.gnu.org/svn/gcc/trunk gcc -r $gccrev
76   rm -rf gcc
77   tar xf $SRC/gcc-4.3.2.tar.bz2
78   mv gcc-* gcc
79
80   echo "Downloading additional required libraries for gcc.."
81   cd gcc
82   rm -rf gmp
83   tar xf $SRC/gmp-4.2.4.tar.bz2
84   mv gmp-* gmp
85
86   rm -rf mpfr
87   tar xf $SRC/mpfr-2.3.2.tar.bz2
88   mv mpfr-* mpfr
89   cd ..
90
91   echo "Downloading crt and headers.."
92   cd $BD/mingw
93   tar xf $SRC/mingw-w64-headers.tar.bz2
94   tar xf $SRC/mingw-w64-crt.tar.bz2
95   cp -prf mingw-w64-headers/include $PF/$TGT/include
96
97   echo "Root setup complete."
98 fi
99
100 if [ $build = "true" ]; then
101   echo "Compiling binutils.." && cd $BD/binutils/build-$HST
102   ../src/configure $baseopts > $out && make -s $j > $out && make install > $out || exit 1
103
104   echo "Compiling bootstrap gcc.." && cd $BD/gcc-svn/build-$HST
105   ../gcc/configure $baseopts > $out && make -s $j all-gcc > $out && make install-gcc > $out || exit 1
106   export PATH=$PF/bin:$PATH
107
108   echo "Compiling crt.." && cd $BD/mingw/build-$HST
109   ../mingw-w64-crt/configure --prefix=$PF --with-sysroot=$PF --host=$TGT > $out && make -s $j > $out && make install > $out || exit 1
110
111   echo "Compiling full gcc.." && cd $BD/gcc-svn/build-$HST
112   make -s $j > $out && make install > $out || exit 1
113
114   cd $PF
115   echo "Done building."
116 fi
117
118 cd $PF/bin
119 for i in x86_64-pc-mingw32-*
120 do
121     ln -s $i ${i##x86_64-pc-}
122 done