android-custom/Makefile

37 lines
1.4 KiB
Makefile

PRIVKEY = tools/testkey.pk8
PUBKEY = tools/testkey.x509.pem
ZIPS_DIRS = $(wildcard dist-*)
FILES_COMMON = $(shell find META-INF -type f) $(wildcard common/*)
.SECONDEXPANSION:
.PHONY: $(ZIPS_DIRS:dist-%=clean-%)
#all: $(ZIPS_DIRS:dist-%=android-custom-%-signed.zip)
all: $(ZIPS_DIRS:dist-%=android-custom-%.zip)
clean: $(ZIPS_DIRS:dist-%=clean-%)
# clean targets
$(ZIPS_DIRS:dist-%=clean-%):
rm -rf $(@:clean-%=build-%) $(@:clean-%=android-custom-%.zip) $(@:clean-%=android-custom-%-signed.zip)
# signature targets
$(ZIPS_DIRS:dist-%=android-custom-%-signed.zip): android-custom-%-signed.zip : android-custom-%.zip
java -jar tools/SignApk.jar -w -a 4 $(PUBKEY) $(PRIVKEY) $< $@
@echo "$@ is ready"
# build target
$(ZIPS_DIRS:dist-%=android-custom-%.zip): android-custom-%.zip : $(FILES_COMMON) $$(shell find dist-$$* -type f)
rm -rf build-$*
cp -a dist-$*/data build-$*
cp -a META-INF build-$*
cd build-$* && \
sed -e '/__INSTALL__SCRIPT__/ {' -e 'r ../dist-$*/install_script' -e 'd' -e '}' -i META-INF/com/google/android/update-binary && \
for i in *.addon ; do sed -e "s/__ADDON_D__SCRIPT__FULL__/$${i}/g" -i META-INF/com/google/android/update-binary ; done && \
for i in *.addon ; do sed -e "s/__ADDON_D__SCRIPT__TARGET__/$${i/.addon/}/g" -i META-INF/com/google/android/update-binary ; done && \
sed -e '/__HEADER__/ {' -e 'r ../common/addon_head' -e 'd' -e '}' -i *.addon && \
zip ../$@ $$(find . -type f)
rm -rf build-$*