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
=11
26 ANDROID_PLATFORM
=$(ANDROID_SDK_PATH
)/platforms
/android-
$(ANDROID_PLATFORM_VERSION
)
29 AAPT
=$(ANDROID_SDK_PATH
)/platform-tools
/aapt
30 DX
=$(ANDROID_SDK_PATH
)/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
:= $(BUILDDIR
)/bin
/AndroidManifest.xml
37 MANIFEST_SRC
:= $(ANDROID_DIR
)/AndroidManifest.xml
39 R_JAVA
:= $(BUILDDIR
)/gen
/$(PACKAGE_PATH
)/R.java
40 R_OBJ
:= $(BUILDDIR
)/bin
/$(PACKAGE_PATH
)/R.class
42 JAVA_SRC
:= $(wildcard $(ANDROID_DIR
)/src
/$(PACKAGE_PATH
)/Helper
/*.java
)
43 JAVA_SRC
+= $(wildcard $(ANDROID_DIR
)/src
/$(PACKAGE_PATH
)/*.java
)
44 JAVA_SRC
+= $(wildcard $(ANDROID_DIR
)/src
/$(PACKAGE_PATH
)/widgets
/*.java
)
45 JAVA_OBJ
:= $(call java2class
,$(subst $(ANDROID
)/src
/$(PACKAGE_PATH
),$(ANDROID
)/bin
/$(PACKAGE_PATH
),$(JAVA_SRC
)))
48 LIBS
:= $(BINLIB_DIR
)/$(BINARY
) $(BINLIB_DIR
)/libmisc.so
49 LIBS
+= $(addprefix $(BINLIB_DIR
)/lib
,$(patsubst %.codec
,%.so
,$(notdir $(CODECS
))))
50 TEMP_APK
:= $(BUILDDIR
)/bin
/_rockbox.apk
51 TEMP_APK2
:= $(BUILDDIR
)/bin
/__rockbox.apk
52 DEX
:= $(BUILDDIR
)/bin
/classes.dex
53 JAR
:= $(BUILDDIR
)/bin
/classes.jar
54 AP_
:= $(BUILDDIR
)/bin
/resources.ap_
55 APK
:= $(BUILDDIR
)/rockbox.apk
57 _DIRS
:= $(BUILDDIR
)/___
/$(PACKAGE_PATH
)
58 DIRS
:= $(subst ___
,bin
,$(_DIRS
))
59 DIRS
+= $(subst ___
,gen
,$(_DIRS
))
60 DIRS
+= $(subst ___
,data
,$(_DIRS
))
61 DIRS
+= $(BUILDDIR
)/libs
/armeabi
63 RES
:= $(wildcard $(ANDROID_DIR
)/res
/*/*)
65 CLEANOBJS
+= bin gen libs data
67 JAVAC_OPTS
+= -implicit
:none
-classpath
$(ANDROID_PLATFORM
)/android.jar
:$(BUILDDIR
)/bin
70 $(MANIFEST
): $(MANIFEST_SRC
) $(DIRS
)
71 $(call PRINTS
,MANIFEST
$(@F
))sed
-e
's/versionName="1.0"/versionName="$(SVNVERSION)"/;s/screenOrientation="portrait"/screenOrientation="$(LCDORIENTATION)"/' $(MANIFEST_SRC
) > $(MANIFEST
)
73 $(R_JAVA
) $(AP_
): $(MANIFEST
) $(RES
) |
$(DIRS
)
74 $(call PRINTS
,AAPT
$(subst $(BUILDDIR
)/,,$@
))$(AAPT
) package
-f
-m \
75 -J
$(BUILDDIR
)/gen
-M
$(MANIFEST
) -S
$(ANDROID_DIR
)/res \
76 -I
$(ANDROID_PLATFORM
)/android.jar
-F
$(AP_
)
78 $(BUILDDIR
)/bin
/$(PACKAGE_PATH
)/R.class
: $(R_JAVA
)
79 $(call PRINTS
,JAVAC
$(subst $(ROOTDIR
)/,,$<))javac
-d
$(BUILDDIR
)/bin \
81 -sourcepath
$(ANDROID_DIR
)/gen
$<
83 $(BUILDDIR
)/bin
/$(PACKAGE_PATH
)/%.class
: $(ANDROID_DIR
)/src
/$(PACKAGE_PATH
)/%.java
$(BUILDDIR
)/bin
/$(PACKAGE_PATH
)/R.class
84 $(call PRINTS
,JAVAC
$(subst $(ROOTDIR
)/,,$<))javac
-d
$(BUILDDIR
)/bin \
86 -sourcepath
$(ANDROID_DIR
)/src
$<
88 $(JAR
): $(JAVA_SRC
) $(R_JAVA
)
89 $(call PRINTS
,JAVAC
$(subst $(ROOTDIR
)/,,$?
))javac
-d
$(BUILDDIR
)/bin \
91 -sourcepath
$(ANDROID_DIR
)/src
:$(ANDROID_DIR
)/gen
$?
92 $(call PRINTS
,JAR
$(subst $(BUILDDIR
)/,,$@
))jar cf
$(JAR
) -C
$(BUILDDIR
)/bin org
97 @echo
"Checking for deleted class files" && $(foreach obj
,$(JAVA_OBJ
) $(R_OBJ
), \
98 (test -f
$(obj
) ||
(echo
"$(obj) is missing. Run 'make classes' to fix." && false
)) && ) true
99 $(call PRINTS
,DX
$(subst $(BUILDDIR
)/,,$@
))$(DX
) --dex
--output
=$@
$<
103 classes
: $(R_OBJ
) $(JAVA_OBJ
)
105 $(BINLIB_DIR
)/$(BINARY
): $(BUILDDIR
)/$(BINARY
)
106 $(call PRINTS
,CP
$(BINARY
))cp
$^
$@
108 $(BINLIB_DIR
)/libmisc.so
: $(BUILDDIR
)/rockbox.zip
109 $(call PRINTS
,CP rockbox.zip
)cp
$^
$@
111 $(BINLIB_DIR
)/lib
%.so
: $(BUILDDIR
)/apps
/codecs
/%.codec
112 $(call PRINTS
,CP
$(@F
))cp
$^
$@
116 $(TEMP_APK
): $(AP_
) $(LIBS
) $(DEX
) |
$(DIRS
)
117 $(call PRINTS
,APK
$(subst $(BUILDDIR
)/,,$@
))$(APKBUILDER
) $@ \
118 -u
-z
$(AP_
) -f
$(DEX
) -nf
$(BUILDDIR
)/libs
121 $(SILENT
)mkdir
-p
$(HOME
)/.android
122 $(call PRINTS
,KEYTOOL debug.keystore
)keytool
-genkey \
123 -alias androiddebugkey
-keystore
$@ \
124 -storepass android
-keypass android
-validity
365 \
125 -dname
"CN=Android Debug,O=Android,C=US"
128 $(APK
): $(TEMP_APK
) $(KEYSTORE
)
130 $(APK
): $(TEMP_APK
) $(BUILDDIR
)/rockbox.zip
$(KEYSTORE
)
133 $(call PRINTS
,SIGN
$(subst $(BUILDDIR
)/,,$@
))jarsigner \
134 -keystore
"$(KEYSTORE)" -storepass
"android" -keypass
"android" \
135 -signedjar
$(TEMP_APK2
) $(TEMP_APK
) "androiddebugkey"
136 $(SILENT
)$(ZIPALIGN
) -v
4 $(TEMP_APK2
) $@
> /dev
/null
146 $(SILENT
)$(ADB
) install -r
$(APK
)
149 $(SILENT
)echo
'am start -a android.intent.action.MAIN -n org.rockbox/.RockboxActivity; exit' |
$(ADB
) shell >/dev
/null