-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (33 loc) · 1.1 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
EXEC = bin/sfn
CC = clang
CFLAGS = -Wall -Iinclude -Ilib/oniguruma/src
LDFLAGS = lib/oniguruma/src/.libs/libonig.a
SRC = $(wildcard src/*.c)
OBJ = $(SRC:.c=.o)
TEST_SRC = $(wildcard tests/*.c)
TEST_OBJ = $(TEST_SRC:.c=.o)
TEST_EXEC = bin/test_gitleaks
ONIGURUMA_DIR = lib/oniguruma
ONIGURUMA_LIB = $(ONIGURUMA_DIR)/src/.libs/libonig.a
all: $(ONIGURUMA_LIB) $(EXEC)
$(EXEC): $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
$(EXEC)_nosanitize: $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS_NOSANITIZE)
$(TEST_EXEC): $(TEST_OBJ) $(filter-out src/main.o, $(OBJ))
$(CC) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -o $@ -c $< $(CFLAGS)
$(ONIGURUMA_DIR)/configure:
cd $(ONIGURUMA_DIR) && ./autogen.sh
$(ONIGURUMA_LIB): $(ONIGURUMA_DIR)/configure
cd $(ONIGURUMA_DIR) && ./configure --disable-shared && make
.PHONY: clean test memtest memtest_nosanitize
clean:
@rm -rf src/*.o tests/*.o $(EXEC) $(TEST_EXEC) $(EXEC)_nosanitize
test: $(TEST_EXEC)
@./$(TEST_EXEC)
memtest: $(EXEC)
@leaks --atExit -- ./$(EXEC) directory out.txt
memtest_nosanitize: $(EXEC)_nosanitize
@leaks --atExit -- ./$(EXEC)_nosanitize directory out.txt