"Fossies" - the Fresh Open Source Software Archive

Member "nnn-4.2/misc/musl/musl-static-ubuntu.sh" (21 Jul 2021, 1843 Bytes) of package /linux/misc/nnn-v4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "musl-static-ubuntu.sh": v4.1.1_vs_v4.2.

    1 #!/usr/bin/env sh
    2 
    3 # Statically compile nnn with netbsd-curses, musl-fts and musl libc on Ubuntu
    4 #
    5 # netbsd-curses: https://github.com/sabotage-linux/netbsd-curses
    6 # musl-fts: https://github.com/void-linux/musl-fts
    7 # musl libc: https://www.musl-libc.org/
    8 #
    9 # Dependencies: git
   10 #
   11 # Usage: musl-static-ubuntu.sh [no_run]
   12 #        # optional argument - do not to execute the binary after compilation
   13 #
   14 # Notes:
   15 #   - run the script within the top-level nnn directory
   16 #   - installs musl & gits netbsd-curses, musl-fts libs
   17 #
   18 # Tested on Ubuntu 20.04 x86_64
   19 # Author: Arun Prakash Jana
   20 
   21 # Exit on first failure
   22 set -e
   23 
   24 # Output binary name
   25 BIN=nnn-musl-static
   26 
   27 # Install musl
   28 sudo apt install -y --no-install-recommends musl musl-dev musl-tools
   29 
   30 # Get netbsd-curses
   31 [ ! -d "./netbsd-curses" ] && git clone https://github.com/sabotage-linux/netbsd-curses
   32 
   33 # Enter the library dir
   34 cd netbsd-curses
   35 
   36 # Get the last known working version
   37 git checkout v0.3.2
   38 
   39 # Compile the static netbsd-curses libraries
   40 if [ ! -d "./libs" ]; then
   41     mkdir libs
   42 else
   43     rm -vf libs/*
   44 fi
   45 make CC=musl-gcc CFLAGS=-O3 LDFLAGS=-static all-static -j$(($(nproc)+1))
   46 cp -v libcurses/libcurses.a libterminfo/libterminfo.a libs/
   47 
   48 # Get musl-fts library
   49 cd ..
   50 [ ! -d "./musl-fts" ] && git clone https://github.com/void-linux/musl-fts --depth=1
   51 
   52 # Compile the static musl-fts library
   53 cd musl-fts
   54 ./bootstrap.sh
   55 ./configure
   56 make CC=musl-gcc CFLAGS=-O3 LDFLAGS=-static -j$(($(nproc)+1))
   57 
   58 # Compile nnn
   59 cd ..
   60 [ -e "./netbsd-curses" ] || rm "$BIN"
   61 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
   62 strip "$BIN"
   63 
   64 if [ -z "$1" ]; then
   65     # Run the binary with it selected
   66     ./"$BIN" -d "$BIN"
   67 fi