about summary refs log tree commit diff stats
path: root/Makefile
blob: 9f8b7baa1a95650de563172fb787f7be45dd23d6 (plain) (blame)
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
.POSIX:
.SUFFIXES: .c .o

BIN = rf
VERSION = 0.0.2
OBJS = rf.o
MANPAGE = rf.1
CC = cc
DEPS = config.h
LIBS =
INC =
CFLAGS := ${CFLAGS}
CFLAGS += -ansi \
	  -Wpedantic \
	  -Wall \
	  -Werror=format-security \
	  -Werror=implicit-function-declaration \
	  -O2 \
	  -fstack-protector-strong \
	  -fpie \
	  -D_FORTIFY_SOURCE=2 \
	  -DVERSION='"$(VERSION)"' \
	  -DNAME='"$(BIN)"' \
	  $(INC) $(LIBS)
PREFIX ?= /usr/local

build: $(BIN)

$(BIN): $(OBJS)
	$(CC) $(BIN).c $(CFLAGS) -o $(BIN)

debug: $(OBJS)
	$(CC) $(BIN).c $(CFLAGS) -g -o $(BIN)

test: clean debug
	valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 ./$(BIN) ^$
	valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 ./$(BIN) ^$$
	valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 ./$(BIN) rf

static: $(OBJS)
	$(CC) $(BIN).c $(CFLAGS) -static -o $(BIN)

%.o: %.c $(DEPS)
	$(CC) -c -o $@ $< $(CFLAGS)

install: build
	install $(BIN) $(DESTDIR)$(PREFIX)/bin/
	install -TD $(MANPAGE) $(DESTDIR)$(PREFIX)/man/man1/$(MANPAGE)
	gzip $(PREFIX)/man/man1/$(MANPAGE)

clean:
	rm -vf $(BIN) *.o