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