Skip to content

Commit bddd38c

Browse files
pschneider1968vondele
authored andcommitted
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 #3901 No functional change
1 parent 9083050 commit bddd38c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/Makefile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ endif
2727

2828
### Target Windows OS
2929
ifeq ($(OS),Windows_NT)
30-
target_windows = yes
30+
ifneq ($(COMP),ndk)
31+
target_windows = yes
32+
endif
3133
else ifeq ($(COMP),mingw)
3234
target_windows = yes
3335
ifeq ($(WINE_PATH),)
@@ -451,11 +453,19 @@ ifeq ($(COMP),ndk)
451453
ifeq ($(arch),armv7)
452454
CXX=armv7a-linux-androideabi16-clang++
453455
CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
454-
STRIP=arm-linux-androideabi-strip
456+
ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
457+
STRIP=arm-linux-androideabi-strip
458+
else
459+
STRIP=llvm-strip
460+
endif
455461
endif
456462
ifeq ($(arch),armv8)
457463
CXX=aarch64-linux-android21-clang++
458-
STRIP=aarch64-linux-android-strip
464+
ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
465+
STRIP=aarch64-linux-android-strip
466+
else
467+
STRIP=llvm-strip
468+
endif
459469
endif
460470
LDFLAGS += -static-libstdc++ -pie -lm -latomic
461471
endif
@@ -801,7 +811,7 @@ strip:
801811
install:
802812
-mkdir -p -m 755 $(BINDIR)
803813
-cp $(EXE) $(BINDIR)
804-
-strip $(BINDIR)/$(EXE)
814+
$(STRIP) $(BINDIR)/$(EXE)
805815

806816
# clean all
807817
clean: objclean profileclean
@@ -833,7 +843,7 @@ net:
833843

834844
# clean binaries and objects
835845
objclean:
836-
@rm -f $(EXE) *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
846+
@rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
837847

838848
# clean auxiliary profiling files
839849
profileclean:

0 commit comments

Comments
 (0)