aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-01-19 23:08:03 +0100
committerlonkaars <loek@pipeframe.xyz>2023-01-19 23:08:03 +0100
commit9905b8cefdee18f2ed9b503ef27814e9545d8f61 (patch)
tree775d2d61628d1ce3ea27bf7d262bf7313437714e
parenta0984f9d54d1881592cc7fbd6c5f78e30d51f336 (diff)
move filters to variables in makefile
-rw-r--r--common.mk11
1 files changed, 9 insertions, 2 deletions
diff --git a/common.mk b/common.mk
index 957f31d..709dafa 100644
--- a/common.mk
+++ b/common.mk
@@ -1,8 +1,15 @@
+TO_SINGLE_LINE:=tr '\n' ' '
+REMOVE_DOUBLE_SLASH_COMMENTS:=sed 's/\/\/.*$$//g'
+REMOVE_SLASH_STAR_COMMENTS:=sed 's/\/\*[^\/]*\*\///g'
+REMOVE_TABS:=sed 's/\t//g'
+REMOVE_WHITESPACE:=sed 's/ */ /g'
+TRIM_WHITESPACE:=sed -E 's/^\s*(.*)\s+$$/\1/g'
+
%.min.js: %.js
- sed 's/\/\/.*$$//g' $< | tr '\n' ' ' | sed 's/\/\*[^\/]*\*\///g' | sed 's/\t//g' | sed 's/ */ /g' > $@
+ cat $< | $(REMOVE_DOUBLE_SLASH_COMMENTS) | $(TO_SINGLE_LINE) | $(REMOVE_SLASH_STAR_COMMENTS) | $(REMOVE_TABS) | $(REMOVE_WHITESPACE) | $(TRIM_WHITESPACE) > $@
%.min.css: %.css
- cat $< | tr '\n' ' ' | sed 's/\/\*[^\/]*\*\///g' | sed 's/\t//g' | sed 's/ */ /g' > $@
+ cat $< | $(TO_SINGLE_LINE) | $(REMOVE_SLASH_STAR_COMMENTS) | $(REMOVE_TABS) | $(REMOVE_WHITESPACE) | $(TRIM_WHITESPACE) > $@
%.html: %.m4
m4 $< > $@