-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
81 lines (62 loc) · 2.57 KB
/
makefile
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
78
79
80
81
BUILD = ./build/
BUILD_PATH = $(BUILD)kana-totsugeki/
BUILD_TMP_PATH = $(BUILD)tmp/
SCSS_PATH = ./scss/
SCSS_MAIN = $(SCSS_PATH)kana_totsugeki.scss
SCSS_FILES = $(shell find $(SCSS_PATH) -type f -name '*.scss')
CSS_TARGET_PATH = $(BUILD_PATH)css/
CSS_TARGET = $(CSS_TARGET_PATH)kana_totsugeki.css
JS_PATH = ./js/
JS_FILES = $(shell find $(JS_PATH) -type f -name '*.js')
JS_TARGET_PATH = $(BUILD_PATH)js/
JS_TARGET = $(JS_TARGET_PATH)kana_totsugeki.js
JS_TMP_TARGET = $(BUILD_TMP_PATH)tmp.js
ESCAPE_SED = sed -e 's/[]\/$*.^|[]/\\&/g'
IMAGES_PATH = ./images/
IMAGES_FILES = $(shell find $(IMAGES_PATH) -type f -name '*.png')
IMAGES_TARGET_PATH = $(BUILD_PATH)images/
IMAGES_TMP_TARGET = $(shell echo $(IMAGES_PATH) | $(ESCAPE_SED))
IMAGES_TMP_TARGET_PATH = $(shell echo $(IMAGES_TARGET_PATH) | $(ESCAPE_SED))
IMAGES_TARGETS = $(shell echo $(IMAGES_FILES) | sed 's/$(IMAGES_TMP_TARGET)/$(IMAGES_TMP_TARGET_PATH)/g')
HTML_FILE = index.html
BUILD_PATH_ESCAPED = $(shell echo $(BUILD_PATH) | $(ESCAPE_SED))
HTML_FILE_TARGET = $(shell echo $(HTML_FILE) | sed 's/^/$(BUILD_PATH_ESCAPED)/g')
DIRECTORIES = $(BUILD_PATH) $(CSS_TARGET_PATH) $(JS_TARGET_PATH) $(IMAGES_TARGET_PATH)
all: | $(DIRECTORIES) css js html images
css: $(SCSS_FILES) | $(DIRECTORIES) $(CSS_TARGET)
js: $(JS_FILES) | $(DIRECTORIES) $(JS_TARGET)
html: $(HTML_FILE) | $(DIRECTORIES) $(HTML_FILE_TARGET)
images: $(IMAGES_FILES) | $(DIRECTORIES) $(IMAGES_TARGETS)
$(IMAGES_TARGETS): $(IMAGES_FILES)
@echo -e "Copying Images files...\t\t\t\c"
@cp $(IMAGES_FILES) $(IMAGES_TARGET_PATH)
@echo -e "[ Done ]"
$(HTML_FILE_TARGET): $(HTML_FILE)
@echo -e "Copying HTML files...\t\t\t\c"
@cp $(HTML_FILE) $(BUILD_PATH)
@echo "[ Done ]"
$(CSS_TARGET): $(SCSS_FILES)
@echo -e "Compiling SCSS...\t\t\t\c"
@scss -C --sourcemap=none $(SCSS_MAIN) $(CSS_TARGET) -t compressed
@echo -e "[ Done ]"
$(JS_TARGET): $(JS_FILES)
@echo -e "Concating JS files...\t\t\t\c"
@mkdir -p $(BUILD_TMP_PATH)
@rm -f $(JS_TMP_TARGET)
@for JS in $(JS_FILES); do \
cat $$JS >> $(JS_TMP_TARGET); \
done
@echo -e "[ Done ]\nCompressing JS...\t\t\t\c"
@yuicompressor --type js --charset utf-8 --nomunge -o $(JS_TARGET) $(JS_TMP_TARGET) > /dev/null 2>&1
@rm -rf $(BUILD_TMP_PATH)
@echo "[ Done ]"
$(DIRECTORIES):
@echo -e "Making directories...\t\t\t\c"
@mkdir -p $(BUILD)
@mkdir -p $(BUILD_PATH)
@mkdir -p $(JS_TARGET_PATH)
@mkdir -p $(CSS_TARGET_PATH)
@mkdir -p $(IMAGES_TARGET_PATH)
@echo "[ Done ]"
clean:
@rm -rf $(CSS_TARGET_PATH) $(JS_TARGET_PATH) $(BUILD_PATH) $(BUILD)