2 # Common Makefile pieces for building Java / Android apps.
6 # BOOTSTRAPDIR needs to be set to this directory before starting this
9 # Probably would be best to just stop fooling around with the possibilities to
10 # set various stuff with the -env command line parameters (and environment
11 # variables?) and in a plethora of rc files, and hardcode construction of
12 # *all* required pathnames based on the app installation location for Android
13 # (and iOS), etc. We don't really win anything by having so many layers of
14 # configurability on platforms like Android and iOS where apps based on LO
15 # code are very much self-contained pre-packaged thingies.
16 APP_DATA_PATH=/data/data/$(APP_PACKAGE)
18 SODEST=libs/$(ANDROID_APP_ABI)
19 OBJLOCAL=obj/local/$(ANDROID_APP_ABI)
22 $(error COPYSO should not be used now with DISABLE_DYNLOADING)
26 mkdir -p libs && cp $(1) libs
34 # The Android SDK recommends you copy/paste some big -package-resources
35 # rule in order to not pack certain kinds of resources. Unfortunately this
36 # rule interacts with the rest of the ant code in horrible ways such that
37 # upgrading your SDK auto-breaks everything.
41 $(BOOTSTRAPDIR)/no-resource-compress.xml : $(ANDROID_SDK_HOME)/tools/ant/build.xml
43 android_sdk_ver=`grep 'Pkg.Revision' $(ANDROID_SDK_HOME)/tools/source.properties | sed 's/^.*=//' | sed 's/\..*//'` ; \
44 cp $(BOOTSTRAPDIR)/no-resource-compress-$$android_sdk_ver.xml $(BOOTSTRAPDIR)/no-resource-compress.xml ; \
45 if ! test -f $(BOOTSTRAPDIR)/no-resource-compress.xml; then \
46 echo "Unknown Android SDK version: $$android_sdk_ver"; \
51 android_version_setup : $(BOOTSTRAPDIR)/no-resource-compress.xml
54 echo sdk.dir=$(ANDROID_SDK_HOME) >local.properties
55 echo sdk.dir=$(ANDROID_SDK_HOME) >../../Bootstrap/local.properties
56 echo "# File needed by ndk-gdb" >jni/Application.mk
57 echo "APP_ABI := $(ANDROID_APP_ABI)" > jni/Application.mk
58 echo "APP_PLATFORM := android-14" >> jni/Application.mk
61 unset JAVA_HOME && $(ANT) -quiet debug install
63 @echo 'Run it with "make run"'
67 $(ANDROID_SDK_HOME)/platform-tools/adb uninstall $(APP_PACKAGE)
69 clean: android_version_setup properties
70 $(ANT) -quiet -keep-going clean
71 rm -rf assets libs $(SODEST) $(OBJLOCAL) $(BOOTSTRAPDIR)/no-resource-compress.xml
74 # Build / link the single .so for this app
78 $(wildcard $(OUTDIR)/lib/lib*.a) \
83 $(addprefix -l,$(strip \
86 -Wl,--no-whole-archive
89 $(OBJLOCAL)/liblo-native-code.so : $(wildcard $(OUTDIR)/lib/lib*.a) native-code.cxx
91 $(CXX) -Wl,-Map,liblo-native-code.map -Wl,--gc-sections -Wl,--version-script=../../Bootstrap/version.map -Wl,--no-keep-files-mapped -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -o $(OBJLOCAL)/liblo-native-code.so -I$(SRCDIR)/include -I$(OUTDIR)/inc native-code.cxx -L$(OUTDIR)/lib $(WHOLELIBS) $(LIBS) -lgnustl_static -landroid -ljnigraphics -llog -lz
93 $(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so
95 $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so
97 # shrinkme $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so
99 link-so: $(SODEST)/liblo-native-code.so
101 # If you reinstall an app several times *on the emulator*, even if you
102 # uninstall it between, disk space seems to leak that won't get recycled until
103 # you stop and start... No idea if this holds for a device, too. (And you
104 # can't "stop" a device anyway.)
107 $(ANDROID_SDK_HOME)/platform-tools/adb shell stop && $(ANDROID_SDK_HOME)/platform-tools/adb shell start && sleep 10