1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 01:03:09 +00:00

Fix Makefile for Android NDK cross-compile

For cross-compiling to Android on windows, the Makefile needs some tweaks.

Tested with Android NDK 23.1.7779620 and 21.4.7075529, using
Windows 10 with clean MSYS2 environment (i.e. no MINGW/GCC/Clang
toolchain in PATH) and Fedora 35, with build target:
build ARCH=armv8 COMP=ndk

The resulting binary runs fine inside Droidfish on my Samsung
Galaxy Note20 Ultra and Samsung Galaxy Tab S7+

Other builds tested to exclude regressions: MINGW64/Clang64 build
on Windows; MINGW64 cross build, native Clang and GCC builds on Fedora.

wiki docs https://github.com/glinscott/fishtest/wiki/Cross-compiling-Stockfish-for-Android-on-Windows-and-Linux

closes https://github.com/official-stockfish/Stockfish/pull/3901

No functional change
This commit is contained in:
pschneider1968 2022-01-21 14:11:53 +01:00 committed by Joost VandeVondele
parent 9083050be6
commit bddd38c45e

View file

@ -27,7 +27,9 @@ endif
### Target Windows OS ### Target Windows OS
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
target_windows = yes ifneq ($(COMP),ndk)
target_windows = yes
endif
else ifeq ($(COMP),mingw) else ifeq ($(COMP),mingw)
target_windows = yes target_windows = yes
ifeq ($(WINE_PATH),) ifeq ($(WINE_PATH),)
@ -451,11 +453,19 @@ ifeq ($(COMP),ndk)
ifeq ($(arch),armv7) ifeq ($(arch),armv7)
CXX=armv7a-linux-androideabi16-clang++ CXX=armv7a-linux-androideabi16-clang++
CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
STRIP=arm-linux-androideabi-strip ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
STRIP=arm-linux-androideabi-strip
else
STRIP=llvm-strip
endif
endif endif
ifeq ($(arch),armv8) ifeq ($(arch),armv8)
CXX=aarch64-linux-android21-clang++ CXX=aarch64-linux-android21-clang++
STRIP=aarch64-linux-android-strip ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
STRIP=aarch64-linux-android-strip
else
STRIP=llvm-strip
endif
endif endif
LDFLAGS += -static-libstdc++ -pie -lm -latomic LDFLAGS += -static-libstdc++ -pie -lm -latomic
endif endif
@ -801,7 +811,7 @@ strip:
install: install:
-mkdir -p -m 755 $(BINDIR) -mkdir -p -m 755 $(BINDIR)
-cp $(EXE) $(BINDIR) -cp $(EXE) $(BINDIR)
-strip $(BINDIR)/$(EXE) $(STRIP) $(BINDIR)/$(EXE)
# clean all # clean all
clean: objclean profileclean clean: objclean profileclean
@ -833,7 +843,7 @@ net:
# clean binaries and objects # clean binaries and objects
objclean: objclean:
@rm -f $(EXE) *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o @rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
# clean auxiliary profiling files # clean auxiliary profiling files
profileclean: profileclean: