Fix building issue for VC compiler. And enable GenFvMap in building CCode package.
[mirror_edk2.git] / Tools / gcc / mingw64-gcc-build
CommitLineData
17c3d4b0 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#
14TARGS="${TARGS:-x86_64-pc-mingw64 }"
15
16# Let's be nice
17renice 10 -p $$
18
19# If any thing goes wrong, we'll bail out.
20set -e
21
22#
23# Specify the versions
24#
25GCC=gcc-4.1.1
26BINUTILS=binutils-2.17
27W32API=w32api-3.6
28# BINUTILS=binutils-2.16.91-20060119-1
29CYGWIN_SNAP=20060403 # You may need to find a more recent one.
30export PATH=/bin:/usr/bin:/usr/local/bin
31
32#
33# Where to install
34#
35# PREFIX="${PREFIX:-~/tiano/}"
36PREFIX="${PREFIX:-/opt/tiano/}"
37
38#
39# Where to get the GNU tools
40#
41BINUTILS_URL=ftp://ftp.ibiblio.org/pub/mirrors/gnu/ftp/gnu/binutils/${BINUTILS}.tar.bz2
42GCC_URL=ftp://mirrors.kernel.org/gnu/gcc/$GCC/$GCC.tar.bz2
43CYG_LOC=http://cygwin.com/snapshots/cygwin-src-${CYGWIN_SNAP}.tar.bz2
44W32API_LOC=http://superb-west.dl.sourceforge.net/sourceforge/mingw/${W32API}-src.tar.gz
45# export http_proxy=http://proxy.dp.intel.com:911
46# export ftp_proxy=http://proxy.dp.intel.com:911
47
48#
49# Uncomment one of the following depending upon which your system provides
50#
51#GET_COMMAND="curl --remote-name"
52GET_COMMAND="wget -nc --no-directories --retr-symlinks "
53
54#
55# Allow environment to override some programs
56#
57MAKE="${MAKE:-make}"
58export MAKE
59SHELL="${SHELL:-/bin/sh}"
60export SHELL
61
62#
63# Get the source
64# If you don't have curl on your machine, try using
65# wget --passive-ftp --no-directories --retr-symlinks <<url>>
66# If that doesn't work, try without the --passive-ftp option.
67#
68getSource() {
69 ${GET_COMMAND} "${BINUTILS_URL}" &
70 ${GET_COMMAND} "${GCC_URL}" &
71 ${GET_COMMAND} "${CYG_LOC}" &
72 ${GET_COMMAND} "${W32API_LOC}" &
73 wait
74}
75
76#
77# Unpack the source
78#
79unpackSource() {
80 (rm -rf "${BINUTILS}"
81 tar jxf "${BINUTILS}.tar.bz2"
82 ) &
83
84 (rm -rf "${GCC}"
85 tar jxf "${GCC}.tar.bz2"
86 ) &
87
88 (rm -rf cygwin-snapshot-${CYGWIN_SNAP}-1/
89 tar jxf cygwin-src-${CYGWIN_SNAP}.tar.bz2
90 ) &
91
92 (rm -rf ${W32API}
93 tar zxf ${W32API}-src.tar.gz
94 ) &
95
96 wait
97
98 # Apply patches
99 (cd ${GCC}; patch -p1 < ../gcc_4.1.1.x86_64.061113.diff
100 )
101
102 (cd ${BINUTILS}; patch -p1 < ../binutils.diff
103 )
104
105 wait
106}
107
108CONF_SHELL="${CONF_SHELL:-/bin/bash}"
109# CONF_SHELL="${CONF_SHELL:-echo}"
110
111#
112# Build
113#
114build() {
115 for targ in $TARGS
116 do (
117 export pref=${PREFIX}${targ}
118 export PATH="${pref}/bin:$PATH"
119
120 ( mkdir -p build-binutils-$targ
121 cd build-binutils-$targ
122 "${CONF_SHELL}" "../${BINUTILS}/configure" \
123 --disable-nls "--target=${targ}" "--prefix=${pref}"
124 ${MAKE} -j1 -w all
125 ${MAKE} -w install
126 ) >> ${targ}.log 2>&1
127
128 (
129 mkdir -p $pref/$targ/sys-include;
130 cp -fr cygwin-snapshot-${CYGWIN_SNAP}-1/newlib/libc/include/* $pref/$targ/sys-include
131 cp -fr cygwin-snapshot-${CYGWIN_SNAP}-1/winsup/cygwin/include/* $pref/$targ/sys-include
132 )
133
134 (
135 mkdir -p $pref/$targ/include;
136 cp -fr ${W32API}/include/* $pref/$targ/sys-include;
137 )
138
139 ( mkdir -p build-gcc-$targ
140 cd build-gcc-$targ
141 "${CONF_SHELL}" "../${GCC}/configure" "--target=${targ}" "--prefix=${pref}" \
142 --with-gnu-as --with-gnu-ld --without-headers --with-newlib --verbose \
143 --disable-libssp \
144 --disable-nls --enable-languages=c
145 ${MAKE} -j1 -w all
146 ${MAKE} -w install
147 ) >> ${targ}.log 2>&1
148 ) &
149 done
150
151 wait
152}
153
154
155
156#
157# Do everything
158#
159# Comment out any activities you wish to omit
160#
161getSource
162unpackSource
163build