-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildDependencies.sh
executable file
·139 lines (107 loc) · 3.69 KB
/
buildDependencies.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
#!/bin/bash
colorGreen='\033[1;32m'
colorRed='\033[1;31m'
colorUsual='\033[0m'
curDir=$(pwd)
downloads="${curDir}/downloads"
libs="${curDir}/libs"
function err() {
>&2 echo -e "${colorRed}----- $1 ----- ${colorUsual}"
exit 1
}
function msg() {
echo -e "${colorGreen}----- $1 ----- ${colorUsual}"
}
function main() {
msg "Downloading and building dependencies..."
if ! [ -r "$curDir" ] || ! [ -w "$curDir" ]; then err "Cannot read or write to current directory"; fi
if [ -d "$downloads" ]; then rm -r "$downloads"; fi
if [ -d "$libs" ]; then rm -r "$libs"; fi
mkdir "$downloads" "$libs"
}
function sdl() {
msg "Processing SDL2..."
lib="${libs}/sdl"
bin="${lib}/bin"
include="${lib}/include"
if ! (mkdir "$lib" && mkdir "$bin" && mkdir "$include")
then err "unable to create directories"; fi
if ! (cd "$downloads" \
&& wget https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.26.5.tar.gz \
&& tar -xf release-2.26.5.tar.gz && cd SDL-release-2.26.5 \
&& mkdir build && cd build && cmake .. && make all \
&& cp *.so *.so.* *.a "$bin" \
&& cd .. \
&& cp include/*.h "$include")
then err "failed to retrieve & build SDL2"; fi
msg "SDL2 finished"
}
function sdlNet() {
msg "Processing SDL2Net..."
lib="${libs}/sdl"
bin="${lib}/bin"
include="${lib}/include"
if ! (cd "$downloads" \
&& wget https://github.com/libsdl-org/SDL_net/releases/download/release-2.2.0/SDL2_net-2.2.0.tar.gz \
&& tar -xf SDL2_net-2.2.0.tar.gz && cd SDL2_net-2.2.0 \
&& mkdir build && cd build && cmake .. && make all \
&& cp *.so *.so.* "$bin" \
&& cd .. \
&& cp *.h "$include")
then err "failed to retrieve & build SDL2Net"; fi
msg "SDL2Net finished"
}
function sodium() {
msg "Processing Sodium..."
lib="${libs}/sodium"
bin="${lib}/bin"
include="${lib}/include"
if ! (mkdir "$lib" && mkdir "$bin" && mkdir "$include")
then err "unable to create directories"; fi
if ! (cd "$downloads" \
&& wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz \
&& tar -xf libsodium-1.0.18.tar.gz && cd libsodium-1.0.18 \
&& ./configure && make \
&& cd src/libsodium/.libs \
&& cp *.so *.so.* *.a "$bin" \
&& cd "${downloads}/libsodium-1.0.18/src/libsodium/include" \
&& cp sodium.h "$include" \
&& cp -r sodium "$include")
then err "failed to retrieve & build Sodium"; fi
msg "Sodium finished"
}
function sqlite() {
msg "Processing SQLite3..."
lib="${libs}/sqlite3"
bin="${lib}/bin"
include="${lib}/include"
if ! (mkdir "$lib" && mkdir "$bin" && mkdir "$include")
then err "unable to create directories"; fi
if ! (cd "$downloads" \
&& wget https://sqlite.org/2023/sqlite-autoconf-3420000.tar.gz \
&& tar -xf sqlite-autoconf-3420000.tar.gz && cd sqlite-autoconf-3420000 \
&& ./configure && make \
&& cp sqlite3.h "$include" \
&& cd .libs \
&& cp *.so *.so.* *.a "$bin")
then err "failed to retrieve & build SQLite3"; fi
msg "SQLite3 finished"
}
function nuklear() {
msg "Processing Nuklear..."
lib="${libs}/nuklear"
include="${lib}/include"
if ! (mkdir "$lib" && mkdir "$include")
then err "unable to create directories"; fi
if ! (cd "$downloads" \
&& wget https://github.com/Immediate-Mode-UI/Nuklear/archive/refs/tags/4.10.5.tar.gz \
&& tar -xf 4.10.5.tar.gz && cd Nuklear-4.10.5 \
&& cd src && ./paq.sh > ../nuklear.h \
&& cp ../nuklear.h "$include" \
&& cp ../demo/sdl_renderer/nuklear_sdl_renderer.h "$include")
then err "failed to retrieve Nuklear"; fi
msg "Nuklear finished"
}
main && sdl && sdlNet && sodium && sqlite && nuklear \
&& rm -r "$downloads" \
&& msg "All dependencies were built and placed in the 'libs' directory"