-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·48 lines (37 loc) · 1020 Bytes
/
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
#!/usr/bin/env make -f
.SILENT:
.DEFAULT_GOAL = build
API_URL ?= "https://api.andrewflbarnes.com"
CDN_URL ?= "https://aflbcdn.com"
OUT_PATH := static
SRC_PATH := src
SRC := $(foreach x, $(SRC_PATH), $(wildcard $(addprefix $(x)/*,.*)))
OUT := $(addprefix $(OUT_PATH)/, $(notdir $(SRC)))
define get_time
$(shell date +"%T")
endef
.PHONY: clean
clean:
@printf "$(call get_time) %-30s - Deleting folder\n" $(OUT_PATH)
rm -rf $(OUT_PATH)
.PHONY: loop
loop:
@echo "starting build loop"
while make build; do sleep 1; done
.PHONY: build
build: $(OUT_PATH) $(OUT)
$(OUT_PATH):
@printf "$(call get_time) %-30s - Creating folder\n" $@
@mkdir $@
$(OUT_PATH)/%: $(SRC_PATH)/%
@printf "$(call get_time) %-30s - Copy from %s\n" $@ $<
@cp $< $@
@if echo "$@" | grep -E "\.(js|html)$$" > /dev/null; then \
printf "$(call get_time) %-30s - Updating placeholders\n" $@; \
sed \
-i.delete \
-e 's|{{API_URL}}|'$(API_URL)'|g' \
-e 's|{{CDN_URL}}|'$(CDN_URL)'|g' \
$@; \
rm $@.delete; \
fi