Makefile 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. # build options
  2. OS := $(shell uname)
  3. # compile with GPROF
  4. # GPROF = 1
  5. # build for build platform
  6. API = 14
  7. APP_PLATFORM = android-$(API)
  8. ANDR_ROOT = $(shell pwd)
  9. PROJ_ROOT = $(shell realpath $(ANDR_ROOT)/../..)
  10. APP_ROOT = $(ANDR_ROOT)/src/main
  11. GAMES_TO_COPY = minetest_game
  12. MODS_TO_COPY =
  13. VERSION_MAJOR := $(shell cat $(PROJ_ROOT)/CMakeLists.txt | \
  14. grep ^set\(VERSION_MAJOR\ | sed 's/)/ /' | cut -f2 -d' ')
  15. VERSION_MINOR := $(shell cat $(PROJ_ROOT)/CMakeLists.txt | \
  16. grep ^set\(VERSION_MINOR\ | sed 's/)/ /' | cut -f2 -d' ')
  17. VERSION_PATCH := $(shell cat $(PROJ_ROOT)/CMakeLists.txt | \
  18. grep ^set\(VERSION_PATCH\ | sed 's/)/ /' | cut -f2 -d' ')
  19. ################################################################################
  20. # toolchain config for arm new processors
  21. ################################################################################
  22. TARGET_HOST = arm-linux
  23. TARGET_ABI = armeabi-v7a
  24. TARGET_LIBDIR = armeabi-v7a
  25. TARGET_TOOLCHAIN = arm-linux-androideabi-
  26. TARGET_CFLAGS_ADDON = -mfloat-abi=softfp -mfpu=vfpv3 -O3 -D__ANDROID_API__=$(API)
  27. TARGET_CXXFLAGS_ADDON = $(TARGET_CFLAGS_ADDON)
  28. TARGET_ARCH = armv7
  29. CROSS_PREFIX = arm-linux-androideabi-
  30. COMPILER_VERSION = 4.9
  31. HAVE_LEVELDB = 0
  32. ################################################################################
  33. # toolchain config for little endian mips
  34. ################################################################################
  35. #TARGET_HOST = mipsel-linux
  36. #TARGET_ABI = mips
  37. #TARGET_LIBDIR = mips
  38. #TARGET_TOOLCHAIN = mipsel-linux-android-
  39. #TARGET_ARCH = mips32
  40. #CROSS_PREFIX = mipsel-linux-android-
  41. #COMPILER_VERSION = 4.9
  42. #HAVE_LEVELDB = 0
  43. ################################################################################
  44. # toolchain config for x86
  45. ################################################################################
  46. #TARGET_HOST = x86-linux
  47. #TARGET_ABI = x86
  48. #TARGET_LIBDIR = x86
  49. #TARGET_TOOLCHAIN = x86-
  50. #CROSS_PREFIX = i686-linux-android-
  51. #TARGET_ARCH = x86
  52. #COMPILER_VERSION = 4.9
  53. #HAVE_LEVELDB = 0
  54. ################################################################################
  55. ASSETS_TIMESTAMP = deps/assets_timestamp
  56. LEVELDB_DIR = $(ANDR_ROOT)/deps/leveldb/
  57. LEVELDB_LIB = $(LEVELDB_DIR)libleveldb.a
  58. LEVELDB_TIMESTAMP = $(LEVELDB_DIR)/timestamp
  59. LEVELDB_TIMESTAMP_INT = $(ANDR_ROOT)/deps/leveldb_timestamp
  60. LEVELDB_URL_GIT = https://github.com/google/leveldb
  61. LEVELDB_COMMIT = 2d0320a458d0e6a20fff46d5f80b18bfdcce7018
  62. OPENAL_DIR = $(ANDR_ROOT)/deps/openal-soft/
  63. OPENAL_LIB = $(OPENAL_DIR)libs/$(TARGET_ABI)/libopenal.so
  64. OPENAL_TIMESTAMP = $(OPENAL_DIR)/timestamp
  65. OPENAL_TIMESTAMP_INT = $(ANDR_ROOT)/deps/openal_timestamp
  66. OPENAL_URL_GIT = https://github.com/apportable/openal-soft
  67. OGG_DIR = $(ANDR_ROOT)/deps/libvorbis-libogg-android/
  68. OGG_LIB = $(OGG_DIR)libs/$(TARGET_ABI)/libogg.so
  69. VORBIS_LIB = $(OGG_DIR)libs/$(TARGET_ABI)/libogg.so
  70. OGG_TIMESTAMP = $(OGG_DIR)timestamp
  71. OGG_TIMESTAMP_INT = $(ANDR_ROOT)/deps/ogg_timestamp
  72. OGG_URL_GIT = https://gitlab.com/minetest/libvorbis-libogg-android
  73. IRRLICHT_REVISION = 5145
  74. IRRLICHT_DIR = $(ANDR_ROOT)/deps/irrlicht/
  75. IRRLICHT_LIB = $(IRRLICHT_DIR)lib/Android/libIrrlicht.a
  76. IRRLICHT_TIMESTAMP = $(IRRLICHT_DIR)timestamp
  77. IRRLICHT_TIMESTAMP_INT = $(ANDR_ROOT)/deps/irrlicht_timestamp
  78. IRRLICHT_URL_SVN = https://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@$(IRRLICHT_REVISION)
  79. OPENSSL_VERSION = 1.0.2k
  80. OPENSSL_BASEDIR = openssl-$(OPENSSL_VERSION)
  81. OPENSSL_DIR = $(ANDR_ROOT)/deps/$(OPENSSL_BASEDIR)/
  82. OPENSSL_LIB = $(OPENSSL_DIR)/libssl.so.1.0.0
  83. OPENSSL_TIMESTAMP = $(OPENSSL_DIR)timestamp
  84. OPENSSL_TIMESTAMP_INT = $(ANDR_ROOT)/deps/openssl_timestamp
  85. OPENSSL_URL = https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz
  86. CURL_VERSION = 7.60.0
  87. CURL_DIR = $(ANDR_ROOT)/deps/curl-$(CURL_VERSION)
  88. CURL_LIB = $(CURL_DIR)/lib/.libs/libcurl.a
  89. CURL_TIMESTAMP = $(CURL_DIR)/timestamp
  90. CURL_TIMESTAMP_INT = $(ANDR_ROOT)/deps/curl_timestamp
  91. CURL_URL_HTTP = https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.bz2
  92. FREETYPE_DIR = $(ANDR_ROOT)/deps/freetype2-android/
  93. FREETYPE_LIB = $(FREETYPE_DIR)/Android/obj/local/$(TARGET_ABI)/libfreetype2-static.a
  94. FREETYPE_TIMESTAMP = $(FREETYPE_DIR)timestamp
  95. FREETYPE_TIMESTAMP_INT = $(ANDR_ROOT)/deps/freetype_timestamp
  96. FREETYPE_URL_GIT = https://github.com/cdave1/freetype2-android
  97. ICONV_VERSION = 1.14
  98. ICONV_DIR = $(ANDR_ROOT)/deps/libiconv/
  99. ICONV_LIB = $(ICONV_DIR)/lib/.libs/libiconv.so
  100. ICONV_TIMESTAMP = $(ICONV_DIR)timestamp
  101. ICONV_TIMESTAMP_INT = $(ANDR_ROOT)/deps/iconv_timestamp
  102. ICONV_URL_HTTP = https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$(ICONV_VERSION).tar.gz
  103. SQLITE3_FOLDER = sqlite-amalgamation-3240000
  104. SQLITE3_URL = https://www.sqlite.org/2018/$(SQLITE3_FOLDER).zip
  105. ANDROID_SDK = $(shell grep '^sdk\.dir' local.properties | sed 's/^.*=[[:space:]]*//')
  106. ANDROID_NDK = $(shell grep '^ndk\.dir' local.properties | sed 's/^.*=[[:space:]]*//')
  107. #use interim target variable to switch leveldb on or off
  108. ifeq ($(HAVE_LEVELDB),1)
  109. LEVELDB_TARGET = $(LEVELDB_LIB)
  110. endif
  111. .PHONY : debug release reconfig delconfig \
  112. leveldb_download clean_leveldb leveldb\
  113. irrlicht_download clean_irrlicht irrlicht \
  114. clean_assets assets sqlite3_download \
  115. freetype_download clean_freetype freetype \
  116. apk clean_apk \
  117. clean_all clean prep_srcdir \
  118. install_debug install_release envpaths all \
  119. $(ASSETS_TIMESTAMP) $(LEVELDB_TIMESTAMP) \
  120. $(OPENAL_TIMESTAMP) $(OGG_TIMESTAMP) \
  121. $(IRRLICHT_TIMESTAMP) $(CURL_TIMESTAMP) \
  122. $(OPENSSL_TIMESTAMP) \
  123. $(ANDR_ROOT)/jni/src/android_version.h \
  124. $(ANDR_ROOT)/jni/src/android_version_githash.h
  125. debug : local.properties
  126. export NDEBUG=; \
  127. export BUILD_TYPE=debug; \
  128. $(MAKE) apk
  129. all : debug release
  130. release : local.properties
  131. @export NDEBUG=1; \
  132. export BUILD_TYPE=release; \
  133. $(MAKE) apk
  134. reconfig: delconfig
  135. @$(MAKE) local.properties
  136. delconfig:
  137. $(RM) local.properties
  138. local.properties:
  139. @echo "Please specify path of ANDROID NDK"; \
  140. echo "e.g. $$HOME/Android/ndk-r11c/"; \
  141. read ANDROID_NDK ; \
  142. if [ ! -d $$ANDROID_NDK ] ; then \
  143. echo "$$ANDROID_NDK is not a valid folder"; \
  144. exit 1; \
  145. fi; \
  146. echo "ndk.dir = $$ANDROID_NDK" > local.properties; \
  147. echo "Please specify path of ANDROID SDK"; \
  148. echo "e.g. $$HOME/Android/sdk/"; \
  149. read SDKFLDR ; \
  150. if [ ! -d $$SDKFLDR ] ; then \
  151. echo "$$SDKFLDR is not a valid folder"; \
  152. exit 1; \
  153. fi; \
  154. echo "sdk.dir = $$SDKFLDR" >> local.properties;
  155. $(OPENAL_TIMESTAMP) : openal_download
  156. @LAST_MODIF=$$(find ${OPENAL_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  157. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  158. touch ${OPENAL_TIMESTAMP}; \
  159. fi
  160. openal_download :
  161. @if [ ! -d ${OPENAL_DIR} ] ; then \
  162. echo "openal sources missing, downloading..."; \
  163. mkdir -p ${ANDR_ROOT}/deps; \
  164. cd ${ANDR_ROOT}/deps ; \
  165. git clone ${OPENAL_URL_GIT} || exit 1; \
  166. fi
  167. openal : $(OPENAL_LIB)
  168. $(OPENAL_LIB): $(OPENAL_TIMESTAMP)
  169. + @REFRESH=0; \
  170. if [ ! -e ${OPENAL_TIMESTAMP_INT} ] ; then \
  171. REFRESH=1; \
  172. fi; \
  173. if [ ${OPENAL_TIMESTAMP} -nt ${OPENAL_TIMESTAMP_INT} ] ; then \
  174. REFRESH=1; \
  175. fi; \
  176. if [ $$REFRESH -ne 0 ] ; then \
  177. echo "changed timestamp for openal detected building..."; \
  178. cd ${OPENAL_DIR}; \
  179. export APP_PLATFORM=${APP_PLATFORM}; \
  180. export TARGET_ABI=${TARGET_ABI}; \
  181. ${ANDROID_NDK}/ndk-build NDEBUG=${NDEBUG} \
  182. NDK_APPLICATION_MK=${ANDR_ROOT}/jni/Deps.mk || exit 1; \
  183. touch ${OPENAL_TIMESTAMP}; \
  184. touch ${OPENAL_TIMESTAMP_INT}; \
  185. else \
  186. echo "nothing to be done for openal"; \
  187. fi
  188. clean_openal :
  189. $(RM) -rf ${OPENAL_DIR}
  190. $(OGG_TIMESTAMP) : ogg_download
  191. @LAST_MODIF=$$(find ${OGG_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  192. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  193. touch ${OGG_TIMESTAMP}; \
  194. fi
  195. ogg_download :
  196. @if [ ! -d ${OGG_DIR} ] ; then \
  197. echo "ogg sources missing, downloading..."; \
  198. mkdir -p ${ANDR_ROOT}/deps; \
  199. cd ${ANDR_ROOT}/deps ; \
  200. git clone ${OGG_URL_GIT}|| exit 1; \
  201. cd libvorbis-libogg-android ; \
  202. patch -p1 < ${ANDR_ROOT}/patches/libvorbis-libogg-fpu.patch || exit 1; \
  203. fi
  204. ogg : $(OGG_LIB)
  205. $(OGG_LIB): $(OGG_TIMESTAMP)
  206. + @REFRESH=0; \
  207. if [ ! -e ${OGG_TIMESTAMP_INT} ] ; then \
  208. echo "${OGG_TIMESTAMP_INT} doesn't exist"; \
  209. REFRESH=1; \
  210. fi; \
  211. if [ ${OGG_TIMESTAMP} -nt ${OGG_TIMESTAMP_INT} ] ; then \
  212. REFRESH=1; \
  213. fi; \
  214. if [ $$REFRESH -ne 0 ] ; then \
  215. echo "changed timestamp for ogg detected building..."; \
  216. cd ${OGG_DIR}; \
  217. export APP_PLATFORM=${APP_PLATFORM}; \
  218. export TARGET_ABI=${TARGET_ABI}; \
  219. ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
  220. --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
  221. --platform=${APP_PLATFORM} \
  222. --install-dir=$${TOOLCHAIN}; \
  223. touch ${OGG_TIMESTAMP}; \
  224. touch ${OGG_TIMESTAMP_INT}; \
  225. else \
  226. echo "nothing to be done for libogg/libvorbis"; \
  227. fi
  228. clean_ogg :
  229. $(RM) -rf ${OGG_DIR}
  230. $(OPENSSL_TIMESTAMP) : openssl_download
  231. @LAST_MODIF=$$(find ${OPENSSL_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  232. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  233. touch ${OPENSSL_TIMESTAMP}; \
  234. fi
  235. openssl_download :
  236. @if [ ! -d ${OPENSSL_DIR} ] ; then \
  237. echo "openssl sources missing, downloading..."; \
  238. mkdir -p ${ANDR_ROOT}/deps; \
  239. cd ${ANDR_ROOT}/deps ; \
  240. wget ${OPENSSL_URL} || exit 1; \
  241. tar -xzf ${OPENSSL_BASEDIR}.tar.gz; \
  242. cd ${OPENSSL_BASEDIR}; \
  243. patch -p1 < ${ANDR_ROOT}/patches/openssl_arch.patch; \
  244. fi
  245. openssl : $(OPENSSL_LIB)
  246. $(OPENSSL_LIB): $(OPENSSL_TIMESTAMP)
  247. @REFRESH=0; \
  248. if [ ! -e ${OPENSSL_TIMESTAMP_INT} ] ; then \
  249. echo "${OPENSSL_TIMESTAMP_INT} doesn't exist"; \
  250. REFRESH=1; \
  251. fi; \
  252. if [ ${OPENSSL_TIMESTAMP} -nt ${OPENSSL_TIMESTAMP_INT} ] ; then \
  253. REFRESH=1; \
  254. fi; \
  255. if [ $$REFRESH -ne 0 ] ; then \
  256. echo "changed timestamp for openssl detected building..."; \
  257. cd ${OPENSSL_DIR}; \
  258. ln -s ${OPENSSL_DIR} ../openssl; \
  259. export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-openssl; \
  260. ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
  261. --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
  262. --platform=${APP_PLATFORM} \
  263. --install-dir=$${TOOLCHAIN}; \
  264. export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
  265. CC=${CROSS_PREFIX}gcc ./Configure -DL_ENDIAN android-${TARGET_ARCH};\
  266. CC=${CROSS_PREFIX}gcc ANDROID_DEV=/tmp/ndk-${TARGET_HOST} make depend; \
  267. CC=${CROSS_PREFIX}gcc ANDROID_DEV=/tmp/ndk-${TARGET_HOST} make build_libs; \
  268. touch ${OPENSSL_TIMESTAMP}; \
  269. touch ${OPENSSL_TIMESTAMP_INT}; \
  270. $(RM) -rf $${TOOLCHAIN}; \
  271. else \
  272. echo "nothing to be done for openssl"; \
  273. fi
  274. clean_openssl :
  275. $(RM) -rf ${OPENSSL_DIR}; \
  276. $(RM) -rf $(ANDR_ROOT)/deps/${OPENSSL_BASEDIR}.tar.gz; \
  277. $(RM) -rf $(ANDR_ROOT)/deps/openssl
  278. $(LEVELDB_TIMESTAMP) : leveldb_download
  279. @LAST_MODIF=$$(find ${LEVELDB_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  280. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  281. touch ${LEVELDB_TIMESTAMP}; \
  282. fi
  283. leveldb_download :
  284. @if [ ! -d ${LEVELDB_DIR} ] ; then \
  285. echo "leveldb sources missing, downloading..."; \
  286. mkdir -p ${ANDR_ROOT}/deps; \
  287. cd ${ANDR_ROOT}/deps ; \
  288. git clone ${LEVELDB_URL_GIT} || exit 1; \
  289. cd ${LEVELDB_DIR} || exit 1; \
  290. git checkout ${LEVELDB_COMMIT} || exit 1; \
  291. fi
  292. leveldb : $(LEVELDB_LIB)
  293. ifeq ($(HAVE_LEVELDB),1)
  294. $(LEVELDB_LIB): $(LEVELDB_TIMESTAMP)
  295. @REFRESH=0; \
  296. if [ ! -e ${LEVELDB_TIMESTAMP_INT} ] ; then \
  297. REFRESH=1; \
  298. fi; \
  299. if [ ${LEVELDB_TIMESTAMP} -nt ${LEVELDB_TIMESTAMP_INT} ] ; then \
  300. REFRESH=1; \
  301. fi; \
  302. if [ $$REFRESH -ne 0 ] ; then \
  303. echo "changed timestamp for leveldb detected building..."; \
  304. cd deps/leveldb; \
  305. export CROSS_PREFIX=${CROSS_PREFIX}; \
  306. export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-leveldb; \
  307. ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
  308. --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
  309. --platform=${APP_PLATFORM} \
  310. --install-dir=$${TOOLCHAIN}; \
  311. export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
  312. export CC=${CROSS_PREFIX}gcc; \
  313. export CXX=${CROSS_PREFIX}g++; \
  314. export CFLAGS="$${CFLAGS} ${TARGET_CFLAGS_ADDON}"; \
  315. export CPPFLAGS="$${CPPFLAGS} ${TARGET_CXXFLAGS_ADDON}"; \
  316. export LDFLAGS="$${LDFLAGS} ${TARGET_LDFLAGS_ADDON}"; \
  317. export TARGET_OS=OS_ANDROID_CROSSCOMPILE; \
  318. $(MAKE) || exit 1; \
  319. touch ${LEVELDB_TIMESTAMP}; \
  320. touch ${LEVELDB_TIMESTAMP_INT}; \
  321. $(RM) -rf $${TOOLCHAIN}; \
  322. else \
  323. echo "nothing to be done for leveldb"; \
  324. fi
  325. endif
  326. clean_leveldb :
  327. $(RM) -rf deps/leveldb
  328. $(FREETYPE_TIMESTAMP) : freetype_download
  329. @LAST_MODIF=$$(find ${FREETYPE_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  330. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  331. touch ${FREETYPE_TIMESTAMP}; \
  332. fi
  333. freetype_download :
  334. @if [ ! -d ${FREETYPE_DIR} ] ; then \
  335. echo "freetype sources missing, downloading..."; \
  336. mkdir -p ${ANDR_ROOT}/deps; \
  337. cd deps; \
  338. git clone ${FREETYPE_URL_GIT} || exit 1; \
  339. fi
  340. freetype : $(FREETYPE_LIB)
  341. $(FREETYPE_LIB) : $(FREETYPE_TIMESTAMP)
  342. + @REFRESH=0; \
  343. if [ ! -e ${FREETYPE_TIMESTAMP_INT} ] ; then \
  344. REFRESH=1; \
  345. fi; \
  346. if [ ! -e ${FREETYPE_LIB} ] ; then \
  347. REFRESH=1; \
  348. fi; \
  349. if [ ${FREETYPE_TIMESTAMP} -nt ${FREETYPE_TIMESTAMP_INT} ] ; then \
  350. REFRESH=1; \
  351. fi; \
  352. if [ $$REFRESH -ne 0 ] ; then \
  353. mkdir -p ${FREETYPE_DIR}; \
  354. echo "changed timestamp for freetype detected building..."; \
  355. cd ${FREETYPE_DIR}/Android/jni; \
  356. export APP_PLATFORM=${APP_PLATFORM}; \
  357. export TARGET_ABI=${TARGET_ABI}; \
  358. ${ANDROID_NDK}/ndk-build NDEBUG=${NDEBUG} \
  359. NDK_APPLICATION_MK=${ANDR_ROOT}/jni/Deps.mk || exit 1; \
  360. touch ${FREETYPE_TIMESTAMP}; \
  361. touch ${FREETYPE_TIMESTAMP_INT}; \
  362. else \
  363. echo "nothing to be done for freetype"; \
  364. fi
  365. clean_freetype :
  366. $(RM) -rf ${FREETYPE_DIR}
  367. $(ICONV_TIMESTAMP) : iconv_download
  368. @LAST_MODIF=$$(find ${ICONV_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  369. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  370. touch ${ICONV_TIMESTAMP}; \
  371. fi
  372. iconv_download :
  373. @if [ ! -d ${ICONV_DIR} ] ; then \
  374. echo "iconv sources missing, downloading..."; \
  375. mkdir -p ${ANDR_ROOT}/deps; \
  376. cd ${ANDR_ROOT}/deps; \
  377. wget ${ICONV_URL_HTTP} || exit 1; \
  378. tar -xzf libiconv-${ICONV_VERSION}.tar.gz || exit 1; \
  379. rm libiconv-${ICONV_VERSION}.tar.gz; \
  380. ln -s libiconv-${ICONV_VERSION} libiconv; \
  381. cd ${ICONV_DIR}; \
  382. patch -p1 < ${ANDR_ROOT}/patches/libiconv_android.patch; \
  383. patch -p1 < ${ANDR_ROOT}/patches/libiconv_stdio.patch; \
  384. fi
  385. iconv : $(ICONV_LIB)
  386. $(ICONV_LIB) : $(ICONV_TIMESTAMP)
  387. @REFRESH=0; \
  388. if [ ! -e ${ICONV_TIMESTAMP_INT} ] ; then \
  389. REFRESH=1; \
  390. fi; \
  391. if [ ! -e ${ICONV_LIB} ] ; then \
  392. REFRESH=1; \
  393. fi; \
  394. if [ ${ICONV_TIMESTAMP} -nt ${ICONV_TIMESTAMP_INT} ] ; then \
  395. REFRESH=1; \
  396. fi; \
  397. if [ $$REFRESH -ne 0 ] ; then \
  398. mkdir -p ${ICONV_DIR}; \
  399. echo "changed timestamp for iconv detected building..."; \
  400. cd ${ICONV_DIR}; \
  401. \
  402. export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-iconv; \
  403. ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
  404. --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
  405. --platform=${APP_PLATFORM} \
  406. --install-dir=$${TOOLCHAIN}; \
  407. export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
  408. export CFLAGS="$${CFLAGS} ${TARGET_CFLAGS_ADDON}"; \
  409. export CC=${CROSS_PREFIX}gcc; \
  410. export CXX=${CROSS_PREFIX}g++; \
  411. export TARGET_OS=OS_ANDROID_CROSSCOMPILE; \
  412. ./configure --host=${TARGET_HOST} || exit 1; \
  413. sed -i 's/LIBICONV_VERSION_INFO) /LIBICONV_VERSION_INFO) -avoid-version /g' lib/Makefile; \
  414. grep "iconv_LDFLAGS" src/Makefile; \
  415. $(MAKE) -s || exit 1; \
  416. touch ${ICONV_TIMESTAMP}; \
  417. touch ${ICONV_TIMESTAMP_INT}; \
  418. rm -rf ${TOOLCHAIN}; \
  419. else \
  420. echo "nothing to be done for iconv"; \
  421. fi
  422. clean_iconv :
  423. $(RM) -rf ${ICONV_DIR}
  424. #Note: Texturehack patch is required for gpu's not supporting color format
  425. # correctly. Known bad GPU:
  426. # -geforce on emulator
  427. # -Vivante Corporation GC1000 core (e.g. Galaxy Tab 3)
  428. irrlicht_download :
  429. @if [ ! -d "deps/irrlicht" ] ; then \
  430. echo "irrlicht sources missing, downloading..."; \
  431. mkdir -p ${ANDR_ROOT}/deps; \
  432. cd deps; \
  433. svn co ${IRRLICHT_URL_SVN} irrlicht || exit 1; \
  434. cd irrlicht; \
  435. patch -p1 < ${ANDR_ROOT}/patches/irrlicht-touchcount.patch || exit 1; \
  436. patch -p1 < ${ANDR_ROOT}/patches/irrlicht-back_button.patch || exit 1; \
  437. patch -p1 < ${ANDR_ROOT}/patches/irrlicht-texturehack.patch || exit 1; \
  438. patch -p1 < ${ANDR_ROOT}/patches/irrlicht-native_activity.patch || exit 1; \
  439. fi
  440. $(IRRLICHT_TIMESTAMP) : irrlicht_download
  441. @LAST_MODIF=$$(find ${IRRLICHT_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  442. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  443. touch ${IRRLICHT_TIMESTAMP}; \
  444. fi
  445. irrlicht : $(IRRLICHT_LIB)
  446. $(IRRLICHT_LIB): $(IRRLICHT_TIMESTAMP) $(FREETYPE_LIB)
  447. + @REFRESH=0; \
  448. if [ ! -e ${IRRLICHT_TIMESTAMP_INT} ] ; then \
  449. REFRESH=1; \
  450. fi; \
  451. if [ ! -e ${IRRLICHT_LIB} ] ; then \
  452. REFRESH=1; \
  453. fi; \
  454. if [ ${IRRLICHT_TIMESTAMP} -nt ${IRRLICHT_TIMESTAMP_INT} ] ; then \
  455. REFRESH=1; \
  456. fi; \
  457. if [ $$REFRESH -ne 0 ] ; then \
  458. mkdir -p ${IRRLICHT_DIR}; \
  459. echo "changed timestamp for irrlicht detected building..."; \
  460. cd deps/irrlicht/source/Irrlicht/Android; \
  461. export APP_PLATFORM=${APP_PLATFORM}; \
  462. export TARGET_ABI=${TARGET_ABI}; \
  463. ${ANDROID_NDK}/ndk-build NDEBUG=${NDEBUG} \
  464. NDK_APPLICATION_MK=${ANDR_ROOT}/jni/Irrlicht.mk || exit 1; \
  465. touch ${IRRLICHT_TIMESTAMP}; \
  466. touch ${IRRLICHT_TIMESTAMP_INT}; \
  467. else \
  468. echo "nothing to be done for irrlicht"; \
  469. fi
  470. clean_irrlicht :
  471. $(RM) -rf deps/irrlicht
  472. $(CURL_TIMESTAMP) : curl_download
  473. @LAST_MODIF=$$(find ${CURL_DIR} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  474. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  475. touch ${CURL_TIMESTAMP}; \
  476. fi
  477. curl_download :
  478. @if [ ! -d "deps/curl-${CURL_VERSION}" ] ; then \
  479. echo "curl sources missing, downloading..."; \
  480. mkdir -p ${ANDR_ROOT}/deps; \
  481. cd deps; \
  482. wget ${CURL_URL_HTTP} || exit 1; \
  483. tar -xjf curl-${CURL_VERSION}.tar.bz2 || exit 1; \
  484. rm curl-${CURL_VERSION}.tar.bz2; \
  485. ln -s curl-${CURL_VERSION} curl; \
  486. fi
  487. curl : $(CURL_LIB)
  488. $(CURL_LIB): $(CURL_TIMESTAMP) $(OPENSSL_LIB)
  489. @REFRESH=0; \
  490. if [ ! -e ${CURL_TIMESTAMP_INT} ] ; then \
  491. REFRESH=1; \
  492. fi; \
  493. if [ ! -e ${CURL_LIB} ] ; then \
  494. REFRESH=1; \
  495. fi; \
  496. if [ ${CURL_TIMESTAMP} -nt ${CURL_TIMESTAMP_INT} ] ; then \
  497. REFRESH=1; \
  498. fi; \
  499. if [ $$REFRESH -ne 0 ] ; then \
  500. mkdir -p ${CURL_DIR}; \
  501. echo "changed timestamp for curl detected building..."; \
  502. cd deps/curl-${CURL_VERSION}; \
  503. export CROSS_PREFIX=${CROSS_PREFIX}; \
  504. export TOOLCHAIN=/tmp/ndk-${TARGET_HOST}-curl; \
  505. ${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
  506. --toolchain=${TARGET_TOOLCHAIN}${COMPILER_VERSION} \
  507. --platform=${APP_PLATFORM} \
  508. --install-dir=$${TOOLCHAIN}; \
  509. export PATH="$${TOOLCHAIN}/bin:$${PATH}"; \
  510. export CC=${CROSS_PREFIX}gcc; \
  511. export CXX=${CROSS_PREFIX}g++; \
  512. export TARGET_OS=OS_ANDROID_CROSSCOMPILE; \
  513. export CPPFLAGS="$${CPPFLAGS} -I${OPENSSL_DIR}/include ${TARGET_CFLAGS_ADDON}"; \
  514. export CFLAGS="$${CFLAGS} ${TARGET_CFLAGS_ADDON}"; \
  515. export LDFLAGS="$${LDFLAGS} -L${OPENSSL_DIR} ${TARGET_LDFLAGS_ADDON}"; \
  516. ./configure --host=${TARGET_HOST} --disable-shared --enable-static --with-ssl; \
  517. $(MAKE) -s || exit 1; \
  518. touch ${CURL_TIMESTAMP}; \
  519. touch ${CURL_TIMESTAMP_INT}; \
  520. $(RM) -rf $${TOOLCHAIN}; \
  521. else \
  522. echo "nothing to be done for curl"; \
  523. fi
  524. clean_curl :
  525. $(RM) -rf deps/curl-${CURL_VERSION} \
  526. $(RM) -f deps/curl
  527. sqlite3_download: deps/${SQLITE3_FOLDER}/sqlite3.c
  528. deps/${SQLITE3_FOLDER}/sqlite3.c :
  529. cd deps; \
  530. wget ${SQLITE3_URL}; \
  531. unzip ${SQLITE3_FOLDER}.zip; \
  532. ln -s ${SQLITE3_FOLDER} sqlite; \
  533. cd ${SQLITE3_FOLDER};
  534. clean_sqlite3:
  535. cd deps && $(RM) -rf ${SQLITE3_FOLDER} && $(RM) -f ${SQLITE3_FOLDER}.zip && \
  536. $(RM) -f sqlite
  537. $(ASSETS_TIMESTAMP) : $(IRRLICHT_LIB)
  538. @mkdir -p ${ANDR_ROOT}/deps; \
  539. for DIRNAME in {builtin,client,doc,fonts,games,mods,po,textures}; do \
  540. LAST_MODIF=$$(find ${PROJ_ROOT}/${DIRNAME} -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  541. if [ $$(basename $$LAST_MODIF) != "timestamp" ]; then \
  542. touch ${PROJ_ROOT}/${DIRNAME}/timestamp; \
  543. touch ${ASSETS_TIMESTAMP}; \
  544. echo ${DIRNAME} changed $$LAST_MODIF; \
  545. fi; \
  546. done; \
  547. LAST_MODIF=$$(find ${IRRLICHT_DIR}/media -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "); \
  548. if [ $$(basename $$LAST_MODIF) != "timestamp" ] ; then \
  549. touch ${IRRLICHT_DIR}/media/timestamp; \
  550. touch ${ASSETS_TIMESTAMP}; \
  551. fi; \
  552. if [ ${PROJ_ROOT}/minetest.conf.example -nt ${ASSETS_TIMESTAMP} ] ; then \
  553. echo "conf changed"; \
  554. touch ${ASSETS_TIMESTAMP}; \
  555. fi; \
  556. if [ ${PROJ_ROOT}/README.txt -nt ${ASSETS_TIMESTAMP} ] ; then \
  557. touch ${ASSETS_TIMESTAMP}; \
  558. fi; \
  559. if [ ! -e $(ASSETS_TIMESTAMP) ] ; then \
  560. touch $(ASSETS_TIMESTAMP); \
  561. fi
  562. assets : $(ASSETS_TIMESTAMP)
  563. @REFRESH=0; \
  564. if [ ! -e ${ASSETS_TIMESTAMP}.old ] ; then \
  565. REFRESH=1; \
  566. fi; \
  567. if [ ${ASSETS_TIMESTAMP} -nt ${ASSETS_TIMESTAMP}.old ] ; then \
  568. REFRESH=1; \
  569. fi; \
  570. if [ ! -d ${APP_ROOT}/assets ] ; then \
  571. REFRESH=1; \
  572. fi; \
  573. if [ $$REFRESH -ne 0 ] ; then \
  574. echo "assets changed, refreshing..."; \
  575. $(MAKE) clean_assets; \
  576. mkdir -p ${APP_ROOT}/assets/Minetest; \
  577. cp ${PROJ_ROOT}/minetest.conf.example ${APP_ROOT}/assets/Minetest; \
  578. cp ${PROJ_ROOT}/README.txt ${APP_ROOT}/assets/Minetest; \
  579. cp -r ${PROJ_ROOT}/builtin ${APP_ROOT}/assets/Minetest; \
  580. mkdir -p ${APP_ROOT}/assets/Minetest/client; \
  581. cp -r ${PROJ_ROOT}/client/shaders ${APP_ROOT}/assets/Minetest/client; \
  582. cp ${PROJ_ROOT}/doc/lgpl-2.1.txt ${APP_ROOT}/assets/Minetest/LICENSE.txt; \
  583. mkdir -p ${APP_ROOT}/assets/Minetest/fonts; \
  584. cp -r ${PROJ_ROOT}/fonts/*.ttf ${APP_ROOT}/assets/Minetest/fonts/; \
  585. mkdir -p ${APP_ROOT}/assets/Minetest/games; \
  586. for game in ${GAMES_TO_COPY}; do \
  587. cp -r ${PROJ_ROOT}/games/$$game ${APP_ROOT}/assets/Minetest/games/; \
  588. done; \
  589. mkdir -p ${APP_ROOT}/assets/Minetest/mods; \
  590. for mod in ${MODS_TO_COPY}; do \
  591. cp -r ${PROJ_ROOT}/mods/$$mod ${APP_ROOT}/assets/Minetest/mods/; \
  592. done; \
  593. cp -r ${PROJ_ROOT}/po ${APP_ROOT}/assets/Minetest; \
  594. cp -r ${PROJ_ROOT}/textures ${APP_ROOT}/assets/Minetest; \
  595. mkdir -p ${APP_ROOT}/assets/Minetest/media; \
  596. cp -r ${IRRLICHT_DIR}/media/Shaders ${APP_ROOT}/assets/Minetest/media; \
  597. cd ${APP_ROOT}/assets || exit 1; \
  598. find . -name "timestamp" -exec rm {} \; ; \
  599. find . -name "*.blend" -exec rm {} \; ; \
  600. find . -name "*~" -exec rm {} \; ; \
  601. find . -type d -path "*.git" -exec rm -rf {} \; ; \
  602. find . -type d -path "*.svn" -exec rm -rf {} \; ; \
  603. find . -type f -path "*.gitignore" -exec rm -rf {} \; ; \
  604. ls -R | grep ":$$" | sed -e 's/:$$//' -e 's/\.//' -e 's/^\///' > "index.txt"; \
  605. find -L Minetest > filelist.txt; \
  606. cp ${ANDR_ROOT}/${ASSETS_TIMESTAMP} ${ANDR_ROOT}/${ASSETS_TIMESTAMP}.old; \
  607. else \
  608. echo "nothing to be done for assets"; \
  609. fi
  610. clean_assets :
  611. @$(RM) -r ${APP_ROOT}/assets
  612. apk: local.properties assets $(ICONV_LIB) $(IRRLICHT_LIB) $(CURL_LIB) $(LEVELDB_TARGET) \
  613. $(OPENAL_LIB) $(OGG_LIB) prep_srcdir $(ANDR_ROOT)/jni/src/android_version.h \
  614. $(ANDR_ROOT)/jni/src/android_version_githash.h sqlite3_download
  615. + @export TARGET_LIBDIR=${TARGET_LIBDIR}; \
  616. export HAVE_LEVELDB=${HAVE_LEVELDB}; \
  617. export APP_PLATFORM=${APP_PLATFORM}; \
  618. export TARGET_ABI=${TARGET_ABI}; \
  619. ${ANDROID_NDK}/ndk-build || exit 1; \
  620. if [ ! -e ${APP_ROOT}/jniLibs ]; then \
  621. ln -s ${ANDR_ROOT}/libs ${APP_ROOT}/jniLibs || exit 1; \
  622. fi; \
  623. export VERSION_STR="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" && \
  624. export BUILD_TYPE_C=$$(echo "$${BUILD_TYPE}" | sed 's/./\U&/') && \
  625. ./gradlew assemble$$BUILD_TYPE_C && \
  626. echo "APK stored at: build/outputs/apk/Minetest-$$BUILD_TYPE.apk" && \
  627. echo "You can install it with \`make install_$$BUILD_TYPE\`"
  628. # These Intentionally doesn't depend on their respective build steps,
  629. # because it takes a while to verify that everything's up-to-date.
  630. install_debug:
  631. ${ANDROID_SDK}/platform-tools/adb install -r build/outputs/apk/Minetest-debug.apk
  632. install_release:
  633. ${ANDROID_SDK}/platform-tools/adb install -r build/outputs/apk/Minetest-release.apk
  634. prep_srcdir :
  635. @if [ ! -e ${ANDR_ROOT}/jni/src ]; then \
  636. ln -s ${PROJ_ROOT}/src ${ANDR_ROOT}/jni/src; \
  637. fi; \
  638. if [ ! -e ${ANDR_ROOT}/jni/lib ]; then \
  639. ln -s ${PROJ_ROOT}/lib ${ANDR_ROOT}/jni/lib; \
  640. fi
  641. clean_apk :
  642. ./gradlew clean
  643. clean_all :
  644. @$(MAKE) clean_apk; \
  645. $(MAKE) clean_assets clean_iconv clean_irrlicht clean_leveldb clean_curl \
  646. clean_openssl clean_openal clean_ogg; \
  647. sleep 1; \
  648. $(RM) -r gen libs obj deps bin Debug and_env
  649. $(ANDR_ROOT)/jni/src/android_version_githash.h : prep_srcdir
  650. @export VERSION_FILE=${ANDR_ROOT}/jni/src/android_version_githash.h; \
  651. export VERSION_FILE_NEW=$${VERSION_FILE}.new; \
  652. { \
  653. echo "#ifndef ANDROID_MT_VERSION_GITHASH_H"; \
  654. echo "#define ANDROID_MT_VERSION_GITHASH_H"; \
  655. export GITHASH=$$(git rev-parse --short=8 HEAD); \
  656. export VERSION_STR="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"; \
  657. echo "#define VERSION_GITHASH \"$$VERSION_STR-$$GITHASH-Android\""; \
  658. echo "#endif"; \
  659. } > "$${VERSION_FILE_NEW}"; \
  660. if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \
  661. echo "android_version_githash.h changed, updating..."; \
  662. mv "$${VERSION_FILE_NEW}" "$${VERSION_FILE}"; \
  663. else \
  664. rm "$${VERSION_FILE_NEW}"; \
  665. fi
  666. $(ANDR_ROOT)/jni/src/android_version.h : prep_srcdir
  667. @export VERSION_FILE=${ANDR_ROOT}/jni/src/android_version.h; \
  668. export VERSION_FILE_NEW=$${VERSION_FILE}.new; \
  669. { \
  670. echo "#ifndef ANDROID_MT_VERSION_H"; \
  671. echo "#define ANDROID_MT_VERSION_H"; \
  672. echo "#define VERSION_MAJOR ${VERSION_MAJOR}"; \
  673. echo "#define VERSION_MINOR ${VERSION_MINOR}"; \
  674. echo "#define VERSION_PATCH ${VERSION_PATCH}"; \
  675. echo "#define VERSION_STRING STR(VERSION_MAJOR) \".\" STR(VERSION_MINOR) \
  676. \".\" STR(VERSION_PATCH)"; \
  677. echo "#endif"; \
  678. } > $${VERSION_FILE_NEW}; \
  679. if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \
  680. echo "android_version.h changed, updating..."; \
  681. mv "$${VERSION_FILE_NEW}" "$${VERSION_FILE}"; \
  682. else \
  683. rm "$${VERSION_FILE_NEW}"; \
  684. fi
  685. clean : clean_apk clean_assets