-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (47 loc) · 1.76 KB
/
Makefile
File metadata and controls
64 lines (47 loc) · 1.76 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
CC ?= cc
CFLAGS ?= -O2
CFLAGS += -std=c17 -Wall -Wextra -Wpedantic
CFLAGS += -Iinclude -Isrc
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man/man1
SRCS = src/main.c src/cli.c src/buf.c src/log.c src/platform.c src/fs.c src/lang.c \
src/handlers/c_like.c src/handlers/python.c src/handlers/shell.c \
src/handlers/hash.c src/handlers/lua.c
OBJS = $(SRCS:.c=.o)
TEST_SRCS = tests/test_main.c src/buf.c \
src/handlers/c_like.c src/handlers/python.c src/handlers/shell.c \
src/handlers/hash.c src/handlers/lua.c
TARGET = decomment
TEST_TARGET = tests/test_runner
.PHONY: all clean test install uninstall lint sanitize
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
test: $(TEST_TARGET)
./$(TEST_TARGET)
$(TEST_TARGET): $(TEST_SRCS)
$(CC) $(CFLAGS) -DTESTING -o $@ $(TEST_SRCS)
clean:
rm -f $(OBJS) $(TARGET) $(TEST_TARGET)
rm -f tests/test_runner
install: $(TARGET)
install -d $(DESTDIR)$(BINDIR)
install -m 755 $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
uninstall:
rm -f $(DESTDIR)$(BINDIR)/$(TARGET)
lint:
@echo "Running cppcheck (if available)..."
-cppcheck --enable=all --std=c17 -Iinclude -Isrc --suppress=missingIncludeSystem src/ 2>&1
@echo "Running clang-tidy (if available)..."
-clang-tidy src/*.c src/handlers/*.c -- $(CFLAGS) 2>&1
sanitize:
$(CC) $(CFLAGS) -fsanitize=address,undefined -g -o $(TARGET)_asan $(SRCS)
$(CC) $(CFLAGS) -fsanitize=address,undefined -g -DTESTING -o $(TEST_TARGET)_asan $(TEST_SRCS)
./$(TEST_TARGET)_asan
rm -f $(TARGET)_asan $(TEST_TARGET)_asan
$(OBJS): include/decomment.h include/buf.h include/cli.h include/fs.h \
include/lang.h include/log.h include/platform.h \
src/handlers/handlers.h