Thomas Martitz | f8381d9 | 2010-09-02 00:24:40 +0000 | [diff] [blame] | 1 | # __________ __ ___. |
| 2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 6 | # \/ \/ \/ \/ \/ |
| 7 | # $Id$ |
| 8 | # |
| 9 | |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 10 | .SECONDEXPANSION: # $$(JAVA_OBJ) is not populated until after this |
Thomas Martitz | f8381d9 | 2010-09-02 00:24:40 +0000 | [diff] [blame] | 11 | .SECONDEXPANSION: # $$(OBJ) is not populated until after this |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 12 | .PHONY: apk classes clean dex dirs libs jar |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 13 | |
Thomas Martitz | f8381d9 | 2010-09-02 00:24:40 +0000 | [diff] [blame] | 14 | $(BUILDDIR)/$(BINARY): $$(OBJ) $(VOICESPEEXLIB) $(FIRMLIB) $(SKINLIB) |
| 15 | $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 16 | |
| 17 | PACKAGE=org.rockbox |
| 18 | PACKAGE_PATH=org/rockbox |
| 19 | ANDROID_DIR=$(ROOTDIR)/android |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 20 | BINLIB_DIR=$(BUILDDIR)/libs/armeabi |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 21 | |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 22 | java2class = $(addsuffix .class,$(basename $(subst $(ANDROID_DIR),$(BUILDDIR),$(1)))) |
| 23 | |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 24 | # API version |
Maurus Cuelenaere | 4364111 | 2011-03-11 15:45:34 +0000 | [diff] [blame] | 25 | ANDROID_PLATFORM_VERSION=11 |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 26 | ANDROID_PLATFORM=$(ANDROID_SDK_PATH)/platforms/android-$(ANDROID_PLATFORM_VERSION) |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 27 | |
| 28 | # android tools |
Maurus Cuelenaere | 4364111 | 2011-03-11 15:45:34 +0000 | [diff] [blame] | 29 | AAPT=$(ANDROID_SDK_PATH)/platform-tools/aapt |
| 30 | DX=$(ANDROID_SDK_PATH)/platform-tools/dx |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 31 | APKBUILDER=$(ANDROID_SDK_PATH)/tools/apkbuilder |
| 32 | ZIPALIGN=$(ANDROID_SDK_PATH)/tools/zipalign |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 33 | KEYSTORE=$(HOME)/.android/debug.keystore |
Antoine Cellerier | a448d8b | 2011-01-24 17:06:04 +0000 | [diff] [blame] | 34 | ADB=$(ANDROID_SDK_PATH)/platform-tools/adb |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 35 | |
Dominik Riebeling | fc68a0d | 2011-05-29 18:44:42 +0000 | [diff] [blame] | 36 | MANIFEST := $(BUILDDIR)/bin/AndroidManifest.xml |
Dominik Riebeling | bc3f9c1 | 2011-05-29 17:23:52 +0000 | [diff] [blame] | 37 | MANIFEST_SRC := $(ANDROID_DIR)/AndroidManifest.xml |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 38 | |
| 39 | R_JAVA := $(BUILDDIR)/gen/$(PACKAGE_PATH)/R.java |
| 40 | R_OBJ := $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class |
| 41 | |
Thomas Martitz | 33de9cd | 2011-07-18 21:02:47 +0000 | [diff] [blame] | 42 | JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java) |
| 43 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/Helper/*.java) |
Antoine Cellerier | c0c769c | 2011-01-29 20:47:32 +0000 | [diff] [blame] | 44 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/widgets/*.java) |
Thomas Martitz | 33de9cd | 2011-07-18 21:02:47 +0000 | [diff] [blame] | 45 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/monitors/*.java) |
Björn Stenberg | 1c80a1f | 2010-09-20 22:04:32 +0000 | [diff] [blame] | 46 | JAVA_OBJ := $(call java2class,$(subst $(ANDROID)/src/$(PACKAGE_PATH),$(ANDROID)/bin/$(PACKAGE_PATH),$(JAVA_SRC))) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 47 | |
Thomas Martitz | 50a9d50 | 2010-10-31 14:13:52 +0000 | [diff] [blame] | 48 | |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 49 | LIBS := $(BINLIB_DIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so |
Dominik Riebeling | 70b81e6 | 2011-05-31 21:26:18 +0000 | [diff] [blame] | 50 | LIBS += $(addprefix $(BINLIB_DIR)/lib,$(patsubst %.codec,%.so,$(notdir $(CODECS)))) |
Björn Stenberg | a8ed339 | 2010-09-24 12:03:15 +0000 | [diff] [blame] | 51 | TEMP_APK := $(BUILDDIR)/bin/_rockbox.apk |
| 52 | TEMP_APK2 := $(BUILDDIR)/bin/__rockbox.apk |
Thomas Martitz | a994401 | 2010-09-12 16:35:02 +0000 | [diff] [blame] | 53 | DEX := $(BUILDDIR)/bin/classes.dex |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 54 | JAR := $(BUILDDIR)/bin/classes.jar |
Thomas Martitz | a994401 | 2010-09-12 16:35:02 +0000 | [diff] [blame] | 55 | AP_ := $(BUILDDIR)/bin/resources.ap_ |
Björn Stenberg | a8ed339 | 2010-09-24 12:03:15 +0000 | [diff] [blame] | 56 | APK := $(BUILDDIR)/rockbox.apk |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 57 | |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 58 | _DIRS := $(BUILDDIR)/___/$(PACKAGE_PATH) |
| 59 | DIRS := $(subst ___,bin,$(_DIRS)) |
| 60 | DIRS += $(subst ___,gen,$(_DIRS)) |
| 61 | DIRS += $(subst ___,data,$(_DIRS)) |
| 62 | DIRS += $(BUILDDIR)/libs/armeabi |
| 63 | |
Maurus Cuelenaere | 13f7dff | 2010-11-06 02:02:54 +0000 | [diff] [blame] | 64 | RES := $(wildcard $(ANDROID_DIR)/res/*/*) |
| 65 | |
Björn Stenberg | a8ed339 | 2010-09-24 12:03:15 +0000 | [diff] [blame] | 66 | CLEANOBJS += bin gen libs data |
| 67 | |
Thomas Martitz | 0f4dfc4 | 2011-02-02 13:57:01 +0000 | [diff] [blame] | 68 | JAVAC_OPTS += -implicit:none -classpath $(ANDROID_PLATFORM)/android.jar:$(BUILDDIR)/bin |
| 69 | |
Dominik Riebeling | bc3f9c1 | 2011-05-29 17:23:52 +0000 | [diff] [blame] | 70 | .PHONY: |
Dominik Riebeling | fc68a0d | 2011-05-29 18:44:42 +0000 | [diff] [blame] | 71 | $(MANIFEST): $(MANIFEST_SRC) $(DIRS) |
Dominik Riebeling | 26a92fa | 2011-06-04 10:36:34 +0000 | [diff] [blame] | 72 | $(call PRINTS,MANIFEST $(@F))sed -e 's/versionName="1.0"/versionName="$(SVNVERSION)"/;s/screenOrientation="portrait"/screenOrientation="$(LCDORIENTATION)"/' $(MANIFEST_SRC) > $(MANIFEST) |
Dominik Riebeling | bc3f9c1 | 2011-05-29 17:23:52 +0000 | [diff] [blame] | 73 | |
Frank Gevaerts | 3808478 | 2011-02-02 23:10:51 +0000 | [diff] [blame] | 74 | $(R_JAVA) $(AP_): $(MANIFEST) $(RES) | $(DIRS) |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 75 | $(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 Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 78 | |
| 79 | $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class: $(R_JAVA) |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 80 | $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \ |
Thomas Martitz | 0f4dfc4 | 2011-02-02 13:57:01 +0000 | [diff] [blame] | 81 | $(JAVAC_OPTS) \ |
| 82 | -sourcepath $(ANDROID_DIR)/gen $< |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 83 | |
Antoine Cellerier | a448d8b | 2011-01-24 17:06:04 +0000 | [diff] [blame] | 84 | $(BUILDDIR)/bin/$(PACKAGE_PATH)/%.class: $(ANDROID_DIR)/src/$(PACKAGE_PATH)/%.java $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 85 | $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \ |
Thomas Martitz | 0f4dfc4 | 2011-02-02 13:57:01 +0000 | [diff] [blame] | 86 | $(JAVAC_OPTS) \ |
| 87 | -sourcepath $(ANDROID_DIR)/src $< |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 88 | |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 89 | $(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 Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 94 | |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 95 | jar: $(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 Martitz | a994401 | 2010-09-12 16:35:02 +0000 | [diff] [blame] | 101 | |
| 102 | dex: $(DEX) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 103 | |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 104 | classes: $(R_OBJ) $(JAVA_OBJ) |
| 105 | |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 106 | $(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 107 | $(call PRINTS,CP $(BINARY))cp $^ $@ |
| 108 | |
Thomas Martitz | 7f9e765 | 2010-09-22 20:58:54 +0000 | [diff] [blame] | 109 | $(BINLIB_DIR)/libmisc.so: $(BUILDDIR)/rockbox.zip |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 110 | $(call PRINTS,CP rockbox.zip)cp $^ $@ |
| 111 | |
Dominik Riebeling | 70b81e6 | 2011-05-31 21:26:18 +0000 | [diff] [blame] | 112 | $(BINLIB_DIR)/lib%.so: $(BUILDDIR)/apps/codecs/%.codec |
| 113 | $(call PRINTS,CP $(@F))cp $^ $@ |
| 114 | |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 115 | libs: $(LIBS) |
| 116 | |
Frank Gevaerts | 3808478 | 2011-02-02 23:10:51 +0000 | [diff] [blame] | 117 | $(TEMP_APK): $(AP_) $(LIBS) $(DEX) | $(DIRS) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 118 | $(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(APKBUILDER) $@ \ |
Thomas Martitz | a994401 | 2010-09-12 16:35:02 +0000 | [diff] [blame] | 119 | -u -z $(AP_) -f $(DEX) -nf $(BUILDDIR)/libs |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 120 | |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 121 | $(KEYSTORE): |
Thomas Martitz | c77b014 | 2011-04-21 09:35:35 +0000 | [diff] [blame] | 122 | $(SILENT)mkdir -p $(HOME)/.android |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 123 | $(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 Stenberg | 35cd408 | 2011-06-22 14:14:49 +0000 | [diff] [blame] | 128 | ifdef NODEPS |
| 129 | $(APK): $(TEMP_APK) $(KEYSTORE) |
| 130 | else |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 131 | $(APK): $(TEMP_APK) $(BUILDDIR)/rockbox.zip $(KEYSTORE) |
Björn Stenberg | 35cd408 | 2011-06-22 14:14:49 +0000 | [diff] [blame] | 132 | endif |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 133 | $(SILENT)rm -f $@ |
| 134 | $(call PRINTS,SIGN $(subst $(BUILDDIR)/,,$@))jarsigner \ |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 135 | -keystore "$(KEYSTORE)" -storepass "android" -keypass "android" \ |
| 136 | -signedjar $(TEMP_APK2) $(TEMP_APK) "androiddebugkey" |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 137 | $(SILENT)$(ZIPALIGN) -v 4 $(TEMP_APK2) $@ > /dev/null |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 138 | |
Thomas Martitz | aa0f895 | 2010-09-12 20:50:30 +0000 | [diff] [blame] | 139 | $(DIRS): |
| 140 | $(SILENT)mkdir -p $@ |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 141 | |
Thomas Martitz | aa0f895 | 2010-09-12 20:50:30 +0000 | [diff] [blame] | 142 | dirs: $(DIRS) |
| 143 | |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 144 | apk: $(APK) |
Antoine Cellerier | a448d8b | 2011-01-24 17:06:04 +0000 | [diff] [blame] | 145 | |
| 146 | install: apk |
Maurus Cuelenaere | 42f69c2 | 2011-03-11 15:45:55 +0000 | [diff] [blame] | 147 | $(SILENT)$(ADB) install -r $(APK) |
Antoine Cellerier | a448d8b | 2011-01-24 17:06:04 +0000 | [diff] [blame] | 148 | |
Maurus Cuelenaere | 42f69c2 | 2011-03-11 15:45:55 +0000 | [diff] [blame] | 149 | launch: |
| 150 | $(SILENT)echo 'am start -a android.intent.action.MAIN -n org.rockbox/.RockboxActivity; exit' | $(ADB) shell >/dev/null |