-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
204 lines (169 loc) · 8.59 KB
/
Makefile
File metadata and controls
204 lines (169 loc) · 8.59 KB
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
# Copyright (c) 2023-2025 Stappler LLC <admin@stappler.dev>
# Copyright (c) 2025 Stappler Team <admin@stappler.org>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
.DEFAULT_GOAL := all
THIS_FILE := $(lastword $(MAKEFILE_LIST))
LIBS_MAKE_FILE := $(realpath $(lastword $(MAKEFILE_LIST)))
LIBS_MAKE_ROOT := $(dir $(LIBS_MAKE_FILE))
SRC_ROOT := $(LIBS_MAKE_ROOT)src
TMP_DIR := $(LIBS_MAKE_ROOT)tmp
XWIN_ROOT := $(LIBS_MAKE_ROOT)xwin
WGET = wget
MKDIR = mkdir -p
TAR_XF = tar -xf
LIBS = \
jpeg \
libjpeg-turbo \
libpng \
giflib \
libwebp \
brotli \
curl \
freetype \
sqlite \
libuidna \
mbedtls \
nghttp3 \
libzip \
zlib \
openssl \
openssl-gost-engine \
wasm-micro-runtime
UNAME := $(shell uname -a)
# DO NOT use MSYS cmake - it's buggy for compiling with clang on windows
MSYS_PREPARE := pacman --noconfirm --needed -S curl wget tar sed unzip git binutils gcc pkg-config
PREPARE := $(if $(filter MSYS_NT%,$(UNAME)),$(MSYS_PREPARE))
get_tar_top_dir = `tar -tf $(1) | head -1 | cut -f1 -d"/"`
unpack_tar = $(MKDIR) $(SRC_ROOT) $(TMP_DIR); \
cd $(TMP_DIR); \
$(WGET) -O $(notdir $(1)) $(1); \
$(TAR_XF) $(notdir $(1)); \
mv -f $(call get_tar_top_dir,$(notdir $(1))) $(SRC_ROOT)/$(firstword $(2)); \
rm $(notdir $(1))
prepare:
$(PREPARE)
all: $(addprefix $(SRC_ROOT)/,$(LIBS)) replacements/curl/cacert.pem
all:
rm -rf $(TMP_DIR)
clean:
rm -rf $(SRC_ROOT) $(XWIN_ROOT) $(TMP_DIR) replacements/curl/cacert.pem
# https://www.zlib.net/
$(SRC_ROOT)/zlib: prepare
$(call unpack_tar, https://www.zlib.net/zlib-1.3.1.tar.gz, zlib) # revised: 11 aug 2025
# http://www.ijg.org/
$(SRC_ROOT)/jpeg: prepare
$(call unpack_tar, http://ijg.org/files/jpegsrc.v9f.tar.gz, jpeg) # revised: 11 aug 2025
# https://github.com/libjpeg-turbo/libjpeg-turbo/releases
$(SRC_ROOT)/libjpeg-turbo: prepare
$(call unpack_tar, https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/3.1.1/libjpeg-turbo-3.1.1.tar.gz, libjpeg-turbo) # revised: 19 aug 2025
# http://www.libpng.org/pub/png/libpng.html
$(SRC_ROOT)/libpng: prepare
$(call unpack_tar, http://prdownloads.sourceforge.net/libpng/libpng-1.6.50.tar.xz, libpng) # revised: 11 aug 2025
# https://sourceforge.net/projects/giflib/files/latest/download
$(SRC_ROOT)/giflib: prepare
$(call unpack_tar, https://altushost-swe.dl.sourceforge.net/project/giflib/giflib-5.2.2.tar.gz, giflib) # revised: 11 aug 2025
# https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html
$(SRC_ROOT)/libwebp: prepare
$(call unpack_tar, https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.6.0.tar.gz, libwebp) # revised: 11 aug 2025
# https://github.com/google/brotli/releases
$(SRC_ROOT)/brotli: prepare
$(call unpack_tar, https://github.com/google/brotli/archive/refs/tags/v1.1.0.tar.gz, brotli) # revised: 11 aug 2025
# https://github.com/Mbed-TLS/mbedtls/releases
$(SRC_ROOT)/mbedtls: prepare
$(call unpack_tar, https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.4/mbedtls-3.6.4.tar.bz2, mbedtls) # revised: 11 aug 2025
# https://github.com/ngtcp2/nghttp3/releases
$(SRC_ROOT)/nghttp3: prepare
$(call unpack_tar, https://github.com/ngtcp2/nghttp3/releases/download/v1.11.0/nghttp3-1.11.0.tar.xz, nghttp3) # revised: 11 aug 2025
# https://curl.se/download.html
$(SRC_ROOT)/curl: prepare
$(call unpack_tar, https://curl.se/download/curl-8.15.0.tar.xz, curl) # revised: 11 aug 2025
# https://download.savannah.gnu.org/releases/freetype/?C=M&O=D
$(SRC_ROOT)/freetype: prepare
$(call unpack_tar, https://download.savannah.gnu.org/releases/freetype/freetype-2.13.3.tar.xz, freetype) # revised: 11 aug 2025
# https://www.sqlite.org/download.html
$(SRC_ROOT)/sqlite: prepare
@$(MKDIR) $(SRC_ROOT) $(TMP_DIR)
cd $(TMP_DIR); $(WGET) https://www.sqlite.org/2025/sqlite-amalgamation-3500400.zip # revised: 11 aug 2025
cd $(TMP_DIR); unzip sqlite-amalgamation-3500400.zip -d .
rm $(TMP_DIR)/sqlite-amalgamation-3500400.zip
mv -f $(TMP_DIR)/sqlite-amalgamation-3500400 $(SRC_ROOT)/sqlite
# https://github.com/SBKarr/libuidna
$(SRC_ROOT)/libuidna: prepare
@$(MKDIR) $(SRC_ROOT)
rm -rf $(SRC_ROOT)/libuidna
cd $(SRC_ROOT); git clone https://github.com/SBKarr/libuidna.git $(SRC_ROOT)/libuidna # use upstream: 11 aug 2025
# https://libzip.org/download/
$(SRC_ROOT)/libzip: prepare
$(call unpack_tar, https://libzip.org/download/libzip-1.11.4.tar.xz, libzip) # revised: 11 aug 2025
# https://openssl-library.org/source/index.html
$(SRC_ROOT)/openssl: prepare
$(call unpack_tar, https://github.com/openssl/openssl/releases/download/openssl-3.5.2/openssl-3.5.2.tar.gz, openssl) # revised: 11 aug 2025
cp -f replacements/openssl/async_posix.c $(SRC_ROOT)/openssl/crypto/async/arch/async_posix.c
# https://github.com/gost-engine/engine
$(SRC_ROOT)/openssl-gost-engine: prepare
@$(MKDIR) $(SRC_ROOT)
rm -rf $(SRC_ROOT)/openssl-gost-engine
cd $(SRC_ROOT); git clone --recurse-submodules https://github.com/gost-engine/engine.git --depth 1 openssl-gost-engine # revised: 11 aug 2025
cp -f replacements/openssl-gost-engine/CMakeLists.txt $(SRC_ROOT)/openssl-gost-engine
# https://github.com/bytecodealliance/wasm-micro-runtime
$(SRC_ROOT)/wasm-micro-runtime: prepare
@$(MKDIR) $(SRC_ROOT)
rm -rf $(SRC_ROOT)/wasm-micro-runtime
cd $(SRC_ROOT); git clone --recurse-submodules --branch WAMR-2.4.1 https://github.com/bytecodealliance/wasm-micro-runtime.git --depth 1 wasm-micro-runtime # revised: 10 feb 2025
# cd $(SRC_ROOT)/wasm-micro-runtime; git apply ../../replacements/wamr/0001-Initial-e2k-support.patch
# cd $(SRC_ROOT)/wasm-micro-runtime; git apply ../../replacements/wamr/0002-Windows-clang-fixes.patch
# Inject Russia Ministry of Digital Development certificates
# https://curl.se/ca
# https://www.gosuslugi.ru/crt
replacements/curl/cacert.pem: prepare $(LIBS_MAKE_FILE)
@$(MKDIR) replacements/curl
cd $(TMP_DIR); wget https://curl.se/ca/cacert-2025-08-12.pem # revised: 19 aug 2025
printf "\nhttps://www.gosuslugi.ru/crt - Root\n====================\n" > $(TMP_DIR)/russian_trusted_root_ca_pem.crt.txt
cd $(TMP_DIR); wget https://gu-st.ru/content/lending/russian_trusted_root_ca_pem.crt
printf "\nhttps://www.gosuslugi.ru/crt - Sub\n====================\n" > $(TMP_DIR)/russian_trusted_sub_ca_pem.crt.txt
cd $(TMP_DIR); wget https://gu-st.ru/content/lending/russian_trusted_sub_ca_pem.crt
printf "\nhttps://www.gosuslugi.ru/crt - Sub 2024\n====================\n" > $(TMP_DIR)/russian_trusted_sub_ca_2024_pem.crt.txt
cd $(TMP_DIR); wget https://gu-st.ru/content/lending/russian_trusted_sub_ca_2024_pem.crt
cd replacements/curl; cat \
$(TMP_DIR)/cacert-2025-08-12.pem \
$(TMP_DIR)/russian_trusted_root_ca_pem.crt.txt \
$(TMP_DIR)/russian_trusted_root_ca_pem.crt \
$(TMP_DIR)/russian_trusted_sub_ca_pem.crt.txt \
$(TMP_DIR)/russian_trusted_sub_ca_pem.crt \
$(TMP_DIR)/russian_trusted_sub_ca_2024_pem.crt.txt \
$(TMP_DIR)/russian_trusted_sub_ca_2024_pem.crt > cacert.pem
@rm \
$(TMP_DIR)/cacert-2025-08-12.pem \
$(TMP_DIR)/russian_trusted_root_ca_pem.crt.txt \
$(TMP_DIR)/russian_trusted_root_ca_pem.crt \
$(TMP_DIR)/russian_trusted_sub_ca_pem.crt.txt \
$(TMP_DIR)/russian_trusted_sub_ca_pem.crt \
$(TMP_DIR)/russian_trusted_sub_ca_2024_pem.crt.txt \
$(TMP_DIR)/russian_trusted_sub_ca_2024_pem.crt
# https://github.com/Jake-Shadle/xwin/releases
xwin: prepare
@$(MKDIR) $(SRC_ROOT)
$(WGET) https://github.com/Jake-Shadle/xwin/releases/download/0.6.5/xwin-0.6.5-x86_64-unknown-linux-musl.tar.gz # revised: 10 feb 2025
$(TAR_XF) xwin-0.6.5-x86_64-unknown-linux-musl.tar.gz
rm xwin-0.6.5-x86_64-unknown-linux-musl.tar.gz
mv xwin-0.6.5-x86_64-unknown-linux-musl xwin
cd xwin; ./xwin --accept-license unpack; ./xwin --accept-license splat
mv xwin/.xwin-cache/splat xwin/splat
.PHONY: all clean prepare