-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
155 lines (111 loc) · 4.78 KB
/
makefile
File metadata and controls
155 lines (111 loc) · 4.78 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
BUILD_DIR := build/
SRC_DIR := src/
# Function to make changing the document root easier
changeroot = $(shell python3 helpers/changeroot.py $(1) $(2))
#### Get list of src files
### css/
## *.css
CSS_SRC_DIR := $(SRC_DIR)css/
CSS_SRC_FILES := $(shell find $(CSS_SRC_DIR) -type f -iname '*.css')
CSS_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(CSS_SRC_FILES))
# Copy .css files to the build directory
$(CSS_BUILD_FILES): $(CSS_SRC_FILES)
mkdir -p $(dir $@)
cp $(call changeroot,$(SRC_DIR),$@) $@
## *.scss | *.sass
SASS_SRC_DIR := $(SRC_DIR)css/
SASS_SRC_FILES := $(shell find $(SASS_SRC_DIR) -type f \( -iname \*.scss -o -iname \*.sass \))
SASS_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(SASS_SRC_FILES))
# Compile .scss or .sass files into .css files in the build directory
$(SASS_BUILD_FILES): $(SASS_SRC_FILES)
mkdir -p $(dir $@)
node_modules/sass/sass.js $(call changeroot,$(SRC_DIR),$@) $@
### html/
## *.html
HTML_SRC_DIR := $(SRC_DIR)html/
HTML_SRC_FILES := $(shell find $(HTML_SRC_DIR) -type f -iname '*.html')
HTML_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(HTML_SRC_FILES))
# Copy .html files to the build directory
$(HTML_BUILD_FILES): $(HTML_SRC_FILES)
mkdir -p $(dir $@)
cp $(call changeroot,$(SRC_DIR),$@) $@
## *.ejs
EJS_SRC_DIR := $(SRC_DIR)html/
EJS_SRC_FILES := $(shell find $(EJS_SRC_DIR) -type f -iname '*.ejs')
EJS_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(EJS_SRC_FILES:.ejs=.html))
# Compile .ejs files to .html files in the build directory
$(EJS_BUILD_FILES): $(EJS_SRC_FILES)
mkdir -p $(dir $@)
node helpers/ejs.js $(call changeroot,$(SRC_DIR),$(basename $@).ejs) > $@
### js/
## *.js
JS_SRC_DIR := $(SRC_DIR)js/
JS_SRC_FILES := $(shell find $(JS_SRC_DIR) -type f -iname '*.js')
JS_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(JS_SRC_FILES))
# Copy .js files to the build directory
$(JS_BUILD_FILES): $(JS_SRC_FILES)
mkdir -p $(dir $@)
cp $(call changeroot,$(SRC_DIR),$@) $@
## *.coffee
COFFEE_SRC_DIR := $(SRC_DIR)js/
COFFEE_SRC_FILES := $(shell find $(COFFEE_SRC_DIR) -type f -iname '*.coffee')
COFFEE_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(COFFEE_SRC_FILES:.coffee=.js))
# Compile .coffee files to .js files in the build directory
$(COFFEE_BUILD_FILES): $(COFFEE_SRC_FILES)
mkdir -p $(dir $@)
cat $(call changeroot,$(SRC_DIR),$(basename $@).coffee) | node_modules/coffeescript/bin/coffee -sc > $@
### server/html
## server/*.html
SERVER_HTML_SRC_DIR := $(SRC_DIR)server/ejs/
SERVER_HTML_SRC_FILES := $(shell find $(SERVER_HTML_SRC_DIR) -type f -iname '*.html')
SERVER_HTML_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(SERVER_HTML_SRC_FILES))
# Copy server .html files to the build directory
$(SERVER_HTML_BUILD_FILES): $(SERVER_HTML_SRC_FILES)
mkdir -p $(dir $@)
cp $(call changeroot,$(SRC_DIR),$@) $@
## server/*.ejs
SERVER_EJS_SRC_DIR := $(SRC_DIR)server/ejs/
SERVER_EJS_SRC_FILES := $(shell find $(SERVER_EJS_SRC_DIR) -type f -iname '*.ejs')
SERVER_EJS_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(SERVER_EJS_SRC_FILES))
# Copy server .ejs files to the build directory
$(SERVER_EJS_BUILD_FILES): $(SERVER_EJS_SRC_FILES)
mkdir -p $(dir $@)
cp $(call changeroot,$(SRC_DIR),$@) $@
### server/js
## server/*.js
SERVER_JS_SRC_DIR := $(SRC_DIR)server/js/
SERVER_JS_SRC_FILES := $(shell find $(SERVER_JS_SRC_DIR) -type f -iname '*.js')
SERVER_JS_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(SERVER_JS_SRC_FILES))
# Copy server .js files to the build directory
$(SERVER_JS_BUILD_FILES): $(SERVER_JS_SRC_FILES)
mkdir -p $(dir $@)
cp $(call changeroot,$(SRC_DIR),$@) $@
## server/*.coffee
SERVER_COFFEE_SRC_DIR := $(SRC_DIR)server/js/
SERVER_COFFEE_SRC_FILES := $(shell find $(SERVER_COFFEE_SRC_DIR) -type f -iname '*.coffee')
SERVER_COFFEE_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(SERVER_COFFEE_SRC_FILES:.coffee=.js))
# Compile server .coffee files to .js files in the build directory
$(SERVER_COFFEE_BUILD_FILES): $(SERVER_COFFEE_SRC_FILES)
mkdir -p $(dir $@)
cat $(call changeroot,$(SRC_DIR),$(basename $@).coffee) | node_modules/coffeescript/bin/coffee -sc > $@
### static/
## *
STATIC_SRC_DIR := $(SRC_DIR)/static/
STATIC_SRC_FILES := $(shell find $(STATIC_SRC_DIR) -type f)
STATIC_BUILD_FILES := $(call changeroot,$(BUILD_DIR),$(STATIC_SRC_FILES))
# Copy all files to the build directory
$(STATIC_BUILD_FILES): $(STATIC_SRC_FILES)
mkdir -p $(dir $@)
cp $(call changeroot,$(SRC_DIR),$@) $@
### Special Rules
all: html css js serverjs serverhtml static
html: $(HTML_BUILD_FILES) $(EJS_BUILD_FILES)
css: $(CSS_BUILD_FILES) $(SASS_BUILD_FILES)
js: $(JS_BUILD_FILES) $(COFFEE_BUILD_FILES)
serverjs: $(SERVER_JS_BUILD_FILES) $(SERVER_COFFEE_BUILD_FILES)
serverhtml: $(SERVER_EJS_BUILD_FILES) $(SERVER_HTML_BUILD_FILES)
static: $(STATIC_BUILD_FILES)
clean:
rm -rf $(BUILD_DIR)
.PHONY: all clean html css js serverjs serverhtml static
.DEFAULT_GOAL := all