-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
201 lines (146 loc) · 5.78 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
SYSCONFDIR = /etc
PREFIX ?= /usr
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man
LIBDIR = $(PREFIX)/lib
RCLIBDIR = $(LIBDIR)/rc
########### runit ###########
RCDIR = $(SYSCONFDIR)/rc
RUNITDIR = $(SYSCONFDIR)/runit
SVDIR = $(RUNITDIR)/sv
RUNSVDIR = $(RUNITDIR)/runsvdir
SERVICEDIR = /etc/service
RUNDIR = /run/runit
TMPFILESDIR = $(LIBDIR)/tmpfiles.d
TMPFILES = misc/tmpfile.conf
BIN = script/zzz src/pause
STAGES = \
script/1 \
script/2 \
script/3 \
script/ctrlaltdel
RCLOCAL = script/rc.local.start script/rc.shutdown.stop
UDEV = $(wildcard sv/udevd/*)
AGETTY_CONSOLE = $(wildcard sv/agetty-console/*)
AGETTY_CONSOLE_S = supervise.agetty-console
AGETTY_GENERIC = $(wildcard sv/agetty-generic/*)
AGETTY_SERIAL = $(wildcard sv/agetty-serial/*)
AGETTY_TTY1 = $(wildcard sv/agetty-tty1/*)
AGETTY_TTY1_S = supervise.agetty-tty1
AGETTY_TTY2 = $(wildcard sv/agetty-tty2/*)
AGETTY_TTY2_S = supervise.agetty-tty2
AGETTY_TTY3 = $(wildcard sv/agetty-tty3/*)
AGETTY_TTY3_S = supervise.agetty-tty3
AGETTY_TTY4 = $(wildcard sv/agetty-tty4/*)
AGETTY_TTY4_S = supervise.agetty-tty4
AGETTY_TTY5 = $(wildcard sv/agetty-tty5/*)
AGETTY_TTY5_S = supervise.agetty-tty5
AGETTY_TTY6 = $(wildcard sv/agetty-tty6/*)
AGETTY_TTY6_S = supervise.agetty-tty6
AGETTY_TTYAMA0 = $(wildcard sv/agetty-ttyAMA0/*)
AGETTY_TTYAMA0_S = supervise.agetty-ttyAMA0
AGETTY_TTYS0 = $(wildcard sv/agetty-ttyS0/*)
AGETTY_TTYS0_S = supervise.agetty-ttyS0
AGETTY_TTYUSB0 = $(wildcard sv/agetty-ttyUSB0/*)
AGETTY_TTYUSB0_S = supervise.agetty-ttyUSB0
AGETTY_SULOGIN = $(wildcard sv/sulogin/*)
AGETTY_SULOGIN_S = supervise.sulogin
AGETTY_SYMS = \
agetty-tty1 \
agetty-tty2 \
agetty-tty3 \
agetty-tty4 \
agetty-tty5 \
agetty-tty6
SULOGIN_SYM = sulogin
########### end ###########
LN = ln -sf
CP = cp -R --no-dereference --preserve=mode,links -v
RM = rm -f
RMD = rm -fr --one-file-system
M4 = m4 -P
CHMODAW = chmod a-w
CHMODX = chmod +x
EDIT = sed \
-e "s|@RCDIR[@]|$(RCDIR)|g" \
-e "s|@RUNITDIR[@]|$(RUNITDIR)|g" \
-e "s|@SERVICEDIR[@]|$(SERVICEDIR)|g" \
-e "s|@RUNSVDIR[@]|$(RUNSVDIR)|g" \
-e "s|@RUNDIR[@]|$(RUNDIR)|g" \
-e "s|@SYSCONFDIR[@]|$(SYSCONFDIR)|g" \
-e "s|@RCLIBDIR[@]|$(RCLIBDIR)|g"
%: %.in Makefile
@echo "GEN $@"
@$(RM) "$@"
@$(M4) [email protected] | $(EDIT) >$@
@$(CHMODAW) "$@"
@$(CHMODX) "$@"
all: all-runit
all-runit: $(STAGES) $(RCLOCAL)
$(CC) $(CFLAGS) src/pause.c -o src/pause $(LDFLAGS)
install-runit:
install -d $(DESTDIR)$(RUNITDIR)
install -m755 $(STAGES) $(DESTDIR)$(RUNITDIR)
install -d $(DESTDIR)$(RUNSVDIR)/single
install -d $(DESTDIR)$(RUNSVDIR)/default
$(LN) default $(DESTDIR)$(RUNSVDIR)/current
$(LN) $(RUNDIR)/reboot $(DESTDIR)$(RUNITDIR)/
$(LN) $(RUNDIR)/stopit $(DESTDIR)$(RUNITDIR)/
install -d $(DESTDIR)$(SYSCONFDIR)/local.d
install -m755 $(RCLOCAL) $(DESTDIR)$(SYSCONFDIR)/local.d
install -d $(DESTDIR)$(BINDIR)
install -m755 $(BIN) $(DESTDIR)$(BINDIR)
install -d $(DESTDIR)$(TMPFILESDIR)
install -m755 $(TMPFILES) $(DESTDIR)$(TMPFILESDIR)/runit.conf
install -d $(DESTDIR)$(SVDIR)/udevd
install -Dm755 $(UDEV) $(DESTDIR)$(SVDIR)/udevd
install -d $(DESTDIR)$(SVDIR)/agetty-console
install -Dm755 $(AGETTY_CONSOLE) $(DESTDIR)$(SVDIR)/agetty-console
$(LN) $(RUNDIR)/$(AGETTY_CONSOLE_S) $(DESTDIR)$(SVDIR)/agetty-console/supervise
install -d $(DESTDIR)$(SVDIR)/agetty-generic
install -Dm755 $(AGETTY_GENERIC) $(DESTDIR)$(SVDIR)/agetty-generic
install -d $(DESTDIR)$(SVDIR)/agetty-serial
install -Dm755 $(AGETTY_SERIAL) $(DESTDIR)$(SVDIR)/agetty-serial
install -d $(DESTDIR)$(SVDIR)/agetty-tty1
install -Dm755 $(AGETTY_TTY1) $(DESTDIR)$(SVDIR)/agetty-tty1
$(LN) $(RUNDIR)/$(AGETTY_TTY1_S) $(DESTDIR)$(SVDIR)/agetty-tty1/supervise
#
install -d $(DESTDIR)$(SVDIR)/agetty-tty2
install -Dm755 $(AGETTY_TTY2) $(DESTDIR)$(SVDIR)/agetty-tty2
$(LN) $(RUNDIR)/$(AGETTY_TTY2_S) $(DESTDIR)$(SVDIR)/agetty-tty2/supervise
install -d $(DESTDIR)$(SVDIR)/agetty-tty3
install -Dm755 $(AGETTY_TTY3) $(DESTDIR)$(SVDIR)/agetty-tty3
$(LN) $(RUNDIR)/$(AGETTY_TTY3_S) $(DESTDIR)$(SVDIR)/agetty-tty3/supervise
install -d $(DESTDIR)$(SVDIR)/agetty-tty4
install -Dm755 $(AGETTY_TTY4) $(DESTDIR)$(SVDIR)/agetty-tty4
$(LN) $(RUNDIR)/$(AGETTY_TTY4_S) $(DESTDIR)$(SVDIR)/agetty-tty4/supervise
install -d $(DESTDIR)$(SVDIR)/agetty-tty5
install -Dm755 $(AGETTY_TTY5) $(DESTDIR)$(SVDIR)/agetty-tty5
$(LN) $(RUNDIR)/$(AGETTY_TTY5_S) $(DESTDIR)$(SVDIR)/agetty-tty5/supervise
install -d $(DESTDIR)$(SVDIR)/agetty-tty6
install -Dm755 $(AGETTY_TTY6) $(DESTDIR)$(SVDIR)/agetty-tty6
$(LN) $(RUNDIR)/$(AGETTY_TTY6_S) $(DESTDIR)$(SVDIR)/agetty-tty6/supervise
install -d $(DESTDIR)$(SVDIR)/agetty-ttyAMA0
install -Dm755 $(AGETTY_TTYAMA0) $(DESTDIR)$(SVDIR)/agetty-ttyAMA0
$(LN) $(RUNDIR)/$(AGETTY_TTYAMA0_S) $(DESTDIR)$(SVDIR)/agetty-ttyAMA0/supervise
install -d $(DESTDIR)$(SVDIR)/agetty-ttyS0
install -Dm755 $(AGETTY_TTYS0) $(DESTDIR)$(SVDIR)/agetty-ttyS0
$(LN) $(RUNDIR)/$(AGETTY_TTYS0_S) $(DESTDIR)$(SVDIR)/agetty-ttyS0/supervise
install -d $(DESTDIR)$(SVDIR)/agetty-ttyUSB0
install -Dm755 $(AGETTY_TTYUSB0) $(DESTDIR)$(SVDIR)/agetty-ttyUSB0
$(LN) $(RUNDIR)/$(AGETTY_TTYUSB0_S) $(DESTDIR)$(SVDIR)/agetty-ttyUSB0/supervise
install -d $(DESTDIR)$(SVDIR)/sulogin
install -Dm755 $(AGETTY_SULOGIN) $(DESTDIR)$(SVDIR)/sulogin
$(LN) $(RUNDIR)/$(AGETTY_SULOGIN_S) $(DESTDIR)$(SVDIR)/sulogin/supervise
$(LN) $(SVDIR)/udevd $(DESTDIR)$(RUNSVDIR)/default/udevd
for g in $(AGETTY_SYMS); do $(LN) $(SVDIR)/$$g $(DESTDIR)$(RUNSVDIR)/default/$$g; done
for g in $(SULOGIN_SYM); do $(LN) $(SVDIR)/$$g $(DESTDIR)$(RUNSVDIR)/single/$$g; done
install -d $(DESTDIR)$(MANDIR)/man1
install -m644 man/pause.1 $(DESTDIR)$(MANDIR)/man1
install -d $(DESTDIR)$(MANDIR)/man8
install -m644 man/zzz.8 $(DESTDIR)$(MANDIR)/man8/zzz.8
install: install-runit
clean-runit:
-$(RM) src/pause $(STAGES) $(RCLOCAL)
clean: clean-runit
.PHONY: all install clean install-runit clean-runit