aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 $< > $@