forked from dracutdevs/dracut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
267 lines (226 loc) · 11 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
-include dracut-version.sh
VERSION ?= $(shell [ -d .git ] && git describe --abbrev=0 --tags 2>/dev/null || echo $(DRACUT_VERSION))
GITVERSION ?= $(shell [ -d .git ] && { v=$$(git describe --tags 2>/dev/null); [ -n "$$v" ] && [ $${v\#*-} != $$v ] && echo -$${v\#*-}; } )
-include Makefile.inc
prefix ?= /usr
libdir ?= ${prefix}/lib
datadir ?= ${prefix}/share
pkglibdir ?= ${libdir}/dracut
sysconfdir ?= ${prefix}/etc
bindir ?= ${prefix}/bin
mandir ?= ${prefix}/share/man
CFLAGS ?= -O2 -g -Wall $(KMOD_CFLAGS)
CFLAGS += -std=gnu99 -D_FILE_OFFSET_BITS=64 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
bashcompletiondir ?= ${datadir}/bash-completion/completions
pkgconfigdatadir ?= $(datadir)/pkgconfig
man1pages = lsinitrd.1
man5pages = dracut.conf.5
man7pages = dracut.cmdline.7 \
dracut.bootup.7 \
dracut.modules.7
man8pages = dracut.8 \
dracut-catimages.8 \
mkinitrd.8 \
mkinitrd-suse.8 \
modules.d/98dracut-systemd/dracut-cmdline.service.8 \
modules.d/98dracut-systemd/dracut-initqueue.service.8 \
modules.d/98dracut-systemd/dracut-mount.service.8 \
modules.d/98dracut-systemd/dracut-shutdown.service.8 \
modules.d/98dracut-systemd/dracut-pre-mount.service.8 \
modules.d/98dracut-systemd/dracut-pre-pivot.service.8 \
modules.d/98dracut-systemd/dracut-pre-trigger.service.8 \
modules.d/98dracut-systemd/dracut-pre-udev.service.8
manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
.PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh
all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio
DRACUT_INSTALL_OBJECTS = \
install/dracut-install.o \
install/hashmap.o\
install/log.o \
install/strv.o \
install/util.o
# deps generated with gcc -MM
install/dracut-install.o: install/dracut-install.c install/log.h install/macro.h \
install/hashmap.h install/util.h
install/hashmap.o: install/hashmap.c install/util.h install/macro.h install/log.h \
install/hashmap.h
install/log.o: install/log.c install/log.h install/macro.h install/util.h
install/util.o: install/util.c install/util.h install/macro.h install/log.h
install/strv.o: install/strv.c install/strv.h install/util.h install/macro.h install/log.h
install/dracut-install: $(DRACUT_INSTALL_OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) $(KMOD_LIBS)
dracut-install: install/dracut-install
ln -fs $< $@
SKIPCPIO_OBJECTS= \
skipcpio/skipcpio.o
skipcpio/skipcpio.o: skipcpio/skipcpio.c
skipcpio/skipcpio: skipcpio/skipcpio.o
indent:
indent -i8 -nut -br -linux -l120 install/dracut-install.c
indent -i8 -nut -br -linux -l120 skipcpio/skipcpio.c
doc: $(manpages) dracut.html
ifneq ($(enable_documentation),no)
all: doc
endif
%: %.xml
@rm -f -- "$@"
xsltproc -o "$@" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
%.xml: %.asc
@rm -f -- "$@"
asciidoc -d manpage -b docbook -o "$@" $<
dracut.8: dracut.usage.asc dracut.8.asc
dracut.html: dracut.asc $(manpages) dracut.css dracut.usage.asc
@rm -f -- dracut.xml
asciidoc -a numbered -d book -b docbook -o dracut.xml dracut.asc
@rm -f -- dracut.html
xsltproc -o dracut.html --xinclude -nonet \
--stringparam custom.css.source dracut.css \
--stringparam generate.css.header 1 \
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
@rm -f -- dracut.xml
dracut.pc: Makefile.inc Makefile
@echo "Name: dracut" > dracut.pc
@echo "Description: dracut" >> dracut.pc
@echo "Version: $(VERSION)$(GITVERSION)" >> dracut.pc
@echo "dracutdir=$(pkglibdir)" >> dracut.pc
@echo "dracutmodulesdir=$(pkglibdir)/modules.d" >> dracut.pc
@echo "dracutconfdir=$(pkglibdir)/dracut.conf.d" >> dracut.pc
install: all
mkdir -p $(DESTDIR)$(pkglibdir)
mkdir -p $(DESTDIR)$(bindir)
mkdir -p $(DESTDIR)$(sysconfdir)
mkdir -p $(DESTDIR)$(pkglibdir)/modules.d
mkdir -p $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 $(DESTDIR)$(mandir)/man8
install -m 0755 dracut.sh $(DESTDIR)$(bindir)/dracut
install -m 0755 dracut-catimages.sh $(DESTDIR)$(bindir)/dracut-catimages
install -m 0755 mkinitrd-dracut.sh $(DESTDIR)$(bindir)/mkinitrd
install -m 0755 lsinitrd.sh $(DESTDIR)$(bindir)/lsinitrd
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
mkdir -p $(DESTDIR)$(pkglibdir)/dracut.conf.d
install -m 0755 dracut-init.sh $(DESTDIR)$(pkglibdir)/dracut-init.sh
install -m 0755 dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions.sh
install -m 0755 dracut-version.sh $(DESTDIR)$(pkglibdir)/dracut-version.sh
ln -fs dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions
install -m 0755 dracut-logger.sh $(DESTDIR)$(pkglibdir)/dracut-logger.sh
install -m 0755 dracut-initramfs-restore.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-restore
cp -arx modules.d $(DESTDIR)$(pkglibdir)
ifneq ($(enable_documentation),no)
for i in $(man1pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man1/$${i##*/}; done
for i in $(man5pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man5/$${i##*/}; done
for i in $(man7pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man7/$${i##*/}; done
for i in $(man8pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man8/$${i##*/}; done
ln -fs dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
endif
if [ -n "$(systemdsystemunitdir)" ]; then \
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
ln -srf $(DESTDIR)$(pkglibdir)/modules.d/98dracut-systemd/dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir)/dracut-shutdown.service; \
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants; \
ln -s ../dracut-shutdown.service \
$(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants/dracut-shutdown.service; \
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/initrd.target.wants; \
for i in \
dracut-cmdline.service \
dracut-initqueue.service \
dracut-mount.service \
dracut-pre-mount.service \
dracut-pre-pivot.service \
dracut-pre-trigger.service \
dracut-pre-udev.service \
; do \
ln -srf $(DESTDIR)$(pkglibdir)/modules.d/98dracut-systemd/$$i $(DESTDIR)$(systemdsystemunitdir); \
ln -s ../$$i \
$(DESTDIR)$(systemdsystemunitdir)/initrd.target.wants/$$i; \
done \
fi
if [ -f install/dracut-install ]; then \
install -m 0755 install/dracut-install $(DESTDIR)$(pkglibdir)/dracut-install; \
fi
if [ -f skipcpio/skipcpio ]; then \
install -m 0755 skipcpio/skipcpio $(DESTDIR)$(pkglibdir)/skipcpio; \
fi
mkdir -p $(DESTDIR)${prefix}/lib/kernel/install.d
install -m 0755 50-dracut.install $(DESTDIR)${prefix}/lib/kernel/install.d/50-dracut.install
install -m 0755 51-dracut-rescue.install $(DESTDIR)${prefix}/lib/kernel/install.d/51-dracut-rescue.install
mkdir -p $(DESTDIR)${bashcompletiondir}
install -m 0644 dracut-bash-completion.sh $(DESTDIR)${bashcompletiondir}/dracut
install -m 0644 lsinitrd-bash-completion.sh $(DESTDIR)${bashcompletiondir}/lsinitrd
mkdir -p $(DESTDIR)${pkgconfigdatadir}
install -m 0644 dracut.pc $(DESTDIR)${pkgconfigdatadir}/dracut.pc
dracut-version.sh:
@rm -f dracut-version.sh
@echo "DRACUT_VERSION=$(VERSION)$(GITVERSION)" > dracut-version.sh
clean:
$(RM) *~
$(RM) */*~
$(RM) */*/*~
$(RM) $(manpages:%=%.xml) dracut.xml
$(RM) test-*.img
$(RM) dracut-*.rpm dracut-*.tar.bz2 dracut-*.tar.xz
$(RM) dracut-version.sh
$(RM) dracut-install install/dracut-install $(DRACUT_INSTALL_OBJECTS)
$(RM) skipcpio/skipcpio $(SKIPCPIO_OBJECTS)
$(RM) $(manpages) dracut.html
$(MAKE) -C test clean
dist: dracut-$(VERSION).tar.xz
dracut-$(VERSION).tar.xz: doc syncheck
@echo "DRACUT_VERSION=$(VERSION)" > dracut-version.sh
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ > dracut-$(VERSION).tar
mkdir -p dracut-$(VERSION)
for i in $(manpages) dracut.html dracut-version.sh; do [ "$${i%/*}" != "$$i" ] && mkdir -p "dracut-$(VERSION)/$${i%/*}"; cp "$$i" "dracut-$(VERSION)/$$i"; done
tar --owner=root --group=root -rf dracut-$(VERSION).tar $$(find dracut-$(VERSION) -type f)
rm -fr -- dracut-$(VERSION).tar.xz dracut-$(VERSION)
xz -9 dracut-$(VERSION).tar
rm -f -- dracut-$(VERSION).tar
rpm: dracut-$(VERSION).tar.xz syncheck
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
cp dracut-$(VERSION).tar.xz "$$rpmbuild"; \
LC_MESSAGES=C $$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
(cd "$$rpmbuild"; \
wget https://www.gnu.org/licenses/lgpl-2.1.txt; \
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr -- "$$rpmbuild"; ls *.rpm )
syncheck:
@ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \
[ "$${i##*/}" = "module-setup.sh" ] && continue; \
read line < "$$i"; [ "$${line#*bash*}" != "$$line" ] && continue; \
[ $$V ] && echo "posix syntax check: $$i"; bash --posix -n "$$i" ; ret=$$(($$ret+$$?)); \
[ $$V ] && echo "checking for [[: $$i"; if grep -Fq '[[ ' "$$i" ; then ret=$$(($$ret+1)); echo "$$i contains [["; fi; \
[ $$V ] && echo "checking for echo -n: $$i"; if grep -Fq 'echo -n ' "$$i" ; then ret=$$(($$ret+1)); echo "$$i contains echo -n"; fi \
done;exit $$ret
@ret=0;for i in *.sh mkinitrd-dracut.sh modules.d/*/*.sh \
modules.d/*/module-setup.sh; do \
[ $$V ] && echo "bash syntax check: $$i"; bash -n "$$i" ; ret=$$(($$ret+$$?)); \
done;exit $$ret
check: all syncheck rpm
@[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
@$(MAKE) -C test check
testimage: all
./dracut.sh -N -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
debugtestimage: all
./dracut.sh --debug -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
testimages: all
./dracut.sh -l -a debug --kernel-only -f test-kernel-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
./dracut.sh -l -a debug --no-kernel -f test-dracut.img $(shell uname -r)
@echo wrote test-dracut.img
debughostimage: all
./dracut.sh --debug -H -l -f test-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
hostimage: all
./dracut.sh -H -l -f test-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
efi: all
./dracut.sh --uefi -H -l -f linux-$(shell uname -r).efi $(shell uname -r)
@echo wrote linux-$(shell uname -r).efi
AUTHORS:
git shortlog --numbered --summary -e |while read a rest || [ -n "$$rest" ]; do echo $$rest;done > AUTHORS
dracut.html.sign: dracut-$(VERSION).tar.xz dracut.html
gpg-sign-all dracut-$(VERSION).tar.xz dracut.html
upload: dracut.html.sign
kup put dracut-$(VERSION).tar.xz dracut-$(VERSION).tar.sign /pub/linux/utils/boot/dracut/
kup put dracut.html dracut.html.sign /pub/linux/utils/boot/dracut/