-
Notifications
You must be signed in to change notification settings - Fork 231
/
Dockerfile
499 lines (459 loc) · 17.5 KB
/
Dockerfile
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
FROM debian:bullseye-slim
ARG VERSION=1.19.0
ARG PREFIX=/w64devkit
ARG BINUTILS_VERSION=2.40
ARG BUSYBOX_VERSION=FRP-4882-g6e0a6b7e5
ARG CTAGS_VERSION=6.0.0
ARG EXPAT_VERSION=2.5.0
ARG GCC_VERSION=13.1.0
ARG GDB_VERSION=13.1
ARG GMP_VERSION=6.2.1
ARG LIBICONV_VERSION=1.17
ARG MAKE_VERSION=4.4
ARG MINGW_VERSION=11.0.0
ARG MPC_VERSION=1.2.1
ARG MPFR_VERSION=4.1.0
ARG NASM_VERSION=2.15.05
ARG PDCURSES_VERSION=3.9
ARG CPPCHECK_VERSION=2.10
ARG VIM_VERSION=9.0
RUN apt-get update && apt-get install --yes --no-install-recommends \
build-essential curl libgmp-dev libmpc-dev libmpfr-dev m4 zip
# Download, verify, and unpack
RUN curl --insecure --location --remote-name-all --remote-header-name \
https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.xz \
https://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz \
https://ftp.gnu.org/gnu/gdb/gdb-$GDB_VERSION.tar.xz \
https://fossies.org/linux/www/expat-$EXPAT_VERSION.tar.xz \
https://ftp.gnu.org/gnu/gmp/gmp-$GMP_VERSION.tar.xz \
https://ftp.gnu.org/gnu/mpc/mpc-$MPC_VERSION.tar.gz \
https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFR_VERSION.tar.xz \
https://ftp.gnu.org/gnu/make/make-$MAKE_VERSION.tar.gz \
https://ftp.gnu.org/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz \
https://frippery.org/files/busybox/busybox-w32-$BUSYBOX_VERSION.tgz \
http://ftp.vim.org/pub/vim/unix/vim-$VIM_VERSION.tar.bz2 \
https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/nasm-$NASM_VERSION.tar.xz \
https://github.com/universal-ctags/ctags/archive/refs/tags/v$CTAGS_VERSION.tar.gz \
https://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v$MINGW_VERSION.tar.bz2 \
https://downloads.sourceforge.net/project/pdcurses/pdcurses/$PDCURSES_VERSION/PDCurses-$PDCURSES_VERSION.tar.gz \
https://github.com/danmar/cppcheck/archive/$CPPCHECK_VERSION.tar.gz
COPY src/SHA256SUMS $PREFIX/src/
RUN sha256sum -c $PREFIX/src/SHA256SUMS \
&& tar xJf binutils-$BINUTILS_VERSION.tar.xz \
&& tar xzf busybox-w32-$BUSYBOX_VERSION.tgz \
&& tar xzf ctags-$CTAGS_VERSION.tar.gz \
&& tar xJf gcc-$GCC_VERSION.tar.xz \
&& tar xJf gdb-$GDB_VERSION.tar.xz \
&& tar xJf expat-$EXPAT_VERSION.tar.xz \
&& tar xzf libiconv-$LIBICONV_VERSION.tar.gz \
&& tar xJf gmp-$GMP_VERSION.tar.xz \
&& tar xzf mpc-$MPC_VERSION.tar.gz \
&& tar xJf mpfr-$MPFR_VERSION.tar.xz \
&& tar xzf make-$MAKE_VERSION.tar.gz \
&& tar xjf mingw-w64-v$MINGW_VERSION.tar.bz2 \
&& tar xzf PDCurses-$PDCURSES_VERSION.tar.gz \
&& tar xJf nasm-$NASM_VERSION.tar.xz \
&& tar xjf vim-$VIM_VERSION.tar.bz2 \
&& tar xzf cppcheck-$CPPCHECK_VERSION.tar.gz
COPY src/w64devkit.c src/w64devkit.ico \
src/alias.c src/debugbreak.c src/pkg-config.c \
$PREFIX/src/
ARG ARCH=x86_64-w64-mingw32
# Build cross-compiler
WORKDIR /binutils-$BINUTILS_VERSION
COPY src/binutils-*.patch $PREFIX/src/
RUN sed -ri 's/(static bool insert_timestamp = )/\1!/' ld/emultempl/pe*.em \
&& cat $PREFIX/src/binutils-*.patch | patch -p1
WORKDIR /x-binutils
RUN /binutils-$BINUTILS_VERSION/configure \
--prefix=/bootstrap \
--with-sysroot=/bootstrap/$ARCH \
--target=$ARCH \
--disable-nls \
--with-static-standard-libraries \
--disable-multilib \
&& make MAKEINFO=true -j$(nproc) \
&& make MAKEINFO=true install
# Fixes i686 Windows XP regression
# https://sourceforge.net/p/mingw-w64/bugs/821/
RUN sed -i /OpenThreadToken/d /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/lib32/kernel32.def
WORKDIR /x-mingw-headers
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \
--prefix=/bootstrap/$ARCH \
--host=$ARCH \
&& make -j$(nproc) \
&& make install
WORKDIR /bootstrap
RUN ln -s $ARCH mingw
WORKDIR /x-gcc
RUN /gcc-$GCC_VERSION/configure \
--prefix=/bootstrap \
--with-sysroot=/bootstrap \
--target=$ARCH \
--enable-static \
--disable-shared \
--with-pic \
--enable-languages=c,c++ \
--enable-libgomp \
--enable-threads=posix \
--enable-version-specific-runtime-libs \
--disable-dependency-tracking \
--disable-nls \
--disable-multilib \
CFLAGS_FOR_TARGET="-Os" \
CXXFLAGS_FOR_TARGET="-Os" \
LDFLAGS_FOR_TARGET="-s" \
CFLAGS="-Os" \
CXXFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) all-gcc \
&& make install-gcc
ENV PATH="/bootstrap/bin:${PATH}"
WORKDIR /x-mingw-crt
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \
--prefix=/bootstrap/$ARCH \
--with-sysroot=/bootstrap/$ARCH \
--host=$ARCH \
--disable-dependency-tracking \
--disable-lib32 \
--enable-lib64 \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /x-winpthreads
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-libraries/winpthreads/configure \
--prefix=/bootstrap/$ARCH \
--with-sysroot=/bootstrap/$ARCH \
--host=$ARCH \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /x-gcc
RUN make -j$(nproc) \
&& make install
# Cross-compile GCC
WORKDIR /binutils
RUN /binutils-$BINUTILS_VERSION/configure \
--prefix=$PREFIX \
--with-sysroot=$PREFIX/$ARCH \
--host=$ARCH \
--target=$ARCH \
--disable-nls \
--with-static-standard-libraries \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make MAKEINFO=true -j$(nproc) \
&& make MAKEINFO=true install \
&& rm $PREFIX/bin/elfedit.exe $PREFIX/bin/gprof.exe $PREFIX/bin/readelf.exe
WORKDIR /gmp
RUN /gmp-$GMP_VERSION/configure \
--prefix=/deps \
--host=$ARCH \
--disable-assembly \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
CXXFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /mpfr
RUN /mpfr-$MPFR_VERSION/configure \
--prefix=/deps \
--host=$ARCH \
--with-gmp-include=/deps/include \
--with-gmp-lib=/deps/lib \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /mpc
RUN /mpc-$MPC_VERSION/configure \
--prefix=/deps \
--host=$ARCH \
--with-gmp-include=/deps/include \
--with-gmp-lib=/deps/lib \
--with-mpfr-include=/deps/include \
--with-mpfr-lib=/deps/lib \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /mingw-headers
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \
--prefix=$PREFIX/$ARCH \
--host=$ARCH \
&& make -j$(nproc) \
&& make install
WORKDIR /mingw-crt
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \
--prefix=$PREFIX/$ARCH \
--with-sysroot=$PREFIX/$ARCH \
--host=$ARCH \
--disable-dependency-tracking \
--disable-lib32 \
--enable-lib64 \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /winpthreads
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-libraries/winpthreads/configure \
--prefix=$PREFIX/$ARCH \
--with-sysroot=$PREFIX/$ARCH \
--host=$ARCH \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /gcc
RUN /gcc-$GCC_VERSION/configure \
--prefix=$PREFIX \
--with-sysroot=$PREFIX/$ARCH \
--with-native-system-header-dir=/include \
--target=$ARCH \
--host=$ARCH \
--enable-static \
--disable-shared \
--with-pic \
--with-gmp-include=/deps/include \
--with-gmp-lib=/deps/lib \
--with-mpc-include=/deps/include \
--with-mpc-lib=/deps/lib \
--with-mpfr-include=/deps/include \
--with-mpfr-lib=/deps/lib \
--enable-languages=c,c++ \
--enable-libgomp \
--enable-threads=posix \
--enable-version-specific-runtime-libs \
--disable-dependency-tracking \
--disable-multilib \
--disable-nls \
--disable-win32-registry \
--enable-mingw-wildcard \
CFLAGS_FOR_TARGET="-Os" \
CXXFLAGS_FOR_TARGET="-Os" \
LDFLAGS_FOR_TARGET="-s" \
CFLAGS="-Os" \
CXXFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install \
&& rm -rf $PREFIX/$ARCH/bin/ $PREFIX/bin/$ARCH-* \
$PREFIX/bin/ld.bfd.exe $PREFIX/bin/c++.exe $PREFIX/bin/lto-dump.exe \
&& $ARCH-gcc -DEXE=g++.exe -DCMD=c++ \
-Os -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/c++.exe \
$PREFIX/src/alias.c -lkernel32
# Create various tool aliases
RUN $ARCH-gcc -DEXE=gcc.exe -DCMD=cc \
-Os -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/cc.exe $PREFIX/src/alias.c -lkernel32 \
&& $ARCH-gcc -DEXE=gcc.exe -DCMD="cc -std=c99" \
-Os -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/c99.exe $PREFIX/src/alias.c -lkernel32 \
&& printf '%s\n' addr2line ar as c++filt cpp dlltool dllwrap elfedit g++ \
gcc gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool ld nm objcopy \
objdump ranlib readelf size strings strip windmc windres \
| xargs -I{} -P$(nproc) \
$ARCH-gcc -DEXE={}.exe -DCMD=$ARCH-{} \
-Os -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/$ARCH-{}.exe $PREFIX/src/alias.c -lkernel32
# Build some extra development tools
WORKDIR /mingw-tools/gendef
COPY src/gendef-silent.patch $PREFIX/src/
RUN patch -d/mingw-w64-v$MINGW_VERSION -p1 <$PREFIX/src/gendef-silent.patch \
&& /mingw-w64-v$MINGW_VERSION/mingw-w64-tools/gendef/configure \
--host=$ARCH \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& cp gendef.exe $PREFIX/bin/
WORKDIR /expat
RUN /expat-$EXPAT_VERSION/configure \
--prefix=/deps \
--host=$ARCH \
--disable-shared \
--without-docbook \
--without-examples \
--without-tests \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /PDCurses-$PDCURSES_VERSION
RUN make -j$(nproc) -C wincon \
CC=$ARCH-gcc AR=$ARCH-ar CFLAGS="-I.. -Os -DPDC_WIDE" pdcurses.a \
&& cp wincon/pdcurses.a /deps/lib/libcurses.a \
&& cp curses.h /deps/include
WORKDIR /libiconv
RUN /libiconv-$LIBICONV_VERSION/configure \
--prefix=/deps \
--host=$ARCH \
--disable-nls \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install
WORKDIR /gdb
COPY src/gdb-*.patch $PREFIX/src/
RUN cat $PREFIX/src/gdb-*.patch | patch -d/gdb-$GDB_VERSION -p1 \
&& sed -i 's/quiet = 0/quiet = 1/' /gdb-$GDB_VERSION/gdb/main.c \
&& /gdb-$GDB_VERSION/configure \
--host=$ARCH \
--with-libexpat-prefix=/deps \
--with-libgmp-prefix=/deps \
--with-libiconv-prefix=/deps \
--enable-tui \
CFLAGS="-Os -DPDC_WIDE" \
CXXFLAGS="-Os -DPDC_WIDE" \
LDFLAGS="-s -L/deps/lib" \
&& make MAKEINFO=true -j$(nproc) \
&& cp gdb/.libs/gdb.exe gdbserver/gdbserver.exe $PREFIX/bin/
WORKDIR /make
RUN /make-$MAKE_VERSION/configure \
--host=$ARCH \
--disable-nls \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& cp make.exe $PREFIX/bin/ \
&& $ARCH-gcc -DEXE=make.exe -DCMD=make \
-Os -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/mingw32-make.exe $PREFIX/src/alias.c -lkernel32
WORKDIR /busybox-w32
COPY src/busybox-*.patch $PREFIX/src/
RUN cat $PREFIX/src/busybox-*.patch | patch -p1 \
&& make mingw64_defconfig \
&& sed -ri 's/^(CONFIG_AR)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_ASCII)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_DPKG\w*)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_FTP\w*)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_LINK)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_MAN)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_MAKE)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_PDPMAKE)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_RPM\w*)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_STRINGS)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_TEST2)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_TSORT)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_UNLINK)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_VI)=y/\1=n/' .config \
&& sed -ri 's/^(CONFIG_XXD)=y/\1=n/' .config \
&& make -j$(nproc) CROSS_COMPILE=$ARCH- \
CONFIG_EXTRA_CFLAGS="-D_WIN32_WINNT=0x502" \
&& cp busybox.exe $PREFIX/bin/
# Create BusyBox command aliases (like "busybox --install")
RUN printf '%s\n' arch ash awk base32 base64 basename bash bc bunzip2 bzcat \
bzip2 cal cat chattr chmod cksum clear cmp comm cp cpio crc32 cut date \
dc dd df diff dirname dos2unix du echo ed egrep env expand expr factor \
false fgrep find fold free fsync getopt grep groups gunzip gzip hd \
head hexdump httpd iconv id inotifyd install ipcalc jn kill killall \
less ln logname ls lsattr lzcat lzma lzop lzopcat md5sum mkdir \
mktemp mv nc nl nproc od paste patch pgrep pidof pipe_progress pkill \
printenv printf ps pwd readlink realpath reset rev rm rmdir sed seq sh \
sha1sum sha256sum sha3sum sha512sum shred shuf sleep sort split \
ssl_client stat su sum sync tac tail tar tee test time timeout touch \
tr true truncate ts ttysize uname uncompress unexpand uniq unix2dos \
unlzma unlzop unxz unzip uptime usleep uudecode uuencode watch \
wc wget which whoami whois xargs xz xzcat yes zcat \
| xargs -I{} -P$(nproc) \
$ARCH-gcc -DEXE=busybox.exe -DCMD={} \
-Os -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/{}.exe $PREFIX/src/alias.c -lkernel32
# TODO: Either somehow use $VIM_VERSION or normalize the workdir
WORKDIR /vim90/src
RUN ARCH= make -j$(nproc) -f Make_ming.mak \
OPTIMIZE=SIZE STATIC_STDCPLUS=yes HAS_GCC_EH=no \
UNDER_CYGWIN=yes CROSS=yes CROSS_COMPILE=$ARCH- \
FEATURES=HUGE VIMDLL=yes NETBEANS=no WINVER=0x0501 \
&& $ARCH-strip vimrun.exe \
&& rm -rf ../runtime/tutor/tutor.* \
&& cp -r ../runtime $PREFIX/share/vim \
&& cp vimrun.exe gvim.exe vim.exe *.dll $PREFIX/share/vim/ \
&& cp xxd/xxd.exe $PREFIX/bin \
&& printf '@set SHELL=\r\n@start "" "%%~dp0/../share/vim/gvim.exe" %%*\r\n' \
>$PREFIX/bin/gvim.bat \
&& printf '@set SHELL=\r\n@"%%~dp0/../share/vim/vim.exe" %%*\r\n' \
>$PREFIX/bin/vim.bat \
&& printf '@set SHELL=\r\n@"%%~dp0/../share/vim/vim.exe" %%*\r\n' \
>$PREFIX/bin/vi.bat \
&& printf '@vim -N -u NONE "+read %s" "+write" "%s"\r\n' \
'$VIMRUNTIME/tutor/tutor' '%TMP%/tutor%RANDOM%' \
>$PREFIX/bin/vimtutor.bat
# NOTE: nasm's configure script is broken, so no out-of-source build
WORKDIR /nasm-$NASM_VERSION
RUN ./configure \
--host=$ARCH \
CFLAGS="-Os" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& cp nasm.exe ndisasm.exe $PREFIX/bin
WORKDIR /ctags-$CTAGS_VERSION
RUN sed -i /RT_MANIFEST/d win32/ctags.rc \
&& make -j$(nproc) -f mk_mingw.mak CC=gcc packcc.exe \
&& make -j$(nproc) -f mk_mingw.mak \
CC=$ARCH-gcc WINDRES=$ARCH-windres \
OPT= CFLAGS=-Os LDFLAGS=-s \
&& cp ctags.exe $PREFIX/bin/
WORKDIR /cppcheck-$CPPCHECK_VERSION
COPY src/cppcheck.mak src/cppcheck-*.patch $PREFIX/src/
RUN cat $PREFIX/src/cppcheck-*.patch | patch -p1 \
&& make -f $PREFIX/src/cppcheck.mak -j$(nproc) CXX=$ARCH-g++ \
&& mkdir $PREFIX/share/cppcheck/ \
&& cp -r cppcheck.exe cfg/ $PREFIX/share/cppcheck \
&& $ARCH-gcc -DEXE=../share/cppcheck/cppcheck.exe -DCMD=cppcheck \
-Os -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/cppcheck.exe \
$PREFIX/src/alias.c -lkernel32
# Pack up a release
WORKDIR /
RUN rm -rf $PREFIX/share/man/ $PREFIX/share/info/ $PREFIX/share/gcc-* \
&& rm -rf $PREFIX/lib/*.a $PREFIX/lib/*.la $PREFIX/include/*.h
COPY README.md Dockerfile src/w64devkit.ini $PREFIX/
RUN printf "id ICON \"$PREFIX/src/w64devkit.ico\"" >w64devkit.rc \
&& $ARCH-windres -o w64devkit.o w64devkit.rc \
&& $ARCH-gcc -DVERSION=$VERSION \
-mno-stack-arg-probe -Xlinker --stack=0x10000,0x10000 \
-Os -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/w64devkit.exe $PREFIX/src/w64devkit.c w64devkit.o \
-lkernel32 \
&& $ARCH-gcc \
-Os -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/debugbreak.exe $PREFIX/src/debugbreak.c \
-lkernel32 \
&& $ARCH-gcc \
-Os -fwhole-program -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib -DPKG_CONFIG_PREFIX="\"/$ARCH\"" \
-o $PREFIX/bin/pkg-config.exe $PREFIX/src/pkg-config.c \
-lkernel32 \
&& $ARCH-gcc -DEXE=pkg-config.exe -DCMD=pkg-config \
-Os -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/$ARCH-pkg-config.exe $PREFIX/src/alias.c -lkernel32 \
&& mkdir -p $PREFIX/$ARCH/lib/pkgconfig \
&& cp /mingw-w64-v$MINGW_VERSION/COPYING.MinGW-w64-runtime/COPYING.MinGW-w64-runtime.txt \
$PREFIX/ \
&& printf "\n===========\nwinpthreads\n===========\n\n" \
>>$PREFIX/COPYING.MinGW-w64-runtime.txt . \
&& cat /mingw-w64-v$MINGW_VERSION/mingw-w64-libraries/winpthreads/COPYING \
>>$PREFIX/COPYING.MinGW-w64-runtime.txt \
&& echo $VERSION >$PREFIX/VERSION.txt
ENV PREFIX=${PREFIX}
CMD zip -q9Xr - $PREFIX