hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 609a12558c79bd1bb3da2675f8f2a29d5b7d0b92 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
CC := clang

WARNINGS := -Wall -Wextra        \
            -Wshadow -Wpedantic  \
            -Wconversion         \
            -Wstrict-prototypes  \
            -Wmissing-prototypes \
            -Wsign-conversion

CFLAGS := $(WARNINGS) \
          -O2        \
          -pthread   \
          -std=c17

LDFLAGS := -lz \
           -pthread

DEBUGFLAGS := $(WARNINGS) \
              -g         \
              -O0        \
              -pthread   \
              -std=c17   \
              -fno-omit-frame-pointer \
              -fsanitize=address,undefined

DEBUGLDFLAGS := -lz \
                -pthread \
                -fsanitize=address,undefined

CPPCHECKFLAGS := --error-exitcode=1              \
                 --project=compile_commands.json \
                 --enable=warning,style,performance,portability

TARGET := jafm
SRC := jafm.c

PREFIX ?= /usr/local
MANPREFIX ?= $(PREFIX)/share/man
BINDIR := $(DESTDIR)$(PREFIX)/bin
MANDIR := $(DESTDIR)$(MANPREFIX)/man1

all: $(TARGET)

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

debug: $(SRC)
	$(CC) $(DEBUGFLAGS) $(SRC) -o $(TARGET) $(DEBUGLDFLAGS)

check:
	bear -- make clean debug
	cppcheck $(CPPCHECKFLAGS)

install: $(TARGET)
	install -d $(BINDIR)
	install -m 755 $(TARGET) $(BINDIR)/$(TARGET)
	install -d $(MANDIR)
	install -m 644 $(TARGET).1 $(MANDIR)/$(TARGET).1

uninstall:
	rm -f $(BINDIR)/$(TARGET)
	rm -f $(MANDIR)/$(TARGET).1

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

.PHONY: all debug check install uninstall clean