hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 4ccb77885d11b2fe75cf0a0a0ff43664b89e55bc (plain)
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
CC := clang
STD := c17

SANITIZE ?= 1

CFLAGS := -std=$(STD)          \
          -Wall                \
          -Wextra              \
          -Wshadow             \
          -Wpedantic           \
          -Wconversion         \
          -Wstrict-prototypes  \
          -Wsign-conversion    \
          -Wmissing-prototypes

ifeq ($(SANITIZE),1)
CFLAGS += -g -fno-omit-frame-pointer -fsanitize=address,undefined
LDFLAGS += -fsanitize=address,undefined
else
CFLAGS += -O2
endif

TARGET := mkproj
SRC := mkproj.c

PREFIX ?= /usr/local
bindir := $(DESTDIR)$(PREFIX)/bin
mandir := $(DESTDIR)$(PREFIX)/share/man/man1

all: $(TARGET)

$(TARGET): $(SRC)
	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

check:
	bear -- make clean all
	cppcheck --enable=warning,style,performance,portability \
             --project=compile_commands.json                \
	         --error-exitcode=1

clean:
	rm -f $(TARGET)

install: mkproj.1
	$(MAKE) SANITIZE=0 clean all
	install -d $(bindir)
	install -m 755 $(TARGET) $(bindir)/$(TARGET)
	install -d $(mandir)
	install -m 644 mkproj.1 $(mandir)/mkproj.1

uninstall:
	rm -f $(bindir)/$(TARGET)
	rm -f $(mandir)/mkproj.1

.PHONY: all check clean install uninstall