istereo2

annotate android/Makefile @ 23:7d795dade0bc

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