-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
57 lines (47 loc) · 1.39 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
.PHONY: all clean dump test
.DEFAULT_GOAL := all
SRC_DIR := src
INCLUDE_FILES := $(wildcard $(SRC_DIR)/*.sh)
MIRROR_DIR := $(SRC_DIR)/mirrors
TEMPLATE_FILE := $(SRC_DIR)/main.sh
MIRROR_FILES := $(wildcard $(MIRROR_DIR)/*)
OTHER_FILES := $(SRC_DIR)/config.cfg
OUT_DIR := output
OUT_FILE := $(OUT_DIR)/hustmirror-cli
OUT_MIRROR_DIR := $(OUT_DIR)/mirrors
OUT_MIRROR_FILES := $(patsubst $(MIRROR_DIR)/%,$(OUT_MIRROR_DIR)/%,$(MIRROR_FILES))
PREFIX := /usr/local
DPREFIX := $(DESTDIR)$(PREFIX)
INSTALL_DIR := $(DPREFIX)/bin/
all: $(OUT_FILE)
@echo "Done, object script is $(OUT_FILE)."
test: $(OUT_FILE)
@tests/test.sh
install: $(OUT_FILE)
@mkdir -p $(INSTALL_DIR)
@cp $(OUT_FILE) $(INSTALL_DIR)
$(OUT_FILE): $(TEMPLATE_FILE) $(OUT_MIRROR_FILES) $(INCLUDE_FILES) $(OTHER_FILES)
@mkdir -p $(OUT_DIR)
@echo "Process $<"
@scripts/template-instantiate.py $< > $@.tmp
@grep -E -v "vim:.+:" $@.tmp > $@
@rm $@.tmp
@chmod +x $@
$(OUT_MIRROR_FILES): $(OUT_MIRROR_DIR)/%: $(MIRROR_DIR)/%
@echo "Process $<"
@mkdir -p $(OUT_MIRROR_DIR)
@scripts/gen-mirror.py $< > $@.tmp
@mv $@.tmp $@
clean:
@rm -rf $(OUT_DIR)
@echo "Cleaned."
clean-test-log:
@rm -rf tests/log
@echo "Cleaned."
# used for debug Makefile
dump:
$(foreach v, \
$(shell echo "$(filter-out .VARIABLES,$(.VARIABLES))" | tr ' ' '\n' | sort), \
$(info $(shell printf "%-20s" "$(v)")= $(value $(v))) \
)
# vim: set noexpandtab ts=4 sw=4 ft=make: