Skip to content

Commit b5ceb2f

Browse files
committed
Changes required to build and run on Android.
1 parent e703937 commit b5ceb2f

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

src/Makefile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
# Makefile
33
#
44

5-
LIBS = -lpthread
5+
LIBS =
6+
NDK = /android/ndk
7+
SYSROOT = $(NDK)/platforms/android-8/arch-arm
8+
CC = $(NDK)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc --sysroot=$(SYSROOT)
69

710

8-
default: fire
11+
default: firenzina
912

1013
OFILES = main.o \
1114
50move.o \
@@ -63,22 +66,23 @@ OFILES = main.o \
6366
top_node.o \
6467
unmake_move.o \
6568
utility.o \
66-
67-
69+
cpu-features.o \
70+
71+
6872
$(OFILES):
6973

70-
fire: $(OFILES)
71-
gcc -o fire $(OFILES) $(LIBS)
74+
firenzina: $(OFILES)
75+
$(CC) -o firenzina $(OFILES) $(LIBS)
7276

7377
clean:
74-
rm -f *.o fire
78+
rm -f *.o firenzina
7579

7680
.c.o: main.c
77-
gcc -c -g $*.c -Wall -w -pipe -s -std=c99 -DNDEBUG -DHAVE_STRUCT_TIMESPEC -Ofast -static \
81+
$(CC) -c -g $*.c -Wall -w -pipe -s -std=c99 -DNDEBUG -DHAVE_STRUCT_TIMESPEC -Ofast -static \
7882
-flto -fwhole-program -finline-functions -fprefetch-loop-arrays \
79-
-Wfatal-errors -mtune=native -DHasPreFetch -DRobboBases \
80-
81-
83+
-Wfatal-errors -mtune=arm7 -DHasPreFetch -DRobboBases \
84+
85+
8286

8387
# for popcount (AMD) = -march=amdfam10 -mtune=amdfam10 -mpopcnt -DHasPopCNT
8488
# for popcount (INTEL) = -msse4.2 -march=corei7 -mtune=corei7 -mpopcnt -DHasPopCNT

src/fire.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ along with this program. If not, see http://www.gnu.org/licenses/.
5050

5151
#if defined(__i386__)
5252
#define Plat "Linux 32"
53+
#elif defined(__ANDROID__)
54+
#define boolean bool
55+
#define Plat "Android"
5356
#else
5457
#define Plat "Linux 64"
5558
//#define LinuxLargePages
@@ -495,4 +498,4 @@ char String3[MaxCPUs][64], String4[MaxCPUs][64];
495498
#endif
496499

497500
char *InputBuffer, *input_ptr;
498-
#endif
501+
#endif

src/utility.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ void GetSysInfo()
385385
SYSTEM_INFO sysinfo;
386386
GetSystemInfo(&sysinfo);
387387
NumCPUs = sysinfo.dwNumberOfProcessors;
388+
#elif defined(__ANDROID__)
389+
#include "cpu-features.h"
390+
NumCPUs = android_getCpuCount();
388391
#else
389392
#include <sys/sysinfo.h>
390393
NumCPUs = get_nprocs();

src/win-linux.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ HANDLE PThread[MaxCPUs], PThreadIO;
106106
#define uint64 unsigned long long int
107107
#define INLINE inline
108108
#define Type64Bit "%lld"
109+
#ifdef __ANDROID__
110+
#define MemAlign(a, b, c) a = memalign (b, c)
111+
#else
109112
#define MemAlign(a, b, c) posix_memalign ((void*) &(a), b, c)
113+
#endif
110114
#define AlignedFree(x) free (x)
111115
#include "bits.h"
112116
#include <pthread.h>

0 commit comments

Comments
 (0)