summaryrefslogtreecommitdiff
path: root/Tools/gcc/mingw64-gcc-build
blob: 9045080914c6d151893f4f8554ebbcaf2b07449b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash

#
# Build a mingw64 compiler for doing x64 compiles.
#

###
### CYGWIN :: Make sure that cygwin is mouting its file systems in binmode.
###

#
# Specify the architectures for which the tools are to be built
#
TARGS="${TARGS:-x86_64-pc-mingw64 }"

# Let's be nice
renice 10 -p $$

# If any thing goes wrong, we'll bail out.
set -e

#
# Specify the versions
#
GCC=gcc-4.1.1
BINUTILS=binutils-2.17
W32API=w32api-3.6
# BINUTILS=binutils-2.16.91-20060119-1
CYGWIN_SNAP=20060403 # You may need to find a more recent one.
export PATH=/bin:/usr/bin:/usr/local/bin

#
# Where to install
#
# PREFIX="${PREFIX:-~/tiano/}"
PREFIX="${PREFIX:-/opt/tiano/}"

#
# Where to get the GNU tools
#
BINUTILS_URL=ftp://ftp.ibiblio.org/pub/mirrors/gnu/ftp/gnu/binutils/${BINUTILS}.tar.bz2
GCC_URL=ftp://mirrors.kernel.org/gnu/gcc/$GCC/$GCC.tar.bz2
CYG_LOC=http://cygwin.com/snapshots/cygwin-src-${CYGWIN_SNAP}.tar.bz2
W32API_LOC=http://superb-west.dl.sourceforge.net/sourceforge/mingw/${W32API}-src.tar.gz
# export http_proxy=http://proxy.dp.intel.com:911
# export ftp_proxy=http://proxy.dp.intel.com:911

#
# Uncomment one of the following depending upon which your system provides
#
#GET_COMMAND="curl --remote-name"
GET_COMMAND="wget -nc --no-directories --retr-symlinks "

#
# Allow environment to override some programs
#
MAKE="${MAKE:-make}"
export MAKE
SHELL="${SHELL:-/bin/sh}"
export SHELL

#
# Get the source
# If you don't have curl on your machine, try using
#     wget --passive-ftp --no-directories --retr-symlinks <<url>>
# If that doesn't work, try without the --passive-ftp option.
#
getSource() {
    ${GET_COMMAND}  "${BINUTILS_URL}" &
    ${GET_COMMAND}  "${GCC_URL}" &
    ${GET_COMMAND}  "${CYG_LOC}" &
    ${GET_COMMAND}  "${W32API_LOC}" &
    wait
}

#
# Unpack the source
#
unpackSource() {
    (rm -rf "${BINUTILS}"
    tar jxf "${BINUTILS}.tar.bz2"
    ) &

    (rm -rf "${GCC}"
    tar jxf "${GCC}.tar.bz2"
    ) &

    (rm -rf cygwin-snapshot-${CYGWIN_SNAP}-1/
    tar jxf cygwin-src-${CYGWIN_SNAP}.tar.bz2
    ) &

    (rm -rf ${W32API}
    tar zxf ${W32API}-src.tar.gz
    ) &

    wait

    # Apply patches
    (cd ${GCC}; patch -p1 < ../gcc_4.1.1.x86_64.061113.diff
    )

    (cd ${BINUTILS}; patch -p1 < ../binutils.diff
    )

    wait
}

CONF_SHELL="${CONF_SHELL:-/bin/bash}"
# CONF_SHELL="${CONF_SHELL:-echo}"

#
# Build
#
build() {
    for targ in $TARGS
    do (
        export pref=${PREFIX}${targ}
        export PATH="${pref}/bin:$PATH"

        ( mkdir -p build-binutils-$targ
        cd build-binutils-$targ
        "${CONF_SHELL}" "../${BINUTILS}/configure" \
            --disable-nls "--target=${targ}" "--prefix=${pref}"
        ${MAKE} -j1 -w all
        ${MAKE} -w install
        ) >> ${targ}.log 2>&1 

        (
            mkdir -p $pref/$targ/sys-include;
            cp -fr cygwin-snapshot-${CYGWIN_SNAP}-1/newlib/libc/include/* $pref/$targ/sys-include
            cp -fr cygwin-snapshot-${CYGWIN_SNAP}-1/winsup/cygwin/include/* $pref/$targ/sys-include
        ) 

        (
            mkdir -p $pref/$targ/include;
            cp -fr ${W32API}/include/* $pref/$targ/sys-include;
        ) 

        ( mkdir -p build-gcc-$targ
        cd build-gcc-$targ
        "${CONF_SHELL}" "../${GCC}/configure" "--target=${targ}" "--prefix=${pref}" \
            --with-gnu-as --with-gnu-ld --without-headers --with-newlib --verbose \
            --disable-libssp \
            --disable-nls --enable-languages=c
        ${MAKE} -j1 -w all
        ${MAKE} -w install 
        ) >> ${targ}.log 2>&1
    ) &
    done

    wait
}



#
# Do everything
#
# Comment out any activities you wish to omit
#
getSource
unpackSource
build