Makefile 3.74 KB
Newer Older
Natanael Copa's avatar
Natanael Copa committed
1

Natanael Copa's avatar
Natanael Copa committed
2
VERSION		:= 3.5.0
Natanael Copa's avatar
Natanael Copa committed
3

Ain's avatar
Ain committed
4
sbindir		?= /sbin
5
6
7
sysconfdir	?= /etc/mkinitfs
datarootdir	?= /usr/share
datadir		?= $(datarootdir)/mkinitfs
Ain's avatar
Ain committed
8
mandir		?= $(datarootdir)/man
9

Natanael Copa's avatar
Natanael Copa committed
10
SBIN_FILES	:= mkinitfs bootchartd nlplug-findfs
11
SHARE_FILES	:= initramfs-init fstab passwd group
Natanael Copa's avatar
Natanael Copa committed
12
CONF_FILES	:= mkinitfs.conf \
13
14
15
16
		features.d/ata.modules \
		features.d/base.files \
		features.d/base.modules \
		features.d/bootchart.files \
17
		features.d/btrfs.files \
18
19
20
		features.d/btrfs.modules \
		features.d/cdrom.modules \
		features.d/cramfs.modules \
lemmarathon's avatar
lemmarathon committed
21
		features.d/cryptkey.files \
22
23
		features.d/cryptsetup.files \
		features.d/cryptsetup.modules \
24
		features.d/ena.modules \
25
26
27
28
29
30
31
32
33
34
35
		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 \
Timo Teräs's avatar
Timo Teräs committed
36
		features.d/mmc.modules \
37
38
		features.d/nbd.files \
		features.d/nbd.modules \
39
40
		features.d/network.files \
		features.d/network.modules \
41
		features.d/nvme.modules \
42
		features.d/ocfs2.modules \
43
		features.d/raid.files \
44
45
46
47
48
49
50
		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 \
Henrik Riomar's avatar
Henrik Riomar committed
51
		features.d/xenpci.modules \
Sascha Paunovic's avatar
Sascha Paunovic committed
52
		features.d/xfs.files \
Carlo Landmeter's avatar
Carlo Landmeter committed
53
		features.d/xfs.modules \
54
		features.d/zfs.files \
55
56
		features.d/zfs.modules \
		features.d/qeth.modules \
57
		features.d/dasd_mod.modules \
58
		features.d/zfcp.modules \
59
		features.d/dhcp.files \
60
		features.d/dhcp.modules \
61
		features.d/https.files
Ain's avatar
Ain committed
62
MAN_FILES       := mkinitfs.1 mkinitfs-bootparam.7 nlplug-findfs.1
Natanael Copa's avatar
Natanael Copa committed
63

Natanael Copa's avatar
Natanael Copa committed
64
SCRIPTS		:= mkinitfs bootchartd initramfs-init
Ain's avatar
Ain committed
65
IN_FILES	:= $(addsuffix .in,$(SCRIPTS) $(MAN_FILES))
66

67
GIT_REV := $(shell test -d .git && git describe || echo exported)
68
69
70
71
72
73
74
75
76
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
Natanael Copa's avatar
Natanael Copa committed
77
78

INSTALL		:= install
79
SED		:= sed
80
81
82
SED_REPLACE	:= -e 's:@VERSION@:$(FULL_VERSION):g' \
		-e 's:@sysconfdir@:$(sysconfdir):g' \
		-e 's:@datadir@:$(datadir):g'
83

84
DEFAULT_FEATURES ?= ata base cdrom ext4 keymap kms mmc nvme raid scsi usb virtio
85
ifeq ($(shell uname -m), s390x)
86
DEFAULT_FEATURES += qeth dasd_mod zfcp
87
endif
Natanael Copa's avatar
Natanael Copa committed
88

Natanael Copa's avatar
Natanael Copa committed
89

Ain's avatar
Ain committed
90
all:	$(SBIN_FILES) $(SCRIPTS) $(CONF_FILES) $(MAN_FILES)
91
92

clean:
Ain's avatar
Ain committed
93
	rm -f $(SCRIPTS) $(MAN_FILES) mkinitfs.conf
94

Natanael Copa's avatar
Natanael Copa committed
95
help:
Natanael Copa's avatar
Natanael Copa committed
96
	@echo mkinitfs $(VERSION)
Natanael Copa's avatar
Natanael Copa committed
97
98
	@echo "usage: make install [DESTDIR=]"

Natanael Copa's avatar
Natanael Copa committed
99
100
101
102
103
104
105
106
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)
107
108
CRYPTSETUP_CFLAGS := $(shell $(PKGCONF) --cflags libcryptsetup)
CRYPTSETUP_LIBS	:= $(shell $(PKGCONF) --libs libcryptsetup)
Natanael Copa's avatar
Natanael Copa committed
109

110
111
CFLAGS		+= $(BLKID_CFLAGS) $(LIBKMOD_CFLAGS) $(CRYPTSETUP_CFLAGS)
LIBS		= $(BLKID_LIBS) $(LIBKMOD_LIBS) $(CRYPTSETUP_LIBS)
Natanael Copa's avatar
Natanael Copa committed
112
113

%.o: %.c
Timo Teräs's avatar
Timo Teräs committed
114
	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
Natanael Copa's avatar
Natanael Copa committed
115
116
117
118

nlplug-findfs: nlplug-findfs.o
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

119
120
121
122
123
.SUFFIXES:	.in
.in:
	${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@

install: $(SBIN_FILES) $(SHARE_FILES) $(CONF_FILES)
Natanael Copa's avatar
Natanael Copa committed
124
	for i in $(SBIN_FILES); do \
Ain's avatar
Ain committed
125
		$(INSTALL) -Dm755 $$i $(DESTDIR)/$(sbindir)/$$i;\
Natanael Copa's avatar
Natanael Copa committed
126
127
	done
	for i in $(CONF_FILES); do \
Ain's avatar
Ain committed
128
		$(INSTALL) -Dm644 $$i $(DESTDIR)/$(sysconfdir)/$$i;\
Natanael Copa's avatar
Natanael Copa committed
129
130
	done
	for i in $(SHARE_FILES); do \
Ain's avatar
Ain committed
131
		$(INSTALL) -D $$i $(DESTDIR)/$(datadir)/$$i;\
Natanael Copa's avatar
Natanael Copa committed
132
	done
Ain's avatar
Ain committed
133
134
135
	for i in $(MAN_FILES); do \
		$(INSTALL) -D $$i $(DESTDIR)$(mandir)/man$${i##*.}/$$i;\
	done
Natanael Copa's avatar
Natanael Copa committed
136

Natanael Copa's avatar
Natanael Copa committed
137
138
mkinitfs.conf:
	echo 'features="$(DEFAULT_FEATURES)"' > $@