]> Sergey Matveev's repositories - nnn.git/commitdiff
Compilation script for netbsd-curses + musl libc
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 11 May 2021 13:36:13 +0000 (19:06 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 11 May 2021 13:36:13 +0000 (19:06 +0530)
misc/musl/musl-static-ubuntu.sh [new file with mode: 0755]

diff --git a/misc/musl/musl-static-ubuntu.sh b/misc/musl/musl-static-ubuntu.sh
new file mode 100755 (executable)
index 0000000..bc54ede
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/env sh
+
+# Statically compile nnn with netbsd-curses and musl libc on Ubuntu
+#
+# netbsd-curses: https://github.com/sabotage-linux/netbsd-curses
+# musl libc: https://www.musl-libc.org/
+#
+# Notes:
+#   - Run the script within the top-level nnn directory
+#   - installs musl and downloads netbsd-curses library
+#
+# Tested on Ubuntu 20.04 x86_64
+# Author: Arun Prakash Jana
+
+# Exit on first failure
+set -e
+
+# Output binary name
+BIN=nnn-musl-static
+
+# Install musl
+sudo apt install -y --no-install-recommends musl musl-dev musl-tools
+
+# Get netbsd-curses
+[ ! -d "./netbsd-curses" ] && git clone https://github.com/sabotage-linux/netbsd-curses --depth=1
+
+# Compile the static libraries
+cd netbsd-curses
+[ ! -d "./libs" ] && mkdir libs || rm -vf libs/*
+make CC=musl-gcc CFLAGS=-O3 LDFLAGS=-static all-static -j$((`nproc`+1))
+cp -v libcurses/libcurses.a libterminfo/libterminfo.a libs/
+
+# Compile nnn
+cd ..
+rm "$BIN"
+musl-gcc -O3 -DNORL -I./netbsd-curses/libcurses -o "$BIN" src/nnn.c -Wl,-Bsymbolic-functions -L./netbsd-curses/libs -lcurses -lterminfo -static
+strip "$BIN"
+
+# Run the binary with it selected
+./"$BIN" -d "$BIN"