92 lines
3.7 KiB
Makefile
92 lines
3.7 KiB
Makefile
.ONESHELL:
|
|
|
|
SHELL=/bin/makefile-bash-wrapper.sh
|
|
|
|
# the include of the Makefile.app-config defines the Makefile
|
|
# variables $(BUILDTOOLS), $(ANDROID_JAR) and $(PACKAGE)
|
|
# which depend on the configuration and are necessary to have the Makefile work
|
|
# the rule whose target is Makefile.app-config will trigger a reload of this include as ncessary
|
|
# (as explained https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#include)
|
|
include Makefile.app-config
|
|
|
|
# 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 ./keystore
|
|
$(BUILDTOOLS)/zipalign -v -f 4 $< $@
|
|
$(BUILDTOOLS)/apksigner sign --ks keystore --key-pass pass:armena --ks-pass pass:armena $@
|
|
|
|
# sign the apk file (first sign)
|
|
./result/signed.apk : ./result/unsigned.apk ./keystore
|
|
jarsigner -verbose -keystore ./keystore -storepass armena -keypass armena -signedjar $@ $< helljniKey
|
|
|
|
# make a "keystore" for the cryptographic signing stuff
|
|
./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 "$@"
|
|
$(BUILDTOOLS)/aapt package \
|
|
-v -u -f -M ./AndroidManifest.xml -S ./res \
|
|
-I $(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
|
|
$(BUILDTOOLS)/d8 ./obj/$(PACKAGE)/*.class \
|
|
--lib $(ANDROID_JAR) --output ./result/bin
|
|
|
|
# compile (javac) the class from
|
|
./obj/$(PACKAGE)/AppActivity.class : ./src/$(PACKAGE)/AppActivity.java ./src/$(PACKAGE)/R.java
|
|
mkdir -p ./obj/$(PACKAGE)
|
|
javac -d ./obj -classpath $(ANDROID_JAR) -sourcepath ./src $<
|
|
|
|
|
|
# make the resources "R.java" thing
|
|
./src/$(PACKAGE)/R.java : $(shell find ./res -type f) app-config.sh ./AndroidManifest.xml ./android-sdk/installed | ./src/$(PACKAGE)
|
|
$(BUILDTOOLS)/aapt package \
|
|
-v -f -m -S ./res -J ./src -M ./AndroidManifest.xml \
|
|
-I $(ANDROID_JAR)
|
|
|
|
# generate the AppActivity.java (template
|
|
# the "|" denotes an "order-only" prerequiste (as in https://stackoverflow.com/a/58040049/1711186)
|
|
./src/$(PACKAGE)/AppActivity.java: app-config.sh | ./src/$(PACKAGE)
|
|
./.Makefile.scripts/make--AppActivity.java.sh > $@
|
|
|
|
./src/$(PACKAGE):
|
|
mkdir -p $@
|
|
|
|
# install the necessary android sdks
|
|
./android-sdk/installed: app-config.sh ./.Makefile.scripts/make--android-sdk.sh
|
|
./.Makefile.scripts/make--android-sdk.sh
|
|
|
|
# generate the AndroidManifest.xml
|
|
./AndroidManifest.xml: app-config.sh ./.Makefile.scripts/make--AndroidManifest.xml
|
|
./.Makefile.scripts/make--AndroidManifest.xml
|
|
|
|
# !!this step (when/if) run will trigger a restart of the "make" as the rules tartget is included
|
|
Makefile.app-config: app-config.sh Makefile
|
|
source app-config.sh; \
|
|
tee $@ << MAKEFILE_APP_CONFIG
|
|
BUILDTOOLS:=$${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)
|
|
ANDROID_JAR:=$${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.platforms.version.current)/android.jar
|
|
PACKAGE:=$$(echo "$$APP_PACKAGE" | tr '.' '/')
|
|
MAKEFILE_APP_CONFIG
|
|
|
|
# use whiptail textgui to make configuration (android API level, app-name, app-label etc...)
|
|
app-config.sh:
|
|
./.Makefile.scripts/make--app-config.sh
|
|
|
|
# rule to effectuate a cleanup
|
|
clean:
|
|
rm -rf obj/* result/*
|
|
|
|
# this rule's purpose is to run "by force" no matter what, doing nothing
|
|
# as listed prerequisite to another rule it causes that rule to be made/run
|
|
# unconditionally every time
|
|
FORCE:
|
|
@true
|