- Add debug and release targets
- Add key signing for release target
- Prevent deleting intermediate files
- Fix non xml resources
- Miscellaneous formatting
OpenSSL can be used to create a Java compatible KeyStore from a PEM
encoded certificate and key:
openssl pkcs12 -export \
-name android \
-in android.crt \
-inkey android.key \
-out android.p12
-include config.mk
# Settings
-include config.mk
# Settings
-ANDROID ?= /opt/android-sdk-update-manager/platforms/android-10/android.jar
PACKAGE ?= org.pileus.spades
PACKAGE ?= org.pileus.spades
-OUTPUT ?= bin/Spades.apk
+KEYFILE ?= ~/.android/android.p12
+KEYTYPE ?= pkcs12
+KEYNAME ?= android
+ANDROID ?= /opt/android-sdk-update-manager/platforms/android-10/android.jar
-RES := $(shell find res -name '*.xml')
+RES := $(shell find res -type f)
SRC := $(shell find src -name '*.java')
# Objects
SRC := $(shell find src -name '*.java')
# Objects
$(GEN:gen/%=obj/%))
# Targets
$(GEN:gen/%=obj/%))
# Targets
+debug: bin/$(PROGRAM).dbg
+
+release: bin/$(PROGRAM).apk
- adb logcat Spades:D AndroidRuntime:E '*:S'
+ adb logcat $(PROGRAM):D AndroidRuntime:E '*:S'
- adb shell am start -W -a android.intent.action.MAIN -n $(PACKAGE)/.Main
+ adb shell am start -W \
+ -a android.intent.action.MAIN \
+ -n $(PACKAGE)/.Main
-install bin/install.stamp: $(OUTPUT)
+install bin/install.stamp: bin/$(PROGRAM).dbg
adb install -r $+
touch bin/install.stamp
adb install -r $+
touch bin/install.stamp
-%.apk: %.dex %.res | bin
+%.dbg: %.dex %.res | bin
@echo "APK $@.in"
@apkbuilder $@.in -f $*.dex -z $*.res
@echo "APK $@.in"
@apkbuilder $@.in -f $*.dex -z $*.res
+ @echo "ALIGN $@"
+ @zipalign -f 4 $@.in $@
+
+%.apk: %.dex %.res | bin
+ @echo "APKU $@.in"
+ @apkbuilder $@.in -u -f $*.dex -z $*.res
+ @echo "SIGN $@.in"
+ @jarsigner -storetype $(KEYTYPE) \
+ -keystore $(KEYFILE) \
+ $@.in $(KEYNAME)
+ @echo "ALIGN $@"
@zipalign -f 4 $@.in $@
%.dex: $(OBJ) | bin
@zipalign -f 4 $@.in $@
%.dex: $(OBJ) | bin
-F $*.res
$(OBJ): $(SRC) $(GEN) | obj
-F $*.res
$(OBJ): $(SRC) $(GEN) | obj
@javac -g -Xlint:unchecked \
-bootclasspath $(ANDROID) \
-encoding UTF-8 \
@javac -g -Xlint:unchecked \
-bootclasspath $(ANDROID) \
-encoding UTF-8 \
@mkdir -p $@
# Use parallel javac instead
@mkdir -p $@
# Use parallel javac instead