8 # build for build platform
10 APP_PLATFORM = android-$(API)
12 ANDR_ROOT = $(shell pwd)
13 PROJ_ROOT = $(shell realpath $(ANDR_ROOT)/../..)
14 APP_ROOT = $(ANDR_ROOT)/src/main
16 GAMES_TO_COPY = minetest_game
20 VERSION_MAJOR := $(shell cat $(PROJ_ROOT)/CMakeLists.txt | \
21 grep ^set\(VERSION_MAJOR\ | sed 's/)/ /' | cut -f2 -d' ')
22 VERSION_MINOR := $(shell cat $(PROJ_ROOT)/CMakeLists.txt | \
23 grep ^set\(VERSION_MINOR\ | sed 's/)/ /' | cut -f2 -d' ')
24 VERSION_PATCH := $(shell cat $(PROJ_ROOT)/CMakeLists.txt | \
25 grep ^set\(VERSION_PATCH\ | sed 's/)/ /' | cut -f2 -d' ')
27 ################################################################################
28 # toolchain config for arm new processors
29 ################################################################################
30 TARGET_HOST = arm-linux
31 TARGET_ABI = armeabi-v7a
32 TARGET_LIBDIR = armeabi-v7a
33 TARGET_TOOLCHAIN = arm-linux-androideabi-
34 TARGET_CFLAGS_ADDON = -mfloat-abi=softfp -mfpu=vfpv3 -O3 -D__ANDROID_API__=$(API)
35 TARGET_CXXFLAGS_ADDON = $(TARGET_CFLAGS_ADDON)
37 CROSS_PREFIX = arm-linux-androideabi-
38 COMPILER_VERSION = 4.9
41 ################################################################################
42 # toolchain config for little endian mips
43 ################################################################################
44 #TARGET_HOST = mipsel-linux
47 #TARGET_TOOLCHAIN = mipsel-linux-android-
49 #CROSS_PREFIX = mipsel-linux-android-
50 #COMPILER_VERSION = 4.9
53 ################################################################################
54 # toolchain config for x86
55 ################################################################################
56 #TARGET_HOST = x86-linux
59 #TARGET_TOOLCHAIN = x86-
60 #CROSS_PREFIX = i686-linux-android-
62 #COMPILER_VERSION = 4.9
65 ################################################################################
66 ASSETS_TIMESTAMP = deps/assets_timestamp
68 LEVELDB_DIR = $(ANDR_ROOT)/deps/leveldb/
69 LEVELDB_LIB = $(LEVELDB_DIR)libleveldb.a
70 LEVELDB_TIMESTAMP = $(LEVELDB_DIR)/timestamp
71 LEVELDB_TIMESTAMP_INT = $(ANDR_ROOT)/deps/leveldb_timestamp
72 LEVELDB_URL_GIT = https://github.com/google/leveldb
73 LEVELDB_COMMIT = 2d0320a458d0e6a20fff46d5f80b18bfdcce7018
75 OPENAL_DIR = $(ANDR_ROOT)/deps/openal-soft/
76 OPENAL_LIB = $(OPENAL_DIR)libs/$(TARGET_ABI)/libopenal.so
77 OPENAL_TIMESTAMP = $(OPENAL_DIR)/timestamp
78 OPENAL_TIMESTAMP_INT = $(ANDR_ROOT)/deps/openal_timestamp
79 OPENAL_URL_GIT = https://github.com/apportable/openal-soft
81 OGG_DIR = $(ANDR_ROOT)/deps/libvorbis-libogg-android/
82 OGG_LIB = $(OGG_DIR)libs/$(TARGET_ABI)/libogg.so
83 VORBIS_LIB = $(OGG_DIR)libs/$(TARGET_ABI)/libogg.so
84 OGG_TIMESTAMP = $(OGG_DIR)timestamp
85 OGG_TIMESTAMP_INT = $(ANDR_ROOT)/deps/ogg_timestamp
86 OGG_URL_GIT = https://github.com/vincentjames501/libvorbis-libogg-android
88 IRRLICHT_REVISION = 5145
89 IRRLICHT_DIR = $(ANDR_ROOT)/deps/irrlicht/
90 IRRLICHT_LIB = $(IRRLICHT_DIR)lib/Android/libIrrlicht.a
91 IRRLICHT_TIMESTAMP = $(IRRLICHT_DIR)timestamp
92 IRRLICHT_TIMESTAMP_INT = $(ANDR_ROOT)/deps/irrlicht_timestamp
93 IRRLICHT_URL_SVN = https://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@$(IRRLICHT_REVISION)
95 OPENSSL_VERSION = 1.0.2k
96 OPENSSL_BASEDIR = openssl-$(OPENSSL_VERSION)
97 OPENSSL_DIR = $(ANDR_ROOT)/deps/$(OPENSSL_BASEDIR)/
98 OPENSSL_LIB = $(OPENSSL_DIR)/libssl.so.1.0.0
99 OPENSSL_TIMESTAMP = $(OPENSSL_DIR)timestamp
100 OPENSSL_TIMESTAMP_INT = $(ANDR_ROOT)/deps/openssl_timestamp
101 OPENSSL_URL = https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz
103 CURL_VERSION = 7.54.0
104 CURL_DIR = $(ANDR_ROOT)/deps/curl-$(CURL_VERSION)
105 CURL_LIB = $(CURL_DIR)/lib/.libs/libcurl.a
106 CURL_TIMESTAMP = $(CURL_DIR)/timestamp
107 CURL_TIMESTAMP_INT = $(ANDR_ROOT)/deps/curl_timestamp
108 CURL_URL_HTTP = https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.bz2
111 GMP_DIR = $(ANDR_ROOT)/deps/gmp-$(GMP_VERSION)
112 GMP_LIB = $(GMP_DIR)/usr/lib/libgmp.so
113 GMP_TIMESTAMP = $(GMP_DIR)/timestamp
114 GMP_TIMESTAMP_INT = $(ANDR_ROOT)/deps/gmp_timestamp
115 GMP_URL_HTTP = https://gmplib.org/download/gmp/gmp-$(GMP_VERSION).tar.bz2
117 FREETYPE_DIR = $(ANDR_ROOT)/deps/freetype2-android/
118 FREETYPE_LIB = $(FREETYPE_DIR)/Android/obj/local/$(TARGET_ABI)/libfreetype2-static.a
119 FREETYPE_TIMESTAMP = $(FREETYPE_DIR)timestamp
120 FREETYPE_TIMESTAMP_INT = $(ANDR_ROOT)/deps/freetype_timestamp
121 FREETYPE_URL_GIT = https://github.com/cdave1/freetype2-android
124 ICONV_DIR = $(ANDR_ROOT)/deps/libiconv/
125 ICONV_LIB = $(ICONV_DIR)/lib/.libs/libiconv.so
126 ICONV_TIMESTAMP = $(ICONV_DIR)timestamp
127 ICONV_TIMESTAMP_INT = $(ANDR_ROOT)/deps/iconv_timestamp
128 ICONV_URL_HTTP = https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$(ICONV_VERSION).tar.gz
130 SQLITE3_FOLDER = sqlite-amalgamation-3180000
131 SQLITE3_URL = https://www.sqlite.org/2017/$(SQLITE3_FOLDER).zip
133 ANDROID_SDK = $(shell grep '^sdk\.dir' local.properties | sed 's/^.*=[[:space:]]*//')
134 ANDROID_NDK = $(shell grep '^ndk\.dir' local.properties | sed 's/^.*=[[:space:]]*//')
136 #use interim target variable to switch leveldb on or off
137 ifeq ($(HAVE_LEVELDB),1)
138 LEVELDB_TARGET = $(LEVELDB_LIB)
141 .PHONY : debug release reconfig delconfig \
142 leveldb_download clean_leveldb leveldb\
143 irrlicht_download clean_irrlicht irrlicht \
144 clean_assets assets sqlite3_download \
145 freetype_download clean_freetype freetype \
147 clean_all clean prep_srcdir \
148 install_debug install_release envpaths all \
149 $(ASSETS_TIMESTAMP) $(LEVELDB_TIMESTAMP) \
150 $(OPENAL_TIMESTAMP) $(OGG_TIMESTAMP) \
151 $(IRRLICHT_TIMESTAMP) $(CURL_TIMESTAMP) \
152 $(OPENSSL_TIMESTAMP) \
153 $(ANDR_ROOT)/jni/src/android_version.h \
154 $(ANDR_ROOT)/jni/src/android_version_githash.h
156 debug : local.properties
158 export BUILD_TYPE=debug; \
163 release : local.properties
165 export BUILD_TYPE=release; \
169 @$(MAKE) local.properties
172 $(RM) local.properties
175 @echo "Please specify path of ANDROID NDK"; \
176 echo "e.g. $$HOME/Android/ndk-r11c/"; \
178 if [ ! -d $$ANDROID_NDK ] ; then \
179 echo "$$ANDROID_NDK is not a valid folder"; \
182 echo "ndk.dir = $$ANDROID_NDK" > local.properties; \
183 echo "Please specify path of ANDROID SDK"; \
184 echo "e.g. $$HOME/Android/sdk/"; \
186 if [ ! -d $$SDKFLDR ] ; then \
187 echo "$$SDKFLDR is not a valid folder"; \
190 echo "sdk.dir = $$SDKFLDR" >> local.properties;
193 $(OPENAL_TIMESTAMP) : openal_download
194 @LAST_MODIF=$$(find ${OPENAL_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
195 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
196 touch ${OPENAL_TIMESTAMP}; \
200 @if [ ! -d ${OPENAL_DIR} ] ; then \
201 echo "openal sources missing, downloading..."; \
202 mkdir -p ${ANDR_ROOT}/deps; \
203 cd ${ANDR_ROOT}/deps ; \
204 git clone ${OPENAL_URL_GIT} || exit 1; \
207 openal : $(OPENAL_LIB)
209 $(OPENAL_LIB): $(OPENAL_TIMESTAMP)
211 if [ ! -e ${OPENAL_TIMESTAMP_INT} ] ; then \
214 if [ ${OPENAL_TIMESTAMP} -nt ${OPENAL_TIMESTAMP_INT} ] ; then \
217 if [ $$REFRESH -ne 0 ] ; then \
218 echo "changed timestamp for openal detected building..."; \
220 export APP_PLATFORM=${APP_PLATFORM}; \
221 export TARGET_ABI=${TARGET_ABI}; \
222 ${ANDROID_NDK}/ndk-build NDEBUG=${NDEBUG} \
223 NDK_APPLICATION_MK=${ANDR_ROOT}/jni/Deps.mk || exit 1; \
224 touch ${OPENAL_TIMESTAMP}; \
225 touch ${OPENAL_TIMESTAMP_INT}; \
227 echo "nothing to be done for openal"; \
231 $(RM) -rf ${OPENAL_DIR}
233 $(OGG_TIMESTAMP) : ogg_download
234 @LAST_MODIF=$$(find ${OGG_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
235 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
236 touch ${OGG_TIMESTAMP}; \
240 @if [ ! -d ${OGG_DIR} ] ; then \
241 echo "ogg sources missing, downloading..."; \
242 mkdir -p ${ANDR_ROOT}/deps; \
243 cd ${ANDR_ROOT}/deps ; \
244 git clone ${OGG_URL_GIT}|| exit 1; \
245 cd libvorbis-libogg-android ; \
246 patch -p1 < ${ANDR_ROOT}/patches/libvorbis-libogg-fpu.patch || exit 1; \
251 $(OGG_LIB): $(OGG_TIMESTAMP)
253 if [ ! -e ${OGG_TIMESTAMP_INT} ] ; then \
254 echo "${OGG_TIMESTAMP_INT} doesn't exist"; \
257 if [ ${OGG_TIMESTAMP} -nt ${OGG_TIMESTAMP_INT} ] ; then \
260 if [ $$REFRESH -ne 0 ] ; then \
261 echo "changed timestamp for ogg detected building..."; \
263 export APP_PLATFORM=${APP_PLATFORM}; \
264 export TARGET_ABI=${TARGET_ABI}; \
265 ${ANDROID_NDK}/ndk-build NDEBUG=${NDEBUG} \
266 NDK_APPLICATION_MK=${ANDR_ROOT}/jni/Deps.mk || exit 1; \
267 touch ${OGG_TIMESTAMP}; \
268 touch ${OGG_TIMESTAMP_INT}; \
270 echo "nothing to be done for libogg/libvorbis"; \
276 $(OPENSSL_TIMESTAMP) : openssl_download
277 @LAST_MODIF=$$(find ${OPENSSL_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
278 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
279 touch ${OPENSSL_TIMESTAMP}; \
283 @if [ ! -d ${OPENSSL_DIR} ] ; then \
284 echo "openssl sources missing, downloading..."; \
285 mkdir -p ${ANDR_ROOT}/deps; \
286 cd ${ANDR_ROOT}/deps ; \
287 wget ${OPENSSL_URL} || exit 1; \
288 tar -xzf ${OPENSSL_BASEDIR}.tar.gz; \
289 cd ${OPENSSL_BASEDIR}; \
290 patch -p1 < ${ANDR_ROOT}/patches/openssl_arch.patch; \
293 openssl : $(OPENSSL_LIB)
295 $(OPENSSL_LIB): $(OPENSSL_TIMESTAMP) $(GMP_LIB)
297 if [ ! -e ${OPENSSL_TIMESTAMP_INT} ] ; then \
298 echo "${OPENSSL_TIMESTAMP_INT} doesn't exist"; \
301 if [ ${OPENSSL_TIMESTAMP} -nt ${OPENSSL_TIMESTAMP_INT} ] ; then \
304 if [ $$REFRESH -ne 0 ] ; then \
305 echo "changed timestamp for openssl detected building..."; \
307 ln -s ${OPENSSL_DIR} ../openssl; \
308 export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-openssl; \
309 ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
310 --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
311 --platform=${APP_PLATFORM} \
312 --install-dir=$${TOOLCHAIN}; \
313 export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
314 CC=${CROSS_PREFIX}gcc ./Configure enable-gmp -DL_ENDIAN -I${GMP_DIR} -L${GMP_DIR}/usr/lib android-${TARGET_ARCH};\
315 CC=${CROSS_PREFIX}gcc ANDROID_DEV=/tmp/ndk-${TARGET_HOST} make depend; \
316 CC=${CROSS_PREFIX}gcc ANDROID_DEV=/tmp/ndk-${TARGET_HOST} make build_libs; \
317 touch ${OPENSSL_TIMESTAMP}; \
318 touch ${OPENSSL_TIMESTAMP_INT}; \
319 $(RM) -rf $${TOOLCHAIN}; \
321 echo "nothing to be done for openssl"; \
325 $(RM) -rf ${OPENSSL_DIR}; \
326 $(RM) -rf $(ANDR_ROOT)/deps/${OPENSSL_BASEDIR}.tar.gz; \
327 $(RM) -rf $(ANDR_ROOT)/deps/openssl
329 $(LEVELDB_TIMESTAMP) : leveldb_download
330 @LAST_MODIF=$$(find ${LEVELDB_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
331 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
332 touch ${LEVELDB_TIMESTAMP}; \
336 @if [ ! -d ${LEVELDB_DIR} ] ; then \
337 echo "leveldb sources missing, downloading..."; \
338 mkdir -p ${ANDR_ROOT}/deps; \
339 cd ${ANDR_ROOT}/deps ; \
340 git clone ${LEVELDB_URL_GIT} || exit 1; \
341 cd ${LEVELDB_DIR} || exit 1; \
342 git checkout ${LEVELDB_COMMIT} || exit 1; \
345 leveldb : $(LEVELDB_LIB)
346 ifeq ($(HAVE_LEVELDB),1)
347 $(LEVELDB_LIB): $(LEVELDB_TIMESTAMP)
349 if [ ! -e ${LEVELDB_TIMESTAMP_INT} ] ; then \
352 if [ ${LEVELDB_TIMESTAMP} -nt ${LEVELDB_TIMESTAMP_INT} ] ; then \
355 if [ $$REFRESH -ne 0 ] ; then \
356 echo "changed timestamp for leveldb detected building..."; \
358 export CROSS_PREFIX=${CROSS_PREFIX}; \
359 export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-leveldb; \
360 ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
361 --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
362 --platform=${APP_PLATFORM} \
363 --install-dir=$${TOOLCHAIN}; \
364 export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
365 export CC=${CROSS_PREFIX}gcc; \
366 export CXX=${CROSS_PREFIX}g++; \
367 export CFLAGS="$${CFLAGS} ${TARGET_CFLAGS_ADDON}"; \
368 export CPPFLAGS="$${CPPFLAGS} ${TARGET_CXXFLAGS_ADDON}"; \
369 export LDFLAGS="$${LDFLAGS} ${TARGET_LDFLAGS_ADDON}"; \
370 export TARGET_OS=OS_ANDROID_CROSSCOMPILE; \
372 touch ${LEVELDB_TIMESTAMP}; \
373 touch ${LEVELDB_TIMESTAMP_INT}; \
374 $(RM) -rf $${TOOLCHAIN}; \
376 echo "nothing to be done for leveldb"; \
381 $(RM) -rf deps/leveldb
383 $(FREETYPE_TIMESTAMP) : freetype_download
384 @LAST_MODIF=$$(find ${FREETYPE_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
385 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
386 touch ${FREETYPE_TIMESTAMP}; \
390 @if [ ! -d ${FREETYPE_DIR} ] ; then \
391 echo "freetype sources missing, downloading..."; \
392 mkdir -p ${ANDR_ROOT}/deps; \
394 git clone ${FREETYPE_URL_GIT} || exit 1; \
397 freetype : $(FREETYPE_LIB)
399 $(FREETYPE_LIB) : $(FREETYPE_TIMESTAMP)
401 if [ ! -e ${FREETYPE_TIMESTAMP_INT} ] ; then \
404 if [ ! -e ${FREETYPE_LIB} ] ; then \
407 if [ ${FREETYPE_TIMESTAMP} -nt ${FREETYPE_TIMESTAMP_INT} ] ; then \
410 if [ $$REFRESH -ne 0 ] ; then \
411 mkdir -p ${FREETYPE_DIR}; \
412 echo "changed timestamp for freetype detected building..."; \
413 cd ${FREETYPE_DIR}/Android/jni; \
414 export APP_PLATFORM=${APP_PLATFORM}; \
415 export TARGET_ABI=${TARGET_ABI}; \
416 ${ANDROID_NDK}/ndk-build NDEBUG=${NDEBUG} \
417 NDK_APPLICATION_MK=${ANDR_ROOT}/jni/Deps.mk || exit 1; \
418 touch ${FREETYPE_TIMESTAMP}; \
419 touch ${FREETYPE_TIMESTAMP_INT}; \
421 echo "nothing to be done for freetype"; \
425 $(RM) -rf ${FREETYPE_DIR}
427 $(ICONV_TIMESTAMP) : iconv_download
428 @LAST_MODIF=$$(find ${ICONV_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
429 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
430 touch ${ICONV_TIMESTAMP}; \
434 @if [ ! -d ${ICONV_DIR} ] ; then \
435 echo "iconv sources missing, downloading..."; \
436 mkdir -p ${ANDR_ROOT}/deps; \
437 cd ${ANDR_ROOT}/deps; \
438 wget ${ICONV_URL_HTTP} || exit 1; \
439 tar -xzf libiconv-${ICONV_VERSION}.tar.gz || exit 1; \
440 rm libiconv-${ICONV_VERSION}.tar.gz; \
441 ln -s libiconv-${ICONV_VERSION} libiconv; \
443 patch -p1 < ${ANDR_ROOT}/patches/libiconv_android.patch; \
444 patch -p1 < ${ANDR_ROOT}/patches/libiconv_stdio.patch; \
449 $(ICONV_LIB) : $(ICONV_TIMESTAMP)
451 if [ ! -e ${ICONV_TIMESTAMP_INT} ] ; then \
454 if [ ! -e ${ICONV_LIB} ] ; then \
457 if [ ${ICONV_TIMESTAMP} -nt ${ICONV_TIMESTAMP_INT} ] ; then \
460 if [ $$REFRESH -ne 0 ] ; then \
461 mkdir -p ${ICONV_DIR}; \
462 echo "changed timestamp for iconv detected building..."; \
465 export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-iconv; \
466 ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
467 --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
468 --platform=${APP_PLATFORM} \
469 --install-dir=$${TOOLCHAIN}; \
470 export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
471 export CFLAGS="$${CFLAGS} ${TARGET_CFLAGS_ADDON}"; \
472 export CC=${CROSS_PREFIX}gcc; \
473 export CXX=${CROSS_PREFIX}g++; \
474 export TARGET_OS=OS_ANDROID_CROSSCOMPILE; \
475 ./configure --host=${TARGET_HOST} || exit 1; \
476 sed -i 's/LIBICONV_VERSION_INFO) /LIBICONV_VERSION_INFO) -avoid-version /g' lib/Makefile; \
477 grep "iconv_LDFLAGS" src/Makefile; \
478 $(MAKE) -s || exit 1; \
479 touch ${ICONV_TIMESTAMP}; \
480 touch ${ICONV_TIMESTAMP_INT}; \
481 rm -rf ${TOOLCHAIN}; \
483 echo "nothing to be done for iconv"; \
487 $(RM) -rf ${ICONV_DIR}
489 #Note: Texturehack patch is required for gpu's not supporting color format
490 # correctly. Known bad GPU:
491 # -geforce on emulator
492 # -Vivante Corporation GC1000 core (e.g. Galaxy Tab 3)
495 @if [ ! -d "deps/irrlicht" ] ; then \
496 echo "irrlicht sources missing, downloading..."; \
497 mkdir -p ${ANDR_ROOT}/deps; \
499 svn co ${IRRLICHT_URL_SVN} irrlicht || exit 1; \
501 patch -p1 < ${ANDR_ROOT}/patches/irrlicht-touchcount.patch || exit 1; \
502 patch -p1 < ${ANDR_ROOT}/patches/irrlicht-back_button.patch || exit 1; \
503 patch -p1 < ${ANDR_ROOT}/patches/irrlicht-texturehack.patch || exit 1; \
504 patch -p1 < ${ANDR_ROOT}/patches/irrlicht-native_activity.patch || exit 1; \
507 $(IRRLICHT_TIMESTAMP) : irrlicht_download
508 @LAST_MODIF=$$(find ${IRRLICHT_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
509 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
510 touch ${IRRLICHT_TIMESTAMP}; \
513 irrlicht : $(IRRLICHT_LIB)
515 $(IRRLICHT_LIB): $(IRRLICHT_TIMESTAMP) $(FREETYPE_LIB)
517 if [ ! -e ${IRRLICHT_TIMESTAMP_INT} ] ; then \
520 if [ ! -e ${IRRLICHT_LIB} ] ; then \
523 if [ ${IRRLICHT_TIMESTAMP} -nt ${IRRLICHT_TIMESTAMP_INT} ] ; then \
526 if [ $$REFRESH -ne 0 ] ; then \
527 mkdir -p ${IRRLICHT_DIR}; \
528 echo "changed timestamp for irrlicht detected building..."; \
529 cd deps/irrlicht/source/Irrlicht/Android; \
530 export APP_PLATFORM=${APP_PLATFORM}; \
531 export TARGET_ABI=${TARGET_ABI}; \
532 ${ANDROID_NDK}/ndk-build NDEBUG=${NDEBUG} \
533 NDK_APPLICATION_MK=${ANDR_ROOT}/jni/Irrlicht.mk || exit 1; \
534 touch ${IRRLICHT_TIMESTAMP}; \
535 touch ${IRRLICHT_TIMESTAMP_INT}; \
537 echo "nothing to be done for irrlicht"; \
541 $(RM) -rf deps/irrlicht
543 $(CURL_TIMESTAMP) : curl_download
544 @LAST_MODIF=$$(find ${CURL_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
545 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
546 touch ${CURL_TIMESTAMP}; \
550 @if [ ! -d "deps/curl-${CURL_VERSION}" ] ; then \
551 echo "curl sources missing, downloading..."; \
552 mkdir -p ${ANDR_ROOT}/deps; \
554 wget ${CURL_URL_HTTP} || exit 1; \
555 tar -xjf curl-${CURL_VERSION}.tar.bz2 || exit 1; \
556 rm curl-${CURL_VERSION}.tar.bz2; \
557 ln -s curl-${CURL_VERSION} curl; \
562 $(CURL_LIB): $(CURL_TIMESTAMP) $(OPENSSL_LIB)
564 if [ ! -e ${CURL_TIMESTAMP_INT} ] ; then \
567 if [ ! -e ${CURL_LIB} ] ; then \
570 if [ ${CURL_TIMESTAMP} -nt ${CURL_TIMESTAMP_INT} ] ; then \
573 if [ $$REFRESH -ne 0 ] ; then \
574 mkdir -p ${CURL_DIR}; \
575 echo "changed timestamp for curl detected building..."; \
576 cd deps/curl-${CURL_VERSION}; \
577 export CROSS_PREFIX=${CROSS_PREFIX}; \
578 export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-curl; \
579 ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
580 --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
581 --platform=${APP_PLATFORM} \
582 --install-dir=$${TOOLCHAIN}; \
583 export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
584 export CC=${CROSS_PREFIX}gcc; \
585 export CXX=${CROSS_PREFIX}g++; \
586 export TARGET_OS=OS_ANDROID_CROSSCOMPILE; \
587 export CPPFLAGS="$${CPPFLAGS} -I${OPENSSL_DIR}/include ${TARGET_CFLAGS_ADDON}"; \
588 export CFLAGS="$${CFLAGS} ${TARGET_CFLAGS_ADDON}"; \
589 export LDFLAGS="$${LDFLAGS} -L${OPENSSL_DIR} ${TARGET_LDFLAGS_ADDON}"; \
590 ./configure --host=${TARGET_HOST} --disable-shared --enable-static --with-ssl; \
591 $(MAKE) -s || exit 1; \
592 touch ${CURL_TIMESTAMP}; \
593 touch ${CURL_TIMESTAMP_INT}; \
594 $(RM) -rf $${TOOLCHAIN}; \
596 echo "nothing to be done for curl"; \
600 $(RM) -rf deps/curl-${CURL_VERSION} \
603 $(GMP_TIMESTAMP) : gmp_download
604 @LAST_MODIF=$$(find ${GMP_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
605 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
606 touch ${GMP_TIMESTAMP}; \
610 @if [ ! -d "${GMP_DIR}" ] ; then \
611 echo "gmp sources missing, downloading..."; \
612 mkdir -p ${ANDR_ROOT}/deps; \
614 wget ${GMP_URL_HTTP} || exit 1; \
615 tar -xjf gmp-${GMP_VERSION}.tar.bz2 || exit 1; \
616 rm gmp-${GMP_VERSION}.tar.bz2; \
617 ln -s gmp-${GMP_VERSION} gmp; \
622 $(GMP_LIB): $(GMP_TIMESTAMP)
624 if [ ! -e ${GMP_TIMESTAMP_INT} ] ; then \
627 if [ ! -e ${GMP_LIB} ] ; then \
630 if [ ${GMP_TIMESTAMP} -nt ${GMP_TIMESTAMP_INT} ] ; then \
633 if [ $$REFRESH -ne 0 ] ; then \
634 mkdir -p ${GMP_DIR}; \
635 echo "changed timestamp for gmp detected building..."; \
636 cd deps/gmp-${GMP_VERSION}; \
637 export CROSS_PREFIX=${CROSS_PREFIX}; \
638 export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-gmp; \
639 ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
640 --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
641 --platform=${APP_PLATFORM} \
642 --install-dir=$${TOOLCHAIN}; \
643 export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
644 export CC=${CROSS_PREFIX}gcc; \
645 export CXX=${CROSS_PREFIX}g++; \
646 export LIBGMP_LDFLAGS="-avoid-version"; \
647 export LIBGMPXX_LDFLAGS="-avoid-version"; \
648 ./configure --disable-static --host=${TARGET_HOST} --prefix=/usr; \
649 $(MAKE) install DESTDIR=/${GMP_DIR} || exit 1; \
650 touch ${GMP_TIMESTAMP}; \
651 touch ${GMP_TIMESTAMP_INT}; \
652 $(RM) -rf $${TOOLCHAIN}; \
654 echo "nothing to be done for gmp"; \
658 $(RM) -rf deps/gmp-${GMP_VERSION} \
661 sqlite3_download: deps/${SQLITE3_FOLDER}/sqlite3.c
663 deps/${SQLITE3_FOLDER}/sqlite3.c :
665 wget ${SQLITE3_URL}; \
666 unzip ${SQLITE3_FOLDER}.zip; \
667 ln -s ${SQLITE3_FOLDER} sqlite; \
668 cd ${SQLITE3_FOLDER};
671 cd deps && $(RM) -rf ${SQLITE3_FOLDER} && $(RM) -f ${SQLITE3_FOLDER}.zip && \
674 $(ASSETS_TIMESTAMP) : $(IRRLICHT_LIB)
675 @mkdir -p ${ANDR_ROOT}/deps; \
676 for DIRNAME in {builtin,client,doc,fonts,games,mods,po,textures}; do \
677 LAST_MODIF=$$(find ${PROJ_ROOT}/${DIRNAME} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
678 if [ $$(basename $$LAST_MODIF) != "timestamp" ]; then \
679 touch ${PROJ_ROOT}/${DIRNAME}/timestamp; \
680 touch ${ASSETS_TIMESTAMP}; \
681 echo ${DIRNAME} changed $$LAST_MODIF; \
684 LAST_MODIF=$$(find ${IRRLICHT_DIR}/media -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
685 if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
686 touch ${IRRLICHT_DIR}/media/timestamp; \
687 touch ${ASSETS_TIMESTAMP}; \
689 if [ ${PROJ_ROOT}/minetest.conf.example -nt ${ASSETS_TIMESTAMP} ] ; then \
690 echo "conf changed"; \
691 touch ${ASSETS_TIMESTAMP}; \
693 if [ ${PROJ_ROOT}/README.txt -nt ${ASSETS_TIMESTAMP} ] ; then \
694 touch ${ASSETS_TIMESTAMP}; \
696 if [ ! -e $(ASSETS_TIMESTAMP) ] ; then \
697 touch $(ASSETS_TIMESTAMP); \
700 assets : $(ASSETS_TIMESTAMP)
702 if [ ! -e ${ASSETS_TIMESTAMP}.old ] ; then \
705 if [ ${ASSETS_TIMESTAMP} -nt ${ASSETS_TIMESTAMP}.old ] ; then \
708 if [ ! -d ${APP_ROOT}/assets ] ; then \
711 if [ $$REFRESH -ne 0 ] ; then \
712 echo "assets changed, refreshing..."; \
713 $(MAKE) clean_assets; \
714 mkdir -p ${APP_ROOT}/assets/Minetest; \
715 cp ${PROJ_ROOT}/minetest.conf.example ${APP_ROOT}/assets/Minetest; \
716 cp ${PROJ_ROOT}/README.txt ${APP_ROOT}/assets/Minetest; \
717 cp -r ${PROJ_ROOT}/builtin ${APP_ROOT}/assets/Minetest; \
718 mkdir -p ${APP_ROOT}/assets/Minetest/client; \
719 cp -r ${PROJ_ROOT}/client/shaders ${APP_ROOT}/assets/Minetest/client; \
720 cp ${PROJ_ROOT}/doc/lgpl-2.1.txt ${APP_ROOT}/assets/Minetest/LICENSE.txt; \
721 mkdir -p ${APP_ROOT}/assets/Minetest/fonts; \
722 cp -r ${PROJ_ROOT}/fonts/*.ttf ${APP_ROOT}/assets/Minetest/fonts/; \
723 mkdir -p ${APP_ROOT}/assets/Minetest/games; \
724 for game in ${GAMES_TO_COPY}; do \
725 cp -r ${PROJ_ROOT}/games/$$game ${APP_ROOT}/assets/Minetest/games/; \
727 mkdir -p ${APP_ROOT}/assets/Minetest/mods; \
728 for mod in ${MODS_TO_COPY}; do \
729 cp -r ${PROJ_ROOT}/mods/$$mod ${APP_ROOT}/assets/Minetest/mods/; \
731 cp -r ${PROJ_ROOT}/po ${APP_ROOT}/assets/Minetest; \
732 cp -r ${PROJ_ROOT}/textures ${APP_ROOT}/assets/Minetest; \
733 mkdir -p ${APP_ROOT}/assets/Minetest/media; \
734 cp -r ${IRRLICHT_DIR}/media/Shaders ${APP_ROOT}/assets/Minetest/media; \
735 cd ${APP_ROOT}/assets || exit 1; \
736 find . -name "timestamp" -exec rm {} \; ; \
737 find . -name "*.blend" -exec rm {} \; ; \
738 find . -name "*~" -exec rm {} \; ; \
739 find . -type d -path "*.git" -exec rm -rf {} \; ; \
740 find . -type d -path "*.svn" -exec rm -rf {} \; ; \
741 find . -type f -path "*.gitignore" -exec rm -rf {} \; ; \
742 ls -R | grep ":$$" | sed -e 's/:$$//' -e 's/\.//' -e 's/^\///' > "index.txt"; \
743 find -L Minetest > filelist.txt; \
744 cp ${ANDR_ROOT}/${ASSETS_TIMESTAMP} ${ANDR_ROOT}/${ASSETS_TIMESTAMP}.old; \
746 echo "nothing to be done for assets"; \
752 apk: local.properties assets $(ICONV_LIB) $(IRRLICHT_LIB) $(CURL_LIB) $(GMP_LIB) $(LEVELDB_TARGET) \
753 $(OPENAL_LIB) $(OGG_LIB) prep_srcdir $(ANDR_ROOT)/jni/src/android_version.h \
754 $(ANDR_ROOT)/jni/src/android_version_githash.h sqlite3_download
755 + @export TARGET_LIBDIR=${TARGET_LIBDIR}; \
756 export HAVE_LEVELDB=${HAVE_LEVELDB}; \
757 export APP_PLATFORM=${APP_PLATFORM}; \
758 export TARGET_ABI=${TARGET_ABI}; \
759 ${ANDROID_NDK}/ndk-build || exit 1; \
760 if [ ! -e ${APP_ROOT}/jniLibs ]; then \
761 ln -s ${ANDR_ROOT}/libs ${APP_ROOT}/jniLibs || exit 1; \
763 export VERSION_STR="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" && \
764 export BUILD_TYPE_C=$$(echo "$${BUILD_TYPE}" | sed 's/./\U&/') && \
765 ./gradlew assemble$$BUILD_TYPE_C && \
766 echo "APK stored at: build/outputs/apk/Minetest-$$BUILD_TYPE.apk" && \
767 echo "You can install it with \`make install_$$BUILD_TYPE\`"
769 # These Intentionally doesn't depend on their respective build steps,
770 # because it takes a while to verify that everything's up-to-date.
772 ${ANDROID_SDK}/platform-tools/adb install -r build/outputs/apk/Minetest-debug.apk
775 ${ANDROID_SDK}/platform-tools/adb install -r build/outputs/apk/Minetest-release.apk
778 @if [ ! -e ${ANDR_ROOT}/jni/src ]; then \
779 ln -s ${PROJ_ROOT}/src ${ANDR_ROOT}/jni/src; \
781 if [ ! -e ${ANDR_ROOT}/jni/lib ]; then \
782 ln -s ${PROJ_ROOT}/lib ${ANDR_ROOT}/jni/lib; \
789 @$(MAKE) clean_apk; \
790 $(MAKE) clean_assets clean_iconv clean_irrlicht clean_leveldb clean_curl \
791 clean_openssl clean_openal clean_ogg clean_gmp; \
793 $(RM) -r gen libs obj deps bin Debug and_env
795 $(ANDR_ROOT)/jni/src/android_version_githash.h : prep_srcdir
796 @export VERSION_FILE=${ANDR_ROOT}/jni/src/android_version_githash.h; \
797 export VERSION_FILE_NEW=$${VERSION_FILE}.new; \
799 echo "#ifndef ANDROID_MT_VERSION_GITHASH_H"; \
800 echo "#define ANDROID_MT_VERSION_GITHASH_H"; \
801 export GITHASH=$$(git rev-parse --short=8 HEAD); \
802 export VERSION_STR="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"; \
803 echo "#define VERSION_GITHASH \"$$VERSION_STR-$$GITHASH-Android\""; \
805 } > "$${VERSION_FILE_NEW}"; \
806 if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \
807 echo "android_version_githash.h changed, updating..."; \
808 mv "$${VERSION_FILE_NEW}" "$${VERSION_FILE}"; \
810 rm "$${VERSION_FILE_NEW}"; \
814 $(ANDR_ROOT)/jni/src/android_version.h : prep_srcdir
815 @export VERSION_FILE=${ANDR_ROOT}/jni/src/android_version.h; \
816 export VERSION_FILE_NEW=$${VERSION_FILE}.new; \
818 echo "#ifndef ANDROID_MT_VERSION_H"; \
819 echo "#define ANDROID_MT_VERSION_H"; \
820 echo "#define VERSION_MAJOR ${VERSION_MAJOR}"; \
821 echo "#define VERSION_MINOR ${VERSION_MINOR}"; \
822 echo "#define VERSION_PATCH ${VERSION_PATCH}"; \
823 echo "#define VERSION_STRING STR(VERSION_MAJOR) \".\" STR(VERSION_MINOR) \
824 \".\" STR(VERSION_PATCH)"; \
826 } > $${VERSION_FILE_NEW}; \
827 if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \
828 echo "android_version.h changed, updating..."; \
829 mv "$${VERSION_FILE_NEW}" "$${VERSION_FILE}"; \
831 rm "$${VERSION_FILE_NEW}"; \
834 clean : clean_apk clean_assets