-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (49 loc) · 1.17 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
.PHONY: all build clean includes
CC := clang++
CFLAGS := -std=c++11 -Wall -Werror ${CFLAGS}
SRC_DIR := src
BUILD_DIR := build
EXECUTABLE := npm-review
SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
OBJECTS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SOURCES))
print_build = \
printf "%-30s" $(1); \
$(2); \
echo "\x1b[32m✔\x1b[0m"
all: build
build: includes $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
@$(call print_build, "Building executable", \
$(CC) $(CFLAGS) -lncurses $^ -o $@ \
)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@$(call print_build, "Compiling $(<F)",\
$(CC) $(CFLAGS) -c $< -o $@ \
)
debug: build
debug: CFLAGS += -g
install: build
cp npm-review /opt/homebrew/bin/
_watch: debug
@echo ""
watch:
@printf "Watching for changes...\n\n"
@fswatch src/ --event Updated --one-per-batch | xargs -I @ make _watch
includes:
@mkdir -p $(BUILD_DIR)
@for file in $$(ls scripts); do \
sed -n '/# SCRIPT/,//p' scripts/$$file | \
sed -E \
-e '1s/.*/STR(/' \
-e '$$s/.*/&)/' \
-e 's/%/%%/g' \
-e 's/\$$[a-z_]{2,}/%s/g' \
-e 's/\\$$//g' | \
tr -d '\n' \
\
> $(BUILD_DIR)/$$(basename $$file .sh); \
done
test:
@./tests/run-tests.sh
clean:
rm -rf build/