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
|
---
name: "utils-windows"
suites:
- "precise"
architectures:
- "i386"
packages:
- "automake"
- "libtool"
- "zip"
# XXX: Only needed to dump the spec.
- "g++-mingw-w64-i686"
# Needed for compiling gcc.
- "libmpc-dev"
# Needed for compiling nsis.
- "scons"
- "libcppunit-dev"
reference_datetime: "2000-01-01 00:00:00"
remotes:
- "url": "http://git.code.sf.net/p/mingw-w64/mingw-w64"
"dir": "mingw-w64-git"
- "url": "https://github.com/libevent/libevent.git"
"dir": "libevent"
- "url": "https://github.com/madler/zlib.git"
"dir": "zlib"
files:
- "binutils.tar.bz2"
- "gcc.tar.bz2"
- "yasm.tar.gz"
- "openssl.tar.gz"
- "gmp.tar.bz2"
- "enable-reloc-section-ld.patch"
- "peXXigen.patch"
- "versions"
- "dzip.sh"
- "nsis.tar.bz2"
- "nsis-debian.tar.xz"
- "nsis-missing-unistd-include.patch"
script: |
INSTDIR="$HOME/install"
source versions
export REFERENCE_DATETIME
export TZ=UTC
export LC_ALL=C
umask 0022
# Building GCC to use it as the host compiler. Firefox 38 needs GCC >= 4.7 but
# Ubuntu Precise is only shipping with GCC 4.6.x.
tar xjf gcc.tar.bz2
cd gcc-*
./configure --prefix=$INSTDIR/gcc --disable-multilib --enable-languages=c,c++
make $MAKEOPTS
make install
cd ..
# Building Yasm to use it for our Firefox compilation later. Firefox ESR52
# requires Yasm >= 1.2.0 which Ubuntu Precise does not ship.
tar xaf yasm.tar.gz
cd yasm-*
./configure --prefix=$INSTDIR/yasm
make $MAKEOPTS
make install
cd ..
# Building binutils
tar xjf binutils.tar.bz2
cd binutils*
# XXX: This is needed due to bug 10102.
sed 's/= extern_rt_rel_d;/= extern_rt_rel_d;\n memset (extern_rt_rel_d, 0, PE_IDATA5_SIZE);/' -i ld/pe-dll.c
# Needed for the hardening...
patch -p1 < ../enable-reloc-section-ld.patch
# Zeroing timestamps in PE headers reliably, see bug 12753.
patch -p1 < ../peXXigen.patch
./configure --prefix=$INSTDIR/mingw-w64 --target=i686-w64-mingw32 --disable-multilib
make $MAKEOPTS
make install
# Make sure our ld etc. is found and used.
export PATH=$INSTDIR/mingw-w64/bin:$PATH
cd ~/build
# Building mingw-w64
mkdir -p mingw-w64/mingw-w64-headers32
cd mingw-w64/mingw-w64-headers32
../../mingw-w64-git/mingw-w64-headers/configure --host=i686-w64-mingw32 --prefix=$INSTDIR/mingw-w64/i686-w64-mingw32 --enable-sdk=all --enable-secure-api --enable-idl
make install
cd ..
cd ..
# First stage of gcc compilation
mkdir gcc
cd gcc
tar -xjvf ../gcc.tar.bz2
# We don't want to link against msvcrt.dll due to bug 9084.
i686-w64-mingw32-g++ -dumpspecs > ~/build/msvcr100.spec
sed 's/msvcrt/msvcr100/' -i ~/build/msvcr100.spec
# Linking libgcc against msvcrt is hard-coded...
sed 's/msvcrt/msvcr100/' -i gcc-*/gcc/config/i386/t-mingw-w32
# LDFLAGS_FOR_TARGET does not work for some reason. Thus, we take
# CFLAGS_FOR_TARGET.
export CFLAGS_FOR_TARGET="-specs=/home/ubuntu/build/msvcr100.spec -Wl,--nxcompat -Wl,--dynamicbase"
gcc-*/configure --prefix=$INSTDIR/mingw-w64 --target=i686-w64-mingw32 --disable-multilib --enable-languages=c,c++
make $MAKEOPTS all-gcc
make install-gcc
cd ..
#
cd mingw-w64
mkdir mingw-w64-crt32 && cd mingw-w64-crt32
../../mingw-w64-git/mingw-w64-crt/configure --host=i686-w64-mingw32 --prefix=$INSTDIR/mingw-w64/i686-w64-mingw32
make $MAKEOPTS
make install
cd ..
#
mkdir widl32 && cd widl32
../../mingw-w64-git/mingw-w64-tools/widl/configure --prefix=$INSTDIR/mingw-w64 --target=i686-w64-mingw32
make $MAKEOPTS
make install
cd ..
cd ..
# Second stage of gcc compilation
cd gcc
find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
make $MAKEOPTS
make install
mkdir -p $INSTDIR/gcclibs
cp i686-w64-mingw32/libssp/.libs/libssp-0.dll $INSTDIR/gcclibs
cp i686-w64-mingw32/libgcc/shlib/libgcc_s_sjlj-1.dll $INSTDIR/gcclibs
cd ..
# Building zlib
export CFLAGS="-mwindows -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security"
export LDFLAGS="-mwindows -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -lssp -L$INSTDIR/gcclibs/"
cd zlib
find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
make BINARY_PATH=$INSTDIR/zlib/lib INCLUDE_PATH=$INSTDIR/zlib/include LIBRARY_PATH=$INSTDIR/zlib/lib -f win32/Makefile.gcc PREFIX=i686-w64-mingw32- $MAKEOPTS SHARED_MODE=1 LOC="-fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -lssp -L$INSTDIR/gcclibs/"
make BINARY_PATH=$INSTDIR/zlib/lib INCLUDE_PATH=$INSTDIR/zlib/include LIBRARY_PATH=$INSTDIR/zlib/lib -f win32/Makefile.gcc PREFIX=i686-w64-mingw32- $MAKEOPTS SHARED_MODE=1 LOC="-fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -lssp -L$INSTDIR/gcclibs/" install
cd ..
# Building Libevent
cd libevent
./autogen.sh
find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
./configure --disable-static --host=i686-w64-mingw32 --prefix=$INSTDIR/libevent
make $MAKEOPTS
make install
cd ..
# Building OpenSSL
tar xzf openssl.tar.gz
cd openssl-*
find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
# TODO: Add enable-ec_nistp_64_gcc_128 for 64bit Windows.
./Configure -shared --cross-compile-prefix=i686-w64-mingw32- mingw "-fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -lssp -L$INSTDIR/gcclibs/" --prefix=$INSTDIR/openssl
# Using $MAKEOPTS breaks the build. Might be the issue mentioned on
# http://cblfs.cross-lfs.org/index.php/OpenSSL.
make
make install
cd ..
# Building GMP
tar xjf gmp.tar.bz2
cd gmp-*
find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
# Even if we are not shipping libgmpxx anymore we still need --enable-xcc
# during compile time.
./configure --prefix=$INSTDIR/gmp --host=i686-w64-mingw32 --enable-cxx --disable-static --enable-shared
make
make install
cd ..
# Building nsis
tar xf nsis.tar.bz2
cd nsis-${NSIS_VER}-src
tar xf ../nsis-debian.tar.xz
patch -p1 < ../nsis-missing-unistd-include.patch
# nsis_system_zlib.patch and parallel_build.patch cause build errors
# so we remove them
rm -f debian/patches/nsis_system_zlib.patch
rm -f debian/patches/parallel_build.patch
for patch in $(grep '\.patch$' debian/patches/series)
do
[ -f debian/patches/$patch ] && patch -p1 < debian/patches/$patch
done
# When the gcc-mingw-w64-i686 package is installed, files from
# /usr/i686-w64-mingw32/include are used, causing the build to fail.
# To prevent that we remove the gcc-mingw-w64-i686 package.
sudo -i apt-get remove -y gcc-mingw-w64-i686
scons APPEND_CCFLAGS="-fgnu89-inline" VERSION=${NSIS_VER} SKIPUTILS='NSIS Menu' XGCC_W32_PREFIX=i686-w64-mingw32- PREFIX=$INSTDIR/nsis
scons APPEND_CCFLAGS="-fgnu89-inline" VERSION=${NSIS_VER} SKIPUTILS='NSIS Menu' XGCC_W32_PREFIX=i686-w64-mingw32- PREFIX=$INSTDIR/nsis install
cd ..
# Grabbing the remaining results
# Since we stopped using libfaketime, the gcc, gmp, zlib, openssl,
# libevent, mingw-w64 archives are no longer reproducible. The main
# reason is that they include some .a archives which include timestamps.
# Those files are however not part of the files we ship.
cd $INSTDIR
# We might want to bump binutils independent of bumping mingw-w64.
touch binutils-$BINUTILS_VER-win32-utils.zip
~/build/dzip.sh gcc-$GCC_VER-linux32-precise-utils.zip gcc
~/build/dzip.sh yasm-$YASM_VER-linux32-precise-utils.zip yasm
~/build/dzip.sh mingw-w64-$GCC_VER-win32-utils.zip mingw-w64
~/build/dzip.sh zlib-${ZLIB_TAG#v}-win32-utils.zip zlib
~/build/dzip.sh libevent-${LIBEVENT_TAG#release-}-win32-utils.zip libevent
~/build/dzip.sh openssl-$OPENSSL_VER-win32-utils.zip openssl
~/build/dzip.sh gmp-$GMP_VER-win32-utils.zip gmp
~/build/dzip.sh gcclibs-$GCC_VER-win32-utils.zip gcclibs
~/build/dzip.sh nsis-$NSIS_VER-win32-utils.zip nsis
cp *-utils.zip $OUTDIR/
|