Add a safety check in the resume seek code, just in case.
[kugel-rb.git] / android / android.make
blob53d5d46bbfd214b1ccb6153bb8380f1b6b495293
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 .SECONDEXPANSION: # $$(JAVA_OBJ) is not populated until after this
11 .SECONDEXPANSION: # $$(OBJ) is not populated until after this
12 .PHONY: apk classes clean dex dirs libs
14 $(BUILDDIR)/$(BINARY): $$(OBJ) $(VOICESPEEXLIB) $(FIRMLIB) $(SKINLIB)
15 $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS)
17 PACKAGE=org.rockbox
18 PACKAGE_PATH=org/rockbox
19 ANDROID_DIR=$(ROOTDIR)/android
20 BINLIB_DIR=$(BUILDDIR)/libs/armeabi
22 java2class = $(addsuffix .class,$(basename $(subst $(ANDROID_DIR),$(BUILDDIR),$(1))))
24 # API version
25 ANDROID_PLATFORM_VERSION=8
26 ANDROID_PLATFORM=$(ANDROID_SDK_PATH)/platforms/android-$(ANDROID_PLATFORM_VERSION)
28 # android tools
29 AAPT=$(ANDROID_PLATFORM)/tools/aapt
30 DX=$(ANDROID_PLATFORM)/tools/dx
31 APKBUILDER=$(ANDROID_SDK_PATH)/tools/apkbuilder
32 ZIPALIGN=$(ANDROID_SDK_PATH)/tools/zipalign
33 KEYSTORE=$(HOME)/.android/debug.keystore
34 ADB=$(ANDROID_SDK_PATH)/platform-tools/adb
36 MANIFEST := $(ANDROID_DIR)/AndroidManifest.xml
38 R_JAVA := $(BUILDDIR)/gen/$(PACKAGE_PATH)/R.java
39 R_OBJ := $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class
41 JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/Helper/*.java)
42 JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java)
43 JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/widgets/*.java)
44 JAVA_OBJ := $(call java2class,$(subst $(ANDROID)/src/$(PACKAGE_PATH),$(ANDROID)/bin/$(PACKAGE_PATH),$(JAVA_SRC)))
47 LIBS := $(BINLIB_DIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so
48 TEMP_APK := $(BUILDDIR)/bin/_rockbox.apk
49 TEMP_APK2 := $(BUILDDIR)/bin/__rockbox.apk
50 DEX := $(BUILDDIR)/bin/classes.dex
51 AP_ := $(BUILDDIR)/bin/resources.ap_
52 APK := $(BUILDDIR)/rockbox.apk
54 _DIRS := $(BUILDDIR)/___/$(PACKAGE_PATH)
55 DIRS := $(subst ___,bin,$(_DIRS))
56 DIRS += $(subst ___,gen,$(_DIRS))
57 DIRS += $(subst ___,data,$(_DIRS))
58 DIRS += $(BUILDDIR)/libs/armeabi
60 RES := $(wildcard $(ANDROID_DIR)/res/*/*)
62 CLEANOBJS += bin gen libs data
64 $(R_JAVA) $(AP_): $(MANIFEST) $(DIRS) $(RES)
65 $(call PRINTS,AAPT $(subst $(BUILDDIR)/,,$@))$(AAPT) package -f -m \
66 -J $(BUILDDIR)/gen -M $(MANIFEST) -S $(ANDROID_DIR)/res \
67 -I $(ANDROID_PLATFORM)/android.jar -F $(AP_)
69 $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class: $(R_JAVA)
70 $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \
71 -classpath $(ANDROID_PLATFORM)/android.jar:$(BUILDDIR)/bin \
72 -sourcepath $(ANDROID_DIR)/gen:$(ANDROID_DIR)/src $<
74 $(BUILDDIR)/bin/$(PACKAGE_PATH)/%.class: $(ANDROID_DIR)/src/$(PACKAGE_PATH)/%.java $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class
75 $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \
76 -classpath $(ANDROID_PLATFORM)/android.jar:$(BUILDDIR)/bin \
77 -sourcepath $(ANDROID_DIR)/gen:$(ANDROID_DIR)/src $<
79 $(DEX): $(R_OBJ) $(JAVA_OBJ)
80 $(call PRINTS,DX $(subst $(BUILDDIR)/,,$@))$(DX) --dex --output=$@ $(BUILDDIR)/bin
82 classes: $(R_OBJ) $(JAVA_OBJ)
84 dex: $(DEX)
86 $(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY)
87 $(call PRINTS,CP $(BINARY))cp $^ $@
89 $(BINLIB_DIR)/libmisc.so: $(BUILDDIR)/rockbox.zip
90 $(call PRINTS,CP rockbox.zip)cp $^ $@
92 libs: $(LIBS)
94 $(TEMP_APK): $(AP_) $(DIRS) $(LIBS) $(DEX)
95 $(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(APKBUILDER) $@ \
96 -u -z $(AP_) -f $(DEX) -nf $(BUILDDIR)/libs
98 $(KEYSTORE):
99 $(call PRINTS,KEYTOOL debug.keystore)keytool -genkey \
100 -alias androiddebugkey -keystore $@ \
101 -storepass android -keypass android -validity 365 \
102 -dname "CN=Android Debug,O=Android,C=US"
104 $(APK): $(TEMP_APK) $(BUILDDIR)/rockbox.zip $(KEYSTORE)
105 $(SILENT)rm -f $@
106 $(call PRINTS,SIGN $(subst $(BUILDDIR)/,,$@))jarsigner \
107 -keystore "$(KEYSTORE)" -storepass "android" -keypass "android" \
108 -signedjar $(TEMP_APK2) $(TEMP_APK) "androiddebugkey"
109 $(SILENT)$(ZIPALIGN) -v 4 $(TEMP_APK2) $@ > /dev/null
111 $(DIRS):
112 $(SILENT)mkdir -p $@
114 dirs: $(DIRS)
116 apk: $(APK)
118 install: apk
119 $(ADB) install -r $(APK)