forked from dagwieers/mvfs71
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
267 lines (240 loc) · 9.04 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#
# Copyright (C) 2003, 2013 IBM Corporation.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#
# Author: IBM Corporation
# This module is part of the IBM (R) Rational (R) ClearCase (R)
# Multi-version file system (MVFS).
# For support, please visit http://www.ibm.com/software/support
#
# Set LINUX_KERNEL_DIR to point at the build tree for your kernel
# (commonly available via a symlink from /lib/modules/`uname -r`/build,
# or you can override it in mvfs_param.mk.config)
#
# If you wish to build for a system other than the one you are currently
# running, provide proper definitions for the following variables in
# mvfs_param.mk.config:
# LINUX_KERNEL_DIR= path to the kernel build tree
# INSTALL_DIR= path to the directory to install the mvfs module for insmod.
# If you are building for a 2.6 kernel with standard source and installation
# directories, you may just define RELEASE to match the target system.
# The command "man modules.conf" will provide information about the
# default search rules used by modutils.
# As needed you may also redefine KERNEL_REV, RELEASE and MACH.
KERNEL_REV := $(shell uname -r |cut -d . -f 1-2)
RELEASE := $(shell uname -r)
MACH := $(shell uname -m)
ARCH=$(shell echo $(MACH) |sed -e s:i.86:i386:)
LINUX_KERNEL_DIR=/lib/modules/$(RELEASE)/build
INSTALL_DIR=/lib/modules/$(RELEASE)/kernel/fs/mvfs
SRCDIR=.
MVFSSRCDIR=.
# The following is supposed to detect kernel ABI changes, at least on Red Hat.
KABI=$(shell rpm -q --provides kernel-$(RELEASE) | grep kABI )
MVFS_DEBUG_FLAGS=
NM=nm
DEPMOD=/sbin/depmod
ifdef RATLHOME
RATL_HOME=${RATLHOME}
else
RATL_HOME=/opt/rational
endif
ifdef CLEARCASE_COMMON
CC_COMMON=${CLEARCASE_COMMON}
else
CC_COMMON=${RATL_HOME}/common
endif
ifdef CLEARCASEHOME
CCHOME=${CLEARCASEHOME}
else
CCHOME=${RATL_HOME}/clearcase
endif
CCINSTALL=${CC_COMMON}/install
JAVA=$(CC_COMMON)/java/jre/bin/java
INSTALL_BASE=com.ibm.rational.team.install.cc
JARFILE=$(INSTALL_BASE).jar
PARAM_METHOD=$(INSTALL_BASE).mvfs.CreateMvfsParams
CLASSPATH=$(CCINSTALL)/$(JARFILE)
ifndef KBUILD_EXTMOD
# The 2.6 kernel Makefile framework (which sets the KBUILD_EXTMOD variable)
# sets the "obj" variable).
obj=.
else
KERNEL_REV=2.6
endif
# All values that can be redefined in mvfs_param.mk.config must be defined
# before this point.
# Only include mvfs_param.mk.config if it exists
# This eliminates bogus attemtps to rebuild it on make clean
exists := $(shell cat $(obj)/mvfs_param.mk.config)
ifneq ($(strip $(exists)),)
include $(obj)/mvfs_param.mk.config
endif
KINC=$(LINUX_KERNEL_DIR)/include
ADAPTER_OBJECTS= \
mvfs_param.o \
mvfs_linux_asops.o \
mvfs_linux_builtins.o \
mvfs_linux_dops.o \
mvfs_linux_fops.o \
mvfs_linux_glue.o \
mvfs_linux_iops.o \
mvfs_linux_mvops.o \
mvfs_linux_rpcglue.o \
mvfs_linux_shadow.o \
mvfs_linux_sops.o \
mvfs_linux_utils.o \
mvfs_linux_mdki.o
MVFS_OBJECTS= \
mvfs_vfsops.o \
mvfs_vnodeops.o \
mvfs_clearops.o \
mvfs_vwdirops.o \
mvfs_procops.o \
mvfs_utils.o \
mvfs_mnode.o \
mvfs_debug.o \
mvfs_rdc.o \
mvfs_auditops.o \
mvfs_dncops.o \
mvfs_clnt.o \
mvfs_ntvwops.o \
mvfs_rpcutl.o \
mvfs_mioctl.o \
mvfs_kmem.o \
mvfs_copy.o \
mvfs_transtype.o \
xdr_tbs_kernel.o \
xdr_view_kernel.o \
tbs_errno.o \
xdr_albd_kernel.o \
xdr_ks_kernel.o \
credutl_kernel.o \
mvfs_mdep_linux.o \
mvfs_tunables.o
MVFS_ARCH_64BIT=-DATRIA_LP64 -DRATL_COMPAT32
MVFS_ARCH_DEF.i386=-DATRIA_LINUX_IA32
# only 64 bits is supported
MVFS_ARCH_DEF.s390=-DATRIA_LINUX_390 $(MVFS_ARCH_64BIT)
MVFS_ARCH_DEF.ppc64=-DATRIA_LINUX_PPC $(MVFS_ARCH_64BIT)
MVFS_ARCH_DEF.s390x=$(MVFS_ARCH_DEF.s390)
MVFS_ARCH_DEF.x86_64=$(MVFS_ARCH_DEF.i386) $(MVFS_ARCH_64BIT)
MVFS_ARCH_DEF=$(MVFS_ARCH_DEF.$(ARCH))
MVFS_DEFS= \
-DATRIA_ANSI_C \
-DATRIA_LARGEFILE64_SOURCE \
-DATRIA_LINUX \
$(MVFS_ARCH_DEF) \
-DATRIA_UNIX \
-DI18N_MSGS \
-DLINUX \
-DXREV_CLIENTS_SUPPORT_V6_SERVERS \
-DXREV_SERVERS_SUPPORT_V5_CLIENTS \
-DXREV_SERVERS_SUPPORT_V6_CLIENTS \
-D_LARGEFILE64_SOURCE
# This little bit of checking is to allow us to build properly on a
# 2.6.9-5.0.5.EL errata kernel for RHEL4.
UPDATE_VER=$(shell echo $(RELEASE) |cut -d - -f 2 | cut -d . -f 1-2)
ifeq ($(UPDATE_VER), 5.0)
WARNING_FLAGS = -Wall -Wstrict-prototypes -Wunused
else
ifneq (,$(findstring s390,$(ARCH)))
#SLES11 SP3 (3.0.79) kernel has kernel headers that generate a warning
#but only on the S390.
UPDATE_VER=$(shell echo $(RELEASE) |cut -d - -f 1 | cut -d . -f 1-3)
ifeq (3.0,$(shell echo $(UPDATE_VER) | cut -d . -f 1-2))
BUILD_NUM=$(shell echo $(UPDATE_VER) | cut -d . -f 3)
ifeq (1,$(shell test $(BUILD_NUM) -ge 76 && echo "1"))
WARNING_FLAGS = -w
endif #ifeq(1,$(shell...
endif #ifeq(3.0...
endif #ifneq (,$(findstring...
endif # ifeq($(UPDATE_VER...
ifeq ($(WARNING_FLAGS),)
#Use defaults if we didn't set it above.
WARNING_FLAGS = -Wall -Wstrict-prototypes -Wunused -Werror
endif
all: mvfs_param.mk.config
$(MAKE) -C $(LINUX_KERNEL_DIR) SUBDIRS=`pwd`
# try to build a reasonable RATL_EXTRAFLAGS if it is set to empty (but not undefined)
ifeq (,$(if $(findstring undefined,$(origin RATL_EXTRAFLAGS)),undefined,$(RATL_EXTRAFLAGS)))
# but only for x86
ifneq (,$(if $(findstring x86_64,$(ARCH)),x86_64,$(findstring i386,$(ARCH))))
# and only for RH with kernel 2.6.33
__KBASE=$(shell uname -r | grep -o '2\.6\.33')
__DIST_R=$(shell if [ -f /etc/redhat-release ] ; then sed -ne 's/^Red Hat.*release \([56]\).*/\1/p' /etc/redhat-release ; fi)
ifneq (,$(if $(__KBASE),$(__DIST_R)))
RATL_EXTRAFLAGS:=-DRATL_REDHAT -DRATL_VENDOR_VER=$(__DIST_R)00 -DRATL_EXTRA_VER=0
ifeq ($(ARCH),x86_64)
RATL_EXTRAFLAGS+=-DRATL_COMPAT32
endif
endif
endif
endif
# If your system is running RHEL4 and has had certain errata installed to
# fix problems with flock on NFS, uncomment the following line.
#RATL_EXTRAFLAGS += -DMVFS_REMOVE_FLOCK_DEFENSIVE_CODE
OPT_SPACE= -Os
ifeq ($(ARCH), x86_64)
# don't optimize for space in this file--GCC will generate a function
# call to memcmp which is unavailable in some kernel environments.
$(obj)/mvfs_linux_builtins.o : OPT_SPACE=
endif
# On SLES11 s390x the compiler uses the warn-framesize value for a >= check
# rather than the > check the GCC documentation would imply. Passing in
# this argument will override the kernel build environment -mwarn-framesize=256
# and prevent our -Werror option from generating an error. The fno-tree-ter
# option is used to deactivate the temporary expression replacement to keep
# the frame size under limit.
ifneq (,$(findstring s390,$(ARCH)))
__SLES11_390:=$(CC) $(RATL_EXTRAFLAGS)
ifneq (,$(if $(findstring RATL_SUSE,$(__SLES11_390)),$(findstring RATL_VENDOR_VER=11,$(__SLES11_390))))
RATL_EXTRAFLAGS += -mwarn-framesize=257 -fno-tree-ter
endif
endif
VNODE_CONSTRUCTED_OBJS=timestamp.o
VNODE_BUILT_OBJECTS=$(addprefix $(obj)/,$(ADAPTER_OBJECTS))
VNODE_GEN_OBJECTS=$(addprefix $(obj)/,$(VNODE_CONSTRUCTED_OBJS))
MVFS_EXTRA_CFLAGS += $(WARNING_FLAGS) $(RATL_EXTRAFLAGS) -I$(obj) -D_KERNEL $(OPT_SPACE) $(MVFS_MOD_FLAGS)
$(VNODE_BUILT_OBJECTS) $(VNODE_GEN_OBJECTS) : MVFS_MOD_FLAGS= -Wunused
$(VNODE_BUILT_OBJECTS) $(VNODE_GEN_OBJECTS) : ccflags-y+=$(MVFS_EXTRA_CFLAGS)
$(VNODE_BUILT_OBJECTS) $(VNODE_GEN_OBJECTS) : EXTRA_CFLAGS:=$(EXTRA_CFLAGS) $(MVFS_EXTRA_CFLAGS)
MVFS_BUILT_OBJECTS=$(addprefix $(obj)/,$(MVFS_OBJECTS))
$(MVFS_BUILT_OBJECTS) : MVFS_MOD_FLAGS=${MVFS_DEFS} -Wno-unused
$(MVFS_BUILT_OBJECTS) : ccflags-y+=$(WARNING_FLAGS) $(RATL_EXTRAFLAGS) -I$(obj) -D_KERNEL $(OPT_SPACE) $(MVFS_MOD_FLAGS)
$(MVFS_BUILT_OBJECTS) : EXTRA_CFLAGS:=$(EXTRA_CFLAGS) $(WARNING_FLAGS) $(RATL_EXTRAFLAGS) -I$(obj) -D_KERNEL $(OPT_SPACE) $(MVFS_MOD_FLAGS)
obj-${CONFIG_MVFS} += mvfs.o
mvfs-objs := $(MVFS_OBJECTS) $(ADAPTER_OBJECTS) $(VNODE_CONSTRUCTED_OBJS)
$(obj)/mvfs_tunables.o: $(obj)/mvfs_when.h
$(obj)/mvfs_param.mk.config:
$(JAVA) -classpath $(CLASSPATH) $(PARAM_METHOD) $(LINUX_KERNEL_DIR) $(obj)
# Include the debug version string in the timestamp because mvfs_when.h,
# which contains the version string, is only built once for all the variants
# of a particular architecture.
#
$(obj)/timestamp.c: $(VNODE_BUILT_OBJECTS) $(MVFS_BUILT_OBJECTS)
@echo GENERATE $@
@TZ=GMT date '+const char mdki_vnode_build_time[] = "$$Date: %Y-%m-%d.%T$(MVFS_DEBUG_FLAGS) (UTC) $$";' >$(obj)/timestamp.c
@echo 'static const char mdki_vnode_build_host[] = "$$BuiltOn: '`uname -a`' $$";' >>$(obj)/timestamp.c
install: mvfs.ko
mkdir -p $(INSTALL_DIR)
install --backup --suffix=.save mvfs.ko $(INSTALL_DIR)/mvfs.ko
$(DEPMOD)
clean: cleano
-rm -f mvfs_param.mk.config
cleano:
-rm -rf *.o *.kobj *.obj *.ko *.mod.? .*.cmd .tmp_versions
# $Id: 7438f150.ff6b11e2.8ed0.00:01:83:09:28:25 $