-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-linux.sh
executable file
·630 lines (571 loc) · 18.5 KB
/
build-linux.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
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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
#!/bin/bash
# PROJECT: XTchain
# LICENSE: See the COPYING.md in the top level directory
# FILE: build-linux.sh
# DESCRIPTION: Toolchain building and assembly script
# DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
# Working Directories
BINDIR="$(pwd)/binaries"
PCHDIR="$(pwd)/patches"
SRCDIR="$(pwd)/sources"
WRKDIR="$(pwd)"
# Architecture Settings
ARCHS="aarch64 armv7 i686 x86_64"
GENERIC="generic-w64-mingw32"
# Binutils Settings
BINUTILSDIR="${SRCDIR}/binutils"
BINUTILSTAG="binutils-2_41"
BINUTILSVCS="git://sourceware.org/git/binutils-gdb.git"
# CMake Settings
CMAKEDIR="${SRCDIR}/cmake"
CMAKETAG="v3.27.6"
CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git"
# LLVM Settings
LLVMDIR="${SRCDIR}/llvm"
LLVMTAG="llvmorg-17.0.3"
LLVMVCS="https://github.com/llvm/llvm-project.git"
# Make Settings
MAKEDIR="${SRCDIR}/make"
MAKETAG="4.4.1"
MAKEVCS="git://git.savannah.gnu.org/make"
# Mingw-w64 Settings
MINGWDIR="${SRCDIR}/mingw-w64"
MINGWLIB="ucrt"
MINGWTAG="master"
MINGWNTV="0x601"
MINGWVCS="https://github.com/mirror/mingw-w64.git"
# Ninja Settings
NINJADIR="${SRCDIR}/ninja"
NINJATAG="v1.11.1"
NINJAVCS="https://github.com/ninja-build/ninja.git"
# Wine Settings
WINEDIR="${SRCDIR}/wine"
WINETAG="wine-8.17"
WINEVCS="git://source.winehq.org/git/wine.git"
# This function applies a patches to the 3rd party project
apply_patches()
{
local PACKAGE="${1}"
local VERSION="${2}"
if [ -d "${PCHDIR}/${PACKAGE}/${VERSION}" ]; then
PATCHES="$(find ${PCHDIR}/${PACKAGE}/${VERSION} -name '*.diff' -o -name '*.patch' | sort -n)"
echo ">>> Applying custom patches ..."
for PATCH in ${PATCHES}; do
if [ -f "${PATCH}" ] && [ -r "${PATCH}" ]; then
for PREFIX in {0..5}; do
if patch -i${PATCH} -p${PREFIX} --silent --dry-run >/dev/null; then
patch -i${PATCH} -p${PREFIX} --silent
echo ">>> Patch ${PATCH} applied ..."
break;
elif [ ${PREFIX} -ge 5 ]; then
echo "Patch ${PATCH} does not fit. Failed applying patch ..."
return 1
fi
done
fi
done
fi
}
# This function compiles and installs GNU BINUTILS
binutils_build()
{
echo ">>> Building BINUTILS ..."
for ARCH in ${ARCHS}; do
[ -z ${CLEAN} ] || rm -rf ${BINUTILSDIR}/build-${ARCH}
mkdir -p ${BINUTILSDIR}/build-${ARCH}
cd ${BINUTILSDIR}/build-${ARCH}
case ${ARCH} in
"armv7")
TARGET="arm"
;;
*)
TARGET="${ARCH}"
;;
esac
../configure \
--target=${TARGET}-w64-mingw32 \
--disable-binutils \
--disable-gdb \
--disable-gprof \
--disable-ld \
--disable-multilib \
--disable-nls \
--disable-werror \
--with-zlib=yes
make -j${CORES}
cp ${BINUTILSDIR}/build-${ARCH}/gas/as-new ${BINDIR}/bin/${ARCH}-w64-mingw32-gas
done
cd ${WRKDIR}
}
# This function downloads GNU BINUTILS from VCS
binutils_fetch()
{
if [ ! -d ${BINUTILSDIR} ]; then
echo ">>> Downloading BINUTILS ..."
git clone ${BINUTILSVCS} ${BINUTILSDIR}
cd ${BINUTILSDIR}
git checkout tags/${BINUTILSTAG}
apply_patches ${BINUTILSDIR##*/} ${BINUTILSTAG##*-}
cd ${WRKDIR}
fi
}
# This function compiles and installs CMAKE
cmake_build()
{
echo ">>> Building CMAKE ..."
[ -z ${CLEAN} ] || rm -rf ${CMAKEDIR}/build-${GENERIC}
mkdir -p ${CMAKEDIR}/build-${GENERIC}
cd ${CMAKEDIR}/build-${GENERIC}
../bootstrap \
--prefix=${BINDIR} \
--parallel=${CORES} \
-- -DCMAKE_USE_OPENSSL=OFF
make -j${CORES}
make install
cd ${WRKDIR}
}
# This function downloads CMAKE from VCS
cmake_fetch()
{
if [ ! -d ${CMAKEDIR} ]; then
echo ">>> Downloading CMAKE ..."
git clone ${CMAKEVCS} ${CMAKEDIR}
cd ${CMAKEDIR}
git checkout tags/${CMAKETAG}
apply_patches ${CMAKEDIR##*/} ${CMAKETAG}
cd ${WRKDIR}
fi
}
# This function compiles and install LLVM
llvm_build()
{
echo ">>> Building LLVM ..."
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/llvm/build
LLVM_ARCHS=()
for ARCH in ${ARCHS}; do
case ${ARCH} in
"aarch64")
LLVM_ARCHS+=( "AArch64" )
;;
"armv7")
LLVM_ARCHS+=( "ARM" )
;;
"i686"|"x86_64")
LLVM_ARCHS+=( "X86" )
;;
esac
done
LLVM_ARCHS=( $(for ARCH in ${LLVM_ARCHS[@]}; do echo ${ARCH}; done | sort -u) )
cd ${LLVMDIR}/llvm/tools
for UTIL in clang lld; do
if [ ! -e ${UTIL} ]; then
ln -sf ../../${UTIL} .
fi
done
mkdir -p ${LLVMDIR}/llvm/build
cd ${LLVMDIR}/llvm/build
cmake -G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX=${BINDIR} \
-DLLDB_INCLUDE_TESTS=FALSE \
-DLLVM_ENABLE_ASSERTIONS=FALSE \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb" \
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_TARGETS_TO_BUILD="$(echo ${LLVM_ARCHS[@]} | tr ' ' ';')" \
-DLLVM_TOOLCHAIN_TOOLS="llvm-addr2line;llvm-ar;llvm-as;llvm-cov;llvm-cvtres;llvm-dlltool;llvm-lib;llvm-ml;llvm-nm;llvm-objdump;llvm-objcopy;llvm-pdbutil;llvm-profdata;llvm-ranlib;llvm-rc;llvm-readelf;llvm-readobj;llvm-strings;llvm-strip;llvm-symbolizer;llvm-windres" \
..
ninja install/strip
cd ${WRKDIR}
}
# This function compiles and install LIBCXX & LIBUNWIND
llvm_build_libs()
{
echo ">>> Building LLVM libraries (libcxx) ..."
for ARCH in ${ARCHS}; do
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/runtimes/build-${ARCH}
mkdir -p ${LLVMDIR}/runtimes/build-${ARCH}
cd ${LLVMDIR}/runtimes/build-${ARCH}
cmake -G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX="${BINDIR}/${ARCH}-w64-mingw32" \
-DCMAKE_AR="${BINDIR}/bin/llvm-ar" \
-DCMAKE_C_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang" \
-DCMAKE_C_COMPILER_WORKS=1 \
-DCMAKE_C_FLAGS_INIT=-mguard=cf \
-DCMAKE_CXX_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang++" \
-DCMAKE_CXX_COMPILER_TARGET=${ARCH}-w64-windows-gnu \
-DCMAKE_CXX_COMPILER_WORKS=1 \
-DCMAKE_CXX_FLAGS_INIT=-mguard=cf \
-DCMAKE_CROSSCOMPILING=TRUE \
-DCMAKE_RANLIB="${BINDIR}/bin/llvm-ranlib" \
-DCMAKE_SYSTEM_NAME="Windows" \
-DLLVM_PATH="${LLVMDIR}/llvm" \
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx" \
-DLIBUNWIND_USE_COMPILER_RT=TRUE \
-DLIBUNWIND_ENABLE_SHARED=TRUE \
-DLIBUNWIND_ENABLE_STATIC=TRUE \
-DLIBCXX_USE_COMPILER_RT=ON \
-DLIBCXX_ENABLE_SHARED=TRUE \
-DLIBCXX_ENABLE_STATIC=TRUE \
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \
-DLIBCXX_CXX_ABI="libcxxabi" \
-DLIBCXX_LIBDIR_SUFFIX="" \
-DLIBCXX_INCLUDE_TESTS=FALSE \
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE \
-DLIBCXXABI_USE_COMPILER_RT=ON \
-DLIBCXXABI_ENABLE_SHARED=OFF \
-DLIBCXXABI_LIBDIR_SUFFIX="" \
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
..
ninja
ninja install
done
cd ${WRKDIR}
}
# This function compiles and install LLVM runtime
llvm_build_runtime()
{
echo ">>> Building LLVM compiler runtime ..."
for ARCH in ${ARCHS}; do
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/compiler-rt/build-${ARCH}
mkdir -p ${LLVMDIR}/compiler-rt/build-${ARCH}
cd ${LLVMDIR}/compiler-rt/build-${ARCH}
cmake -G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_AR="${BINDIR}/bin/llvm-ar" \
-DCMAKE_C_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang" \
-DCMAKE_C_COMPILER_TARGET="${ARCH}-windows-gnu" \
-DCMAKE_C_FLAGS_INIT="-mguard=cf" \
-DCMAKE_CXX_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang++" \
-DCMAKE_CXX_FLAGS_INIT="-mguard=cf" \
-DCMAKE_FIND_ROOT_PATH="${BINDIR}/${ARCH}-w64-mingw32" \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
-DCMAKE_INSTALL_PREFIX=$(${BINDIR}/bin/${ARCH}-w64-mingw32-clang --print-resource-dir) \
-DCMAKE_RANLIB="${BINDIR}/bin/llvm-ranlib" \
-DCMAKE_SYSTEM_NAME="Windows" \
-DCOMPILER_RT_BUILD_BUILTINS=TRUE \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE \
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=TRUE \
-DLLVM_CONFIG_PATH="" \
-DSANITIZER_CXX_ABI="libc++" \
../lib/builtins
ninja
ninja install
done
cd ${WRKDIR}
}
# This function downloads LLVM from VCS
llvm_fetch()
{
if [ ! -d ${LLVMDIR} ]; then
echo ">>> Downloading LLVM ..."
git clone ${LLVMVCS} ${LLVMDIR}
cd ${LLVMDIR}
git checkout tags/${LLVMTAG}
apply_patches ${LLVMDIR##*/} ${LLVMTAG##*-}
cd ${WRKDIR}
fi
}
# This function compiles and install MAKE
make_build()
{
echo ">>> Building Make ..."
[ -z ${CLEAN} ] || rm -rf ${MAKEDIR}/build
cd ${MAKEDIR}
./bootstrap
sed -i "s/-Werror//" maintMakefile
mkdir -p ${MAKEDIR}/build
cd ${MAKEDIR}/build
../configure \
--prefix=${BINDIR} \
--disable-dependency-tracking \
--disable-silent-rules \
--program-prefix=g \
--without-guile
make -j${CORES}
make install
if [ ! -e ${BINDIR}/bin/make ]; then
ln -sf gmake ${BINDIR}/bin/make
fi
cd ${WRKDIR}
}
# This function downloads MAKE from VCS
make_fetch()
{
if [ ! -d ${MAKEDIR} ]; then
echo ">>> Downloading Make ..."
git clone ${MAKEVCS} ${MAKEDIR}
cd ${MAKEDIR}
git checkout tags/${MAKETAG}
apply_patches ${MAKEDIR##*/} ${MAKETAG}
cd ${WRKDIR}
fi
}
# This function compiles and installs MINGW CRT
mingw_build_crt()
{
for ARCH in ${ARCHS}; do
echo ">>> Building Mingw-W64 (CRT) for ${ARCH} ..."
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
mkdir -p ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
cd ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
case ${ARCH} in
"aarch64")
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm64"
;;
"armv7")
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm32"
;;
"i686")
FLAGS="--enable-lib32 --disable-lib64"
;;
"x86_64")
FLAGS="--disable-lib32 --enable-lib64"
;;
esac
ORIGPATH="${PATH}"
PATH="${BINDIR}/bin:${PATH}"
../configure \
--host=${ARCH}-w64-mingw32 \
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
--with-sysroot=${BINDIR} \
--with-default-msvcrt=${MINGWLIB} \
--enable-cfguard \
${FLAGS}
make -j${CORES}
make install
PATH="${ORIGPATH}"
done
cd ${WRKDIR}
}
# This function compiles and installs MINGW headers
mingw_build_headers()
{
echo ">>> Building Mingw-W64 (headers) ..."
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
mkdir -p ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
cd ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
../configure \
--prefix=${BINDIR}/${GENERIC} \
--enable-idl \
--with-default-msvcrt=${MINGWLIB} \
--with-default-win32-winnt=${MINGWNTV}
make -j${CORES}
make install
for ARCH in ${ARCHS}; do
mkdir -p ${BINDIR}/${ARCH}-w64-mingw32
if [ ! -e ${BINDIR}/${ARCH}-w64-mingw32/include ]; then
ln -sfn ../${GENERIC}/include ${BINDIR}/${ARCH}-w64-mingw32/include
fi
done
cd ${WRKDIR}
}
# This function compiles and install MINGW libraries
mingw_build_libs()
{
for LIB in libmangle winpthreads winstorecompat; do
echo ">>> Building Mingw-w64 (libs) for ${ARCH} ..."
for ARCH in ${ARCHS}; do
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
mkdir -p ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
cd ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
ORIGPATH="${PATH}"
PATH="${BINDIR}/bin:${PATH}"
../configure \
--host=${ARCH}-w64-mingw32 \
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
--libdir=${BINDIR}/${ARCH}-w64-mingw32/lib \
CFLAGS="-O2 -mguard=cf" \
CXXFLAGS="-O2 -mguard=cf"
make -j${CORES}
make install
PATH="${ORIGPATH}"
done
done
cd ${WRKDIR}
}
# This function compiles and installs MINGW tools
mingw_build_tools()
{
for TOOL in gendef genidl genlib genpeimg widl; do
for ARCH in ${ARCHS}; do
echo ">>> Building Mingw-w64 (tools) for ${ARCH} ..."
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-tools/${TOOL}/build-${ARCH}
mkdir -p ${MINGWDIR}/mingw-w64-tools/${TOOL}/build-${ARCH}
cd ${MINGWDIR}/mingw-w64-tools/${TOOL}/build-${ARCH}
../configure \
--target=${ARCH}-w64-mingw32 \
--prefix=${BINDIR}
make -j${CORES}
make install
if [ -e ${BINDIR}/bin/${TOOL} ]; then
mv ${BINDIR}/bin/${TOOL} ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL}
fi
done
done
cd ${WRKDIR}
}
# This function downloads MINGW from VCS
mingw_fetch()
{
if [ ! -d ${MINGWDIR} ]; then
echo ">>> Downloading MinGW-w64 ..."
git clone ${MINGWVCS} ${MINGWDIR}
cd ${MINGWDIR}
if [ x"${MINGWTAG}" != x"master" ]; then
git checkout tags/${MINGWTAG}
fi
apply_patches ${MINGWDIR##*/} ${MINGWTAG}
cd ${WRKDIR}
fi
}
# This function compiles and installs NINJA
ninja_build()
{
echo ">>> Building NINJA ..."
[ -z ${CLEAN} ] || rm -rf ${NINJADIR}/build-${GENERIC}
mkdir -p ${NINJADIR}/build-${GENERIC}
cd ${NINJADIR}/build-${GENERIC}
../configure.py --bootstrap
install ninja ${BINDIR}/bin/
cd ${WRKDIR}
}
# This function downloads NINJA from VCS
ninja_fetch()
{
if [ ! -d ${NINJADIR} ]; then
echo ">>> Downloading NINJA ..."
git clone ${NINJAVCS} ${NINJADIR}
cd ${NINJADIR}
git checkout tags/${NINJATAG}
apply_patches ${NINJADIR##*/} ${NINJATAG}
cd ${WRKDIR}
fi
}
# This function compiles and install WINE tools
wine_build()
{
echo ">>> Building Wine ..."
mkdir -p ${WINEDIR}/build
cd ${WINEDIR}/build
../configure \
-enable-win64 \
--without-freetype \
--without-x
for TOOL in winedump wmc wrc; do
make -j${CORES} tools/${TOOL}/all
cp tools/${TOOL}/${TOOL} ${BINDIR}/bin/
for ARCH in ${ARCHS}; do
if [ ! -e ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL} ]; then
ln -sf ${TOOL} ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL}
fi
done
done
cd ${WRKDIR}
}
# This function downloads WINE from VCS
wine_fetch()
{
if [ ! -d ${WINEDIR} ]; then
echo ">>> Downloading WINE ..."
git clone ${WINEVCS} ${WINEDIR}
cd ${WINEDIR}
git checkout tags/${WINETAG}
apply_patches ${WINEDIR##*/} ${WINETAG##*-}
cd ${WRKDIR}
fi
}
# This function installs XTCHAIN scripts, wrappers and symlinks
xtchain_build()
{
echo ">>> Building XTchain ..."
mkdir -p ${BINDIR}/bin
mkdir -p ${BINDIR}/lib/xtchain
mkdir -p ${BINDIR}/${GENERIC}/bin
cp ${WRKDIR}/scripts/*-wrapper ${BINDIR}/${GENERIC}/bin
for ARCH in ${ARCHS}; do
for EXEC in c++ c11 c99 cc clang clang++ g++ gcc; do
ln -sf ../${GENERIC}/bin/clang-target-wrapper ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
done
for EXEC in addr2line ar as nm objcopy pdbutil ranlib rc strings strip; do
ln -sf llvm-${EXEC} ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
done
for EXEC in dlltool ld objdump; do
ln -sf ../${GENERIC}/bin/${EXEC}-wrapper ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
done
for EXEC in bin2c exetool windres xtcspecc; do
if [ ! -e ${BINDIR}/bin/${EXEC} ]; then
gcc ${WRKDIR}/tools/${EXEC}.c -o ${BINDIR}/bin/${EXEC}
fi
ln -sf ${EXEC} ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
done
done
cp ${WRKDIR}/scripts/xtclib ${BINDIR}/lib/xtchain/
cp ${WRKDIR}/scripts/xtchain ${BINDIR}/
}
# Exit immediately on any failure
set -e
# Check number of CPU cores available
if [[ ! -n ${CORES} ]]; then
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
: ${CORES:=$(nproc 2>/dev/null)}
: ${CORES:=1}
fi
# Create working directories
mkdir -p ${BINDIR}
mkdir -p ${SRCDIR}
# XTchain
xtchain_build
# Download LLVM
llvm_fetch
# Build and install LLVM
llvm_build
# Download Mingw-W64
mingw_fetch
# Build and install Mingw-W64 headers
mingw_build_headers
# Build and install Mingw-W64 CRT
mingw_build_crt
# Build and install LLVM compiler runtime
llvm_build_runtime
# Build and install LLVM compiler libraries
llvm_build_libs
# Build and install Mingw-W64 libraries
mingw_build_libs
# Build and install Mingw-W64 tools
mingw_build_tools
# Download Binutils
binutils_fetch
# Build and install Binutils
binutils_build
# Download Wine
wine_fetch
# Build and install Wine tools
wine_build
# Download Make
make_fetch
# Build and install Make
make_build
# Download CMake
cmake_fetch
# Build and install CMake
cmake_build
# Download Ninja
ninja_fetch
# Build and install Ninja
ninja_build
# Remove unneeded files to save disk space
echo ">>> Removing unneeded files to save disk space ..."
rm -rf ${BINDIR}/{doc,include,share/{bash-completion,emacs,info,locale,man,vim}}
rm -rf ${BINDIR}/bin/amdgpu-arch,{clang-{check,exdef-mapping,import-test,offload-*,rename,scan-deps},diagtool,hmaptool,ld64.lld,modularize,nxptx-arch,wasm-ld}
# Save XT Toolchain version
cd ${WRKDIR}
: ${XTCVER:=$(git describe --exact-match --tags 2>/dev/null)}
: ${XTCVER:=DEVEL}
echo "${XTCVER}" > ${BINDIR}/Version
# Prepare archive
echo ">>> Creating toolchain archive ..."
tar -I 'zstd -19' -cpf xtchain-${XTCVER}-linux.tar.zst -C ${BINDIR} .