blob: e4fd3693dea9cce3b24ed7b363b2de0cdeb29b57 [file] [log] [blame]
Thomas Martitzf8381d92010-09-02 00:24:40 +00001# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
9
Thomas Martitz4e982d32010-09-02 03:40:02 +000010.SECONDEXPANSION: # $$(JAVA_OBJ) is not populated until after this
Thomas Martitzf8381d92010-09-02 00:24:40 +000011.SECONDEXPANSION: # $$(OBJ) is not populated until after this
Frank Gevaerts276321e2011-02-02 22:13:51 +000012.PHONY: apk classes clean dex dirs libs jar
Thomas Martitz4e982d32010-09-02 03:40:02 +000013
Thomas Martitzf8381d92010-09-02 00:24:40 +000014$(BUILDDIR)/$(BINARY): $$(OBJ) $(VOICESPEEXLIB) $(FIRMLIB) $(SKINLIB)
15 $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS)
Thomas Martitz4e982d32010-09-02 03:40:02 +000016
17PACKAGE=org.rockbox
18PACKAGE_PATH=org/rockbox
19ANDROID_DIR=$(ROOTDIR)/android
Thomas Martitz994aba12010-09-02 14:58:36 +000020BINLIB_DIR=$(BUILDDIR)/libs/armeabi
Thomas Martitz4e982d32010-09-02 03:40:02 +000021
Thomas Martitz4e982d32010-09-02 03:40:02 +000022java2class = $(addsuffix .class,$(basename $(subst $(ANDROID_DIR),$(BUILDDIR),$(1))))
23
Björn Stenberg40e61a72010-09-21 09:22:52 +000024# API version
Maurus Cuelenaere43641112011-03-11 15:45:34 +000025ANDROID_PLATFORM_VERSION=11
Thomas Martitz4e982d32010-09-02 03:40:02 +000026ANDROID_PLATFORM=$(ANDROID_SDK_PATH)/platforms/android-$(ANDROID_PLATFORM_VERSION)
Björn Stenberg40e61a72010-09-21 09:22:52 +000027
28# android tools
Maurus Cuelenaere43641112011-03-11 15:45:34 +000029AAPT=$(ANDROID_SDK_PATH)/platform-tools/aapt
30DX=$(ANDROID_SDK_PATH)/platform-tools/dx
Thomas Martitz4e982d32010-09-02 03:40:02 +000031APKBUILDER=$(ANDROID_SDK_PATH)/tools/apkbuilder
32ZIPALIGN=$(ANDROID_SDK_PATH)/tools/zipalign
Björn Stenberg40e61a72010-09-21 09:22:52 +000033KEYSTORE=$(HOME)/.android/debug.keystore
Antoine Celleriera448d8b2011-01-24 17:06:04 +000034ADB=$(ANDROID_SDK_PATH)/platform-tools/adb
Thomas Martitz4e982d32010-09-02 03:40:02 +000035
Dominik Riebelingfc68a0d2011-05-29 18:44:42 +000036MANIFEST := $(BUILDDIR)/bin/AndroidManifest.xml
Dominik Riebelingbc3f9c12011-05-29 17:23:52 +000037MANIFEST_SRC := $(ANDROID_DIR)/AndroidManifest.xml
Thomas Martitz4e982d32010-09-02 03:40:02 +000038
39R_JAVA := $(BUILDDIR)/gen/$(PACKAGE_PATH)/R.java
40R_OBJ := $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class
41
Thomas Martitz33de9cd2011-07-18 21:02:47 +000042JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java)
43JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/Helper/*.java)
Antoine Cellerierc0c769c2011-01-29 20:47:32 +000044JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/widgets/*.java)
Thomas Martitz33de9cd2011-07-18 21:02:47 +000045JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/monitors/*.java)
Björn Stenberg1c80a1f2010-09-20 22:04:32 +000046JAVA_OBJ := $(call java2class,$(subst $(ANDROID)/src/$(PACKAGE_PATH),$(ANDROID)/bin/$(PACKAGE_PATH),$(JAVA_SRC)))
Thomas Martitz4e982d32010-09-02 03:40:02 +000047
Thomas Martitz50a9d502010-10-31 14:13:52 +000048
Thomas Martitz994aba12010-09-02 14:58:36 +000049LIBS := $(BINLIB_DIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so
Dominik Riebeling70b81e62011-05-31 21:26:18 +000050LIBS += $(addprefix $(BINLIB_DIR)/lib,$(patsubst %.codec,%.so,$(notdir $(CODECS))))
Björn Stenberga8ed3392010-09-24 12:03:15 +000051TEMP_APK := $(BUILDDIR)/bin/_rockbox.apk
52TEMP_APK2 := $(BUILDDIR)/bin/__rockbox.apk
Thomas Martitza9944012010-09-12 16:35:02 +000053DEX := $(BUILDDIR)/bin/classes.dex
Frank Gevaerts276321e2011-02-02 22:13:51 +000054JAR := $(BUILDDIR)/bin/classes.jar
Thomas Martitza9944012010-09-12 16:35:02 +000055AP_ := $(BUILDDIR)/bin/resources.ap_
Björn Stenberga8ed3392010-09-24 12:03:15 +000056APK := $(BUILDDIR)/rockbox.apk
Thomas Martitz4e982d32010-09-02 03:40:02 +000057
Thomas Martitz994aba12010-09-02 14:58:36 +000058_DIRS := $(BUILDDIR)/___/$(PACKAGE_PATH)
59DIRS := $(subst ___,bin,$(_DIRS))
60DIRS += $(subst ___,gen,$(_DIRS))
61DIRS += $(subst ___,data,$(_DIRS))
62DIRS += $(BUILDDIR)/libs/armeabi
63
Maurus Cuelenaere13f7dff2010-11-06 02:02:54 +000064RES := $(wildcard $(ANDROID_DIR)/res/*/*)
65
Björn Stenberga8ed3392010-09-24 12:03:15 +000066CLEANOBJS += bin gen libs data
67
Thomas Martitz0f4dfc42011-02-02 13:57:01 +000068JAVAC_OPTS += -implicit:none -classpath $(ANDROID_PLATFORM)/android.jar:$(BUILDDIR)/bin
69
Dominik Riebelingbc3f9c12011-05-29 17:23:52 +000070.PHONY:
Dominik Riebelingfc68a0d2011-05-29 18:44:42 +000071$(MANIFEST): $(MANIFEST_SRC) $(DIRS)
Dominik Riebeling26a92fa2011-06-04 10:36:34 +000072 $(call PRINTS,MANIFEST $(@F))sed -e 's/versionName="1.0"/versionName="$(SVNVERSION)"/;s/screenOrientation="portrait"/screenOrientation="$(LCDORIENTATION)"/' $(MANIFEST_SRC) > $(MANIFEST)
Dominik Riebelingbc3f9c12011-05-29 17:23:52 +000073
Frank Gevaerts38084782011-02-02 23:10:51 +000074$(R_JAVA) $(AP_): $(MANIFEST) $(RES) | $(DIRS)
Björn Stenberg40e61a72010-09-21 09:22:52 +000075 $(call PRINTS,AAPT $(subst $(BUILDDIR)/,,$@))$(AAPT) package -f -m \
76 -J $(BUILDDIR)/gen -M $(MANIFEST) -S $(ANDROID_DIR)/res \
77 -I $(ANDROID_PLATFORM)/android.jar -F $(AP_)
Thomas Martitz4e982d32010-09-02 03:40:02 +000078
79$(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class: $(R_JAVA)
Thomas Martitz994aba12010-09-02 14:58:36 +000080 $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \
Thomas Martitz0f4dfc42011-02-02 13:57:01 +000081 $(JAVAC_OPTS) \
82 -sourcepath $(ANDROID_DIR)/gen $<
Thomas Martitz4e982d32010-09-02 03:40:02 +000083
Antoine Celleriera448d8b2011-01-24 17:06:04 +000084$(BUILDDIR)/bin/$(PACKAGE_PATH)/%.class: $(ANDROID_DIR)/src/$(PACKAGE_PATH)/%.java $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class
Thomas Martitz994aba12010-09-02 14:58:36 +000085 $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \
Thomas Martitz0f4dfc42011-02-02 13:57:01 +000086 $(JAVAC_OPTS) \
87 -sourcepath $(ANDROID_DIR)/src $<
Thomas Martitz4e982d32010-09-02 03:40:02 +000088
Frank Gevaerts276321e2011-02-02 22:13:51 +000089$(JAR): $(JAVA_SRC) $(R_JAVA)
90 $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$?))javac -d $(BUILDDIR)/bin \
91 $(JAVAC_OPTS) \
92 -sourcepath $(ANDROID_DIR)/src:$(ANDROID_DIR)/gen $?
93 $(call PRINTS,JAR $(subst $(BUILDDIR)/,,$@))jar cf $(JAR) -C $(BUILDDIR)/bin org
Thomas Martitz4e982d32010-09-02 03:40:02 +000094
Frank Gevaerts276321e2011-02-02 22:13:51 +000095jar: $(JAR)
96
97$(DEX): $(JAR)
98 @echo "Checking for deleted class files" && $(foreach obj,$(JAVA_OBJ) $(R_OBJ), \
99 (test -f $(obj) || (echo "$(obj) is missing. Run 'make classes' to fix." && false)) && ) true
100 $(call PRINTS,DX $(subst $(BUILDDIR)/,,$@))$(DX) --dex --output=$@ $<
Thomas Martitza9944012010-09-12 16:35:02 +0000101
102dex: $(DEX)
Thomas Martitz4e982d32010-09-02 03:40:02 +0000103
Frank Gevaerts276321e2011-02-02 22:13:51 +0000104classes: $(R_OBJ) $(JAVA_OBJ)
105
Thomas Martitz994aba12010-09-02 14:58:36 +0000106$(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY)
Thomas Martitz4e982d32010-09-02 03:40:02 +0000107 $(call PRINTS,CP $(BINARY))cp $^ $@
108
Thomas Martitz7f9e7652010-09-22 20:58:54 +0000109$(BINLIB_DIR)/libmisc.so: $(BUILDDIR)/rockbox.zip
Thomas Martitz4e982d32010-09-02 03:40:02 +0000110 $(call PRINTS,CP rockbox.zip)cp $^ $@
111
Dominik Riebeling70b81e62011-05-31 21:26:18 +0000112$(BINLIB_DIR)/lib%.so: $(BUILDDIR)/apps/codecs/%.codec
113 $(call PRINTS,CP $(@F))cp $^ $@
114
Thomas Martitz4e982d32010-09-02 03:40:02 +0000115libs: $(LIBS)
116
Frank Gevaerts38084782011-02-02 23:10:51 +0000117$(TEMP_APK): $(AP_) $(LIBS) $(DEX) | $(DIRS)
Thomas Martitz4e982d32010-09-02 03:40:02 +0000118 $(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(APKBUILDER) $@ \
Thomas Martitza9944012010-09-12 16:35:02 +0000119 -u -z $(AP_) -f $(DEX) -nf $(BUILDDIR)/libs
Thomas Martitz4e982d32010-09-02 03:40:02 +0000120
Björn Stenberg40e61a72010-09-21 09:22:52 +0000121$(KEYSTORE):
Thomas Martitzc77b0142011-04-21 09:35:35 +0000122 $(SILENT)mkdir -p $(HOME)/.android
Björn Stenberg40e61a72010-09-21 09:22:52 +0000123 $(call PRINTS,KEYTOOL debug.keystore)keytool -genkey \
124 -alias androiddebugkey -keystore $@ \
125 -storepass android -keypass android -validity 365 \
126 -dname "CN=Android Debug,O=Android,C=US"
127
Björn Stenberg35cd4082011-06-22 14:14:49 +0000128ifdef NODEPS
129$(APK): $(TEMP_APK) $(KEYSTORE)
130else
Björn Stenberg40e61a72010-09-21 09:22:52 +0000131$(APK): $(TEMP_APK) $(BUILDDIR)/rockbox.zip $(KEYSTORE)
Björn Stenberg35cd4082011-06-22 14:14:49 +0000132endif
Thomas Martitz4e982d32010-09-02 03:40:02 +0000133 $(SILENT)rm -f $@
134 $(call PRINTS,SIGN $(subst $(BUILDDIR)/,,$@))jarsigner \
Björn Stenberg40e61a72010-09-21 09:22:52 +0000135 -keystore "$(KEYSTORE)" -storepass "android" -keypass "android" \
136 -signedjar $(TEMP_APK2) $(TEMP_APK) "androiddebugkey"
Thomas Martitz994aba12010-09-02 14:58:36 +0000137 $(SILENT)$(ZIPALIGN) -v 4 $(TEMP_APK2) $@ > /dev/null
Thomas Martitz4e982d32010-09-02 03:40:02 +0000138
Thomas Martitzaa0f8952010-09-12 20:50:30 +0000139$(DIRS):
140 $(SILENT)mkdir -p $@
Thomas Martitz994aba12010-09-02 14:58:36 +0000141
Thomas Martitzaa0f8952010-09-12 20:50:30 +0000142dirs: $(DIRS)
143
Björn Stenberg40e61a72010-09-21 09:22:52 +0000144apk: $(APK)
Antoine Celleriera448d8b2011-01-24 17:06:04 +0000145
146install: apk
Maurus Cuelenaere42f69c22011-03-11 15:45:55 +0000147 $(SILENT)$(ADB) install -r $(APK)
Antoine Celleriera448d8b2011-01-24 17:06:04 +0000148
Maurus Cuelenaere42f69c22011-03-11 15:45:55 +0000149launch:
150 $(SILENT)echo 'am start -a android.intent.action.MAIN -n org.rockbox/.RockboxActivity; exit' | $(ADB) shell >/dev/null