commit 41081dd
Giacomo Tesio
·
2024-12-12 18:33:49 +0000 UTC
parent 4ea4293
examples: add instructions to statically link snac with musl libc
1 files changed,
+77,
-0
+77,
-0
1@@ -0,0 +1,77 @@
2+# How to build a statically linked Snac with musl
3+
4+Prepare the environment
5+```
6+mkdir build
7+cd build
8+export BUILD_TARGET=$PWD
9+export CC="musl-gcc"
10+```
11+
12+Download and build latest zlib
13+```
14+wget http://zlib.net/current/zlib.tar.gz
15+tar xvf zlib.tar.gz
16+cd zlib-1.3.1/
17+./configure --prefix=$BUILD_TARGET --static
18+make
19+make install
20+cd ..
21+```
22+
23+Download and build latest openssl
24+```
25+wget https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz
26+tar xvf openssl-3.4.0.tar.gz
27+cd openssl-3.4.0
28+CC="musl-gcc -fPIE -pie -static -idirafter /usr/include/ -idirafter /usr/include/x86_64-linux-gnu/" \
29+ ./Configure no-shared no-async --prefix=$BUILD_TARGET --openssldir=$BUILD_TARGET/ssl linux-x86_64
30+make depend
31+make
32+make install
33+cd ..
34+```
35+
36+Download and build latest curl
37+```
38+wget https://curl.se/download/curl-7.88.1.tar.gz
39+tar xvf curl-7.88.1.tar.gz
40+cd curl-7.88.1
41+./configure --disable-shared --enable-static --disable-silent-rules \
42+ --disable-debug --disable-warnings --disable-werror \
43+ --disable-curldebug --disable-symbol-hiding --disable-ares \
44+ --disable-rt --disable-ech --disable-dependency-tracking \
45+ --disable-libtool-lock --enable-http --disable-ftp \
46+ --disable-file --disable-ldap --disable-ldaps \
47+ --disable-rtsp --disable-proxy --disable-dict \
48+ --disable-telnet --disable-tftp --disable-pop3 \
49+ --disable-imap --disable-smb --disable-smtp --disable-gopher \
50+ --disable-mqtt --disable-manual --disable-libcurl-option --disable-ipv6 \
51+ --disable-openssl-auto-load-config --disable-versioned-symbols
52+ --disable-verbose --disable-sspi --disable-crypto-auth \
53+ --disable-ntlm --disable-ntlm-wb --disable-tls-srp \
54+ --disable-unix-sockets --disable-cookies --disable-socketpair \
55+ --disable-http-auth --disable-doh --disable-mime --disable-dateparse \
56+ --disable-netrc --disable-progress-meter --disable-dnsshuffle \
57+ --disable-get-easy-options --disable-alt-svc --disable-websockets \
58+ --without-brotli --without-zstd --without-libpsl --without-libgsasl \
59+ --without-librtmp --without-winidn --disable-threaded-resolver \
60+ --with-openssl=$BUILD_TARGET/ --with-zlib=$BUILD_TARGET/ \
61+ --prefix=$BUILD_TARGET/
62+make
63+make install
64+cd ..
65+```
66+
67+Download and build latest snac2
68+```
69+git clone https://codeberg.org/grunfink/snac2.git # or cd to your existing repo
70+cd snac2
71+make CFLAGS="-g -Wall -Wextra -pedantic -static -DWITHOUT_SHM" \
72+ LDFLAGS="-L$BUILD_TARGET/lib64 -lcurl -lssl -lcrypto -lz" \
73+ PREFIX=$BUILD_TARGET
74+make install PREFIX=$BUILD_TARGET
75+cd ..
76+```
77+
78+Finally a statically linked snac is ready at $BUILD_TARGET/bin