forked from bitstreamout/showconsole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
228 lines (209 loc) · 7.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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#
# Makefile for compiling console tools
#
# Author: Werner Fink, <[email protected]>
#
LOG_BUFFER_SIZE = 65536
TRANS_BUFFER = 4096
BOOT_LOGFILE = /var/log/boot.log
BOOT_OLDLOGFILE = /var/log/boot.old
BOOT_FIFO = /dev/blog
#DEBUG = -DDEBUG=1
#DESTDIR = /tmp/root
DEBUG =
DESTDIR =
MAJOR := 2
MINOR := 18
VERSION := $(MAJOR).$(MINOR)
DATE = $(shell date +'%d%b%y' | tr '[:lower:]' '[:upper:]')
COPTS =
#
# Architecture
#
ARCH = $(shell uname -m | sed 's@\(i\)[34567]\(86\)@\13\2@')
CFLAGS = $(RPM_OPT_FLAGS) $(COPTS) $(DEBUG) -D_GNU_SOURCE \
-DLOG_BUFFER_SIZE=$(LOG_BUFFER_SIZE) \
-DTRANS_BUFFER_SIZE=$(TRANS_BUFFER) \
-DBOOT_LOGFILE=\"$(BOOT_LOGFILE)\" \
-DBOOT_OLDLOGFILE=\"$(BOOT_OLDLOGFILE)\" \
-D_PATH_BLOG_FIFO=\"$(BOOT_FIFO)\" \
-ffunction-sections -Wall -pipe
CLOOP = -funroll-loops
ifeq ($(BLOGGER),1)
CFLAGS += -DBLOGGER
endif
SEDOPTS = s|@@BOOT_LOGFILE@@|$(BOOT_LOGFILE)|;s|@@BOOT_OLDLOGFILE@@|$(BOOT_OLDLOGFILE)|
CC = gcc -g3
RM = rm -f
MKDIR = mkdir -p
RMDIR = rm -rf
INSTBINFLAGS = -s -m 0700
INSTBIN = install $(INSTBINFLAGS)
INSTDOCFLAGS = -c -m 0644
INSTDOC = install $(INSTDOCFLAGS)
INSTCONFLAGS = -c -m 0644
INSTCON = install $(INSTDOCFLAGS)
INSTSCRFLAGS = -c -m 0755
INSTSCR = install $(INSTSCRFLAGS)
LINK = ln -sf
AR = ar
LD = ld -shared -O2
SED = sed -r
SO = echo .so man8/
#
MANPATH = /usr/share/man
SDOCDIR = $(MANPATH)/man8
SBINDIR = /sbin
CONFDIR = /etc
LSBDIR = /usr/lib/lsb
LIBDIR = /usr/lib
INCDIR = /usr/include
DRACUTMOD = /usr/lib/dracut/modules.d/99blog
SYSDUNITS = /usr/lib/systemd/system
#
#
#
TODO = showconsole blogd blogger blogctl isserial libblogger.so
TODO += blog-store-messages.service blogd.8 blogger.8
L := libconsole/
CFLAGS += -I ./ -I ./$(L)
libfiles := $(sort $(wildcard $(L)*.c))
all: $(TODO)
%.o: %.c
$(CC) $(CFLAGS) $(CLOOP) -D_REENTRANT -fPIC -o $@ -c $< -pthread
%: %.in
$(SED) '$(SEDOPTS)' $< > $@
$(libfiles): $(L)libconsole.h listing.h
libconsole.a: $(patsubst %.c,%.o,$(libfiles))
$(AR) rusv $@ $^
libblogger.o: libconsole.a
libblogger.o: libblogger.c libblogger.h
$(CC) $(CFLAGS) $(CLOOP) -fPIC -c $<
libblogger.so: libblogger.o libconsole/signals.o
$(CC) -shared -Wl,-O2 -Wl,-soname=$@.$(MAJOR) -o $@ $^
showconsole: showconsole.c libconsole.a
$(CC) $(CFLAGS) $(CLOOP) -o $@ $^ -Wl,-O2 -Wl,-gc-sections -L ./ -lconsole -Wl,--as-needed -lutil -lrt -pthread
blogd: blogd.c libconsole.a
$(CC) $(CFLAGS) $(CLOOP) -D_REENTRANT -o $@ $< -Wl,-O2 -Wl,-gc-sections -L ./ -lconsole -Wl,--as-needed -lutil -lrt -pthread
blogctl: blogctl.c libconsole.a
$(CC) $(CFLAGS) $(CLOOP) -D_REENTRANT -o $@ $< -Wl,-O2 -Wl,-gc-sections -L ./ -lconsole -Wl,--as-needed -lutil -lrt -pthread
blogger: blogger.c libblogger.so
$(CC) $(CFLAGS) $(CLOOP) -o $@ $< -Wl,-O2 -Wl,-gc-sections -Wl,-rpath-link=. -L . -lblogger
isserial: isserial.c
$(CC) $(CFLAGS) $(CLOOP) -o $@ $^
clean:
$(RM) *.o *.a *.so* *~ libconsole/*.o libconsole/*~ showconsole blogctl blogd blogger isserial $(patsubst %.in,%,$(wildcard *.in))
install: $(TODO)
$(MKDIR) $(DESTDIR)$(SBINDIR)
$(MKDIR) $(DESTDIR)$(SDOCDIR)
$(MKDIR) $(DESTDIR)$(CONFDIR)
$(MKDIR) $(DESTDIR)$(LSBDIR)
$(MKDIR) $(DESTDIR)$(LIBDIR)
$(MKDIR) $(DESTDIR)$(INCDIR)
$(MKDIR) $(DESTDIR)$(DRACUTMOD)
$(MKDIR) $(DESTDIR)$(SYSDUNITS)
for target in basic default emergency halt initrd-switch-root kexec multi-user poweroff reboot rescue shutdown sysinit ; do \
$(MKDIR) $(DESTDIR)$(SYSDUNITS)/$${target}.target.wants ; \
done
for unit in systemd-ask-password-blog ; do \
$(MKDIR) $(DESTDIR)$(SYSDUNITS)/$${unit}.service.wants ; \
done
$(INSTBIN) showconsole $(DESTDIR)$(SBINDIR)/
$(LINK) showconsole $(DESTDIR)$(SBINDIR)/setconsole
$(INSTBIN) blogger $(DESTDIR)$(SBINDIR)/
$(INSTDOC) blogger.8 $(DESTDIR)$(SDOCDIR)/
$(INSTDOC) showconsole.8 $(DESTDIR)$(SDOCDIR)/
$(SO)showconsole.8 > $(DESTDIR)$(SDOCDIR)/setconsole.8
$(INSTBIN) blogd $(DESTDIR)$(SBINDIR)/
$(INSTDOC) blogd.8 $(DESTDIR)$(SDOCDIR)/
$(INSTBIN) blogctl $(DESTDIR)$(SBINDIR)/
$(INSTDOC) blogctl.8 $(DESTDIR)$(SDOCDIR)/
$(INSTCON) libblogger.h $(DESTDIR)$(INCDIR)/
$(INSTCON) libblogger.so $(DESTDIR)$(LIBDIR)/libblogger.so.$(MAJOR).$(MINOR)
$(INSTBIN) isserial $(DESTDIR)$(SBINDIR)/
$(INSTDOC) isserial.8 $(DESTDIR)$(SDOCDIR)/
$(INSTSCR) module-setup.sh $(DESTDIR)$(DRACUTMOD)/
$(LINK) libblogger.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libblogger.so.$(MAJOR)
$(LINK) libblogger.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libblogger.so
for unit in blog blog-final blog-quit blog-store-messages blog-switch-root blog-umount ; do \
$(INSTCON) $${unit}.service $(DESTDIR)$(SYSDUNITS)/ ; \
done
for unit in systemd-ask-password-blog.path systemd-ask-password-blog.service ; do \
$(INSTCON) $${unit} $(DESTDIR)$(SYSDUNITS)/ ; \
done
for unit in blog.service ; do \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/basic.target.wants/$${unit} ; \
done
for unit in blog-final.service blog-umount.service ; do \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/halt.target.wants/$${unit} ; \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/kexec.target.wants/$${unit} ; \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/poweroff.target.wants/$${unit} ; \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/reboot.target.wants/$${unit} ; \
done
for unit in blog-quit.service ; do \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/default.target.wants/$${unit} ; \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/emergency.target.wants/$${unit} ; \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/rescue.target.wants/$${unit} ; \
done
for unit in blog.service blog-switch-root.service ; do \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/initrd-switch-root.target.wants/$${unit} ; \
done
for unit in blog-store-messages.service systemd-ask-password-blog.path ; do \
$(LINK) ../$${unit} $(DESTDIR)$(SYSDUNITS)/sysinit.target.wants/${uni$t} ; \
done
#
# Make distribution
#
FILES = README \
COPYING \
OTHERS \
Makefile \
libblogger.c \
libblogger.h \
libconsole/*.c \
libconsole/*.h \
listing.h \
showconsole.8 \
showconsole.c \
blogd.c \
blogd.8.in \
blogger.c \
blogger.8.in \
blogctl.c \
blogctl.8 \
isserial.c \
isserial.8 \
blog.service \
blog-final.service \
blog-quit.service \
blog-store-messages.service.in \
blog-switch-root.service \
blog-umount.service \
systemd-ask-password-blog.path \
systemd-ask-password-blog.service \
module-setup.sh \
showconsole-$(VERSION).lsm
dest:
$(MKDIR) showconsole-$(VERSION)
@echo -e "Begin3\n\
Title: console tools for boot scripts\n\
Version: $(VERSION)\n\
Entered-date: $(DATE)\n\
Description: Used for fetch the real device in boot scripts\n\
x running on /dev/console.\n\
Keywords: boot control\n\
Author: Werner Fink <[email protected]>\n\
Maintained-by: Werner Fink <[email protected]>\n\
Primary-site: sunsite.unc.edu /pub/Linux/system/daemons/init\n\
x @UNKNOWN showconsole-$(VERSION).tar.gz\n\
Alternate-site: ftp.suse.com /pub/projects/init\n\
Platforms: Linux with System VR2 or higher boot scheme\n\
Copying-policy: GPL\n\
End" | sed 's@^ @@g;s@^x@@g' > showconsole-$(VERSION).lsm
tar cpf - $(FILES) | tar -xpf - -C showconsole-$(VERSION)
tar -cp -jf showconsole-$(VERSION).tar.bz2 showconsole-$(VERSION)/
$(RMDIR) showconsole-$(VERSION)
set -- `find showconsole-$(VERSION).tar.bz2 -printf '%s'` ; \
sed "s:@UNKNOWN:$$1:" < showconsole-$(VERSION).lsm > \
showconsole-$(VERSION).lsm.tmp ; \
mv showconsole-$(VERSION).lsm.tmp showconsole-$(VERSION).lsm