-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
124 lines (82 loc) · 2.71 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
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
MULTICALL = 1
CFLAGS = -Os -g -Wall -W
CFLAGS += -std=c23
PREFIX = /usr/local
RST2MAN = rst2man
RM = rm -f
APPLETS = dlog drlog dslog
O = deps/cflag/cflag.o deps/clog/clog.o deps/dbuf/dbuf.o \
conf.o task.o multicall.o util.o
D = $(O:.o=.d) dmon.d nofork.d setunbuf.d $(APPLETS:=.d)
all: all-multicall-$(MULTICALL)
all-multicall-1:
@$(MAKE) programs A='$(APPLETS)'
all-multicall-0:
@$(MAKE) programs P='$(APPLETS)'
programs: dmon $(APPLETS)
.PHONY: all-multicall-0 all-multicall-1 programs
.c.o: CFLAGS := $(CFLAGS)
setunbuf.o: CFLAGS := $(CFLAGS) -fPIC
.c.o:
$(CC) -DMULTICALL=$(MULTICALL) $(CFLAGS) -MMD -MF $(@:.o=.d) -c -o $@ $<
.SUFFIXES: .c .o
-include $D
libdmon.a: $O $(A:=.o)
$(AR) rcs $@ $?
dmon $P: dmon.o $(P:=.o) libdmon.a
$(CC) $(LDFLAGS) -o $@ [email protected] libdmon.a $(LDLIBS)
nofork: libnofork.so
libnofork.so: nofork.o
$(CC) $(LDFLAGS) -shared -o $@ nofork.o $(LDLIBS)
setunbuf: libsetunbuf.so
libsetunbuf.so: setunbuf.o
$(CC) $(LDFLAGS) -shared -o $@ setunbuf.o $(LDLIBS)
.PHONY: nofork setunbuf
$(A:=-symlink): $A
$A: dmon
ln -sf dmon $@
.PHONY: $(A:=-symlink)
man: dmon.8 dlog.8 dslog.8 drlog.8
.rst.8:
$(RST2MAN) $< $@
.PHONY: man
.SUFFIXES: .rst .8
clean:
$(RM) dmon dlog dslog drlog libdmon.a dmon.o dlog.o dslog.o drlog.o nofork.o libnofork.so setunbuf.o libsetunbuf.so $O
mrproper: clean
$(RM) $D
.PHONY: clean mrproper
install-all: install-all-multicall-$(MULTICALL)
install-all-multicall-1: install-common
ln -sf dmon $(DESTDIR)$(PREFIX)/bin/dlog
ln -sf dmon $(DESTDIR)$(PREFIX)/bin/drlog
ln -sf dmon $(DESTDIR)$(PREFIX)/bin/dslog
install-all-multicall-0: install-common
install -m 755 $(APPLETS) $(DESTDIR)$(PREFIX)/bin
install-common:
install -d $(DESTDIR)$(PREFIX)/share/man/man8
install -m 644 dmon.8 dlog.8 dslog.8 drlog.8 \
$(DESTDIR)$(PREFIX)/share/man/man8
install -d $(DESTDIR)$(PREFIX)/bin
install -m 755 dmon $(DESTDIR)$(PREFIX)/bin
.PHONY: install-common install-all-multicall-0 install-all-multicall-0
install: install-multicall-$(MULTICALL)
install-multicall-1: all-multicall-1
@$(MAKE) install-all A='$(APPLETS)'
install-multicall-0: all-multicall-0
@$(MAKE) install-all P='$(APPLETS)'
.PHONY: install install-multicall-0 install-multicall-1
dist:
@$(MAKE) dist-files VERSION=$$(jq -r .version package.json)
dist-files: \
dmon-$(VERSION).tar.xz \
dmon-$(VERSION).tar.xz.asc \
dmon-$(VERSION).tar.xz.sha512
dmon-$(VERSION).tar.xz:
git archive --format=tar --prefix=dmon-$(VERSION)/ v$(VERSION) | xz -9c > $@
dmon-$(VERSION).tar.xz.asc: dmon-$(VERSION).tar.xz
$(RM) $@
gpg --armor --detach-sign --output=$@ dmon-$(VERSION).tar.xz
dmon-$(VERSION).tar.xz.sha512: dmon-$(VERSION).tar.xz
sha512sum --tag dmon-$(VERSION).tar.xz > $@
.PHONY: dist dist-files