[Android Software Development] DualJoe:
Changelog:

20201216 - Added aarch64 files

Info:

- Download the attached file below and patch it like this:

- Fix username/path in *.cmake files.

- Fix OUTPUT path in 'config.mak.64'.

- Rename 'config.mak.64' to 'config.mak' to compile aarch64 musl toolchain.

Sure, it's open-source. But thanks for asking. :sneaky:

Compiling might be somewhat tricky. You're not the first one asking for that so I will try to explain the essential steps:

- For reference: Environment folder/file structure (this is how i have placed the files).

${HOME}/android/gcc-musl_wrapper-hf.sh
${HOME}/android/gcc-musl_wrapper-aarch64.sh
${HOME}/android/gcc-musl-hf (linked to ${HOME}/android/musl-cross-make/output)
${HOME}/android/gcc-musl-aarch64 (linked to ${HOME}/android/musl-cross-make/output64)
${HOME}/android/sysroot-armhf {SYSROOT}
${HOME}/android/sysroot-aarch64 {SYSROOT}
${HOME}/android/musl-cross-make/patches/musl-1.2.1/musl-android-smp.patch
${HOME}/android/cmake-toolchain.cmake
${HOME}/android/cmake-toolchain64.cmake

- use musl-cross-make as toolchain (an important smp patch for Android is attached below. Description is on the 1st post). A preconfigured config.mak is attached as well (to build the toolchain for armhf). Place it beside the config.mak.dist file and compile the toolchain.

$ cd ${HOME}/android/musl-cross-make
- copy musl-android-smp.patch to musl-cross-make/patches/musl-1.2.1
(this folder name is dynamic. See 'musl-cross-make/Makefile' (top area) for musl version.)
$ make -j4 && make install
- files will be placed into musl-cross-make/output

- link the toolchain

ln -s ~/android/musl-cross-make/output ~/android/gcc-musl-hf

- "source" the attached helper script (gcc-musl_wrapper-hf.sh).

$ source ~/android/gcc-musl_wrapper-hf.sh

- Quick test if the toolchain is working:

$ $CC --version
arm-linux-musleabihf-gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

- build the dependencies (rlog-dev libressl-dev fuse-dev boost-dev libtool gettext-dev) and put the compiled headers/libs (not the sourcecode!) into ${SYSROOT} folder (see below for compile example). I usually look for download addresses and patches in Alpine APKBUILD files. The dependencies might need additional dependencies as well. I've taken the 'boost' binaries from Alpine Linux directly (*.a and *.h files) as they are a mess of its own to compile (custom build system) and luckily Alpine provides precompiled static libs.

http://dl-cdn.alpinelinux.org/alpine/edge/main/armhf/boost-dev-1.67.0-r2.apk

http://dl-cdn.alpinelinux.org/alpine/edge/main/armhf/boost-static-1.67.0-r2.apk

(can be extracted with tar/gzip)

- Apply ARM patches when available (e.g. for Alpine/libressl go here and click on 'Git repository' or look on the Termux repo).

- Patches can be applied with:

for i in *.patch; do patch -p1 -N -i $i; done

- Some more custom encfs patches:

CMakeLists.txt:
link_libraries("-static")
add_executable (encfs-bin encfs/main.cpp)

encfs-1.9.5/test/Cipher_test.cpp (needed only for "checkops" binary):
encfs-1.9.5/encfs/test.cpp
"/tmp/encfstestXXXXXX"; -> "/dev/encfstestXXXXXX";

- build: (cmake-toolchain.cmake is attached)

git clone https://github.com/vgough/encfs.git && cd encfs
- apply patches (from above)
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=~/android/cmake-toolchain.cmake -DRUN_HAVE_STD_REGEX=0 -DRUN_HAVE_POSIX_REGEX=0 -DRUN_HAVE_STEADY_CLOCK=0 -DBUILD_STATIC_LIBS=1 ..
make -j4

- Done! Binaries should be in the folder. :)

- Building dependencies or generic binaries:

# rlog 1.4
# http://www.arg0.net/rlog
./configure --host=${CROSS_COMPILE} --prefix=${SYSROOT}/usr --enable-static
make -j4
make install DESTDIR=/tmp/myout DEST_HOME=/tmp/myout/usr DEST_MAN=/tmp/myout/usr/share/man

- files are in /tmp/myout. Copy to ${SYSROOT}.

- Alternative command to enforce static linking. Might break the compile process needing additional intervention (patching 'make' file or manual compilation of the libs with enforced linking order).

./configure LDFLAGS="--static ${LDFLAGS}" --host=${CROSS_COMPILE} --prefix=${SYSROOT}/usr

- The sysroot folder (${HOME}/android/sysroot-armhf) should look something like this (only include and lib are important though):

android/sysroot-armhf
└── usr
├── bin
├── etc
├── include
├── lib
├── man
├── sbin
└── share

- To check if a binary has been linked statically for sure you can use this:

$ file encfs
encfs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, stripped
$ file e2fsck
e2fsck: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-armhf.so.1, stripped