hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 66c84ca5091451f51fce9bd8affee2af49527ee0 (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

DEBUG ?= 1
SANITIZE ?= 1

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

ifeq ($(DEBUG),1)
CFLAGS += -g -fno-omit-frame-pointer
else
CFLAGS += -O2
endif

ifeq ($(SANITIZE),1)
CFLAGS += -fsanitize=address,undefined
LDFLAGS += -fsanitize=address,undefined
endif

TARGET := todo
SRC := todo.c
HDR := config.h

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

all: $(TARGET)

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

clean:
	rm -rf $(TARGET) $(TARGET).dSYM

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

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

.PHONY: all clean install uninstall