-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
91 lines (65 loc) · 2.01 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
PREFIX := /usr/local
BINPREFIX := $(DESTDIR)$(PREFIX)/bin
MANPREFIX := $(DESTDIR)$(PREFIX)/share/man/man1
SRC := $(wildcard src/*.c)
OBJ := $(SRC:.c=.o)
DEP := $(OBJ:.o=.d)
PRE := $(wildcard sh/prev/*)
GEN := gen/help.h gen/previews.h gen/server.h gen/helpers.h
LIBS := magic crypto
ALL_CFLAGS := -O2 -MMD -Wall -Wextra -Wno-unused-parameter $(CFLAGS) $(CPPFLAGS)
ALL_LDFLAGS := $(addprefix -l,$(LIBS)) $(CFLAGS) $(LDFLAGS)
MKDIR := mkdir -p
INSTALL := install
INSTALL_EXE := $(INSTALL)
INSTALL_DATA := $(INSTALL) -m 0644
all: ctpv
options:
@echo "CC = $(CC)"
@echo "CFLAGS = $(ALL_CFLAGS)"
@echo "LDFLAGS = $(ALL_LDFLAGS)"
install: install.bin install.man
install.bin: ctpv quit/ctpvquit ctpvclear
$(MKDIR) $(BINPREFIX)
$(INSTALL_EXE) $^ $(BINPREFIX)
install.man: doc/ctpv.1
$(MKDIR) $(MANPREFIX)
$(INSTALL_DATA) $^ $(MANPREFIX)
uninstall:
$(RM) $(BINPREFIX)/ctpv $(BINPREFIX)/ctpvquit $(BINPREFIX)/ctpvclear \
$(MANPREFIX)/ctpv.1
clean:
$(RM) ctpv $(OBJ) $(DEP) $(GEN)
$(MAKE) -C embed clean
$(MAKE) -C quit clean
docs: README.md doc/ctpv.1
deptable/list.awk $(PRE) | deptable/markdown.sed | deptable/insert.awk README.md
deptable/list.awk $(PRE) | deptable/roff.sed | deptable/insert.awk doc/ctpv.1
./genhelp.sh doc/ctpv.1 > help.txt
ctpv: $(OBJ)
$(CC) -o $@ $+ $(ALL_LDFLAGS)
.c.o:
$(CC) -o $@ $< -c $(ALL_CFLAGS)
# Exclicit rules for generated header files
src/ctpv.o: gen/previews.h gen/help.h
src/shell.o: gen/helpers.h
src/server.o: gen/server.h
gen/help.h: help.txt embed/embed
embed/embed help.txt > $@
gen/previews.h: $(PRE) embed/embed
embed/embed -p prev_scr_ $(PRE) > $@
gen/server.h: sh/clear.sh sh/end.sh embed/embed
embed/embed -p scr_ sh/clear.sh sh/end.sh > $@
gen/helpers.h: sh/helpers.sh embed/embed
embed/embed -p scr_ sh/helpers.sh > $@
$(GEN): | gen
gen:
$(MKDIR) $@
embed/embed: .force
$(MAKE) -C embed
quit/ctpvquit: .force
$(MAKE) -C quit
-include $(DEP)
.PHONY: all options install install.bin install.man uninstall \
clean docs .force
.DELETE_ON_ERROR: