80 lines
3.5 KiB
Makefile
80 lines
3.5 KiB
Makefile
.ONESHELL:
|
|
|
|
SHELL=/bin/makefile-bash-wrapper.sh
|
|
|
|
# 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 : ./result/bin/classes.dex ./assets ./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 $@ ./result/bin
|
|
|
|
# convert "java class"es files (i.e bytecode to dalvic/d8 android thing
|
|
./result/bin/classes.dex : ./obj/package/AppActivity.class
|
|
mkdir -p ./result/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 ./result/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: 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
|
|
|
|
app/.s:
|
|
source app-config.sh
|
|
|
|
|
|
app-config.sh:
|
|
./.Makefile.scripts/make--app-config.sh
|
|
# make symlinks and directories (to cater for the "helpful" java thing, to use folders for package names and yes we need a package name :( )
|
|
#source app-config.sh
|
|
#PKGDIR=$$(echo "$$APP_PACKAGE" | tr '.' '/')
|
|
#for DIR in src obj
|
|
#do
|
|
# mkdir -p $$DIR/$$PKGDIR
|
|
# ln -snfrv $$DIR/$$PKGDIR $$DIR/package
|
|
#done
|
|
|
|
clean:
|
|
rm -rf obj/*
|
|
rm -rf result/*
|
|
FORCE:
|
|
@true
|