-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
61 lines (49 loc) · 1 KB
/
Makefile
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
CC ?= cc
CFLAGS ?= -Wall -Werror -Wextra -Wpedantic -O2
PREFIX ?= /usr/local
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
USE_KQUEUE ?= 1
else ifeq ($(UNAME),FreeBSD)
USE_KQUEUE ?= 1
else
# epoll is default
USE_KQUEUE ?= 0
endif
# build targets
sshp: src/sshp.c src/fdwatcher.o
$(CC) -o $@ $(CFLAGS) $^
src/fdwatcher.o: src/fdwatcher.c src/fdwatcher.h
$(CC) -o $@ -c -D USE_KQUEUE=$(USE_KQUEUE) $(CFLAGS) $<
.PHONY: man
man: man/sshp.1
man/sshp.1: man/sshp.md
md2man-roff $^ > $@
.PHONY: all
all: sshp man
# clean targets
.PHONY: clean
clean:
rm -f sshp
rm -f src/*.o
.PHONY: clean-man
clean-man:
rm -f man/sshp.1
.PHONY: clean-all
clean-all: clean clean-man
# test targets
.PHONY: test
test: sshp
cd test && ./runtest test_*
.PHONY: check
check:
./tools/check src/*.h src/*.c test/* man/*.md
# install/uninstall targets
.PHONY: install
install: sshp
cp man/sshp.1 $(PREFIX)/man/man1
cp sshp $(PREFIX)/bin
.PHONY: uninstall
uninstall:
rm -f $(PREFIX)/bin/sshp
rm -f $(PREFIX)/man/man1/sshp.1