istereo2

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/android/Makefile	Sat Oct 03 06:10:30 2015 +0300
     1.3 @@ -0,0 +1,106 @@
     1.4 +bin = stereotunnel
     1.5 +root = ..
     1.6 +src = $(wildcard $(root)/src/*.c)
     1.7 +ccsrc = $(wildcard $(root)/src/*.cc)
     1.8 +
     1.9 +include $(root)/libs/Makefile
    1.10 +
    1.11 +# --- android settings ---
    1.12 +android_platform = android-19
    1.13 +name = $(bin)
    1.14 +pkgprefix = com.mutantstargoat
    1.15 +# ------------------------
    1.16 +
    1.17 +src += $(wildcard $(root)/src/android/*.c)
    1.18 +
    1.19 +obj = $(src:.c=.o) $(ccsrc:.cc=.o)
    1.20 +lib = libs/armeabi/lib$(name).so
    1.21 +apk-release = bin/$(name).apk
    1.22 +apk-debug = bin/$(name)-debug.apk
    1.23 +
    1.24 +pkg = $(pkgprefix).$(name)
    1.25 +act = android.app.NativeActivity
    1.26 +
    1.27 +CC = arm-linux-androideabi-gcc
    1.28 +CXX = arm-linux-androideabi-g++
    1.29 +
    1.30 +android_libs = -lstdc++ -llog -landroid -lEGL -lGLESv2
    1.31 +
    1.32 +defs += -DANDROID -DAPP_NAME=\"$(name)\" -DNO_FREETYPE -DHAVE_OPENGL_H
    1.33 +CXXFLAGS = -Wall -g $(defs) -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 \
    1.34 +		 $(android_inc) -I$(root)/src -I$(root)/src/android $(incdir)
    1.35 +CFLAGS = -std=c99 $(CXXFLAGS)
    1.36 +LDFLAGS = -Wl,--fix-cortex-a8 -Wl,-z,defs $(android_libs) $(libpaths) -lm
    1.37 +
    1.38 +.PHONY: debug
    1.39 +debug: $(apk-debug)
    1.40 +
    1.41 +.PHONY: release
    1.42 +release: $(apk-release)
    1.43 +
    1.44 +$(apk-debug): $(lib) $(jsrc) AndroidManifest.xml assets/data assets/sdr
    1.45 +	ant debug
    1.46 +
    1.47 +$(apk-release): $(lib) $(jsrc) AndroidManifest.xml assets/data assets/sdr
    1.48 +	ant release
    1.49 +
    1.50 +assets/data:
    1.51 +	mkdir -p assets
    1.52 +	cd assets && rm -f data && ln -s ../../data .
    1.53 +
    1.54 +assets/sdr:
    1.55 +	mkdir -p assets
    1.56 +	cd assets && rm -f sdr && ln -s ../../sdr .
    1.57 +
    1.58 +.PHONY: lib
    1.59 +lib: $(lib)
    1.60 +
    1.61 +$(lib): $(obj)
    1.62 +	@mkdir -p libs/armeabi
    1.63 +	$(CXX) -o $@ -shared $(obj) $(LDFLAGS)
    1.64 +
    1.65 +ant_files = *.xml *.properties proguard-project.txt
    1.66 +ant_dirs = bin libs res obj src gen
    1.67 +
    1.68 +.PHONY: clean
    1.69 +clean:
    1.70 +	rm -f $(obj) $(lib) $(apk-release) $(apk-debug) $(ant_files)
    1.71 +	rm -rf $(ant_dirs)
    1.72 +	rm -f assets/data assets/sdr
    1.73 +	[ -d assets ] && rmdir assets || true
    1.74 +
    1.75 +.PHONY: install
    1.76 +install: install-debug
    1.77 +
    1.78 +.PHONY: install-debug
    1.79 +install-debug:
    1.80 +	adb install -r $(apk-debug)
    1.81 +
    1.82 +.PHONY: install-release
    1.83 +install-release:
    1.84 +	adb install -r $(apk-release)
    1.85 +
    1.86 +.PHONY: uninstall
    1.87 +uninstall:
    1.88 +	adb uninstall $(pkg)
    1.89 +
    1.90 +.PHONY: run
    1.91 +run:
    1.92 +	adb shell am start -n $(pkg)/$(act)
    1.93 +
    1.94 +.PHONY: stop
    1.95 +stop:
    1.96 +	adb shell am force-stop $(pkg)
    1.97 +
    1.98 +AndroidManifest.xml: manifest.xml.in
    1.99 +	android create project -p . -t $(android_platform) -k $(pkg) -a NativeActivity -n $(name)
   1.100 +	cat manifest.xml.in | sed 's/$$APPNAME/$(name)/g' | sed 's/$$APPTITLE/$(title)/g' >$@
   1.101 +#	cd src && rm -f *.java && ln -s ../../src/android/*.java .
   1.102 +
   1.103 +.PHONY: update-project
   1.104 +update-project: build.xml
   1.105 +	android update project -p . -t $(android_platform)
   1.106 +
   1.107 +.PHONY: logcat
   1.108 +logcat:
   1.109 +	adb logcat $(name):V AndroidRuntime:V DEBUG:V '*:S'