For these brief instructions, basic knowledge of the command line under Linux is required.
https://en.m.wikibooks.org/wiki/Linux_Guide/Using_the_shell
- Install Termux from https://f-droid.org/en/packages/com.termux/.
- Grant storage access permission to Termux (Settings --> Applications --> Termux --> Permissions).
- Download CECSA (Chess Engine Compiler Script for Android) and installation script cecsa.sh from
https://sourceforge.net/projects/chess-tools-for-android/files/.
Download Android NDK from https://github.com/Lzhiyong/termux-ndk (this is optional, but I recommend it for a full install).
There should be three files in your download directory (/storage/emulated/0/Download): android-ndk-r23c-aarch64.zip, cecsa.sh and cecsa_2022.10.09.tar.gz (the names of Android NDK and CECSA files depend on their version number).
- Start Termux and copy the installation script to your home directory.
cp /storage/emulated/0/Download/cecsa.sh ./
Start the script with
bash cecsa.sh
Answer all questions with 'Y' and when finished, type 'logout' or 'exit'.
- Start Termux again and change to the cecsa directory.
cd cecsa
To compile Stockfish, enter the following command:
./start.sh stockfish
When finished, a zip file named "Stockfish.zip" will be created in your download directory (/storage/emulated/0/Download).
If you want to enter a special version number for Stockfish (recommended), just compile it with an additional parameter.
Example:
./start.sh stockfish 221016
When finished, a zip file named "Stockfish_221016.zip" will be created in your download directory.
With this method you get a heavily optimized Stockfish. The 64 bit version will be compiled with the GCC compiler combined with profile-guided optimization (PGO). It should run on all armv8-a based architectures. If you want to change that, edit the corresponding parameters in the start script (start.sh). If you just want to compile for yourself (you don't want to distribute the builds), you may get better results with CECSA_DISTRIBUTION_BUILD=false. In this case, the compiler tries to recognize your CPU automatically (-march=native) and optimizes accordingly. For further information what parameters are used, see also the makefile in etc/Stockfish directory.
As a side note, you can use the makefile also outside of CECSA to compile Stockfish (just copy the makefile and current network file to the src directory and compile Stockfish with make profile-build).