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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
| | .POSIX:
CC := gcc
CFLAGS := ${CFLAGS}
CFLAGS += -Werror -Wall -Wextra -Wmissing-declarations
CFLAGS += -pedantic -std=c11 -ggdb
TARGET := olc
PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin
DATADIR ?= ${PREFIX}/share
INFODIR ?= ${DATADIR}/info
MANDIR ?= ${DATADIR}/man
MAN1DIR ?= ${MANDIR}/man1
SRCDIR := src
BUILDDIR := build
SRCS := $(wildcard $(SRCDIR)/*.c)
HEADERS := $(wildcard $(SRCDIR)/*.h)
DEV_MAN_PAGES := $(patsubst %, %.man, $(HEADERS))
OBJS := $(patsubst $(SRCDIR)/%.c, $(BUILDDIR)/%.o, $(SRCS))
.PHONY: all
all: $(TARGET)
.PHONY: info
info: olang.info
# install target
.PHONY: install
install: install-bin install-man install-info
.PHONY: install-bin
install-bin: $(TARGET)
install -Dm755 $< ${DESTDIR}${BINDIR}/$<
.PHONY: install-man
install-man: install-man1
.PHONY: install-man1
install-man1: docs/man/man1/olc.1
install -Dm 644 docs/man/man1/olc.1 ${DESTDIR}${MAN1DIR}/olc.1
gzip -f ${DESTDIR}${MAN1DIR}/olc.1
.PHONY: install-info
install-info: olang.info
install -Dm 644 olang.info ${DESTDIR}${INFODIR}/olang.info
gzip -f ${DESTDIR}${INFODIR}/olang.info
# uninstall target
.PHONY: uninstall
uninstall: uninstall-bin uninstall-man uninstall-info
.PHONY: uninstall-bin
uninstall-bin: ${DESTDIR}${BINDIR}/$(TARGET)
@rm -f ${DESTDIR}${BINDIR}/$(TARGET)
.PHONY: uninstall-man
uninstall-man: uninstall-man1
.PHONY: uninstall-man1
uninstall-man1:
@rm -f ${DESTDIR}${MAN1DIR}/olc.1.gz
.PHONY: uninstall-info
uninstall-info:
@rm -f ${DESTDIR}${INFODIR}/olang.info.gz
olang.info: docs/info/*.texi
$(MAKEINFO) docs/info/olang.texi
$(TARGET): $(BUILDDIR) $(OBJS)
@$(CC) $(CFLAGS) $(OBJS) -o $(TARGET)
@printf 'CCLD\t%s\n' '$@'
$(BUILDDIR):
@mkdir -p $@
.PHONY: format
format: $(SRCS) $(HEADERS)
@clang-format --dry-run --Werror $?
@$(MAKE) --no-print-directory -C tests/unit/ format
.PHONY: format-fix
format-fix: $(SRCS) $(HEADERS)
@clang-format -i $?
@$(MAKE) --no-print-directory -C tests/unit/ format-fix
.PHONY: check-olc
check-olc: $(TARGET)
$(MAKE) -C tests/olc/
.PHONY: check-unit
check-unit: $(TARGET)
$(MAKE) -C tests/unit/
.PHONY: clean
clean:
@rm -f olang.info
@$(MAKE) --no-print-directory -C tests/unit/ clean
@rm -rf build/ $(TARGET)
.PHONY: check
check: check-unit check-olc
.PHONY: docs
docs:
$(MAKE) -C docs
.PHONY: docs-dist
docs-dist:
$(MAKE) -C docs dist
.PHONY:
dev-man-docs: $(DEV_MAN_PAGES)
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
@$(CC) $(CFLAGS) -c $< -o $@
@printf 'CC\t%s\n' '$@'
$(SRCDIR)/%.man: $(SRCDIR)/%
@./scripts/gen-docstring $< `basename $<` docs/man/
|