-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmingw-windows.sh
executable file
·225 lines (150 loc) · 5.88 KB
/
mingw-windows.sh
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/sh
# dependencies
echo "Installing dependencies via Homebrew (http://brew.sh)"
# ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew update
brew tap homebrew/versions
brew install gcc5
brew install wget
# mingw
VERSION="4.0.4"
BINUTILS_VERSION="2.25.1"
GCC_MAJOR="5"
GCC_VERSION="5.2.0"
HOMEBREW_PREFIX=`brew --prefix`
PREFIX="${HOMEBREW_PREFIX}/Cellar/mingw-w64/${VERSION}"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
mkdir -p source
mkdir -p $PREFIX
echo "Downloading binutils\n"
cd ./source
wget -O binutils-${BINUTILS_VERSION}.tar.bz2 http://ftpmirror.gnu.org/binutils/binutils-${BINUTILS_VERSION}.tar.bz2
tar xjf binutils-${BINUTILS_VERSION}.tar.bz2
echo "Building binutils\n"
echo "1/2 32-bit\n"
cd binutils-${BINUTILS_VERSION}
mkdir build
cd build
CC=gcc-${GCC_MAJOR} CXX=g++-${GCC_MAJOR} CPP=cpp-${GCC_MAJOR} LD=gcc-${GCC_MAJOR} ../configure --target=i686-w64-mingw32 --disable-werror --disable-multilib --prefix=$PREFIX --with-sysroot=$PREFIX
make -j4
make install-strip
echo "2/2 64-bit\n"
cd ..
rm -rf build
mkdir build
cd build
CC=gcc-${GCC_MAJOR} CXX=g++-${GCC_MAJOR} CPP=cpp-${GCC_MAJOR} LD=gcc-${GCC_MAJOR} ../configure --target=x86_64-w64-mingw32 --disable-werror --disable-multilib --prefix=$PREFIX --with-sysroot=$PREFIX --enable-64-bit-bfd
make -j4
make install-strip
cd ..
cd ..
echo "Downloading mingw-w64\n"
wget -O mingw-w64-v${VERSION}.tar.bz2 "https://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${VERSION}.tar.bz2"
tar xjf mingw-w64-v${VERSION}.tar.bz2
echo "Building mingw-headers\n"
echo "1/2 32-bit\n"
cd mingw-w64-v${VERSION}
mkdir build-headers
cd build-headers
../mingw-w64-headers/configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32
make -j4
make install-strip
cd $PREFIX/i686-w64-mingw32
ln -s lib lib32
cd $DIR/source/mingw-w64-v${VERSION}
echo "2/2 64-bit\n"
rm -rf build-headers
mkdir build-headers
cd build-headers
../mingw-w64-headers/configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32
make -j4
make install-strip
cd $PREFIX/x86_64-w64-mingw32
ln -s lib lib64
cd $DIR/source/
echo "Downloading gcc\n"
wget -O gcc-${GCC_VERSION}.tar.bz2 http://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2
tar xjf gcc-${GCC_VERSION}.tar.bz2
echo "Building core gcc\n"
echo "1/2 32-bit\n"
cd $PREFIX
ln -s i686-w64-mingw32 mingw
cd $DIR/source/gcc-${GCC_VERSION}
mkdir build32
cd build32
CC=gcc-${GCC_MAJOR} CXX=g++-${GCC_MAJOR} CPP=cpp-${GCC_MAJOR} LD=gcc-${GCC_MAJOR} PATH=${HOMEBREW_PREFIX}/mingw/bin/:$PATH ../configure --target=i686-w64-mingw32 --disable-multilib --enable-languages=c,c++,objc,obj-c++ --with-gmp=${HOMEBREW_PREFIX}/opt/gmp/ --with-mpfr=${HOMEBREW_PREFIX}/opt/mpfr/ --with-mpc=${HOMEBREW_PREFIX}/opt/libmpc/ --with-isl=${HOMEBREW_PREFIX}/opt/isl014/ --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --enable-threads=win32 --disable-sjlj-exceptions --prefix=$PREFIX --with-sysroot=$PREFIX
PATH=${PREFIX}/bin/:$PATH make all-gcc -j4
PATH=${PREFIX}/bin/:$PATH make install-gcc
echo "2/2 64-bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/source/gcc-${GCC_VERSION}
mkdir build64
cd build64
CC=gcc-${GCC_MAJOR} CXX=g++-${GCC_MAJOR} CPP=cpp-${GCC_MAJOR} LD=gcc-${GCC_MAJOR} PATH=${HOMEBREW_PREFIX}/mingw/bin/:$PATH ../configure --target=x86_64-w64-mingw32 --disable-multilib --enable-languages=c,c++,objc,obj-c++ --with-gmp=${HOMEBREW_PREFIX}/opt/gmp/ --with-mpfr=${HOMEBREW_PREFIX}/opt/mpfr/ --with-mpc=${HOMEBREW_PREFIX}/opt/libmpc/ --with-isl=${HOMEBREW_PREFIX}/opt/isl014/ --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --enable-threads=win32 --prefix=$PREFIX --with-sysroot=$PREFIX
PATH=${PREFIX}/bin/:$PATH make all-gcc -j4
PATH=${PREFIX}/bin/:$PATH make install-gcc
echo "Building mingw runtime\n"
cd $PREFIX
rm mingw
ln -s i686-w64-mingw32 mingw
cd $DIR/source/mingw-w64-v${VERSION}
mkdir build-crt
cd build-crt
echo "1/2 32-Bit\n"
PATH=${PREFIX}/bin/:$PATH ../mingw-w64-crt/configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32 --with-sysroot=$PREFIX
PATH=${PREFIX}/bin/:$PATH make
PATH=${PREFIX}/bin/:$PATH make install-strip
echo "2/2 64-Bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/source/mingw-w64-v${VERSION}
rm -rf build-crt
mkdir build-crt
cd build-crt
PATH=${PREFIX}/bin/:$PATH ../mingw-w64-crt/configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32 --with-sysroot=$PREFIX
PATH=${PREFIX}/bin/:$PATH make
PATH=${PREFIX}/bin/:$PATH make install-strip
echo "Building all gcc\n"
echo "1/2 32-Bit\n"
cd $PREFIX
rm mingw
ln -s i686-w64-mingw32 mingw
cd $DIR/source/gcc-${GCC_VERSION}/build32
PATH=${PREFIX}/bin/:$PATH make
PATH=${PREFIX}/bin/:$PATH make install-strip
echo "2/2 64-Bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/source/gcc-${GCC_VERSION}/build64
PATH=${PREFIX}/bin/:$PATH make
PATH=${PREFIX}/bin/:$PATH make install-strip
echo "Linking libgcc\n"
cd $PREFIX/i686-w64-mingw32/lib
ln -s ../../lib/gcc/i686-w64-mingw32/lib/libgcc_s.a ./
cd $PREFIX/x86_64-w64-mingw32/lib
ln -s ../../lib/gcc/x86_64-w64-mingw32/lib/libgcc_s.a ./
echo "Building winpthreads\n"
cd $DIR/source/mingw-w64-v${VERSION}/mingw-w64-libraries/winpthreads
echo "1/2 32-Bit\n"
mkdir -p build
cd build
PATH=${PREFIX}/bin/:$PATH ../configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32
PATH=${PREFIX}/bin/:$PATH make
PATH=${PREFIX}/bin/:$PATH make install-strip
cd ..
rm -rf build
echo "2/2 64-Bit\n"
mkdir -p build
cd build
PATH=${PREFIX}/bin/:$PATH ../configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32
PATH=${PREFIX}/bin/:$PATH make
PATH=${PREFIX}/bin/:$PATH make install-strip
echo "Cleaning up\n"
cd $DIR
rm -rf source
echo "Done"