-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
76 lines (55 loc) · 1.51 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
64
65
66
67
68
69
70
71
72
73
74
75
76
PROJECT = autoclave
OPTIMIZE = -O3
WARN = -Wall -pedantic -Wextra
CSTD += -std=c99 -D_POSIX_C_SOURCE=200112L
CDEFS +=
CFLAGS += ${CSTD} -g ${WARN} ${CDEFS} ${OPTIMIZE}
LDFLAGS +=
BUILD = build
SRC = src
EXAMPLES = examples
MAN = man
EXAMPLE_PROGS= ${BUILD}/crash_example \
${BUILD}/deadlock_example \
${BUILD}/fail_if_argv1_eq_5 \
${BUILD}/gdb_it \
${BUILD}/tick_then_die \
${BUILD}/tick_then_okay \
${BUILD}/tick_then_wait \
all: ${BUILD}/${PROJECT} ${EXAMPLE_PROGS}
OBJS= ${BUILD}/main.o
# Basic targets
${BUILD}/${PROJECT}: ${OBJS}
${CC} -o $@ $< ${LDFLAGS}
${BUILD}/%: ${EXAMPLES}/%.o
${CC} -o $@ $< ${LDFLAGS} -lpthread
clean:
rm -rf ${BUILD}
${BUILD}/%.o: ${SRC}/%.c ${SRC}/*.h | ${BUILD}
${CC} -c -o $@ ${CFLAGS} $<
${BUILD}/%.o: ${EXAMPLES}/%.c ${SRC}/*.h | ${BUILD}
${CC} -o $@ ${CFLAGS} $<
# For the example programs that are shell scripts,
# just copy them into build.
${BUILD}/%: ${EXAMPLES}/% | ${BUILD}
cp $< $@
${BUILD}/*.o: Makefile ${SRC}/types.h
${BUILD}:
mkdir -p $@
# Regenerate documentation (requires ronn)
docs: ${MAN}/${PROJECT}.1 ${MAN}/${PROJECT}.1.html
${MAN}/${PROJECT}.1: ${MAN}/${PROJECT}.1.ronn
ronn --roff $<
${MAN}/${PROJECT}.1.html: ${MAN}/${PROJECT}.1.ronn
ronn --html $<
# Installation
PREFIX ?= /usr/local
INSTALL ?= install
RM ?= rm
MAN_DEST ?= ${PREFIX}/share/man
install:
${INSTALL} -c ${BUILD}/${PROJECT} ${PREFIX}/bin
${INSTALL} -c ${MAN}/${PROJECT}.1 ${MAN_DEST}/man1/
uninstall:
${RM} -f ${PREFIX}/bin/${PROJECT}
${RM} -f ${MAN_DEST}/man1/${PROJECT}.1