forked from StephanTLavavej/mingw-distro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmingw-w64+gcc.sh
More file actions
128 lines (103 loc) · 4.41 KB
/
Copy pathmingw-w64+gcc.sh
File metadata and controls
128 lines (103 loc) · 4.41 KB
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
#!/bin/sh
source ./0_append_distro_path.sh
# Extract vanilla sources.
extract_file gmp-6.1.0.tar
extract_file mpfr-3.1.4.tar
extract_file mpc-1.0.3.tar
extract_file mingw-w64-v4.0.6.zip
extract_file gcc-6.1.0.tar
patch -Z -d /c/temp/gcc/mpfr-3.1.4 -p1 < mpfr.patch
cd /c/temp/gcc
# Build gmp.
mv gmp-6.1.0 src
mkdir build dest
cd build
../src/configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \
--prefix=/c/temp/gcc/dest --disable-shared || fail_with gmp 1 - EPIC FAIL
make $X_MAKE_JOBS all "CFLAGS=-s -O3" || fail_with gmp 2 - EPIC FAIL
make install || fail_with gmp 3 - EPIC FAIL
cd /c/temp/gcc
rm -rf build src
rm -rf dest/lib/*.la dest/share
mv dest gmp
# Build mpfr.
mv mpfr-3.1.4 src
mkdir build dest
cd build
../src/configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \
--prefix=/c/temp/gcc/dest --disable-shared --with-gmp=/c/temp/gcc/gmp || fail_with mpfr 1 - EPIC FAIL
make $X_MAKE_JOBS all "CFLAGS=-s -O3" || fail_with mpfr 2 - EPIC FAIL
make install || fail_with mpfr 3 - EPIC FAIL
cd /c/temp/gcc
rm -rf build src
rm -rf dest/lib/*.la dest/share
mv dest mpfr
# Build mpc.
mv mpc-1.0.3 src
mkdir build dest
cd build
../src/configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \
--prefix=/c/temp/gcc/dest --disable-shared --with-gmp=/c/temp/gcc/gmp --with-mpfr=/c/temp/gcc/mpfr \
|| fail_with mpc 1 - EPIC FAIL
make $X_MAKE_JOBS all "CFLAGS=-s -O3" || fail_with mpc 2 - EPIC FAIL
make install || fail_with mpc 3 - EPIC FAIL
cd /c/temp/gcc
rm -rf build src
rm -rf dest/lib/*.la dest/share
mv dest mpc
# Build mingw-w64.
mv mingw-w64-v4.0.6 src
mkdir build dest
cd build
../src/configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-lib32 \
--prefix=/c/temp/gcc/dest/x86_64-w64-mingw32 --with-sysroot=/c/temp/gcc/dest/x86_64-w64-mingw32 --enable-wildcard \
|| fail_with mingw-w64 1 - EPIC FAIL
make $X_MAKE_JOBS all "CFLAGS=-s -O3" || fail_with mingw-w64 2 - EPIC FAIL
make install || fail_with mingw-w64 3 - EPIC FAIL
cd /c/temp/gcc
rm -rf build src
# Prepare to build gcc.
mv gcc-6.1.0 src
# Prepare to build gcc - perform magic directory surgery.
cp -r dest/x86_64-w64-mingw32/lib dest/x86_64-w64-mingw32/lib64
cp -r dest/x86_64-w64-mingw32 dest/mingw
mkdir -p src/gcc/winsup/mingw
cp -r dest/x86_64-w64-mingw32/include src/gcc/winsup/mingw/include
# Configure.
mkdir build
cd build
../src/configure --with-gmp=/c/temp/gcc/gmp --with-mpfr=/c/temp/gcc/mpfr --with-mpc=/c/temp/gcc/mpc \
--enable-languages=c,c++ --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \
--disable-multilib --prefix=/c/temp/gcc/dest --with-sysroot=/c/temp/gcc/dest --disable-libstdcxx-pch --disable-nls \
--disable-shared --disable-win32-registry --enable-checking=release --with-tune=haswell || fail_with gcc 1 - EPIC FAIL
# --with-gmp=/c/temp/gcc/gmp : Obvious.
# --with-mpfr=/c/temp/gcc/mpfr : Obvious.
# --with-mpc=/c/temp/gcc/mpc : Obvious.
# --enable-languages=c,c++ : I want C and C++ only.
# --build=x86_64-w64-mingw32 : I want a native compiler.
# --host=x86_64-w64-mingw32 : Ditto.
# --target=x86_64-w64-mingw32 : Ditto.
# --disable-multilib : I want 64-bit only.
# --prefix=/c/temp/gcc/dest : I want the compiler to be installed here.
# --with-sysroot=/c/temp/gcc/dest : Ditto. (This one is important!)
# --disable-libstdcxx-pch : I don't use this, and it takes up a ton of space.
# --disable-nls : I don't want Native Language Support.
# --disable-shared : I don't want DLLs.
# --disable-win32-registry : I don't want this abomination.
# --enable-checking=release : I don't want expensive checking if this came from SVN or a snapshot.
# --with-tune=haswell : Tune for Haswell by default.
# Build and install.
make $X_MAKE_JOBS bootstrap "CFLAGS=-g0 -O3" "CXXFLAGS=-g0 -O3" "CFLAGS_FOR_TARGET=-g0 -O3" \
"CXXFLAGS_FOR_TARGET=-g0 -O3" "BOOT_CFLAGS=-g0 -O3" "BOOT_CXXFLAGS=-g0 -O3" || fail_with gcc 2 - EPIC FAIL
make install || fail_with gcc 3 - EPIC FAIL
# Cleanup.
cd /c/temp/gcc
rm -rf build src
rm -rf gmp mpfr mpc
mv dest mingw-w64+gcc
cd mingw-w64+gcc
find -name "*.la" -type f -print -exec rm {} ";"
rm -rf bin/c++.exe bin/x86_64-w64-mingw32-* share
rm -rf mingw x86_64-w64-mingw32/lib64
find -name "*.exe" -type f -print -exec strip -s {} ";"
7z -mx0 a ../mingw-w64+gcc.7z *