]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/gcc/x86_64-mingw-gcc-build
d99086f4d4d693be94eecc3c89fa4b96e72ebb63
[mirror_edk2.git] / BaseTools / gcc / x86_64-mingw-gcc-build
1 #!/bin/bash
2
3 #
4 # Build a mingw64 compiler for doing x64 compiles.
5 #
6
7 ###
8 ### CYGWIN :: Make sure that cygwin is mouting its file systems in binmode.
9 ###
10
11 #
12 # Specify the architectures for which the tools are to be built
13 #
14 TARGS="${TARGS:-x86_64-pc-mingw32}"
15
16 # Let's be nice
17 renice 10 -p $$
18
19 # If any thing goes wrong, we'll bail out.
20 set -e
21
22 #
23 # Specify the versions
24 #
25 GCC_VERSION=4.3-20071207
26 BINUTILS_VERSION=2.17.50.0.18
27 MINGW_HEADERS_VERSION=20070802
28
29 _GCC_=gcc-${GCC_VERSION}
30 _BINUTILS_=binutils-${BINUTILS_VERSION}
31 _MINGW_HEADERS_=mingw-w64-headers-${MINGW_HEADERS_VERSION}
32
33 export PATH=/bin:/usr/bin:/usr/local/bin
34
35 #
36 # Where to install
37 #
38 PREFIX="${PREFIX:-/opt/tiano/}"
39
40 #
41 # Where to get the GNU tools
42 #
43 BINUTILS_URL=http://www.kernel.org/pub/linux/devel/binutils/${_BINUTILS_}.tar.bz2
44 GCC_URL=ftp://gd.tuwien.ac.at/gnu/gcc/snapshots/${GCC_VERSION}/${_GCC_}.tar.bz2
45 MINGW_HEADERS_URL=http://superb-west.dl.sourceforge.net/sourceforge/mingw/${_MINGW_HEADERS_}.tar.bz2
46
47 #
48 # Uncomment one of the following depending upon which your system provides
49 #
50 #GET_COMMAND="curl --remote-name"
51 GET_COMMAND="wget -c -nc --no-directories --retr-symlinks "
52
53 #
54 # Allow environment to override some programs
55 #
56 MAKE="${MAKE:-make}"
57 export MAKE
58 SHELL="${SHELL:-/bin/sh}"
59 export SHELL
60
61 #
62 # Get the source
63 # If you don't have curl on your machine, try using
64 # wget --passive-ftp --no-directories --retr-symlinks <<url>>
65 # If that doesn't work, try without the --passive-ftp option.
66 #
67 getSource() {
68 ${GET_COMMAND} "${BINUTILS_URL}"
69 ${GET_COMMAND} "${GCC_URL}"
70 ${GET_COMMAND} "${MINGW_HEADERS_URL}"
71 wait
72 }
73
74 #
75 # Unpack the source
76 #
77 unpackSource() {
78 (rm -rf "${_BINUTILS_}"
79 tar jxf "${_BINUTILS_}.tar.bz2"
80 )
81
82 (rm -rf "${_GCC_}"
83 tar jxf "${_GCC_}.tar.bz2"
84 )
85
86 (rm -rf "include"
87 tar jxf "${_MINGW_HEADERS_}.tar.bz2"
88 )
89
90 wait
91 }
92
93 CONF_SHELL="${CONF_SHELL:-/bin/bash}"
94 # CONF_SHELL="${CONF_SHELL:-echo}"
95
96 #
97 # Build
98 #
99 build() {
100 for targ in $TARGS
101 do (
102 export pref=${PREFIX}${targ}
103 export PATH="${pref}/bin:$PATH"
104 rm -f ${targ}.log
105
106 (
107 rm -rf build-binutils-$targ
108 mkdir -p build-binutils-$targ
109 cd build-binutils-$targ
110 "${CONF_SHELL}" "../${_BINUTILS_}/configure" \
111 --disable-nls "--target=${targ}" "--prefix=${pref}"
112 ${MAKE} -j1 -w all
113 ${MAKE} -w install
114 ) >> ${targ}.log 2>&1
115
116 (
117 mkdir -p $pref/$targ/include;
118 cp -fr include/* $pref/$targ/include
119 ln -s $pref/$targ $pref/mingw
120 ln -s $pref/$targ/include $pref/$targ/sys-include
121 )
122
123
124 (
125 rm -rf build-gcc-$targ
126 mkdir -p build-gcc-$targ
127 cd build-gcc-$targ
128 "${CONF_SHELL}" "../${_GCC_}/configure" "--target=${targ}" \
129 "--prefix=${pref}" \
130 --without-headers --with-newlib --verbose \
131 --disable-libssp --disable-nls --enable-languages=c
132 ${MAKE} -j1 -w all
133 ${MAKE} -w install
134 ) >> ${targ}.log 2>&1
135
136 # GCC 4.3 needs the symbol links for the gcc and binutils. Otherwise
137 # the cc1 and as, ld etc can not be found by gcc.
138 (
139 rm -f $pref/$targ/bin/*
140 ln -s $pref/bin/$targ-ar $pref/$targ/bin/ar
141 ln -s $pref/bin/$targ-as $pref/$targ/bin/as
142 ln -s $pref/bin/$targ-dlltool $pref/$targ/bin/dlltool
143 ln -s $pref/bin/$targ-gcc $pref/$targ/bin/gcc
144 ln -s $pref/bin/$targ-ld $pref/$targ/bin/ld
145 ln -s $pref/bin/$targ-nm $pref/$targ/bin/nm
146 ln -s $pref/bin/$targ-objcopy $pref/$targ/bin/objcopy
147 ln -s $pref/bin/$targ-objdump $pref/$targ/bin/objdump
148 ln -s $pref/bin/$targ-ranlib $pref/$targ/bin/ranlib
149 ln -s $pref/bin/$targ-strip $pref/$targ/bin/strip
150 )
151 )
152 done
153
154 wait
155 }
156
157
158
159 #
160 # Do everything
161 #
162 # Comment out any activities you wish to omit
163 #
164 getSource
165 unpackSource
166 build