-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
265 lines (212 loc) · 7.91 KB
/
build.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
################
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://www.wtfpl.net/ for more details.
################
sudo dnf -y groupinstall "Development Tools"
sudo dnf -y install python \
ragel \
byacc \
flex \
autoconf \
automake \
lbzip2 \
gettext \
autogen \
libtool \
gperf \
gettext-devel \
meson \
ninja-build \
gcc-c++ \
libattr \
pkg-config \
which \
cmake \
glib2-devel
set -x
. env.sh
mkdir -p ${magicprefix}
# copied from:
# https://gist.github.com/kleisauke/acfa1c09522705efa5eb0541d2d00887
cat > "${magicdir}/emscripten-crossfile.meson" <<END
[binaries]
c = 'emcc'
cpp = 'em++'
ld = 'wasm-ld'
ar = 'emar'
ranlib = 'emranlib'
pkgconfig = ['emconfigure', 'pkg-config']
# https://docs.gtk.org/glib/cross-compiling.html#cross-properties
[properties]
growing_stack = true
have_c99_vsnprintf = true
have_c99_snprintf = true
have_unix98_printf = true
# Ensure that '-s PTHREAD_POOL_SIZE=*' is not injected into .pc files
[built-in options]
c_thread_count = 0
cpp_thread_count = 0
[host_machine]
system = 'emscripten'
cpu_family = 'wasm32'
cpu = 'wasm32'
endian = 'little'
END
check_result() {
if [ $? -eq 0 ]; then
echo "SEEMS GOOD."
else
echo "SHIT HAPPENED."
exit 42
fi
echo "PREVIOUS DIR: " $(pwd)
}
######################
##### zlib
######################
cd ${magicdir}/zlib
emconfigure ./configure --static --prefix=${magicprefix} && \
emmake make && \
emmake make install
check_result
######################
##### libpng
######################
cd ${magicdir}/libpng
cp Makefile.in Makefile.in.original
sed 's/DEFAULT_INCLUDES = .*/DEFAULT_INCLUDES = -I.@am__isrc@ ${CCASFLAGS}/' Makefile.in.original > Makefile.in
emconfigure ./configure --host=${CHOST} --with-binconfigs=no --prefix=${magicprefix} --enable-shared=no --disable-dependency-tracking CFLAGS="$(pkg-config --cflags zlib) -s USE_PTHREADS" LDFLAGS="$(pkg-config --libs zlib) -lpthread" --with-pkgconfigdir=${magicprefix}/lib/pkgconfig/ --with-zlib-prefix=${magicprefix} && \
emmake make && \
emmake make install
check_result
######################
##### pixman
######################
cd ${magicdir}/pixman
./autogen.sh && \
emconfigure ./configure --host=${CHOST} --prefix=${magicprefix} --enable-shared=no --disable-dependency-tracking CFLAGS='-s USE_PTHREADS' LDFLAGS='-lpthread' && \
emmake make && \
emmake make install
check_result
######################
##### freetype
######################
cd ${magicdir}/freetype
./autogen.sh && \
emconfigure ./configure --host=${CHOST} --prefix=${magicprefix} --enable-shared=no --disable-dependency-tracking CFLAGS='-s USE_PTHREADS' LDFLAGS='-lpthread' && \
emmake make && \
emmake make install
check_result
######################
##### expat
######################
cd ${magicdir}/libexpat/expat
./buildconf.sh &&
emconfigure ./configure --without-docbook --host=${CHOST} --prefix=${magicprefix} --enable-shared=no --disable-dependency-tracking CFLAGS='-s USE_PTHREADS' LDFLAGS='-lpthread' && \
emmake make && \
emmake make install
check_result
######################
##### fontconfig
######################
cd ${magicdir}/fontconfig
emconfigure ./autogen.sh --prefix=${magicprefix} && \
emconfigure ./configure --host=${CHOST} --cache-file=enabled --disable-docs --disable-docbook --prefix=${magicprefix} --enable-shared=no --disable-dependency-tracking CFLAGS='-s USE_PTHREADS -pthread' LDFLAGS='-lpthread' && \
emmake make && \
cp fc-cache/fc-cache fc-cache/fc-cache-bak && \
chmod +x fc-cache/fc-cache && \
echo 'exit 0' > fc-cache/fc-cache && \
emmake make install
check_result
######################
##### libffi
######################
cd ${magicdir}/libffi
# the latest source code of libffi has already got emscripten support
# https://github.com/libffi/libffi/pull/763
# but not released yet, so ... the latest commit for me is ac598b7
git checkout ac598b7
./autogen.sh && \
emconfigure ./configure --host=${CHOST} --prefix=${magicprefix} --enable-static --disable-shared --disable-dependency-tracking --disable-builddir --disable-multi-os-directory --disable-raw-api --disable-structs --disable-docs && \
emmake make && \
emmake make install SUBDIRS='include'
check_result
######################
##### glib
######################
cd ${magicdir}/glib
CFLAGS='-s USE_PTHREADS' LDFLAGS='-lpthread' meson setup _build --prefix=${magicprefix} --cross-file=$MESON_CROSS --default-library=static --buildtype=release \
--force-fallback-for=pcre2,gvdb -Dselinux=disabled -Dxattr=false -Dlibmount=disabled -Dnls=disabled \
-Dtests=false -Dglib_assert=false -Dglib_checks=false && \
meson install -C _build
check_result
######################
##### cairo
######################
cd ${magicdir}/cairo
CFLAGS="$(pkg-config --cflags freetype2, fontconfig, expat) -s USE_PTHREADS" LDFLAGS="$(pkg-config --libs freetype2, fontconfig, expat) -lpthread" meson setup _build --prefix=${magicprefix} --cross-file=$MESON_CROSS --default-library=static --buildtype=release -Dtests=disabled && \
meson install -C _build
check_result
######################
##### harfbuzz
######################
cd ${magicdir}/harfbuzz
./autogen.sh && \
emconfigure ./configure --host=${CHOST} --prefix=${magicprefix} --enable-shared=no --disable-dependency-tracking CFLAGS='-s USE_PTHREADS -pthread' LDFLAGS='-lpthread' && \
emmake make && \
emmake make install
check_result
######################
##### reinstall: freetype
##### somebody said I should do this, I don't know why
##### but... fuck it, whatever
######################
cd ${magicdir}/freetype
./autogen.sh && \
emconfigure ./configure --host=${CHOST} --prefix=${magicprefix} --enable-shared=no --disable-dependency-tracking CFLAGS='-s USE_PTHREADS' LDFLAGS='-lpthread' && \
emmake make && \
emmake make install
check_result
######################
##### fribidi
######################
cd ${magicdir}/fribidi
.ci/build-c2man.sh
export PATH=$PATH:${magicdir}/fribidi/c2man/c2man-install
./autogen.sh && \
emconfigure ./configure --host=${CHOST} --prefix=${magicprefix} --enable-shared=no --disable-dependency-tracking CFLAGS='-s USE_PTHREADS -pthread' LDFLAGS='-lpthread' && \
emmake make && \
emmake make install
check_result
######################
##### pango
######################
cd ${magicdir}/pango
# remove test
# because it uses something emscripten don't have?
# like: g_io_channel_unix_new ?
cp meson.build meson.build.original
grep -vwE "subdir\('tests'\)" meson.build.original > meson.build
CFLAGS="$(pkg-config --cflags glib-2.0, cairo, pixman-1, fribidi, freetype2, fontconfig, expat) -s USE_PTHREADS" LDFLAGS="$(pkg-config --libs glib-2.0, cairo, pixman-1, fribidi, freetype2, fontconfig, expat) -lpthread" meson setup _build --prefix=${magicprefix} --cross-file=$MESON_CROSS --default-library=static --buildtype=release -Dintrospection=disabled --force-fallback-for=pcre2,gvdb && \
CFLAGS="$(pkg-config --cflags glib-2.0, cairo, pixman-1, fribidi, freetype2, fontconfig, expat) -s USE_PTHREADS" LDFLAGS="$(pkg-config --libs glib-2.0, cairo, pixman-1, fribidi, freetype2, fontconfig, expat) -lpthread" meson install -C _build
check_result
######################
##### build emscripten ports
######################
embuilder build sdl2 && \
embuilder build sdl2_image && \
embuilder build sdl2_image_jpg && \
embuilder build sdl2_image_png && \
embuilder build sdl2_mixer && \
embuilder build sdl2_mixer_mp3 && \
embuilder build sdl2_mixer_none && \
embuilder build sdl2_net && \
embuilder build sdl2_ttf && \
embuilder build sdl2_gfx && \
embuilder build sdl2-mt && \
embuilder build mpg123 && \
embuilder build ogg
check_result