imxtools/sbloader: implement stmp36xx recovery support
[maemo-rb.git] / android / android.make
blob7bbe199e6fe6199786aa9594e5341ea23ee735f6
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 PACKAGE=org.rockbox
11 PACKAGE_PATH=org/rockbox
12 BINLIB_DIR=$(BUILDDIR)/libs/$(ANDROID_ARCH)
13 ANDROID_DIR=$(ROOTDIR)/android
15 # this is a glibc compatibility hack to provide a get_nprocs() replacement.
16 # The NDK ships cpu-features.c which has a compatible function android_getCpuCount()
17 CPUFEAT = $(ANDROID_DIR)/cpufeatures
18 CPUFEAT_BUILD = $(subst $(ANDROID_DIR),$(BUILDDIR),$(CPUFEAT))
19 INCLUDES += -I$(CPUFEAT)
20 OTHER_SRC += $(CPUFEAT)/cpu-features.c
21 CLEANOBJS += $(CPUFEAT_BUILD)/cpu-features.o
22 $(CPUFEAT_BUILD)/cpu-features.o: $(CPUFEAT)/cpu-features.c
23 $(SILENT)mkdir -p $(dir $@)
24 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -o $@ -c $^ $(GCCOPTS) -Wno-unused
26 .SECONDEXPANSION: # $$(JAVA_OBJ) is not populated until after this
27 .SECONDEXPANSION: # $$(OBJ) is not populated until after this
28 .PHONY: apk classes clean dex dirs libs jar
30 # API version
31 ANDROID_PLATFORM_VERSION=15
32 ANDROID_PLATFORM=$(ANDROID_SDK_PATH)/platforms/android-$(ANDROID_PLATFORM_VERSION)
34 # android tools
35 AAPT=$(ANDROID_SDK_PATH)/platform-tools/aapt
36 DX=$(ANDROID_SDK_PATH)/platform-tools/dx
37 APKBUILDER=$(ANDROID_SDK_PATH)/tools/apkbuilder
38 ZIPALIGN=$(ANDROID_SDK_PATH)/tools/zipalign
39 KEYSTORE=$(HOME)/.android/debug.keystore
40 ADB=$(ANDROID_SDK_PATH)/platform-tools/adb
42 CLASSPATH := $(BUILDDIR)/bin/classes
44 MANIFEST := $(BUILDDIR)/bin/AndroidManifest.xml
45 MANIFEST_SRC := $(ANDROID_DIR)/AndroidManifest.xml
47 R_JAVA := $(BUILDDIR)/gen/$(PACKAGE_PATH)/R.java
48 R_OBJ := $(CLASSPATH)/$(PACKAGE_PATH)/R.class
50 JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java)
51 JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/Helper/*.java)
52 JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/widgets/*.java)
53 JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/monitors/*.java)
55 java2class = $(addsuffix .class,$(basename $(subst $(ANDROID_DIR)/src,$(CLASSPATH),$(1))))
57 JAVA_OBJ := $(call java2class,$(JAVA_SRC))
60 LIBS := $(BINLIB_DIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so
61 LIBS += $(addprefix $(BINLIB_DIR)/lib,$(patsubst %.codec,%.so,$(notdir $(CODECS))))
63 TEMP_APK := $(BUILDDIR)/bin/_rockbox.apk
64 TEMP_APK2 := $(BUILDDIR)/bin/__rockbox.apk
65 DEX := $(BUILDDIR)/bin/classes.dex
66 JAR := $(BUILDDIR)/bin/classes.jar
67 AP_ := $(BUILDDIR)/bin/resources.ap_
68 APK := $(BUILDDIR)/rockbox.apk
70 _DIRS := $(BUILDDIR)/___/$(PACKAGE_PATH)
71 DIRS += $(subst ___,gen,$(_DIRS))
72 DIRS += $(subst ___,data,$(_DIRS))
73 DIRS += $(BUILDDIR)/libs/$(ANDROID_ARCH)
74 DIRS += $(CPUFEAT_BUILD)
75 DIRS += $(CLASSPATH)
77 RES := $(wildcard $(ANDROID_DIR)/res/*/*)
79 CLEANOBJS += bin gen libs data
81 JAVAC_OPTS += -source 1.6 -target 1.6 -implicit:none -classpath $(ANDROID_PLATFORM)/android.jar:$(CLASSPATH)
83 .PHONY:
84 $(MANIFEST): $(MANIFEST_SRC) $(DIRS)
85 $(call PRINTS,MANIFEST $(@F))sed -e 's/versionName="1.0"/versionName="$(SVNVERSION)"/;s/screenOrientation="portrait"/screenOrientation="$(LCDORIENTATION)"/' $(MANIFEST_SRC) > $(MANIFEST)
87 $(R_JAVA) $(AP_): $(MANIFEST) $(RES) | $(DIRS)
88 $(call PRINTS,AAPT $(subst $(BUILDDIR)/,,$@))$(AAPT) package -f -m \
89 -J $(BUILDDIR)/gen -M $(MANIFEST) -S $(ANDROID_DIR)/res \
90 -I $(ANDROID_PLATFORM)/android.jar -F $(AP_)
92 $(CLASSPATH)/$(PACKAGE_PATH)/R.class: $(R_JAVA)
93 $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \
94 $(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/gen $<
96 $(CLASSPATH)/$(PACKAGE_PATH)/%.class: $(ANDROID_DIR)/src/$(PACKAGE_PATH)/%.java $(CLASSPATH)/$(PACKAGE_PATH)/R.class
97 $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(CLASSPATH) \
98 $(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/src $<
100 $(JAR): $(JAVA_SRC) $(R_JAVA)
101 $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$?))javac -d $(CLASSPATH) \
102 $(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/src:$(ANDROID_DIR)/gen $?
103 $(call PRINTS,JAR $(subst $(BUILDDIR)/,,$@))jar cf $(JAR) -C $(CLASSPATH) org
105 jar: $(JAR)
107 $(DEX): $(JAR)
108 @echo "Checking for deleted class files" && $(foreach obj,$(JAVA_OBJ) $(R_OBJ), \
109 (test -f $(obj) || (echo "$(obj) is missing. Run 'make classes' to fix." && false)) && ) true
110 $(call PRINTS,DX $(subst $(BUILDDIR)/,,$@))$(DX) --dex --output=$@ $<
112 dex: $(DEX)
114 classes: $(R_OBJ) $(JAVA_OBJ)
117 $(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(CPUFEAT_BUILD)/cpu-features.o
118 $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
119 $(call PRINTS,OC $(@F))$(call objcopy,$@,$@)
121 $(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY)
122 $(call PRINTS,CP $(BINARY))cp $^ $@
124 $(BINLIB_DIR)/libmisc.so: $(BUILDDIR)/rockbox.zip
125 $(call PRINTS,CP rockbox.zip)cp $^ $@
127 $(BINLIB_DIR)/lib%.so: $(RBCODEC_BLD)/codecs/%.codec
128 $(call PRINTS,CP $(@F))cp $^ $@
130 libs: $(DIRS) $(LIBS)
132 $(TEMP_APK): $(AP_) $(LIBS) $(DEX) | $(DIRS)
133 $(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(APKBUILDER) $@ \
134 -u -z $(AP_) -f $(DEX) -nf $(BUILDDIR)/libs
136 $(KEYSTORE):
137 $(SILENT)mkdir -p $(HOME)/.android
138 $(call PRINTS,KEYTOOL debug.keystore)keytool -genkey \
139 -alias androiddebugkey -keystore $@ \
140 -storepass android -keypass android -validity 365 \
141 -sigalg MD5withRSA -keyalg RSA -keysize 1024 \
142 -dname "CN=Android Debug,O=Android,C=US"
144 ifdef NODEPS
145 $(APK): $(TEMP_APK) $(KEYSTORE)
146 else
147 $(APK): $(TEMP_APK) $(BUILDDIR)/rockbox.zip $(KEYSTORE)
148 endif
149 $(SILENT)rm -f $@
150 $(call PRINTS,SIGN $(subst $(BUILDDIR)/,,$@))jarsigner \
151 -keystore "$(KEYSTORE)" -storepass "android" -keypass "android" \
152 -signedjar $(TEMP_APK2) $(TEMP_APK) "androiddebugkey" \
153 -sigalg MD5withRSA -digestalg SHA1
154 $(SILENT)$(ZIPALIGN) -v 4 $(TEMP_APK2) $@ > /dev/null
156 $(DIRS):
157 $(SILENT)mkdir -p $@
159 dirs: $(DIRS)
161 apk: $(APK)
163 install: apk
164 $(SILENT)$(ADB) install -r $(APK)
166 launch:
167 $(SILENT)echo 'am start -a android.intent.action.MAIN -n org.rockbox/.RockboxActivity; exit' | $(ADB) shell >/dev/null