simplify/cleanup Makefile via include
This commit is contained in:
parent
51b333c3d7
commit
ba9d3ebca2
1 changed files with 39 additions and 36 deletions
75
app/Makefile
75
app/Makefile
|
@ -2,53 +2,59 @@
|
||||||
|
|
||||||
SHELL=/bin/makefile-bash-wrapper.sh
|
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
|
# symlink
|
||||||
./app.apk: ./result/app.apk
|
./app.apk: ./result/app.apk
|
||||||
ln -sfrv ./result/app.apk ./app.apk
|
ln -sfrv ./result/app.apk ./app.apk
|
||||||
|
|
||||||
# zipalign and sign again (second signing)
|
# zipalign and sign again (second signing)
|
||||||
./result/app.apk : ./result/signed.apk app-config.sh
|
./result/app.apk : ./result/signed.apk app-config.sh ./keystore
|
||||||
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/zipalign -v -f 4 $< $@
|
$(BUILDTOOLS)/zipalign -v -f 4 $< $@
|
||||||
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/apksigner sign \
|
$(BUILDTOOLS)/apksigner sign --ks keystore --key-pass pass:armena --ks-pass pass:armena $@
|
||||||
--ks ToyKey.keystore --key-pass pass:armena --ks-pass pass:armena $@
|
|
||||||
|
|
||||||
# sign the apk file (first sign)
|
# sign the apk file (first sign)
|
||||||
./result/signed.apk : ./result/unsigned.apk ./ToyKey.keystore ./result
|
./result/signed.apk : ./result/unsigned.apk ./keystore
|
||||||
jarsigner -verbose -keystore ./ToyKey.keystore -storepass armena -keypass armena -signedjar $@ $< helljniKey
|
jarsigner -verbose -keystore ./keystore -storepass armena -keypass armena -signedjar $@ $< helljniKey
|
||||||
|
|
||||||
# make a "keystore" for the cryptographic signing stuff
|
# make a "keystore" for the cryptographic signing stuff
|
||||||
./ToyKey.keystore :
|
./keystore :
|
||||||
keytool -genkeypair -validity 1000 -dname "CN=alexander,O=Android,C=JPN" -keystore $@ \
|
keytool -genkeypair -validity 1000 -dname "CN=alexander,O=Android,C=JPN" -keystore $@ \
|
||||||
-storepass armena -keypass armena -alias helljniKey -keyalg RSA -v
|
-storepass armena -keypass armena -alias helljniKey -keyalg RSA -v
|
||||||
|
|
||||||
# aapt "package" together the dalvik/hex stuff (and "assets" and "res")
|
# aapt "package" together the dalvik/hex stuff (and "assets" and "res")
|
||||||
./result/unsigned.apk : ./result/bin/classes.dex ./assets ./AndroidManifest.xml
|
./result/unsigned.apk : ./result/bin/classes.dex ./assets ./AndroidManifest.xml
|
||||||
rm -rvf "$@"
|
rm -rvf "$@"
|
||||||
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/aapt package \
|
$(BUILDTOOLS)/aapt package \
|
||||||
-v -u -f -M ./AndroidManifest.xml -S ./res \
|
-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
|
-I $(ANDROID_JAR) -A ./assets -F $@ ./result/bin
|
||||||
|
|
||||||
# convert "java class"es files (i.e bytecode to dalvic/d8 android thing
|
# convert "java class"es files (i.e bytecode) to dalvic/d8 android thing
|
||||||
./result/bin/classes.dex : ./obj/package/AppActivity.class
|
./result/bin/classes.dex : ./obj/$(PACKAGE)/AppActivity.class
|
||||||
mkdir -p ./result/bin
|
mkdir -p ./result/bin
|
||||||
ls ./obj/package/*.class
|
$(BUILDTOOLS)/d8 ./obj/$(PACKAGE)/*.class \
|
||||||
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/d8 $$(realpath --relative-to=. $<)/*.class \
|
--lib $(ANDROID_JAR) --output ./result/bin
|
||||||
--lib $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.platforms.version.current)/android.jar --output ./result/bin
|
|
||||||
|
|
||||||
# compile (javac) the class from
|
# compile (javac) the class from
|
||||||
./obj/package/AppActivity.class : ./src/package/AppActivity.java ./src/package/R.java ./obj/package
|
./obj/$(PACKAGE)/AppActivity.class : ./src/$(PACKAGE)/AppActivity.java ./src/$(PACKAGE)/R.java
|
||||||
javac -d ./obj -classpath $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.platforms.version.current)/android.jar \
|
mkdir -p ./obj/$(PACKAGE)
|
||||||
-sourcepath ./src $$(realpath --relative-to=/src $<)
|
javac -d ./obj -classpath $(ANDROID_JAR) -sourcepath ./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
|
# 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
|
./src/PACKAGE/R.java : $(shell find ./res -type f) app-config.sh ./AndroidManifest.xml ./android-sdk/installed
|
||||||
source app-config.sh; $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.buildtools.version.current)/aapt package \
|
$(BUILDTOOLS)/aapt package \
|
||||||
-v -f -m -S ./res -J ./src -M ./AndroidManifest.xml \
|
-v -f -m -S ./res -J ./src -M ./AndroidManifest.xml \
|
||||||
-I $${ANDROID_SDK_ROOT}/$$(tr ';' '/' < android-sdk/.installed.platforms.version.current)/android.jar
|
-I $(ANDROID_JAR)
|
||||||
|
|
||||||
|
# generate the AppActivity.java (template)
|
||||||
|
./src/package/AppActivity.java: app-config.sh
|
||||||
|
./.Makefile.scripts/make--AppActivity.java.sh > $@
|
||||||
|
|
||||||
# install the necessary android sdks
|
# install the necessary android sdks
|
||||||
./android-sdk/installed: app-config.sh
|
./android-sdk/installed: app-config.sh
|
||||||
|
@ -58,23 +64,20 @@ SHELL=/bin/makefile-bash-wrapper.sh
|
||||||
./AndroidManifest.xml: app-config.sh
|
./AndroidManifest.xml: app-config.sh
|
||||||
./.Makefile.scripts/make--AndroidManifest.xml
|
./.Makefile.scripts/make--AndroidManifest.xml
|
||||||
|
|
||||||
app/.s:
|
Makefile.app-config: app-config.sh Makefile
|
||||||
source app-config.sh
|
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:
|
app-config.sh:
|
||||||
./.Makefile.scripts/make--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:
|
clean:
|
||||||
rm -rf obj/*
|
rm -rf obj/* result/*
|
||||||
rm -rf result/*
|
|
||||||
FORCE:
|
FORCE:
|
||||||
@true
|
@true
|
||||||
|
|
Loading…
Add table
Reference in a new issue