heavy makefile rework
authorGuillaume Castagnino <casta@xwing.info>
Wed, 12 Jul 2017 09:24:32 +0000 (11:24 +0200)
committerGuillaume Castagnino <casta@xwing.info>
Wed, 12 Jul 2017 09:24:32 +0000 (11:24 +0200)
Makefile
dist-google-more/Makefile [deleted file]
dist-google/Makefile [deleted file]
dist-std/Makefile [deleted file]

index a222f40f4a74d19ff7513a0ff7f349c48396c533..d01b19ff7959991a45aa83e5377fc3aa06d6cb4f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,54 +1,29 @@
-ZIPFILE = cm-custom.zip
-ZIPFILE_SIGNED = cm-custom-signed.zip
-ZIPFILE_GOOGLE = cm-custom-google.zip
-ZIPFILE_GOOGLE_SIGNED = cm-custom-google-signed.zip
-ZIPFILE_GOOGLE_MORE = cm-custom-google-more.zip
-ZIPFILE_GOOGLE_MORE_SIGNED = cm-custom-google-more-signed.zip
 PRIVKEY = tools/testkey.pk8
 PUBKEY = tools/testkey.x509.pem
 
-STD = dist-std
-GOOGLE = dist-google
-GOOGLE_MORE = dist-google-more
+ZIPS_DIRS = $(wildcard dist-*)
 FILES_COMMON = $(shell find META-INF -type f)
 
-.PHONY: clean
+.PHONY: $(ZIPS_DIRS:dist-%=clean-%)
 
 all: zip
 
-zip: $(ZIPFILE) $(ZIPFILE_GOOGLE) sign
+zip: $(ZIPS_DIRS:dist-%=sign-%)
 
-clean:
-       rm -f "$(ZIPFILE)" "$(ZIPFILE_SIGNED)" \
-               "$(ZIPFILE_GOOGLE)" "$(ZIPFILE_GOOGLE_SIGNED)" \
-               "$(ZIPFILE_GOOGLE_MORE)" "$(ZIPFILE_GOOGLE_MORE_SIGNED)"
+clean: $(ZIPS_DIRS:dist-%=clean-%)
 
-sign: $(ZIPFILE) $(ZIPFILE_GOOGLE) $(ZIPFILE_GOOGLE_MORE)
-       java -jar tools/SignApk.jar -w -a 4 $(PUBKEY) $(PRIVKEY) $(ZIPFILE) $(ZIPFILE_SIGNED)
-       java -jar tools/SignApk.jar -w -a 4 $(PUBKEY) $(PRIVKEY) $(ZIPFILE_GOOGLE) $(ZIPFILE_GOOGLE_SIGNED)
-       java -jar tools/SignApk.jar -w -a 4 $(PUBKEY) $(PRIVKEY) $(ZIPFILE_GOOGLE_MORE) $(ZIPFILE_GOOGLE_MORE_SIGNED)
-       @echo "$? are ready"
+# clean targets
+$(ZIPS_DIRS:dist-%=clean-%):
+       rm -f $(@:clean-%=cm-custom-%.zip) $(@:clean-%=cm-custom-%-signed.zip)
 
-$(ZIPFILE): clean $(STD)
-       @echo "$(ZIPFILE) is ready"
+# signature targets
+$(ZIPS_DIRS:dist-%=sign-%): sign-% : dist-%
+       java -jar tools/SignApk.jar -w -a 4 $(PUBKEY) $(PRIVKEY) cm-custom-$*.zip cm-custom-$*-signed.zip
+       @echo "cm-custom-$*-signed.zip is ready"
 
-$(ZIPFILE_GOOGLE): clean $(GOOGLE)
-       @echo "$(ZIPFILE_GOOGLE) is ready"
+# build target
+$(ZIPS_DIRS): dist-% : clean-%
+       zip cm-custom-$*.zip $(FILES_COMMON)
+       cd $@ && \
+               zip ../cm-custom-$*.zip $$(find . -type f)
 
-$(ZIPFILE_GOOGLE_MORE): clean $(GOOGLE_MORE)
-       @echo "$(ZIPFILE_GOOGLE_MORE) is ready"
-
-$(FILES_COMMON:%=%.zipped): %.zipped : %
-       @echo "Zipping common files"
-       @zip "$(ZIPFILE)" "$<"
-       @zip "$(ZIPFILE_GOOGLE)" "$<"
-       @zip "$(ZIPFILE_GOOGLE_MORE)" "$<"
-
-$(STD): $(FILES_COMMON:%=%.zipped)
-       make -C $@ ZIPFILE=$(ZIPFILE)
-
-$(GOOGLE): $(FILES_COMMON:%=%.zipped)
-       make -C $@ ZIPFILE=$(ZIPFILE_GOOGLE)
-
-$(GOOGLE_MORE): $(FILES_COMMON:%=%.zipped)
-       make -C $@ ZIPFILE=$(ZIPFILE_GOOGLE_MORE)
diff --git a/dist-google-more/Makefile b/dist-google-more/Makefile
deleted file mode 100644 (file)
index 3a3bd3a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-FILES = $(shell find -type f ! -name Makefile)
-
-all: $(FILES:%=%.zipped)
-
-$(FILES:%=%.zipped): %.zipped : %
-       @echo "Zipping standard files"
-       @zip "../$(ZIPFILE)" "$<"
diff --git a/dist-google/Makefile b/dist-google/Makefile
deleted file mode 100644 (file)
index 3a3bd3a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-FILES = $(shell find -type f ! -name Makefile)
-
-all: $(FILES:%=%.zipped)
-
-$(FILES:%=%.zipped): %.zipped : %
-       @echo "Zipping standard files"
-       @zip "../$(ZIPFILE)" "$<"
diff --git a/dist-std/Makefile b/dist-std/Makefile
deleted file mode 100644 (file)
index 3a3bd3a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-FILES = $(shell find -type f ! -name Makefile)
-
-all: $(FILES:%=%.zipped)
-
-$(FILES:%=%.zipped): %.zipped : %
-       @echo "Zipping standard files"
-       @zip "../$(ZIPFILE)" "$<"