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 | 7d61376 | 2011-12-19 19:58:44 +0000 | [diff] [blame] | 10 | PACKAGE=org.rockbox |
| 11 | PACKAGE_PATH=org/rockbox |
Frank Gevaerts | d1560e5 | 2012-06-11 22:06:34 +0200 | [diff] [blame] | 12 | BINLIB_DIR=$(BUILDDIR)/libs/$(ANDROID_ARCH) |
Thomas Martitz | 7d61376 | 2011-12-19 19:58:44 +0000 | [diff] [blame] | 13 | ANDROID_DIR=$(ROOTDIR)/android |
| 14 | |
Thomas Martitz | 287454d | 2011-12-19 15:42:04 +0000 | [diff] [blame] | 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() |
Thomas Martitz | d798c72 | 2013-01-09 10:29:29 +0100 | [diff] [blame] | 17 | CPUFEAT = $(ANDROID_NDK_PATH)/sources/android/cpufeatures |
| 18 | CPUFEAT_BUILD = $(BUILDDIR) |
Thomas Martitz | 287454d | 2011-12-19 15:42:04 +0000 | [diff] [blame] | 19 | INCLUDES += -I$(CPUFEAT) |
| 20 | OTHER_SRC += $(CPUFEAT)/cpu-features.c |
Thomas Martitz | 7d61376 | 2011-12-19 19:58:44 +0000 | [diff] [blame] | 21 | CLEANOBJS += $(CPUFEAT_BUILD)/cpu-features.o |
| 22 | $(CPUFEAT_BUILD)/cpu-features.o: $(CPUFEAT)/cpu-features.c |
| 23 | $(SILENT)mkdir -p $(dir $@) |
Thomas Martitz | d798c72 | 2013-01-09 10:29:29 +0100 | [diff] [blame] | 24 | $(call PRINTS,CC $(subst $(CPUFEAT)/,,$<))$(CC) -o $@ -c $^ $(GCCOPTS) -Wno-unused |
Thomas Martitz | 287454d | 2011-12-19 15:42:04 +0000 | [diff] [blame] | 25 | |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 26 | .SECONDEXPANSION: # $$(JAVA_OBJ) is not populated until after this |
Thomas Martitz | f8381d9 | 2010-09-02 00:24:40 +0000 | [diff] [blame] | 27 | .SECONDEXPANSION: # $$(OBJ) is not populated until after this |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 28 | .PHONY: apk classes clean dex dirs libs jar |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 29 | |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 30 | # API version |
Thomas Martitz | 6499ce3 | 2014-03-09 18:08:06 +0100 | [diff] [blame] | 31 | ANDROID_PLATFORM_VERSION=19 |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 32 | ANDROID_PLATFORM=$(ANDROID_SDK_PATH)/platforms/android-$(ANDROID_PLATFORM_VERSION) |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 33 | |
| 34 | # android tools |
Frank Gevaerts | be9c227 | 2014-09-25 00:24:38 +0200 | [diff] [blame] | 35 | BUILD_TOOLS_VERSION=$(notdir $(firstword $(wildcard $(ANDROID_SDK_PATH)/build-tools/$(ANDROID_PLATFORM_VERSION).*))) |
Thomas Martitz | 6499ce3 | 2014-03-09 18:08:06 +0100 | [diff] [blame] | 36 | AAPT=$(ANDROID_SDK_PATH)/build-tools/$(BUILD_TOOLS_VERSION)/aapt |
| 37 | DX=$(ANDROID_SDK_PATH)/build-tools/$(BUILD_TOOLS_VERSION)/dx |
Frank Gevaerts | 1d58667 | 2017-09-06 18:26:07 +0200 | [diff] [blame] | 38 | ifneq ("$(wildcard $(ANDROID_SDK_PATH)/tools/zipalign)","") |
| 39 | ZIPALIGN=$(ANDROID_SDK_PATH)/tools/zipalign |
| 40 | else |
| 41 | ZIPALIGN=$(ANDROID_SDK_PATH)/build-tools/$(BUILD_TOOLS_VERSION)/zipalign |
| 42 | endif |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 43 | KEYSTORE=$(HOME)/.android/debug.keystore |
Antoine Cellerier | a448d8b | 2011-01-24 17:06:04 +0000 | [diff] [blame] | 44 | ADB=$(ANDROID_SDK_PATH)/platform-tools/adb |
Thomas Martitz | 6499ce3 | 2014-03-09 18:08:06 +0100 | [diff] [blame] | 45 | BUILDAPK=$(ANDROID_DIR)/buildapk.sh |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 46 | |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 47 | CLASSPATH := $(BUILDDIR)/bin/classes |
| 48 | |
Dominik Riebeling | fc68a0d | 2011-05-29 18:44:42 +0000 | [diff] [blame] | 49 | MANIFEST := $(BUILDDIR)/bin/AndroidManifest.xml |
Dominik Riebeling | bc3f9c1 | 2011-05-29 17:23:52 +0000 | [diff] [blame] | 50 | MANIFEST_SRC := $(ANDROID_DIR)/AndroidManifest.xml |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 51 | |
| 52 | R_JAVA := $(BUILDDIR)/gen/$(PACKAGE_PATH)/R.java |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 53 | R_OBJ := $(CLASSPATH)/$(PACKAGE_PATH)/R.class |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 54 | |
Thomas Martitz | 33de9cd | 2011-07-18 21:02:47 +0000 | [diff] [blame] | 55 | JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java) |
| 56 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/Helper/*.java) |
Antoine Cellerier | c0c769c | 2011-01-29 20:47:32 +0000 | [diff] [blame] | 57 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/widgets/*.java) |
Thomas Martitz | 33de9cd | 2011-07-18 21:02:47 +0000 | [diff] [blame] | 58 | JAVA_SRC += $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/monitors/*.java) |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 59 | |
| 60 | java2class = $(addsuffix .class,$(basename $(subst $(ANDROID_DIR)/src,$(CLASSPATH),$(1)))) |
| 61 | |
| 62 | JAVA_OBJ := $(call java2class,$(JAVA_SRC)) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 63 | |
Thomas Martitz | 50a9d50 | 2010-10-31 14:13:52 +0000 | [diff] [blame] | 64 | |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 65 | LIBS := $(BINLIB_DIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so |
Dominik Riebeling | 70b81e6 | 2011-05-31 21:26:18 +0000 | [diff] [blame] | 66 | LIBS += $(addprefix $(BINLIB_DIR)/lib,$(patsubst %.codec,%.so,$(notdir $(CODECS)))) |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 67 | |
Björn Stenberg | a8ed339 | 2010-09-24 12:03:15 +0000 | [diff] [blame] | 68 | TEMP_APK := $(BUILDDIR)/bin/_rockbox.apk |
| 69 | TEMP_APK2 := $(BUILDDIR)/bin/__rockbox.apk |
Thomas Martitz | d798c72 | 2013-01-09 10:29:29 +0100 | [diff] [blame] | 70 | DEX := $(BUILDDIR)/bin/classes.dex |
| 71 | JAR := $(BUILDDIR)/bin/classes.jar |
| 72 | AP_ := $(BUILDDIR)/bin/resources.ap_ |
| 73 | APK := $(BUILDDIR)/rockbox.apk |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 74 | |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 75 | _DIRS := $(BUILDDIR)/___/$(PACKAGE_PATH) |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 76 | DIRS += $(subst ___,gen,$(_DIRS)) |
| 77 | DIRS += $(subst ___,data,$(_DIRS)) |
Frank Gevaerts | d1560e5 | 2012-06-11 22:06:34 +0200 | [diff] [blame] | 78 | DIRS += $(BUILDDIR)/libs/$(ANDROID_ARCH) |
Thomas Martitz | 7d61376 | 2011-12-19 19:58:44 +0000 | [diff] [blame] | 79 | DIRS += $(CPUFEAT_BUILD) |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 80 | DIRS += $(CLASSPATH) |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 81 | |
Maurus Cuelenaere | 13f7dff | 2010-11-06 02:02:54 +0000 | [diff] [blame] | 82 | RES := $(wildcard $(ANDROID_DIR)/res/*/*) |
| 83 | |
Björn Stenberg | a8ed339 | 2010-09-24 12:03:15 +0000 | [diff] [blame] | 84 | CLEANOBJS += bin gen libs data |
| 85 | |
Frank Gevaerts | 190577e | 2012-06-13 23:43:39 +0200 | [diff] [blame] | 86 | JAVAC_OPTS += -source 1.6 -target 1.6 -implicit:none -classpath $(ANDROID_PLATFORM)/android.jar:$(CLASSPATH) |
Thomas Martitz | 0f4dfc4 | 2011-02-02 13:57:01 +0000 | [diff] [blame] | 87 | |
Dominik Riebeling | bc3f9c1 | 2011-05-29 17:23:52 +0000 | [diff] [blame] | 88 | .PHONY: |
Dominik Riebeling | fc68a0d | 2011-05-29 18:44:42 +0000 | [diff] [blame] | 89 | $(MANIFEST): $(MANIFEST_SRC) $(DIRS) |
Dominik Riebeling | 26a92fa | 2011-06-04 10:36:34 +0000 | [diff] [blame] | 90 | $(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] | 91 | |
Frank Gevaerts | 3808478 | 2011-02-02 23:10:51 +0000 | [diff] [blame] | 92 | $(R_JAVA) $(AP_): $(MANIFEST) $(RES) | $(DIRS) |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 93 | $(call PRINTS,AAPT $(subst $(BUILDDIR)/,,$@))$(AAPT) package -f -m \ |
| 94 | -J $(BUILDDIR)/gen -M $(MANIFEST) -S $(ANDROID_DIR)/res \ |
| 95 | -I $(ANDROID_PLATFORM)/android.jar -F $(AP_) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 96 | |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 97 | $(CLASSPATH)/$(PACKAGE_PATH)/R.class: $(R_JAVA) |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 98 | $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(BUILDDIR)/bin \ |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 99 | $(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/gen $< |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 100 | |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 101 | $(CLASSPATH)/$(PACKAGE_PATH)/%.class: $(ANDROID_DIR)/src/$(PACKAGE_PATH)/%.java $(CLASSPATH)/$(PACKAGE_PATH)/R.class |
| 102 | $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$<))javac -d $(CLASSPATH) \ |
| 103 | $(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/src $< |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 104 | |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 105 | $(JAR): $(JAVA_SRC) $(R_JAVA) |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 106 | $(call PRINTS,JAVAC $(subst $(ROOTDIR)/,,$?))javac -d $(CLASSPATH) \ |
| 107 | $(JAVAC_OPTS) -sourcepath $(ANDROID_DIR)/src:$(ANDROID_DIR)/gen $? |
| 108 | $(call PRINTS,JAR $(subst $(BUILDDIR)/,,$@))jar cf $(JAR) -C $(CLASSPATH) org |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 109 | |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 110 | jar: $(JAR) |
| 111 | |
| 112 | $(DEX): $(JAR) |
| 113 | @echo "Checking for deleted class files" && $(foreach obj,$(JAVA_OBJ) $(R_OBJ), \ |
| 114 | (test -f $(obj) || (echo "$(obj) is missing. Run 'make classes' to fix." && false)) && ) true |
| 115 | $(call PRINTS,DX $(subst $(BUILDDIR)/,,$@))$(DX) --dex --output=$@ $< |
Thomas Martitz | a994401 | 2010-09-12 16:35:02 +0000 | [diff] [blame] | 116 | |
| 117 | dex: $(DEX) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 118 | |
Frank Gevaerts | 276321e | 2011-02-02 22:13:51 +0000 | [diff] [blame] | 119 | classes: $(R_OBJ) $(JAVA_OBJ) |
| 120 | |
Thomas Martitz | 287454d | 2011-12-19 15:42:04 +0000 | [diff] [blame] | 121 | |
Thomas Martitz | f269aa0 | 2012-03-26 22:24:57 +0200 | [diff] [blame] | 122 | $(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(CPUFEAT_BUILD)/cpu-features.o |
Thomas Martitz | 6d19275 | 2012-01-17 15:08:08 +0100 | [diff] [blame] | 123 | $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map |
Thomas Martitz | 4b56ee0 | 2012-04-04 21:43:22 +0200 | [diff] [blame] | 124 | $(call PRINTS,OC $(@F))$(call objcopy,$@,$@) |
Thomas Martitz | 287454d | 2011-12-19 15:42:04 +0000 | [diff] [blame] | 125 | |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 126 | $(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 127 | $(call PRINTS,CP $(BINARY))cp $^ $@ |
| 128 | |
Thomas Martitz | 7f9e765 | 2010-09-22 20:58:54 +0000 | [diff] [blame] | 129 | $(BINLIB_DIR)/libmisc.so: $(BUILDDIR)/rockbox.zip |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 130 | $(call PRINTS,CP rockbox.zip)cp $^ $@ |
| 131 | |
Sean Bartell | f40bfc9 | 2011-06-25 21:32:25 -0400 | [diff] [blame] | 132 | $(BINLIB_DIR)/lib%.so: $(RBCODEC_BLD)/codecs/%.codec |
Dominik Riebeling | 70b81e6 | 2011-05-31 21:26:18 +0000 | [diff] [blame] | 133 | $(call PRINTS,CP $(@F))cp $^ $@ |
| 134 | |
Thomas Martitz | e9cb953 | 2012-01-03 21:15:21 +0000 | [diff] [blame] | 135 | libs: $(DIRS) $(LIBS) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 136 | |
Frank Gevaerts | 3808478 | 2011-02-02 23:10:51 +0000 | [diff] [blame] | 137 | $(TEMP_APK): $(AP_) $(LIBS) $(DEX) | $(DIRS) |
Thomas Martitz | 6499ce3 | 2014-03-09 18:08:06 +0100 | [diff] [blame] | 138 | $(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(BUILDAPK) $(BUILDDIR) $(notdir $@) $(BUILD_TOOLS_VERSION) |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 139 | |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 140 | $(KEYSTORE): |
Thomas Martitz | c77b014 | 2011-04-21 09:35:35 +0000 | [diff] [blame] | 141 | $(SILENT)mkdir -p $(HOME)/.android |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 142 | $(call PRINTS,KEYTOOL debug.keystore)keytool -genkey \ |
| 143 | -alias androiddebugkey -keystore $@ \ |
| 144 | -storepass android -keypass android -validity 365 \ |
Thiago Kenji Okada | a6713a5 | 2012-11-28 23:26:55 -0200 | [diff] [blame] | 145 | -sigalg MD5withRSA -keyalg RSA -keysize 1024 \ |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 146 | -dname "CN=Android Debug,O=Android,C=US" |
| 147 | |
Björn Stenberg | 35cd408 | 2011-06-22 14:14:49 +0000 | [diff] [blame] | 148 | ifdef NODEPS |
| 149 | $(APK): $(TEMP_APK) $(KEYSTORE) |
| 150 | else |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 151 | $(APK): $(TEMP_APK) $(BUILDDIR)/rockbox.zip $(KEYSTORE) |
Björn Stenberg | 35cd408 | 2011-06-22 14:14:49 +0000 | [diff] [blame] | 152 | endif |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 153 | $(SILENT)rm -f $@ |
| 154 | $(call PRINTS,SIGN $(subst $(BUILDDIR)/,,$@))jarsigner \ |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 155 | -keystore "$(KEYSTORE)" -storepass "android" -keypass "android" \ |
Frank Gevaerts | 190577e | 2012-06-13 23:43:39 +0200 | [diff] [blame] | 156 | -signedjar $(TEMP_APK2) $(TEMP_APK) "androiddebugkey" \ |
| 157 | -sigalg MD5withRSA -digestalg SHA1 |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 158 | $(SILENT)$(ZIPALIGN) -v 4 $(TEMP_APK2) $@ > /dev/null |
Thomas Martitz | 4e982d3 | 2010-09-02 03:40:02 +0000 | [diff] [blame] | 159 | |
Thomas Martitz | aa0f895 | 2010-09-12 20:50:30 +0000 | [diff] [blame] | 160 | $(DIRS): |
| 161 | $(SILENT)mkdir -p $@ |
Thomas Martitz | 994aba1 | 2010-09-02 14:58:36 +0000 | [diff] [blame] | 162 | |
Thomas Martitz | aa0f895 | 2010-09-12 20:50:30 +0000 | [diff] [blame] | 163 | dirs: $(DIRS) |
| 164 | |
Björn Stenberg | 40e61a7 | 2010-09-21 09:22:52 +0000 | [diff] [blame] | 165 | apk: $(APK) |
Antoine Cellerier | a448d8b | 2011-01-24 17:06:04 +0000 | [diff] [blame] | 166 | |
| 167 | install: apk |
Maurus Cuelenaere | 42f69c2 | 2011-03-11 15:45:55 +0000 | [diff] [blame] | 168 | $(SILENT)$(ADB) install -r $(APK) |
Antoine Cellerier | a448d8b | 2011-01-24 17:06:04 +0000 | [diff] [blame] | 169 | |
Maurus Cuelenaere | 42f69c2 | 2011-03-11 15:45:55 +0000 | [diff] [blame] | 170 | launch: |
| 171 | $(SILENT)echo 'am start -a android.intent.action.MAIN -n org.rockbox/.RockboxActivity; exit' | $(ADB) shell >/dev/null |