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

Natanael Copa's avatar
Natanael Copa committed
2
VERSION		:= 3.4.1
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
58
59
		features.d/dasd_mod.modules \
		features.d/dhcp.files \
		features.d/https.files
Ain's avatar
Ain committed
60
MAN_FILES       := mkinitfs.1 mkinitfs-bootparam.7 nlplug-findfs.1
Natanael Copa's avatar
Natanael Copa committed
61

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

65
GIT_REV := $(shell test -d .git && git describe || echo exported)
66
67
68
69
70
71
72
73
74
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
75
76

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

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

Natanael Copa's avatar
Natanael Copa committed
87

Ain's avatar
Ain committed
88
all:	$(SBIN_FILES) $(SCRIPTS) $(CONF_FILES) $(MAN_FILES)
89
90

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

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

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

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

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

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

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

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

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