-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile.in
193 lines (154 loc) · 5.67 KB
/
Makefile.in
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
px-objs = pxd.o dev.o iov_iter.o px_version.o kiolib.o pxd_bio_makereq.o pxd_bio_blkmq.o pxd_fastpath.o
obj-m = px.o
KBUILD_CPPFLAGS := -D__KERNEL__
KVERSION=$(shell uname -r)
ifndef KERNELPATH
ifeq ($(shell test -d "/usr/src/linux-headers-$(KVERSION)"; echo $$?),0)
KERNELPATH=/usr/src/linux-headers-$(KVERSION)
else
KERNELPATH=/usr/src/kernels/$(KVERSION)
endif
endif
# Check for version in KERNELPATH version release file
ifeq ($(shell test -f "$(KERNELPATH)/include/generated/utsrelease.h"; echo $$?),0)
CHK_KVER=$(shell sed -n 's/.* *UTS_RELEASE *"\(.*\)".*/\1/p' $(KERNELPATH)/include/generated/utsrelease.h)
endif
# If no KERNELPATH version found or extract fails use $(KVERSION)
ifeq ($(CHK_KVER),)
CHK_KVER=$(KVERSION)
endif
ifeq ($(shell test -d $(KERNELPATH); echo $$?),1)
$(error Kernel path: $(KERNELPATH) directory does not exist.)
endif
MINKVER=3.10
BLKMQ_MINKVER=4.18
KERNELVER=$(shell echo $(CHK_KVER) | /bin/sed 's/\([0-9].[0-9]\+\).*/\1/g')
majorfn=$(shell echo "$1" | /bin/sed 's/\(.*\)\.\(.*\)/\1/g')
minorfn=$(shell echo "$1" | /bin/sed 's/\(.*\)\.\(.*\)/\2/g')
verlater=$(shell test "$1" -gt "$2"; echo $$?)
versameorlater=$(shell test "$1" -ge "$2"; echo $$?)
versame=$(shell test "$1" -eq "$2"; echo $$?)
minver_major=$(call majorfn, ${MINKVER})
minver_minor=$(call minorfn, ${MINKVER})
blkmq_major=$(call majorfn, ${BLKMQ_MINKVER})
blkmq_minor=$(call minorfn, ${BLKMQ_MINKVER})
kmajor=$(call majorfn, ${KERNELVER})
kminor=$(call minorfn, ${KERNELVER})
#makereq interface supports fastpath in all version (not recommended)
#PXDEFINES := -D__PXKERNEL__ -D__PXD_BIO_MAKEREQ__
#FPATH_MINKVER=${kmajor}.${kminor}
#blkmq mode has version check for fastpath (default, enabled)
PXDEFINES := -D__PXKERNEL__ -D__PXD_BIO_BLKMQ__
FPATH_MINKVER=4.12
fp_major=$(call majorfn, ${FPATH_MINKVER})
fp_minor=$(call minorfn, ${FPATH_MINKVER})
## min kernel version checks
ifeq ($(call verlater,${minver_major},${kmajor}),0)
$(error Kernel version error: Build kernel version must be >= $(MINKVER).)
else
ifeq ($(call versame,${minver_major},${kmajor}),0)
ifeq ($(call verlater,${minver_minor},${kminor}),0)
$(error Kernel version error: Build kernel version must be >= $(MINKVER).)
endif
endif
endif
## fastpath checks
ifeq ($(call verlater,${kmajor},${fp_major}),0)
PXDEFINES += -D__PX_FASTPATH__
$(info Kernel version ${KERNELVER} supports fastpath.)
else
ifeq ($(call versame,${kmajor},${fp_major}),0)
ifeq ($(call versameorlater,${kminor},${fp_minor}),0)
PXDEFINES += -D__PX_FASTPATH__
$(info Kernel version ${KERNELVER} supports fastpath.)
endif
endif
endif
## blkmq checks
ifeq ($(call verlater,${kmajor},${blkmq_major}),0)
PXDEFINES += -D__PX_BLKMQ__
$(info Kernel version ${KERNELVER} supports blkmq driver model.)
else
ifeq ($(call versame,${kmajor},${blkmq_major}),0)
ifeq ($(call versameorlater,${kminor},${blkmq_minor}),0)
PXDEFINES += -D__PX_BLKMQ__
$(info Kernel version ${KERNELVER} supports blkmq driver model.)
endif
endif
endif
# EL8-9 Specific kernel checks, uapi version.h file has RHEL specific defines maybe can use.
ifeq ($(shell echo "$(CHK_KVER)" | grep -Eq '.*\.el[8-9].*\.x86_64'; echo $$?),0)
PXDEFINES += -D__PX_BLKMQ__ -D__EL8__
endif
# Check for Suse
ifeq ($(shell test -f "/host-os-release"; echo $$?),0) # inside PX container
ifeq ($(shell cat "/host-os-release" | grep ID_LIKE | grep -q suse; echo $$?),0)
PXDEFINES += -D__SUSE__
endif
else
ifeq ($(shell test -f "/etc/os-release"; echo $$?),0) # check OS
ifeq ($(shell cat "/etc/os-release" | grep ID_LIKE | grep -q suse; echo $$?),0)
PXDEFINES += -D__SUSE__
endif
endif
endif
ifdef CONFIG_SUSE_PATCHLEVEL
ifeq ($(shell test $(CONFIG_SUSE_PATCHLEVEL) -eq 5; echo $$?),0)
PXDEFINES += -D__SUSE_EQ_SP5__
endif
ifeq ($(shell test $(CONFIG_SUSE_PATCHLEVEL) -ge 6; echo $$?),0)
PXDEFINES += -D__SUSE_GTE_SP6__
endif
endif
ifdef KERNELOTHER
KERNELOTHEROPT=O=$(KERNELOTHER)
endif
MAJOR=$(shell echo $(CHK_KVER) | awk -F. '{print $$1}')
MINOR=$(shell echo $(CHK_KVER) | awk -F. '{print $$2}')
PATCH=$(shell echo $(CHK_KVER) | awk -F. '{print $$3}' | awk -F- '{print $$1}')
export REVISION=$(shell echo $(CHK_KVER) | awk -F. '{print $$3}' | awk -F- '{print $$2}')
export VERSION=$(MAJOR).$(MINOR).$(PATCH)
export KERNELPATH
export OUTPATH
ccflags-y := $(ADDCCFLAGS) -Wframe-larger-than=2048 -Werror -I$(src) $(KBUILD_CPPFLAGS) $(PXDEFINES)
# EL8-9 Specific kernel checks - this check also exists above - JAR?
ifeq ($(shell echo "$(CHK_KVER)" | grep -Eq '.*\.el[8-9].*\.x86_64'; echo $$?),0)
PXDEFINES += -D__PX_BLKMQ__ -D__EL8__
else
# 5.x kernel checks
ifeq ($(shell test "$(MAJOR)" = "5"; echo $$?),0)
PXDEFINES += -D__PX_BLKMQ__
endif
endif
ifdef FORCE_CONTAINER_CC
FORCE_CC=CC=$(FORCE_CONTAINER_CC)
endif
ccflags-y := $(ADDCCFLAGS) -Wframe-larger-than=2048 -Werror -I$(src) $(KBUILD_CPPFLAGS) $(PXDEFINES)
.PHONY: rpm
all: px_version.c
make $(FORCE_CC) -C $(KERNELPATH) $(KERNELOTHEROPT) M=$(CURDIR) modules
insert: all
insmod px.ko $(PXD_NUM_CONTEXT_EXPORTED)
clean:
make -C $(KERNELPATH) $(KERNELOTHEROPT) M=$(CURDIR) clean
install:
make V=1 -C $(KERNELPATH) $(KERNELOTHEROPT) M=$(CURDIR) modules_install
test_clean:
@/bin/rm -f test/pxd_test
pxd_test: pxd_test.cc
@echo "Building Test ..."
g++ -I. -std=c++11 test/pxd_test.cc -lgtest -lboost_iostreams -lpthread -o test/pxd_test
rpm:
@cd rpm && ./buildrpm.sh
docker-build-dev:
docker build -t portworx/px-fuse:dev -f Dockerfile .
docker-build: docker-build-dev
docker run --privileged \
-v /usr/src/:/usr/src \
-v $(shell pwd):/home/px-fuse \
portworx/px-fuse:dev make
px_version.c:
echo "const char *gitversion = \"$(shell git name-rev --name-only HEAD | sed 's/remotes\/origin\///g'):$(shell git rev-parse HEAD)\";" > $@
distclean: clean
@/bin/rm -f config.* Makefile
@/bin/rm -f test/pxd_test