-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
178 lines (149 loc) · 5.39 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
# makefile for out-of-kernel AoE build
# uses pre-configured 2.6 kernel sources
#
.PHONY: copy default tools clean realclean realrealclean \
install install_modobj install_nodev kerninst uninstall report
# export all directives to sub makes (aoetools)
export
# where the aoe-stat, aoe-discover, etc. commands will go
SBINDIR = /usr/sbin
MANDIR = /usr/share/man
# the directory in /dev to place device nodes
#DEVSUBDIR=
DEVSUBDIR=etherd
# where the devices nodes will be created
DEVDIR=/dev/$(DEVSUBDIR)
# number of shelves for which dev nodes are created
# (numbering starts at 0)
N_DEV_SHELVES=10
DYNDEVS := $(shell conf/detect-udev)
# number of slots per shelf for static minor device node numbers
NPERSHELF=16
# the number of partitions supported per device; default is 16
# (set to 1 for greater compatibility on systems with poor support
# for large minor device numbers)
AOE_PARTITIONS=16
DRIVER_D = linux/drivers/block/aoe
SCRIPTS_D = linux/Documentation/aoe
TOOLS_D = aoetools-36
# Get the kernel version
KVER := $(shell uname -r)
# kernel sources for building third-party modules should be found here
KDIR := /lib/modules/$(KVER)/build
# INSTDIR is where to put the aoe module
INSTDIR := /lib/modules/$(KVER)/kernel/drivers/block/aoe
PWD := $(shell pwd)
EXTRA_CFLAGS := -DAOE_PARTITIONS=$(AOE_PARTITIONS) -DDEVSUBDIR='\"${DEVSUBDIR}\"'
EXTRA_CFLAGS += -DAOE_DYNDEVS=${DYNDEVS}
KMAK_FLAGS := \
CONFIG_ATA_OVER_ETH=m \
KDIR=${KDIR}
DUMMY := $(shell sh mak/cc-id.sh ${MAKE} -C $(KDIR) $(KMAK_FLAGS) SUBDIRS="$(PWD)/mak" modules)
DUMMY := $(shell sh mak/kernel-id.sh ${KDIR})
DUMMY := $(shell sh mak/src-id.sh ${DRIVER_D})
COPY_DIR = $(HOME)/build/aoe
default: tools ${DRIVER_D}/aoe.ko
${DRIVER_D}/aoe.ko : conf/done mak/src-id.ts
$(MAKE) -C $(KDIR) $(KMAK_FLAGS) SUBDIRS="$(PWD)/$(DRIVER_D)" EXTRA_CFLAGS="${EXTRA_CFLAGS}" modules
@if test "${DYNDEVS}" = "1"; then \
echo "This aoe driver uses dynamic minor device numbers."; \
else \
echo "This aoe driver uses static minor device numbers."; \
fi
# sanity checks and handling of compile-time resolvable compatibility issues
conf/done : mak/cc-id.ts mak/kernel-id.ts
@perl -e '' || { \
echo "Error: the build system depends on perl being available" 1>&2; \
false; \
}
sh -c "cd $(DRIVER_D) && rm -f *.o *.ko core"
@test -r "$(KDIR)/.config" || { \
echo "Error: $(KDIR) sources are not configured." 1>&2; \
false; \
}
@if ! test -r "$(KDIR)/include/asm" && \
! test -r "$(KDIR)/include/generated/autoconf.h"; then \
echo "Error: $(KDIR) sources are not prepared." 1>&2; \
false; \
fi
@if ! test -r "$(KDIR)/scripts/mod/modpost"; then \
echo "Error: $(KDIR) scripts are not present." 1>&2; \
echo " try running 'make scripts' in $(KDIR)" 1>&2; \
false; \
fi
@printf "ensuring compatibility ... "
@cd conf && rm -rf *.o *.ko .tmp_versions .*.*o.cmd .*.*o.d *.mod.c
@sh conf/compat.sh $(DRIVER_D) \
$(MAKE) -C $(KDIR) $(KMAK_FLAGS) SUBDIRS="$(PWD)/conf" C=0 modules
echo > conf/done
@sh mak/src-id.sh ${DRIVER_D}
copy:
@cpio -p `pwd` < /dev/null 2>&0 || { \
echo Error: cpio is required for copy target 1>&2; \
exit 1; \
}
mkdir -p $(COPY_DIR)
find . -name .git -type d -prune -o -print | cpio -p --verbose $(COPY_DIR)
tools:
cd ${TOOLS_D} && make
clean:
rm -f kv.mak conf/kdir.last
cd $(DRIVER_D) && rm -f *.o *.ko core
cd conf && rm -rf *.o *.ko .tmp_versions .*.*o.cmd .*.*o.d *.mod.c
cd ${TOOLS_D} && make clean
realclean: clean
rm -f conf/make.log
cd $(DRIVER_D) && rm -rf .tmp_versions .aoe*.*o.cmd .aoe*.*o.d aoe.mod.c
cd $(DRIVER_D) && rm -rf Module.symvers
cd conf && rm -f *.log Makefile
# revert conf patches
realrealclean: realclean
-sh conf/compat.sh -R $(DRIVER_D) \
$(MAKE) -C $(KDIR) $(KMAK_FLAGS) SUBDIRS="$(PWD)/conf" modules
cd $(DRIVER_D) && rm -rf *.orig *.rej
install_modobj: default
@echo "Install directory is $(INSTDIR)"
mkdir -p $(INSTDIR)
install -m 644 $(DRIVER_D)/aoe.ko $(INSTDIR)
/sbin/depmod -a
install_nodev: install_modobj
# punt if DEVSUBDIR isn't the default. probably should have cleaner solution.
@if test -r /etc/udev/udev.conf; then \
if test "$(DEVSUBDIR)" != "etherd" || \
! conf=/etc/udev/udev.conf sh $(SCRIPTS_D)/udev-install.sh; then \
(echo ; echo "!! DID NOT INSTALL UDEV RULES FOR AOE"; echo) 1>&2; \
fi; \
fi
cd ${TOOLS_D} && make install
install: install_nodev
@if test "${DYNDEVS}" = "0"; then \
echo "creating static device nodes in ${DEVDIR}"; \
n_partitions=$(AOE_PARTITIONS) \
n_shelves=${N_DEV_SHELVES} ${TOOLS_D}/aoe-mkdevs $(DEVDIR); \
fi
# experts can put the driver in a kernel source tree with
# "make kerninst"
kerninst: conf/done mak/src-id.ts
test -d ${KDIR}/drivers/block/aoe
cp -b ${DRIVER_D}/*.[ch] ${KDIR}/drivers/block/aoe
echo "#define AOE_PARTITIONS (${AOE_PARTITIONS})" \
>> ${KDIR}/drivers/block/aoe/aoe.h
echo '#define DEVSUBDIR "${DEVSUBDIR}"' \
>> ${KDIR}/drivers/block/aoe/aoe.h
echo '#define AOE_DYNDEVS (${DYNDEVS})' \
>> ${KDIR}/drivers/block/aoe/aoe.h
echo 'aoe-objs += aoedbg.o' \
>> ${KDIR}/drivers/block/aoe/Makefile
uninstall:
@echo "Removing Module from $(INSTDIR)"
rm -f $(INSTDIR)/aoe.ko
@echo "Removing $(DEVDIR) and components"
rm -rf $(DEVDIR)
/sbin/depmod -a
REPORTF := $(shell awk '$$2=="VERSION"{print $$3}' ${DRIVER_D}/aoe.h)
# remove quotes below
REPORTF := $(shell echo aoe6-${REPORTF}-report.tar)
report:
tar cf ${REPORTF} conf/*.log
gzip ${REPORTF}
@echo The report file is "${REPORTF}.gz".