-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmake-release.sh
executable file
·96 lines (81 loc) · 2.8 KB
/
make-release.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
#!/bin/sh
#
# Script to build release tarballs
# --------------------------------
#
# Compiles for three different platforms:
# - For Win32, using the mingw-w64 compiler,
# - For OSX 32 and 64 bits, using osxcross and GCC
# - For Linux 64bit PC, using GCC,
# - For Linux 32bit PC, using GCC.
#
# Uses link-time-optimizations and disable asserts.
set -e
ncpu=-j6
ver="$(git describe --tags --dirty)"
rdir="../releases"
out="$rdir/fastbasic-$ver"
LTO_FLAGS="-flto -flto-partition=none"
CXX_FLAGS="-DNDEBUG -Os -Wall"
LIN64_FLAGS="$CXX_FLAGS $LTO_FLAGS -static-libstdc++ -Wl,--gc-sections"
WIN_CROSS=i686-w64-mingw32-
WIN_FLAGS="$CXX_FLAGS -static -Wl,--gc-sections"
OSX64_CROSS=x86_64-apple-darwin20.2-
OSX64_FLAGS="$CXX_FLAGS -flto -static-libstdc++"
# Make output folder if not exists
mkdir -p "$rdir"
echo "----------- Compiling release $ver -------------"
echo ""
compile_lin64() {
# Full compile for 64bit Linux (and ATR)
make $ncpu CROSS= OPTFLAGS="$LIN64_FLAGS" dist
mv -f build/fastbasic.zip "${out}-linux64.zip"
mv -f build/fastbasic.atr "${out}.atr"
make CROSS= distclean
}
compile_win32() {
if ! which "${WIN_CROSS}gcc" > /dev/null ; then
echo "-----------------------------------------------------"
echo "--"
echo "-- ERROR: missing windows compiler ${WIN_CROSS}gcc"
echo "--"
echo "-----------------------------------------------------"
return
fi
# Compile with mingw-w64 cross compiler to 32bit:
make $ncpu CROSS="$WIN_CROSS" TARGET_OPTFLAGS="$WIN_FLAGS" build/fastbasic.zip
mv build/fastbasic.zip "${out}-win32.zip"
make CROSS="$WIN_CROSS" distclean
}
compile_osx() {
OPATH="$PATH"
PATH="$PATH:/opt/osx/bin"
if ! which "${OSX64_CROSS}cc" > /dev/null ; then
echo "-----------------------------------------------------"
echo "--"
echo "-- ERROR: missing OSX compiler ${OSX64_CROSS}cc"
echo "--"
echo "-----------------------------------------------------"
return
fi
# Compile FAT binary for OSX.
# Note that this is simpler with CLANG, but it produces a binary slower and twice the size!
# First compile to 64bit:
make $ncpu CROSS="$OSX64_CROSS" CC=cc CXX=c++ TARGET_OPTFLAGS="$OSX64_FLAGS" \
build/fastbasic.zip
mv build/fastbasic.zip "${out}-macosx.zip"
make CROSS="$OSX64_CROSS" CC=cc CXX=c++ distclean
PATH="$OPATH"
}
make distclean
compile_lin64
compile_win32
compile_osx
# Makes PDF using "pandoc"
make build/compiler/MANUAL.md
pandoc build/compiler/MANUAL.md -o "${out}-manual.pdf" \
--from markdown-raw_tex --template template.tex \
--listings --toc --number-sections
make build/compiler/USAGE.md
pandoc build/compiler/USAGE.md -o "${out}-cross-compiler.pdf" \
--from markdown-raw_tex --template template.tex --listings