fireplace/Makefile

90 lines
2.3 KiB
Makefile
Raw Normal View History

2022-01-13 21:38:35 +00:00
NAME = Fireplace
PROJ = org.er2.fireplace
ifeq ($TV,1)
SDK_VER = 24
SDK = 24.0.3
else
SDK_VER = 19
SDK = 19.1.0
endif
SDK_ROOT = ~/Android/Sdk
JAVA_HOME:=$(if $(JAVA_HOME),$(JAVA_HOME),/usr/lib/jvm/java-1.11.0-openjdk-amd64)
VEDBASE = $(SDK_ROOT)/platforms/android-$(SDK_VER)/android.jar
ADB = $(SDK_ROOT)/platform-tools/adb
AAPT = $(SDK_ROOT)/build-tools/$(SDK)/aapt
DX = $(SDK_ROOT)/build-tools/$(SDK)/dx
ZIPALIGN=$(SDK_ROOT)/build-tools/$(SDK)/zipalign
JAVAC = $(JAVA_HOME)/bin/javac
JARSIGNER = $(JAVA_HOME)/bin/jarsigner
PWD=$(shell pwd)
OUT=$(PWD)/bin
GEN=$(PWD)/gen
RES=$(PWD)/res
SRC=$(PWD)/src
#ASS=$(PWD)/assets
SRCS=$(shell find $(SRC) -name '*.java')
CLSS=$(SRCS:$(SRC)/%.java=$(GEN)/%.class)
KEY_PATH ?= debug.keystore
KEY_NAME ?= androiddebugkey
KEY_PASS ?= android
all: debug
debug:
@$(MAKE) DEBUG=true -C $(PWD) build
release:
@$(MAKE) -C $(PWD) build
APK=$(OUT)/$(NAME).apk
CDX=$(OUT)/classes.dex
build: $(APK)
$(APK): $(CDX) package sign zip
@if [ ! -f "$(APK)" ]; then mv $(OUT)/$(NAME).ap_ $(APK); fi
@$(RM) $(OUT)/$(NAME).ap_
prepare: clean
@mkdir -p $(OUT) $(GEN)
@$(AAPT) > /dev/null 2>&1; if ! [ $$? -ne 0 ]; then echo YOU NEED TO install lib32stdc++6 lib32z1; exit 1; fi
@$(AAPT) p $(if $(DEBUG),--debug-mode,) -I $(VEDBASE) -fm -M $(PWD)/AndroidManifest.xml -J $(GEN) -S $(RES)
$(CDX):
# dependencies is here to not re-build on every make
@make -C $(PWD) prepare $(CLSS)
@$(DX) --dex --output=$@ $(GEN)
$(GEN)/%.class: $(SRC)/%.java
-@echo Recompiling $@
@$(JAVAC) $(if $(DEBUG),-g,) -classpath $(VEDBASE) -sourcepath 'src:$(GEN)' -d '$(GEN)' -target 1.7 -source 1.7 $<
package: $(CDX) AndroidManifest.xml
@$(AAPT) p $(if $(DEBUG),--debug-mode,) -I $(VEDBASE) -f -M $(PWD)/AndroidManifest.xml -S $(RES) -F $(OUT)/$(NAME).ap_ # -A $(ASS)
@cd $(OUT) && $(AAPT) a $(NAME).ap_ classes.dex
sign: package $(KEY_PATH)
@$(JARSIGNER) -keystore $(KEY_PATH) -storepass '$(KEY_PASS)' $(OUT)/$(NAME).ap_ $(KEY_NAME)
zip: package
@$(ZIPALIGN) -f 4 $(OUT)/$(NAME).ap_ $(APK)
$(KEY_PATH):
@yes | keytool -genkey -v -keystore $(KEY_PATH) -storepass '$(KEY_PASS)' -alias $(KEY_NAME) -keypass $(KEY_PASS) -keyalg RSA -keysize 2048 -validity 10000
clean:
@rm -rf $(OUT) $(GEN)
run: $(OUT)/$(NAME).apk
-@$(ADB) uninstall $(PROJ)
@$(ADB) install $^
@$(ADB) shell monkey -p $(PROJ) -c android.intent.category.LAUNCHER 1