-
Notifications
You must be signed in to change notification settings - Fork 3
/
common.mak
77 lines (53 loc) · 1.25 KB
/
common.mak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Makefile to build all plugins
# Author: Ariel Flesler
# --
# Runs on a linux-based enviroment (Cygwin can be used on Windows).
# In order to minify, it requires the YUI compressor.
# You must set the $YUI enviroment variable with the jar's path.
NAME=${shell basename $(value PWD)}
VER?=unversioned
SRC=$(NAME).js
MIN=$(NAME)-min.js
VER_NAME=$(NAME)-$(VER)
SRCV=$(VER_NAME).js
MINV=$(VER_NAME)-min.js
ZIP=$(VER_NAME).zip
ZIP_FILES += $(SRC) $(MIN) changes.txt
all: deploy
# Deploy Files
$(ZIP): $(ZIP_FILES)
zip -r9 $(ZIP) $(ZIP_FILES)
zip:$(ZIP)
deploy:$(ZIP) $(SRCV) $(MINV)
# Source File
# $(SRC) is not .PHONY so you need to do make -B to make it run
$(SRC):
$(add-version) -i $(SRC)
$(add-date) -i $(SRC)
src:$(SRC)
$(SRCV):$(SRC)
cp $(SRC) $(SRCV)
# Minified File
$(MIN):$(SRC)
java -jar $(YUI) $(SRC) -o $(MIN)
min: $(MIN)
$(MINV):$(MIN)
cp $(MIN) $(MINV)
# ---Replacements--- #
# Version
define add-version
sed -e 's/^\(.*@version \)[0-9a-z.]\+\(.*\)$|/\1$(VER)\2/'
endef
# Date
TODAY=${shell date +%m\\/%d\\/%Y}
define add-date
sed -e 's/^\(.*Date: \)[0-9/]\+\(.*\)$|/\1$(TODAY)\2/'
endef
# ---Cleaning--- #
# Can be extended
define cmd-clean
rm -f $(MIN) $(SRCV) $(MINV) $(ZIP);
endef
clean:
$(cmd-clean)
.PHONY: clean deploy min