From 29ef23230197faf2b125b9abb8e16f14a7f83769 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Thu, 3 Jun 2021 04:33:17 +0530 Subject: [PATCH] Add Makefile target to compile nnn with musl libc --- Makefile | 16 +++++++++++++--- misc/musl/musl-static-ubuntu.sh | 9 +++++++-- patches/README.md | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index fe9ef383..c2517fd7 100644 --- a/Makefile +++ b/Makefile @@ -205,6 +205,11 @@ static: make O_STATIC=1 O_NERD=1 strip mv $(BIN) $(BIN)-nerd-static +musl: + cp misc/musl/musl-static-ubuntu.sh . + ./musl-static-ubuntu.sh 1 + rm ./musl-static-ubuntu.sh + dist: mkdir -p nnn-$(VERSION) $(CP) -r $(DISTFILES) nnn-$(VERSION) @@ -216,23 +221,23 @@ sign: gpg --detach-sign --yes nnn-$(VERSION).tar.gz rm -f nnn-$(VERSION).tar.gz -upload-local: sign static +upload-local: sign static musl-static $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id)) # upload sign file curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \ -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \ --upload-file nnn-$(VERSION).tar.gz.sig - tar -zcf $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-static # upx compress all static binaries upx -qqq $(BIN)-static upx -qqq $(BIN)-icons-static upx -qqq $(BIN)-nerd-static # upload static binary + tar -zcf $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-static curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-static-$(VERSION).x86_64.tar.gz' \ -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \ --upload-file $(BIN)-static-$(VERSION).x86_64.tar.gz - tar -zcf $(BIN)-icons-static-$(VERSION).x86_64.tar.gz $(BIN)-icons-static # upload icons-in-terminal compiled static binary + tar -zcf $(BIN)-icons-static-$(VERSION).x86_64.tar.gz $(BIN)-icons-static curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-icons-static-$(VERSION).x86_64.tar.gz' \ -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \ --upload-file $(BIN)-icons-static-$(VERSION).x86_64.tar.gz @@ -241,6 +246,11 @@ upload-local: sign static curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-nerd-static-$(VERSION).x86_64.tar.gz' \ -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \ --upload-file $(BIN)-nerd-static-$(VERSION).x86_64.tar.gz + # upload musl static binary + tar -zcf $(BIN)-musl-static-$(VERSION).x86_64.tar.gz $(BIN)-musl-static + curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-musl-static-$(VERSION).x86_64.tar.gz' \ + -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \ + --upload-file $(BIN)-musl-static-$(VERSION).x86_64.tar.gz clean: $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig $(BIN)-static $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-icons-static $(BIN)-icons-static-$(VERSION).x86_64.tar.gz $(BIN)-nerd-static $(BIN)-nerd-static-$(VERSION).x86_64.tar.gz diff --git a/misc/musl/musl-static-ubuntu.sh b/misc/musl/musl-static-ubuntu.sh index f8351aa2..6e0f63d8 100755 --- a/misc/musl/musl-static-ubuntu.sh +++ b/misc/musl/musl-static-ubuntu.sh @@ -8,6 +8,9 @@ # # Dependencies: git # +# Usage: musl-static-ubuntu.sh [no_run] +# # optional argument - do not to execute the binary after compilation +# # Notes: # - run the script within the top-level nnn directory # - installs musl & gits netbsd-curses, musl-fts libs @@ -58,5 +61,7 @@ cd .. 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 strip "$BIN" -# Run the binary with it selected -./"$BIN" -d "$BIN" +if [ -z "$1" ]; then + # Run the binary with it selected + ./"$BIN" -d "$BIN" +fi diff --git a/patches/README.md b/patches/README.md index 316e4c80..67e85fec 100644 --- a/patches/README.md +++ b/patches/README.md @@ -6,7 +6,7 @@ The patches will be adapted on each release when necessary (v4.1 onwards). Each ## List of patches | Patch (a-z) | Description | Make var | -| --- | --- | --- | --- | +| --- | --- | --- | | gitstatus | Add git status column to the detail view. Requires [libgit2](https://github.com/libgit2/libgit2). | `O_GISTATUS` | | namefirst | Print filenames first in the detail view. Print user/group columns when a directory contains different users/groups. | `O_NAMEFIRST` |