-
Notifications
You must be signed in to change notification settings - Fork 48
/
Makefile
176 lines (150 loc) · 4.88 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
VERSION := 3.11.1
sbindir ?= /sbin
sysconfdir ?= /etc/mkinitfs
datarootdir ?= /usr/share
datadir ?= $(datarootdir)/mkinitfs
mandir ?= $(datarootdir)/man
SBIN_FILES := mkinitfs bootchartd nlplug-findfs/nlplug-findfs
SHARE_FILES := initramfs-init fstab passwd group
CONF_FILES := mkinitfs.conf \
features.d/9p.modules \
features.d/ata.modules \
features.d/aoe.modules \
features.d/base.files \
features.d/base.modules \
features.d/bootchart.files \
features.d/btrfs.files \
features.d/btrfs.modules \
features.d/cdrom.modules \
features.d/cramfs.modules \
features.d/cryptkey.files \
features.d/cryptsetup.files \
features.d/cryptsetup.modules \
features.d/ena.modules \
features.d/ext2.modules \
features.d/ext3.modules \
features.d/ext4.modules \
features.d/f2fs.modules \
features.d/floppy.modules \
features.d/gfs2.modules \
features.d/jfs.modules \
features.d/keymap.files \
features.d/kms.modules \
features.d/lvm.files \
features.d/lvm.modules \
features.d/mmc.modules \
features.d/nbd.files \
features.d/nbd.modules \
features.d/nfit.modules \
features.d/network.files \
features.d/network.modules \
features.d/nvme.modules \
features.d/ocfs2.modules \
features.d/raid.files \
features.d/raid.modules \
features.d/reiserfs.modules \
features.d/scsi.modules \
features.d/squashfs.modules \
features.d/ubifs.modules \
features.d/usb.modules \
features.d/virtio.modules \
features.d/xenpci.modules \
features.d/xfs.files \
features.d/xfs.modules \
features.d/zfs.files \
features.d/zfs.modules \
features.d/qeth.modules \
features.d/dasd_mod.modules \
features.d/zfcp.modules \
features.d/dhcp.files \
features.d/dhcp.modules \
features.d/https.files \
features.d/wireguard.files \
features.d/wireguard.modules \
features.d/phy.modules
MAN_FILES := mkinitfs.1 mkinitfs-bootparam.7 nlplug-findfs.1
SCRIPTS := mkinitfs bootchartd initramfs-init
IN_FILES := $(addsuffix .in,$(SCRIPTS) $(MAN_FILES))
GIT_REV := $(shell test -d .git && git describe || echo exported)
ifneq ($(GIT_REV), exported)
FULL_VERSION := $(patsubst $(PACKAGE)-%,%,$(GIT_REV))
FULL_VERSION := $(patsubst v%,%,$(FULL_VERSION))
else
FULL_VERSION := $(VERSION)
endif
DISTFILES := $(IN_FILES) $(CONF_FILES) Makefile
INSTALL := install
SED := sed
SED_REPLACE := -e 's:@VERSION@:$(FULL_VERSION):g' \
-e 's:@sysconfdir@:$(sysconfdir):g' \
-e 's:@datadir@:$(datadir):g'
DEFAULT_FEATURES ?= ata base cdrom ext4 keymap kms mmc nvme raid scsi usb virtio
ifeq ($(shell uname -m), s390x)
DEFAULT_FEATURES += qeth dasd_mod zfcp
endif
ifeq ($(shell uname -m), aarch64)
DEFAULT_FEATURES += phy
endif
all: $(SBIN_FILES) $(SCRIPTS) $(CONF_FILES) $(MAN_FILES)
clean:
rm -fr $(SBIN_FILES) $(SCRIPTS) $(MAN_FILES) mkinitfs.conf \
nlplug-findfs/actual nlplug-findfs/build
help:
@echo mkinitfs $(VERSION)
@echo "usage: make install [DESTDIR=]"
CFLAGS ?= -Wall -Werror -g
CFLAGS += -D_GNU_SOURCE -DDEBUG
PKGCONF ?= pkg-config
BLKID_CFLAGS := $(shell $(PKGCONF) --cflags blkid)
BLKID_LIBS := $(shell $(PKGCONF) --libs blkid)
LIBKMOD_CFLAGS := $(shell $(PKGCONF) --cflags libkmod)
LIBKMOD_LIBS := $(shell $(PKGCONF) --libs libkmod)
CRYPTSETUP_CFLAGS := $(shell $(PKGCONF) --cflags libcryptsetup)
CRYPTSETUP_LIBS := $(shell $(PKGCONF) --libs libcryptsetup)
CFLAGS += $(BLKID_CFLAGS) $(LIBKMOD_CFLAGS) $(CRYPTSETUP_CFLAGS)
LIBS = $(BLKID_LIBS) $(LIBKMOD_LIBS) $(CRYPTSETUP_LIBS)
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
nlplug-findfs/nlplug-findfs: nlplug-findfs/nlplug-findfs.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
check-nlplug-findfs: nlplug-findfs/build
nlplug-findfs/test.sh run
nlplug-findfs/build: nlplug-findfs/init.sh nlplug-findfs/nlplug-findfs nlplug-findfs/test.sh
nlplug-findfs/test.sh build
tests/Kyuafile: $(wildcard tests/*.test)
echo "syntax(2)" > [email protected]
echo "test_suite('mkinitfs')" >> [email protected]
for i in $(notdir $(wildcard tests/*.test)); do \
echo "atf_test_program{name='$$i',timeout=5}" >> [email protected] ; \
done
mv [email protected] $@
Kyuafile:
echo "syntax(2)" > [email protected]
echo "test_suite('mkinitfs')" >> [email protected]
echo "include('tests/Kyuafile')" >> [email protected]
mv [email protected] $@
check: tests/Kyuafile Kyuafile mkinitfs initramfs-init
kyua --variable parallelism=$(shell nproc) test \
|| { kyua report --verbose && exit 1; }
.SUFFIXES: .in
.in:
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > [email protected]
chmod +x [email protected]
mv [email protected] $@
install: $(SBIN_FILES) $(SHARE_FILES) $(CONF_FILES)
install -d -m755 $(DESTDIR)/$(sbindir)
for i in $(SBIN_FILES); do \
$(INSTALL) -Dm755 $$i $(DESTDIR)/$(sbindir)/;\
done
for i in $(CONF_FILES); do \
$(INSTALL) -Dm644 $$i $(DESTDIR)/$(sysconfdir)/$$i;\
done
for i in $(SHARE_FILES); do \
$(INSTALL) -Dm644 $$i $(DESTDIR)/$(datadir)/$$i;\
done
for i in $(MAN_FILES); do \
$(INSTALL) -Dm644 $$i $(DESTDIR)$(mandir)/man$${i##*.}/$$i;\
done
mkinitfs.conf:
echo 'features="$(DEFAULT_FEATURES)"' > $@
.PHONY: all check clean help install