Created
September 1, 2023 23:24
-
-
Save mdawaffe/c9ce621ceb62a1409a3ad3b07f91c497 to your computer and use it in GitHub Desktop.
Statically Compiling Nano
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I was targeting a machine using this version of Debian. Hopefully, you're targeting something newer. | |
docker run --rm -it debian:stretch bash | |
# This version of Debian is old enough that the package list has been moved to the archives. | |
# You may not need to do this. | |
# Note: if you're using a backports distribution, you'll need to do the same for /etc/apt/sources.list.d/* | |
sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list | |
apt update # Some errors. Seems fine? | |
# aptitude is easier to use if there are problems/conflicts. | |
apt install aptitude | |
aptitude install git autoconf automake autopoint gcc gettext groff make pkg-config texinfo libncurses-dev libncursesw5-dev libgpm-dev file | |
git clone git://git.savannah.gnu.org/nano.git | |
cd nano | |
git checkout v7.2 # Or whatever tag | |
# See https://git.savannah.gnu.org/cgit/nano.git/tree/README.hacking | |
./autogen.sh | |
# No idea what I'm doing here :) I just mashed buttons until it worked. | |
# LIBS, in particular was annoying: the order is important, so I ended up duplicating ncursesw and tinfo here | |
# (both of which are already included in nano's build scripts). No doubt there's a better way. | |
./configure CFLAGS="-O2 -Wall -static" LDFLAGS="-static" LIBS="-lncursesw -ltinfo -lgpm" | |
make | |
file src/nano # verify that it worked and is statically linked | |
# On the host, not the Docker container. (In another terminal. Don't log out of the docker container yet!) | |
docker cp /nano/src/nano . # or whatever paths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment