-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
63 lines (47 loc) · 1.47 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
62
63
NAME= xpipe
OBJS= src/xpipe.o
PREFIX?=/usr/local
CFLAGS+= -Wall -Werror -Wextra -I${PREFIX}/include
LDFLAGS+= -L${PREFIX}/lib
LIBS= -lm
OS!=uname
.PHONY: test
all: ${NAME}
help:
@echo "The following targets are available:"
@echo "${NAME} build the ${NAME} executable"
@echo "clean remove executable and intermediate files"
@echo "install install ${NAME} under ${PREFIX}"
@echo "readme generate the README after a manual page update"
@echo "test run the tests under tests/"
.c.o:
${CC} ${CFLAGS} -c $< -o $@
# Sorry, no ./configure, and portable make(1) is a PITA.
configure:
@ \
if [ "x${OS}" = x"Linux" ]; then \
if [ ! -d /usr/include/bsd ] && [ ! -d ${PREFIX}/include/bsd ]; then \
echo "Please install 'libbsd' and 'libbsd-devel'." >&2; \
exit 1; \
fi; \
fi
${NAME}: configure ${OBJS}
${CC} -o ${NAME} ${OBJS} ${LDFLAGS} ${LIBS} $$(echo ${OS} | sed -n -e 's/Linux/-lbsd/p')
clean:
rm -fr ${NAME} ${OBJS}
test: ${NAME}
@cd tests && for t in *.sh; do \
sh $${t}; \
done
install: ${NAME}
mkdir -p ${PREFIX}/bin ${PREFIX}/share/man/man1
install -c -m 555 ${NAME} ${PREFIX}/bin/${NAME}
install -c -m 444 doc/${NAME}.1 ${PREFIX}/share/man/man1/${NAME}.1
man: doc/${NAME}.1.txt
doc/${NAME}.1.txt: doc/${NAME}.1
mandoc -T ascii -c -O width=80 $? | col -b >$@
readme: man
sed -n -e '/^NAME/!p;//q' README.md >.readme
sed -n -e '/^NAME/,$$p' -e '/emailing/q' doc/${NAME}.1.txt >>.readme
echo '```' >>.readme
mv .readme README.md