[Android Software/Hacking General [Developers Only]] osm0sis:
Here are all my dirty tricks to get nano building. I cheated pretty hard and used a prebuilt static arm libncurses.a. ;)

curses.h: http://www.opensource.apple.com/source/ncurses/ncurses-36/ncurses/include/curses.h?txt
ncurses_dll.h: http://www.opensource.apple.com/source/ncurses/ncurses-36/ncurses/include/ncurses_dll.h?txt
unctrl.h: http://www.opensource.apple.com/source/ncurses/ncurses-36/ncurses/include/unctrl.h?txt

libncurses.a (prebuilt): http://www.kevinboone.net/ncurses-5.9_kbox3.deb:/data.tar.gz:/./usr/lib/libncurses.a
(the above headers can also be taken from this .deb)

getpwent.c: https://kernel.googlesource.com/pub/scm/fs/ext2/xfstests-bld/+/master/android-compat/getpwent.c

pty.c: https://raw.githubusercontent.com/CyanogenMod/android_external_busybox/cm-13.0/android/libc/pty.c

git clone http://git.savannah.gnu.org/r/nano;
cd nano; git checkout -f $(git describe --tags `git rev-list --tags --max-count=1`);
# hack to use last working gnulib revision for Cygwin/NDK
sed -i 's|gnulib_hash=.*|gnulib_hash="87e6634b28df65084321fed22f60d114a0931d21"|' autogen.sh;
./autogen.sh;

//modified by osm0sis (//hack)

