2021-05-11 13:36:13 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2021-05-26 18:18:22 +00:00
|
|
|
# Statically compile nnn with netbsd-curses, musl-fts and musl libc on Ubuntu
|
2021-05-11 13:36:13 +00:00
|
|
|
#
|
|
|
|
# netbsd-curses: https://github.com/sabotage-linux/netbsd-curses
|
2021-05-26 18:18:22 +00:00
|
|
|
# musl-fts: https://github.com/void-linux/musl-fts
|
2021-05-11 13:36:13 +00:00
|
|
|
# musl libc: https://www.musl-libc.org/
|
|
|
|
#
|
2021-05-14 03:17:15 +00:00
|
|
|
# Dependencies: git
|
|
|
|
#
|
2021-06-02 23:03:17 +00:00
|
|
|
# Usage: musl-static-ubuntu.sh [no_run]
|
|
|
|
# # optional argument - do not to execute the binary after compilation
|
|
|
|
#
|
2021-05-11 13:36:13 +00:00
|
|
|
# Notes:
|
2021-05-14 03:17:15 +00:00
|
|
|
# - run the script within the top-level nnn directory
|
2021-05-26 18:18:22 +00:00
|
|
|
# - installs musl & gits netbsd-curses, musl-fts libs
|
2021-05-11 13:36:13 +00:00
|
|
|
#
|
|
|
|
# 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
|
2021-05-14 03:17:15 +00:00
|
|
|
[ ! -d "./netbsd-curses" ] && git clone https://github.com/sabotage-linux/netbsd-curses
|
2021-05-11 13:36:13 +00:00
|
|
|
|
2021-05-14 03:17:15 +00:00
|
|
|
# Enter the library dir
|
2021-05-11 13:36:13 +00:00
|
|
|
cd netbsd-curses
|
2021-05-14 03:17:15 +00:00
|
|
|
|
2021-06-12 19:06:45 +00:00
|
|
|
# Get the last known working version
|
|
|
|
git checkout v0.3.2
|
2021-05-14 03:17:15 +00:00
|
|
|
|
|
|
|
# Compile the static netbsd-curses libraries
|
|
|
|
if [ ! -d "./libs" ]; then
|
|
|
|
mkdir libs
|
|
|
|
else
|
|
|
|
rm -vf libs/*
|
|
|
|
fi
|
|
|
|
make CC=musl-gcc CFLAGS=-O3 LDFLAGS=-static all-static -j$(($(nproc)+1))
|
2021-05-11 13:36:13 +00:00
|
|
|
cp -v libcurses/libcurses.a libterminfo/libterminfo.a libs/
|
|
|
|
|
2021-05-26 18:18:22 +00:00
|
|
|
# Get musl-fts library
|
|
|
|
cd ..
|
|
|
|
[ ! -d "./musl-fts" ] && git clone https://github.com/void-linux/musl-fts --depth=1
|
|
|
|
|
|
|
|
# Compile the static musl-fts library
|
|
|
|
cd musl-fts
|
|
|
|
./bootstrap.sh
|
|
|
|
./configure
|
|
|
|
make CC=musl-gcc CFLAGS=-O3 LDFLAGS=-static -j$(($(nproc)+1))
|
|
|
|
|
2021-05-11 13:36:13 +00:00
|
|
|
# Compile nnn
|
|
|
|
cd ..
|
2021-05-12 15:46:18 +00:00
|
|
|
[ -e "./netbsd-curses" ] || rm "$BIN"
|
2021-05-26 18:18:22 +00:00
|
|
|
musl-gcc -O3 -DNORL -DNOMOUSE -std=c11 -Wall -Wextra -Wshadow -I./netbsd-curses/libcurses -I./musl-fts -o "$BIN" src/nnn.c -Wl,-Bsymbolic-functions -lpthread -L./netbsd-curses/libs -lcurses -lterminfo -static -L./musl-fts/.libs -lfts
|
2021-05-11 13:36:13 +00:00
|
|
|
strip "$BIN"
|
|
|
|
|
2021-06-02 23:03:17 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
# Run the binary with it selected
|
|
|
|
./"$BIN" -d "$BIN"
|
|
|
|
fi
|