73 lines
3.6 KiB
Makefile
73 lines
3.6 KiB
Makefile
SHELL=/bin/bash
|
|
|
|
# symlink
|
|
./app.apk: ./result/app.apk
|
|
ln -sfrv ./result/app.apk ./app.apk
|
|
|
|
# zipalign and sign again (second signing)
|
|
./result/app.apk : ./result/signed.apk app-config.sh
|
|
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/zipalign -v -f 4 $< $@
|
|
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/apksigner sign \
|
|
--ks ToyKey.keystore --key-pass pass:armena --ks-pass pass:armena $@
|
|
|
|
# sign the apk file (first sign)
|
|
./result/signed.apk : ./result/unsigned.apk ./ToyKey.keystore ./result
|
|
jarsigner -verbose -keystore ./ToyKey.keystore -storepass armena -keypass armena -signedjar $@ $< helljniKey
|
|
|
|
# make a "keystore" for the cryptographic signing stuff
|
|
./ToyKey.keystore :
|
|
keytool -genkeypair -validity 1000 -dname "CN=alexander,O=Android,C=JPN" -keystore $@ \
|
|
-storepass armena -keypass armena -alias helljniKey -keyalg RSA -v
|
|
|
|
# aapt "package" together the dalvik/hex stuff (and "assets" and "res")
|
|
./result/unsigned.apk : ./bin/classes.dex ./result ./assets ./bin ./AndroidManifest.xml
|
|
rm -rvf "$@"
|
|
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/aapt package \
|
|
-v -u -f -M ./AndroidManifest.xml -S ./res \
|
|
-I $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.platforms.version.current)/android.jar -A ./assets -F $@ ./bin
|
|
|
|
# convert "java class"es files (i.e bytecode to dalvic/d8 android thing
|
|
./bin/classes.dex : ./obj/package ./obj/package/AppActivity.class ./bin
|
|
ls ./obj/package/*.class
|
|
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/d8 $$(realpath --relative-to=. $<)/*.class \
|
|
--lib $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.platforms.version.current)/android.jar --output bin
|
|
|
|
# compile (javac) the class from
|
|
./obj/package/AppActivity.class : ./src/package/AppActivity.java ./src/package/R.java ./obj/package
|
|
javac -d ./obj -classpath $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.platforms.version.current)/android.jar \
|
|
-sourcepath ./src $$(realpath --relative-to=/src $<)
|
|
|
|
# generate teh AppActivity.java (template)
|
|
./src/package/AppActivity.java: ./src/package app-config.sh
|
|
./.Makefile.scripts/make--AppActivity.java.sh > $@
|
|
|
|
# make the resources "R.java" thing
|
|
./src/package/R.java : $(shell find ./res -type f) app-config.sh ./src/package ./AndroidManifest.xml ./android-sdk/installed
|
|
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/aapt package \
|
|
-v -f -m -S ./res -J ./src -M ./AndroidManifest.xml \
|
|
-I $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.platforms.version.current)/android.jar
|
|
|
|
# install the necessary android sdks
|
|
./android-sdk/installed: app-config.sh
|
|
./.Makefile.scripts/make--android-sdk.sh
|
|
|
|
# generate the AndroidManifest.xml
|
|
./AndroidManifest.xml: app-config.sh
|
|
./.Makefile.scripts/make--AndroidManifest.xml
|
|
|
|
# recipe to make directories (if) needed
|
|
./result ./bin ./assets ./src/ ./obj:
|
|
mkdir -p "$@"
|
|
|
|
# make symlinksa and directories (to cater for the "helpful" java thing, to use folders for package names and yes we need a package name :( )
|
|
./src/package: app-config.sh
|
|
set -x; source app-config.sh; PKGDIR=$$(echo "$$APP_PACKAGE" | tr '.' '/'); mkdir -p src/$$PKGDIR; rm -rf $@ ; ln -sfrv src/$$PKGDIR $@
|
|
|
|
./obj/package: app-config.sh
|
|
source app-config.sh; PKGDIR=$$(echo "$$APP_PACKAGE" | tr '.' '/'); mkdir -p obj/$$PKGDIR; rm -rf $@; ln -sfrv obj/$$PKGDIR $@
|
|
|
|
app-config.sh:
|
|
./.Makefile.scripts/make--app-config.sh
|
|
|
|
FORCE:
|
|
@true
|