2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 jar
14 $(BUILDDIR
)/$(BINARY
): $$(OBJ
) $(VOICESPEEXLIB
) $(FIRMLIB
) $(SKINLIB
)
15 $(call PRINTS
,LD
$(BINARY
))$(CC
) -o
$@
$^
$(LDOPTS
) $(GLOBAL_LDOPTS
)
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))))
25 ANDROID_PLATFORM_VERSION
=8
26 ANDROID_PLATFORM
=$(ANDROID_SDK_PATH
)/platforms
/android-
$(ANDROID_PLATFORM_VERSION
)
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 JAR
:= $(BUILDDIR
)/bin
/classes.jar
52 AP_
:= $(BUILDDIR
)/bin
/resources.ap_
53 APK
:= $(BUILDDIR
)/rockbox.apk
55 _DIRS
:= $(BUILDDIR
)/___
/$(PACKAGE_PATH
)
56 DIRS
:= $(subst ___
,bin
,$(_DIRS
))
57 DIRS
+= $(subst ___
,gen
,$(_DIRS
))
58 DIRS
+= $(subst ___
,data
,$(_DIRS
))
59 DIRS
+= $(BUILDDIR
)/libs
/armeabi
61 RES
:= $(wildcard $(ANDROID_DIR
)/res
/*/*)
63 CLEANOBJS
+= bin gen libs data
65 JAVAC_OPTS
+= -implicit
:none
-classpath
$(ANDROID_PLATFORM
)/android.jar
:$(BUILDDIR
)/bin
67 $(R_JAVA
) $(AP_
): $(MANIFEST
) $(RES
) |
$(DIRS
)
68 $(call PRINTS
,AAPT
$(subst $(BUILDDIR
)/,,$@
))$(AAPT
) package
-f
-m \
69 -J
$(BUILDDIR
)/gen
-M
$(MANIFEST
) -S
$(ANDROID_DIR
)/res \
70 -I
$(ANDROID_PLATFORM
)/android.jar
-F
$(AP_
)
72 $(BUILDDIR
)/bin
/$(PACKAGE_PATH
)/R.class
: $(R_JAVA
)
73 $(call PRINTS
,JAVAC
$(subst $(ROOTDIR
)/,,$<))javac
-d
$(BUILDDIR
)/bin \
75 -sourcepath
$(ANDROID_DIR
)/gen
$<
77 $(BUILDDIR
)/bin
/$(PACKAGE_PATH
)/%.class
: $(ANDROID_DIR
)/src
/$(PACKAGE_PATH
)/%.java
$(BUILDDIR
)/bin
/$(PACKAGE_PATH
)/R.class
78 $(call PRINTS
,JAVAC
$(subst $(ROOTDIR
)/,,$<))javac
-d
$(BUILDDIR
)/bin \
80 -sourcepath
$(ANDROID_DIR
)/src
$<
82 $(JAR
): $(JAVA_SRC
) $(R_JAVA
)
83 $(call PRINTS
,JAVAC
$(subst $(ROOTDIR
)/,,$?
))javac
-d
$(BUILDDIR
)/bin \
85 -sourcepath
$(ANDROID_DIR
)/src
:$(ANDROID_DIR
)/gen
$?
86 $(call PRINTS
,JAR
$(subst $(BUILDDIR
)/,,$@
))jar cf
$(JAR
) -C
$(BUILDDIR
)/bin org
91 @echo
"Checking for deleted class files" && $(foreach obj
,$(JAVA_OBJ
) $(R_OBJ
), \
92 (test -f
$(obj
) ||
(echo
"$(obj) is missing. Run 'make classes' to fix." && false
)) && ) true
93 $(call PRINTS
,DX
$(subst $(BUILDDIR
)/,,$@
))$(DX
) --dex
--output
=$@
$<
97 classes
: $(R_OBJ
) $(JAVA_OBJ
)
99 $(BINLIB_DIR
)/$(BINARY
): $(BUILDDIR
)/$(BINARY
)
100 $(call PRINTS
,CP
$(BINARY
))cp
$^
$@
102 $(BINLIB_DIR
)/libmisc.so
: $(BUILDDIR
)/rockbox.zip
103 $(call PRINTS
,CP rockbox.zip
)cp
$^
$@
107 $(TEMP_APK
): $(AP_
) $(LIBS
) $(DEX
) |
$(DIRS
)
108 $(call PRINTS
,APK
$(subst $(BUILDDIR
)/,,$@
))$(APKBUILDER
) $@ \
109 -u
-z
$(AP_
) -f
$(DEX
) -nf
$(BUILDDIR
)/libs
112 $(call PRINTS
,KEYTOOL debug.keystore
)keytool
-genkey \
113 -alias androiddebugkey
-keystore
$@ \
114 -storepass android
-keypass android
-validity
365 \
115 -dname
"CN=Android Debug,O=Android,C=US"
117 $(APK
): $(TEMP_APK
) $(BUILDDIR
)/rockbox.zip
$(KEYSTORE
)
119 $(call PRINTS
,SIGN
$(subst $(BUILDDIR
)/,,$@
))jarsigner \
120 -keystore
"$(KEYSTORE)" -storepass
"android" -keypass
"android" \
121 -signedjar
$(TEMP_APK2
) $(TEMP_APK
) "androiddebugkey"
122 $(SILENT
)$(ZIPALIGN
) -v
4 $(TEMP_APK2
) $@
> /dev
/null
132 $(ADB
) install -r
$(APK
)