1#!/usr/bin/make -f
2
3package := NotePad.apk
4
5all: out/signed-$(package)
6
7clean:
8	rm -rf out
9
10.PHONY: FORCE
11
12DSAPARAM := out/dsaparam
13$(DSAPARAM):
14	mkdir -p $(dir $@)
15	umask 0077 && openssl dsaparam -out $@ 1024
16
17%.pem: $(DSAPARAM) FORCE
18	mkdir -p $(dir $@)
19	umask 0077 && openssl gendsa -out $@.pk~ $(DSAPARAM)
20	umask 0077 && openssl pkcs8 -topk8 -nocrypt \
21		-in $@.pk~ -out $@.pk
22	umask 0077 && openssl req -new -x509 -key $@.pk -out $@ -days 1095 \
23	    -subj "/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com"
24
25cert := out/key1.pem
26out/signed-$(package): $(package) $(cert)
27	mkdir -p $(dir $@)
28	SIGNAPK_DEBUG=1 \
29	signapk -input $< -output $@ \
30		-key $(cert).pk -cert $(cert) -tempdir out
31