src/pty.c:
//hack int ptsname_r(int fd, char* buf, size_t len) {
int bb_ptsname_r(int fd, char* buf, size_t len) {

src/prototypes.h:
//hack to work around bionic stubs
#define ptsname_r bb_ptsname_r
//#define ttyname bb_ttyname //No longer needed on NDK API 21?
#define ttyname_r bb_ttyname_r

src/rcfile.c:
//hack extra default rcfile search dirs
have_nanorc("/sdcard", "/" HOME_RC_NAME) ||
have_nanorc("/sdcard", "/" RCFILE_NAME) ||

export PATH="/home/Chris/x-tools/arm-linux-androideabi-4.9/bin:$PATH";
./configure --host=arm-linux-androideabi --disable-browser --disable-extra --disable-histories --disable-justify --disable-libmagic --disable-mouse --disable-nls --disable-operatingdir --disable-speller --disable-wrapping-as-root LD=arm-linux-androideabi-ld LDFLAGS="-static -Wl,--gc-sections" CFLAGS="-D__ANDROID_API__=21 -O3 -ffunction-sections -s";
make LIBS="getpwent.c pty.c libncurses.a";

Here's my actual "engineering" (read: hacky :p) build script which can update, patch the new prototypes.h and rcfile.c, config and build.

~/nano-build.sh:

#!/bin/bash
# yipyip!

# nano-build.sh
#
# osm0sis @ xda-developers
#
# requires (in addition to the default basic Ubuntu WSL packages):
# make, automake, autopoint, pkg-config, gettext, groff, texinfo, zip, default-jre

RC=0;
MAGISK=$HOME/magisk-modules;

bold() { echo -e "\033[1m"$@"\033[0m"; }

reset() {
bold "--- Removing nano-ndk build environment ...";
rm -rfv $MAGISK/UPDATE-nano.Terminal.Editor* $HOME/android-nano-ndk $(dirname $HOME/nano*/.git)/ zipsigner-*.jar nano-*.zip UPDATE-nano.Terminal.Editor.*-signed.zip;
rmdir $MAGISK 2>/dev/null;
}

ncurses() {
local cflags host ldflags ncurses tarball;
ncurses=$(readlink -f `find $HOME -maxdepth 1 -type d -name 'ncurses*'` 2>/dev/null);
tarball=$(wget -qO- "https://ftp.gnu.org/gnu/ncurses" | grep -o 'ncurses-.*.gz"' | tail -n1 | cut -d\" -f1);
if [ ! "$ncurses" -o "$ncurses" != "$HOME/$(basename $tarball .tar.gz)" ]; then
bold "- Downloading and unpacking latest ncurses source tarball ...";
rm -rf $ncurses;
wget -O $tarball "https://ftp.gnu.org/gnu/ncurses/$tarball";
tar -xzvf $tarball;
rm -f $tarball;
fi;
cd ncurses-*;
cflags="-D__ANDROID_API__=21 -ffunction-sections -O3";
ldflags="-Wl,--gc-sections -s -static";
opts="--enable-widec --disable-nls --without-manpages --without-progs --without-tests";
for host in arm-linux-androideabi aarch64-linux-android; do
export PATH="$(echo $HOME/x-tools/$host* | rev | cut -d\ -f1 | rev)/bin:$PATH";
if [ ! -e config.$host ]; then
bold "--- Configuring $host ...";
./configure CFLAGS="$cflags" LDFLAGS="$ldflags" --host=$host --target=$host $opts;
export RC=$?;
cp -f config.status config.$host;
fi;
bold "--- Building $host ...";
cp -f config.$host config.status;
./config.status;
make;
export RC=$?;
mkdir -p $HOME/android-nano-ndk/ncursesw/include $HOME/android-nano-ndk/ncursesw/lib/$host;
cp -fv include/curses.h include/ncurses_dll.h include/term.h include/unctrl.h $HOME/android-nano-ndk/ncursesw/include;
cp -fv lib/libncursesw.a $HOME/android-nano-ndk/ncursesw/lib/$host;
done;
}

init() {
local file tarball zipsigner;
reset;
bold "--- Initializing nano-ndk build environment ...";
bold "- Cloning official nano git repository at HEAD ...";
git clone https://git.savannah.gnu.org/git/nano.git;

bold "- Cloning nano-ndk installer git repository ...";
mkdir -p $MAGISK;
git clone https://github.com/Magisk-Modules-Repo/nano-ndk $MAGISK/UPDATE-nano.Terminal.Editor;

bold "- Downloading and unpacking latest ncurses source tarball ...";
tarball=$(wget -qO- "https://ftp.gnu.org/gnu/ncurses" | grep -o 'ncurses-.*.gz"' | tail -n1 | cut -d\" -f1);
wget -O $tarball "https://ftp.gnu.org/gnu/ncurses/$tarball";
tar -xzvf $tarball;
rm -f $tarball;

bold "- Downloading and patching code extensions for Android compatibility ...";
mkdir -p $HOME/android-nano-ndk/src;
cd $HOME/android-nano-ndk/src;
wget -O android-compat.tar.gz https://kernel.googlesource.com/pub/scm/fs/ext2/xfstests-bld/+archive/refs/heads/master/fstests-bld/android-compat.tar.gz;
tar -xzf android-compat.tar.gz getpwent.c;
rm -f android-compat.tar.gz;
wget -O pty.c https://raw.githubusercontent.com/CyanogenMod/android_external_busybox/cm-13.0/android/libc/pty.c;
sed -i 's|int ptsname_r|//hack int ptsname_r(int fd, char* buf, size_t len) {\nint bb_ptsname_r|' pty.c;
wget -o /dev/null -O ../readme.html https://forum.xda-developers.com/showpost.php?p=66486572&postcount=671;

bold "- Downloading zipsigner ...";
# GitHub tree parsing broken since they added the Files sidebar
#zipsigner=$(wget -qO- https://github.com/opengapps/opengapps/tree/master/scripts/zipsigner-resources | grep -o 'opengapps/.*jar' | cut -d\" -f1 | sed 's/blob/raw/');
zipsigner="opengapps/opengapps/raw/master/scripts/zipsigner-resources/zipsigner-2.2.jar";
wget -O $HOME/$(basename $zipsigner) https://github.com/$zipsigner;
ncurses;
}

update() {
local curtag protoline rcline;
bold "--- Updating nano-ndk ...";
git fetch --tags;
if [ "$BRANCH" ]; then
curtag=$BRANCH;
else
curtag=$(git describe --tags `git rev-list --tags --max-count=1`);
fi;
bold "- Downloading latest official nano sources at $curtag ... ";
git reset -- . > /dev/null;
git clean -df > /dev/null;
git checkout -- .;
git checkout -f $curtag 2>&1 | tail -n 1;

bold "- Setting up repository and patching for Android ...";
cp -rf $HOME/android-nano-ndk android;
cp -rf android/src/* src/;
# hack to fix gnulib after 87e6634b28df65084321fed22f60d114a0931d21 for Cygwin/NDK
#cd gnulib;
#git reset -- . > /dev/null;
#git clean -df > /dev/null;
#git checkout -- .;
#cd ..;
#./autogen.sh;
#sed -i "s/gl_options=\`grep -v '#' conftest.out\`/gl_options=\`grep -v '#' conftest.out | tr -d '\\\r'\`/" gnulib/m4/gnulib-common.m4;
##
./autogen.sh;
protoline=$((`grep -n "definitions.h" src/prototypes.h | head -n1 | cut -d: -f1` + 1));
sed -i "${protoline}s;^;\n//hack to work around bionic stubs\n#define ptsname_r bb_ptsname_r\n//#define ttyname bb_ttyname\n#define ttyname_r bb_ttyname_r\n;" src/prototypes.h;
rcline=$((`grep -n "if (have_nanorc(homedir," src/rcfile.c | head -n1 | cut -d: -f1` + 1));
sed -i "${rcline}s;^;\t\t\t\t\thave_nanorc(\"/sdcard\", \"/\" HOME_RC_NAME) ||\n\t\t\t\t\thave_nanorc(\"/sdcard\", \"/\" RCFILE_NAME) ||\n;" src/rcfile.c;
if [ "nano-${curtag//v/}" != "$(basename $PWD)" ]; then
cd $HOME;
mv -f $NANO nano-${curtag//v/};
fi;
}

config() {
local host opts ldflags cflags;
cflags="-D__ANDROID_API__=21 -O3 -ffunction-sections -s -I$HOME/android-nano-ndk/ncursesw/include";
opts="--disable-browser --disable-extra --disable-histories --disable-justify --disable-libmagic --disable-mouse --disable-nls --disable-operatingdir --disable-speller";
for host in arm-linux-androideabi aarch64-linux-android; do
bold "--- Configuring $host ...";
export PATH="$(echo $HOME/x-tools/$host* | rev | cut -d\ -f1 | rev)/bin:$PATH";
ldflags="-static -Wl,--gc-sections -L$HOME/android-nano-ndk/ncursesw/lib/$host";
./configure --host=$host $opts LD=$host-ld LDFLAGS="$ldflags" CFLAGS="$cflags";
export RC=$?;
cp -f config.status config.$host;
done;
}

clean() {
bold "--- Cleaning ...";
make clean;
export RC=$?;
}

build() {
local host;
for host in arm-linux-androideabi aarch64-linux-android; do
bold "--- Building $host ...";
export PATH="$(echo $HOME/x-tools/$host* | rev | cut -d\ -f1 | rev)/bin:$PATH";
cp -f config.$host config.status;
./config.status;
make LIBS="getpwent.c pty.c -lncursesw";
export RC=$?;
case $host in
arm*) cp -fpv src/nano src/nano-arm;;
aarch64*) cp -fpv src/nano src/nano-arm64;;
esac;
make clean;
done;
}

bundle() {
local ver curdir modver modcode newmodver newmodcode iteration skipmodprop;
bold "--- Bundling ...";
rm -f nano-*.zip UPDATE-nano.Terminal.Editor.*-signed.zip 2>/dev/null;
ver=$(echo "$NANO" | cut -d- -f2);
if [ -f "$NANO/src/nano-arm" -a -f "$NANO/src/nano-arm64" ]; then
bold "- Copying new nano $ver builds ...";
curdir=$(basename $MAGISK/UPDATE-nano.Terminal.Editor*);
cp -fp $NANO/src/nano-arm $MAGISK/$curdir/bin/nano.bin-arm;
cp -fp $NANO/src/nano-arm64 $MAGISK/$curdir/bin/nano.bin-arm64;
if [ "$curdir" != "UPDATE-nano.Terminal.Editor.v$ver" ]; then
mv $MAGISK/$curdir $MAGISK/UPDATE-nano.Terminal.Editor.v$ver;
fi;
fi;
modver=$(grep -o "^version=.*$" $MAGISK/UPDATE-nano.Terminal.Editor.*/module.prop | cut -d= -f2);
modcode=$(grep -o "^versionCode=.*$" $MAGISK/UPDATE-nano.Terminal.Editor.*/module.prop | cut -d= -f2);
if [ "$ver" == "$modver" ]; then
newmodver="$modver";
newmodcode="$((modcode + 1))";
iteration=1;
else
newmodver="$ver";
newmodcode="${ver//.}0";
test ${#newmodcode} == 3 && newmodcode="$newmodcode"0;
fi;
if [ "$iteration" ]; then
echo -ne "\033[1m\n*** Update Magisk module version code ($modcode -> $newmodcode) (y/n)? \033[0m";
read n; echo;
case $n in
Y|y) ;;
*) skipmodprop=1;;
esac;
fi;
if [ ! "$skipmodprop" ]; then
sed -i -e "s/version=.*/version=$newmodver/" -e "s/versionCode=.*/versionCode=$newmodcode/" $MAGISK/UPDATE-nano.Terminal.Editor.*/module.prop;
sed -i -e "s/version\".*/version\": \"$newmodver\",/" -e "s/versionCode\".*/versionCode\": \"$newmodcode\",/" $MAGISK/UPDATE-nano.Terminal.Editor.*/update.json;
fi;

bold "- Packing \"nano-$ver.zip\" ...";cd
cd $MAGISK/UPDATE-nano.Terminal.Editor.*;
zip -9 -x .git -x .github -x update.json -r -q $HOME/nano-$ver.zip *;
cd $HOME;

bold "- Signing as \"UPDATE-nano.Terminal.Editor.v$ver-signed.zip\" ...";
java -jar zipsigner-*.jar nano-$ver.zip nano-$ver-signed.zip;
mv -f nano-$ver-signed.zip UPDATE-nano.Terminal.Editor.v$ver-signed.zip 2>/dev/null;
rm -f nano-*.zip /tmp/signAPK*.tmp 2>/dev/null;
}

test ! "$1" && set -- help;
until [ ! $1 ]; do
NANO=$(readlink -f `find $HOME -maxdepth 1 -type d -name 'nano*'` 2>/dev/null);
if [ ! "$NANO" ]; then
case $1 in
help|init|reset) ;;
*) echo "nano-build: nano repo not found, run 'init' option"; exit 1;;
esac;
elif [ "$NANO" == "$HOME/nano" -o ! -f "$NANO/configure" ]; then
case $1 in
help|init|reset|update|all) ;;
*) echo "nano-build: nano repo not patched, run 'update' or 'all' option"; exit 1;;
esac;
elif [ ! -d "$HOME/android-nano-ndk/ncursesw" ]; then
case $1 in
help|init|ncurses|reset) ;;
*) echo "nano-build: ncursesw not built, run 'init' or 'ncurses' option"; exit 1;;
esac;
fi;
case $1 in
ncurses|config|build) SAVEDPATH="$PATH";;
esac;
case $1 in
init|reset|ncurses|bundle) cd $HOME; $1;;
update|config|clean|build) cd $NANO; $1;;
all) set -- "$0" update config clean build bundle;;
help) echo "nano-build.sh init ncurses update config build bundle all clean reset"; exit 1;;
*) echo "nano-build: invalid option -- '$*'"; exit 1;;
esac;
case $1 in
ncurses|config|build) export PATH="$SAVEDPATH";;
esac;
shift;
done;

exit $RC;

The above script does pretty much everything for you now, so... 👍🤠