istereo2

annotate android/Makefile @ 24:9d53a4938ce8

port to android mostly complete, ads not done, and needs some polishing
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 04 Oct 2015 08:15:24 +0300
parents 7d795dade0bc
children a9f2d30f7e8e
rev   line source
nuclear@23 1 bin = stereotunnel
nuclear@23 2 root = ..
nuclear@23 3 src = $(wildcard $(root)/src/*.c)
nuclear@23 4 ccsrc = $(wildcard $(root)/src/*.cc)
nuclear@23 5
nuclear@23 6 include $(root)/libs/Makefile
nuclear@23 7
nuclear@23 8 # --- android settings ---
nuclear@23 9 android_platform = android-19
nuclear@23 10 name = $(bin)
nuclear@23 11 pkgprefix = com.mutantstargoat
nuclear@23 12 # ------------------------
nuclear@23 13
nuclear@23 14 src += $(wildcard $(root)/src/android/*.c)
nuclear@24 15 jsrc = $(wildcard $(root)/src/android/*.java)
nuclear@23 16
nuclear@23 17 obj = $(src:.c=.o) $(ccsrc:.cc=.o)
nuclear@23 18 lib = libs/armeabi/lib$(name).so
nuclear@23 19 apk-release = bin/$(name).apk
nuclear@23 20 apk-debug = bin/$(name)-debug.apk
nuclear@23 21
nuclear@23 22 pkg = $(pkgprefix).$(name)
nuclear@24 23 act = $(pkg).MainActivity
nuclear@23 24
nuclear@23 25 CC = arm-linux-androideabi-gcc
nuclear@23 26 CXX = arm-linux-androideabi-g++
nuclear@23 27
nuclear@23 28 android_libs = -lstdc++ -llog -landroid -lEGL -lGLESv2
nuclear@23 29
nuclear@23 30 defs += -DANDROID -DAPP_NAME=\"$(name)\" -DNO_FREETYPE -DHAVE_OPENGL_H
nuclear@23 31 CXXFLAGS = -Wall -g $(defs) -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 \
nuclear@23 32 $(android_inc) -I$(root)/src -I$(root)/src/android $(incdir)
nuclear@23 33 CFLAGS = -std=c99 $(CXXFLAGS)
nuclear@23 34 LDFLAGS = -Wl,--fix-cortex-a8 -Wl,-z,defs $(android_libs) $(libpaths) -lm
nuclear@23 35
nuclear@23 36 .PHONY: debug
nuclear@23 37 debug: $(apk-debug)
nuclear@23 38
nuclear@23 39 .PHONY: release
nuclear@23 40 release: $(apk-release)
nuclear@23 41
nuclear@23 42 $(apk-debug): $(lib) $(jsrc) AndroidManifest.xml assets/data assets/sdr
nuclear@23 43 ant debug
nuclear@23 44
nuclear@23 45 $(apk-release): $(lib) $(jsrc) AndroidManifest.xml assets/data assets/sdr
nuclear@23 46 ant release
nuclear@23 47
nuclear@23 48 assets/data:
nuclear@23 49 mkdir -p assets
nuclear@23 50 cd assets && rm -f data && ln -s ../../data .
nuclear@23 51
nuclear@23 52 assets/sdr:
nuclear@23 53 mkdir -p assets
nuclear@23 54 cd assets && rm -f sdr && ln -s ../../sdr .
nuclear@23 55
nuclear@23 56 .PHONY: lib
nuclear@23 57 lib: $(lib)
nuclear@23 58
nuclear@23 59 $(lib): $(obj)
nuclear@23 60 @mkdir -p libs/armeabi
nuclear@23 61 $(CXX) -o $@ -shared $(obj) $(LDFLAGS)
nuclear@23 62
nuclear@23 63 ant_files = *.xml *.properties proguard-project.txt
nuclear@23 64 ant_dirs = bin libs res obj src gen
nuclear@23 65
nuclear@23 66 .PHONY: clean
nuclear@23 67 clean:
nuclear@23 68 rm -f $(obj) $(lib) $(apk-release) $(apk-debug) $(ant_files)
nuclear@23 69 rm -rf $(ant_dirs)
nuclear@23 70 rm -f assets/data assets/sdr
nuclear@23 71 [ -d assets ] && rmdir assets || true
nuclear@23 72
nuclear@23 73 .PHONY: install
nuclear@23 74 install: install-debug
nuclear@23 75
nuclear@23 76 .PHONY: install-debug
nuclear@23 77 install-debug:
nuclear@23 78 adb install -r $(apk-debug)
nuclear@23 79
nuclear@23 80 .PHONY: install-release
nuclear@23 81 install-release:
nuclear@23 82 adb install -r $(apk-release)
nuclear@23 83
nuclear@23 84 .PHONY: uninstall
nuclear@23 85 uninstall:
nuclear@23 86 adb uninstall $(pkg)
nuclear@23 87
nuclear@23 88 .PHONY: run
nuclear@23 89 run:
nuclear@23 90 adb shell am start -n $(pkg)/$(act)
nuclear@23 91
nuclear@23 92 .PHONY: stop
nuclear@23 93 stop:
nuclear@23 94 adb shell am force-stop $(pkg)
nuclear@23 95
nuclear@23 96 AndroidManifest.xml: manifest.xml.in
nuclear@23 97 android create project -p . -t $(android_platform) -k $(pkg) -a NativeActivity -n $(name)
nuclear@23 98 cat manifest.xml.in | sed 's/$$APPNAME/$(name)/g' | sed 's/$$APPTITLE/$(title)/g' >$@
nuclear@24 99 cd src && rm -f *.java && ln -s ../../src/android/*.java .
nuclear@23 100
nuclear@23 101 .PHONY: update-project
nuclear@23 102 update-project: build.xml
nuclear@23 103 android update project -p . -t $(android_platform)
nuclear@23 104
nuclear@23 105 .PHONY: logcat
nuclear@23 106 logcat:
nuclear@23 107 adb logcat $(name):V AndroidRuntime:V DEBUG:V '*:S'