-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (51 loc) · 1.45 KB
/
Makefile
File metadata and controls
64 lines (51 loc) · 1.45 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 = g++
CFLAGS = -O1 -Iinclude -Wall -Wextra -pedantic -std=c++20
TARGET = ldf
PREFIX = /usr
INSTALL_DIR = $(PREFIX)/bin
BUILD_DIR = build
HEADER_DIR = include
MANPAGE_DIR = $(PREFIX)/share/man/man1
SRC_DIR = src
SRCS := $(wildcard src/*.cpp)
HEADERS := $(wildcard include/*.h)
OBJS := $(addprefix build/, $(notdir $(SRCS:.cpp=.o)))
DEP := $(OBJS:.o=.d)
ifneq ($(findstring clang++, $(CC)),)
CFLAGS += -D__cpp_concepts=202002L -Wno-builtin-macro-redefined -Wno-macro-redefined
endif
all: mkdir_build $(OBJS) $(TARGET)
build/%.o: src/%.cpp
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@
install:
$(info :: Installing $(TARGET))
install -Dm755 $(TARGET) $(INSTALL_DIR)/$(TARGET)
mkdir -p $(INSTALL_DIR) $(MANPAGE_DIR)
install -Dm644 man/$(TARGET).1 $(MANPAGE_DIR)/
uninstall:
$(info :: Uninstalling $(TARGET))
rm $(INSTALL_DIR)/$(TARGET)
rm $(MANPAGE_DIR)/$(TARGET).1
mkdir_build:
@for i in $(BUILD_DIR); do\
if [ ! -f "$$i" ]; then\
mkdir -p $$i;\
fi;\
done
clean:
$(info :: cleaning build)
@for i in $(BUILD_DIR) $(TARGET); do\
if [ -f "$$i" ] || [ -d "$$i" ]; then\
rm -r "$$i";\
fi;\
done
cppcheck: mkdir_build
$(info :: running static code analysis)
$(info )
cppcheck --cppcheck-build-dir=$(BUILD_DIR) --std=c++20 --check-level=exhaustive --suppress=unreadVariable\
--suppress=missingIncludeSystem --enable=all -I $(HEADER_DIR) $(SRC_DIR)
format:
clang-format -i $(SRCS) $(HEADERS)
-include $(DEP)