[16] | 1 | /* $Id: Imakefile,v 1.122.2.10 2006/10/25 18:34:21 mcnabb Exp $ */ |
---|
| 2 | |
---|
| 3 | /***** THIS MUST BE INCLUDED WITH IMAKE FILES *****/ |
---|
| 4 | /* Only include kernel and cxi headers in this layer */ |
---|
| 5 | SetGplIncludePath() |
---|
| 6 | /***** THIS MUST BE INCLUDED WITH IMAKE FILES *****/ |
---|
| 7 | |
---|
| 8 | CheckLinuxDistribution() |
---|
| 9 | |
---|
| 10 | PTHREADS = -lpthread |
---|
| 11 | INSTROOTFLAGS = -c -m 0500 |
---|
| 12 | |
---|
| 13 | #if (LINUX_KERNEL_VERSION >= 2060000) |
---|
| 14 | /* |
---|
| 15 | * The linux 2.6 kernel adds a new component called "modpost", to all the |
---|
| 16 | * kernel modules. Typically, this is done automatically by the linux kernel |
---|
| 17 | * build infrastructure (kbuild). But the kbuild infrastructure is quite cryptic |
---|
| 18 | * to be used by modules like GPFS. Hence, we bypass the linux kbuild |
---|
| 19 | * infrastructure and do the modpost work ourselves. |
---|
| 20 | * |
---|
| 21 | * Here is the summary of what we do: |
---|
| 22 | * If the ".c" file exports a function to the linux kernel then we add the |
---|
| 23 | * CRC of all such functions to the object. This is done to detect version |
---|
| 24 | * mismatch between modules/kernel. |
---|
| 25 | * If a ".c" file exports a function, then its object would have a "__ksymtab" |
---|
| 26 | * section. |
---|
| 27 | * For all such ".c" files, we recompile it with -E -D__GENKSYMS__ defined and |
---|
| 28 | * feed the output to "genksyms" program, which calculates the CRC for all |
---|
| 29 | * such functions. We then put this information into the object file so that |
---|
| 30 | * the corresponding modpost file contains the CRCs required for the module. |
---|
| 31 | * (The modpost work is done in the Imakefile for the "gpl-linux" directory.) |
---|
| 32 | */ |
---|
| 33 | OBJDUMP = /usr/bin/objdump |
---|
| 34 | GENKSYMS = $(KERNEL_BUILD_DIR)/scripts/genksyms/genksyms |
---|
| 35 | handle_linux_sym = @if [ ! -f $(GENKSYMS) ]; then \ @@\ |
---|
| 36 | echo "$(GENKSYMS) not found. Check the value of KERNEL_BUILD_DIR in site.mcr";\ @@\ |
---|
| 37 | exit 1; \ @@\ |
---|
| 38 | fi; \ @@\ |
---|
| 39 | $(OBJDUMP) -h $1 | grep -q __ksymtab; \ @@\ |
---|
| 40 | if [ $$? -eq 0 ]; then \ @@\ |
---|
| 41 | $(C_COMP) -E -D__GENKSYMS__ $(KCFLAGS) $2 | $(GENKSYMS) > $1.ver; \ @@\ |
---|
| 42 | mv $1 $1.tmp; \ @@\ |
---|
| 43 | $(BARELD) -r -o $1 $1.tmp -T $1.ver; \ @@\ |
---|
| 44 | rm -f $1.tmp; \ @@\ |
---|
| 45 | fi |
---|
| 46 | #endif /* LINUX_KERNEL_VERSION */ |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | #if (LINUX_KERNEL_VERSION >= 2060000) |
---|
| 50 | #ifdef LinuxKernelObjectRule |
---|
| 51 | #undef LinuxKernelObjectRule |
---|
| 52 | #define LinuxKernelObjectRule() @@\ |
---|
| 53 | .c.ko: @@\ |
---|
| 54 | $(RM) $@ @@\ |
---|
| 55 | $(C_COMP) -o $@ -c $(KCFLAGS) $*.c @@\ |
---|
| 56 | $(call handle_linux_sym,$@,$*.c) |
---|
| 57 | #endif /* LinuxKernelObjectRule */ |
---|
| 58 | #endif /* LINUX_KERNEL_VERSION */ |
---|
| 59 | |
---|
| 60 | NormalObjectRule() |
---|
| 61 | |
---|
| 62 | #define IHaveSubdirs |
---|
| 63 | #ifdef GPFS_ARCH_POWER |
---|
| 64 | SUBDIRS = power |
---|
| 65 | #endif |
---|
| 66 | #ifdef GPFS_ARCH_I386 |
---|
| 67 | #undef i386 |
---|
| 68 | SUBDIRS = i386 |
---|
| 69 | #endif |
---|
| 70 | #ifdef GPFS_ARCH_IA64 |
---|
| 71 | SUBDIRS = "ia64" |
---|
| 72 | #endif |
---|
| 73 | #ifdef GPFS_ARCH_PPC64 |
---|
| 74 | SUBDIRS = ppc64 |
---|
| 75 | #endif |
---|
| 76 | #ifdef GPFS_ARCH_X86_64 |
---|
| 77 | SUBDIRS = x86_64 |
---|
| 78 | #endif |
---|
| 79 | |
---|
| 80 | #ifdef GPFS_ARCH_POWER |
---|
| 81 | STD_KINCLUDES += -I$(KERNEL_HEADER_DIR)/../arch/ppc |
---|
| 82 | #endif |
---|
| 83 | |
---|
| 84 | #ifdef GPFS_ARCH_I386 |
---|
| 85 | STD_KINCLUDES += -I$(KERNEL_HEADER_DIR)/../arch/$(SUBDIRS)/mach-generic \ |
---|
| 86 | -I$(KERNEL_HEADER_DIR)/asm-$(SUBDIRS)/mach-default |
---|
| 87 | #endif |
---|
| 88 | |
---|
| 89 | #if (LINUX_KERNEL_VERSION > 2060000) |
---|
| 90 | KCFLAGS += $(shell $(DESTDIR)/bin/getupdatelevel) |
---|
| 91 | #endif |
---|
| 92 | |
---|
| 93 | #if (LINUX_KERNEL_VERSION >= 2061600) |
---|
| 94 | comma = , |
---|
| 95 | name-fix = $(subst $(comma),_,$(subst -,_,$1)) |
---|
| 96 | basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))" |
---|
| 97 | KCFLAGS += -D"KBUILD_STR(s)=\#s" $(basename_flags) |
---|
| 98 | #if (LINUX_KERNEL_VERSION >= 2061900) |
---|
| 99 | STD_KINCLUDES += -include $(KERNEL_HEADER_DIR)/linux/autoconf.h |
---|
| 100 | #endif |
---|
| 101 | #endif |
---|
| 102 | |
---|
| 103 | HEADERS = Shark-gpl.h prelinux.h postlinux.h linux2gpfs.h verdep.h \ |
---|
| 104 | Logger-gpl.h arch-gpl.h |
---|
| 105 | #ifdef SMB_LOCKS |
---|
| 106 | HEADERS += oplock.h |
---|
| 107 | #endif |
---|
| 108 | |
---|
| 109 | LINUX_VFS = opsdeclare.ko gpl-ksyms.ko \ |
---|
| 110 | gplInit.ko block.ko file.ko inode.ko dir.ko \ |
---|
| 111 | super.ko cxiSystem.ko cxiVFSStats.ko cxiIOBuffer.ko \ |
---|
| 112 | kx.ko mmap.ko ss.ko acl.ko |
---|
| 113 | |
---|
| 114 | LINUX_CUSTOM = cfiles_cust.ko |
---|
| 115 | |
---|
| 116 | #if defined(GPFS_ARCH_I386) && (LINUX_KERNEL_VERSION > 2060500) && !defined(NOKREGPARMS) |
---|
| 117 | MMLDFLAGS += --wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3 |
---|
| 118 | MMFS = mmfs-i386r |
---|
| 119 | /* kdump must have regparms turned off */ |
---|
| 120 | KDUMPCFLAGS = $(KCFLAGS) -mregparm=0 |
---|
| 121 | #else |
---|
| 122 | #if defined(GPFS_ARCH_IA64) && (LINUX_KERNEL_VERSION > 2060500) |
---|
| 123 | /* Need to include additional code sections with ia64 2.6 kernel modules */ |
---|
| 124 | MMLDFLAGS = -T /usr/src/linux/arch/ia64/module.lds |
---|
| 125 | #else |
---|
| 126 | MMLDFLAGS = |
---|
| 127 | #endif |
---|
| 128 | MMFS = mmfs |
---|
| 129 | KDUMPCFLAGS = $(KCFLAGS) |
---|
| 130 | #endif |
---|
| 131 | #if defined(GPFS_ARCH_PPC64) && (LINUX_KERNEL_VERSION > 2060900) |
---|
| 132 | MMFS = mmfs-ppc64-rh4 |
---|
| 133 | #endif |
---|
| 134 | |
---|
| 135 | #if (LINUX_KERNEL_VERSION > 2060000) |
---|
| 136 | |
---|
| 137 | /* |
---|
| 138 | * The default value for KERNEL_BUILD_DIR in site.mcr contains backquotes, |
---|
| 139 | * which the "make" does not understand. So, we call the shell to expand it |
---|
| 140 | */ |
---|
| 141 | KERNEL_BUILD_DIR := $(call shell, echo "$(KERNEL_BUILD_DIR)") |
---|
| 142 | #ifdef PCE_26_PCE |
---|
| 143 | MODPOST := $(KERNEL_BUILD_DIR)/scripts/mod/modpost |
---|
| 144 | #else |
---|
| 145 | MODPOST := $(if $(wildcard $(KERNEL_BUILD_DIR)/scripts/mod/modpost), \ |
---|
| 146 | $(KERNEL_BUILD_DIR)/scripts/mod/modpost, \ |
---|
| 147 | $(KERNEL_BUILD_DIR)/scripts/modpost) |
---|
| 148 | #endif |
---|
| 149 | |
---|
| 150 | SYSVERFILE := $(KERNEL_BUILD_DIR)/Module.symvers |
---|
| 151 | |
---|
| 152 | ifeq ($(LINUX_DISTRIBUTION), REDHAT_AS_LINUX) |
---|
| 153 | MODPOST_FLAG := -m |
---|
| 154 | else |
---|
| 155 | /* The modpost program on SLES9 does not recognize '-m' flag. The modversioning |
---|
| 156 | seems to be turned on by default. But on SLES10, this program requires the |
---|
| 157 | '-m' flag. |
---|
| 158 | */ |
---|
| 159 | #if (LINUX_KERNEL_VERSION >= 2061600) |
---|
| 160 | MODPOST_FLAG := -m |
---|
| 161 | #else |
---|
| 162 | MODPOST_FLAG := |
---|
| 163 | #endif |
---|
| 164 | endif |
---|
| 165 | |
---|
| 166 | #if (LINUX_KERNEL_VERSION >= 2061600 ) |
---|
| 167 | gpfs_module_name = -DKBUILD_MODNAME=\"$1\" |
---|
| 168 | #else |
---|
| 169 | gpfs_module_name = -DKBUILD_MODNAME=$1 |
---|
| 170 | #endif |
---|
| 171 | |
---|
| 172 | /* |
---|
| 173 | * For Linux kernel 2.6, we handle the modpost work ourselves. This way, we can |
---|
| 174 | * use the kernel modversioning to detect module/kernel mismatch. |
---|
| 175 | * To achieve this we do the folloing things: |
---|
| 176 | * (1) Recompile all the ".c" files which export functions to the linux kernel. |
---|
| 177 | * - the ".c" files are recompiled with -E -D__GENKSYMS__ and its output is |
---|
| 178 | * is feeded to the "genksyms" program, which calculates the CRC for |
---|
| 179 | * the function signature (for MODVERSION). |
---|
| 180 | * This part is done in the "imake.tmpl" file. |
---|
| 181 | * (2) Inovke the "modpost" script to generate "tracedev.mod.c" and |
---|
| 182 | * "mmfslinux.mod.c" files and relinking it to the corresponding module. |
---|
| 183 | * |
---|
| 184 | * Note that for mmfs26 module, we continue to use the modpost.c file in the |
---|
| 185 | * gpl-linux directory. |
---|
| 186 | */ |
---|
| 187 | |
---|
| 188 | |
---|
| 189 | #ifdef PCE_26_PCE |
---|
| 190 | /* |
---|
| 191 | * Experimental: |
---|
| 192 | * 2.6.16 code seems to want the module name quoted in order to compile. |
---|
| 193 | */ |
---|
| 194 | handle_modpost = @if [ ! -f $(MODPOST) ] ; then \ @@\ |
---|
| 195 | echo "$(MODPOST) not found. Check the value of \ @@\ |
---|
| 196 | KERNEL_BUILD_DIR in site.mcr file."; \ @@\ |
---|
| 197 | exit 1; \ @@\ |
---|
| 198 | fi; \ @@\ |
---|
| 199 | $(MODPOST) $(MODPOST_FLAG) -i $2 -o $1.symvers $(PWD)/$1 ; \ @@\ |
---|
| 200 | $(C_COMP) -o $1.mod.o -c $(KCFLAGS) -DKBUILD_MODNAME=\"$1\" $1.mod.c |
---|
| 201 | #else |
---|
| 202 | handle_modpost = @if [ ! -f $(MODPOST) ] ; then \ @@\ |
---|
| 203 | echo "$(MODPOST) not found. Check the value of \ @@\ |
---|
| 204 | KERNEL_BUILD_DIR in site.mcr file."; \ @@\ |
---|
| 205 | exit 1; \ @@\ |
---|
| 206 | fi; \ @@\ |
---|
| 207 | $(MODPOST) $(MODPOST_FLAG) -i $2 -o $1.symvers $(PWD)/$1 ; \ @@\ |
---|
| 208 | $(C_COMP) -o $1.mod.o -c $(KCFLAGS) $(call gpfs_module_name,$1) $1.mod.c |
---|
| 209 | #endif |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | #endif |
---|
| 213 | |
---|
| 214 | SharedObjectTarget(libgpfs_gpl.so, tscalls.o, -lc) |
---|
| 215 | InstallFiles(libgpfs_gpl.so, $(INSTPROGFLAGS), $(GPL_LIB_DIR)) |
---|
| 216 | |
---|
| 217 | tracedev: tracedev.ko tracedev-ksyms.ko |
---|
| 218 | $(RM) $@ |
---|
| 219 | $(BARELD) -r -o $@ -Map $@.map --cref $(MMLDFLAGS) $^ |
---|
| 220 | #if (LINUX_KERNEL_VERSION > 2060000) |
---|
| 221 | @if [ ! -f $(SYSVERFILE) ]; then \ @@\ |
---|
| 222 | echo "WARNING: $(SYSVERFILE) file not found. Check the value of KERNEL_BUILD_DIR \ @@\ |
---|
| 223 | in site.mcr file"; \ @@\ |
---|
| 224 | fi |
---|
| 225 | $(call handle_modpost,$@,$(SYSVERFILE)) |
---|
| 226 | mv -f $@ $@.tmp |
---|
| 227 | $(BARELD) -r -o $@ -Map $@.map --cref $(MMLDFLAGS) $@.tmp $@.mod.o $$($(C_COMP) -print-libgcc-file-name) |
---|
| 228 | mv -f $@.mod.c $@.mod.c.saved |
---|
| 229 | rm -f $@.tmp |
---|
| 230 | #endif |
---|
| 231 | |
---|
| 232 | MMFS_KEXTS = mmfslinux |
---|
| 233 | #if (LINUX_KERNEL_VERSION > 2060000) |
---|
| 234 | MMFS_KEXTS += mmfs26 |
---|
| 235 | #endif |
---|
| 236 | |
---|
| 237 | #ifdef MOUNT_HELPER |
---|
| 238 | ROOT_CMDS = lxtrace dumpconv umount.gpfs |
---|
| 239 | #else |
---|
| 240 | ROOT_CMDS = lxtrace dumpconv |
---|
| 241 | #endif |
---|
| 242 | |
---|
| 243 | SITEMCRREV_ARG = $(filter 1.%,$(SITEMCRREV_RAW)) |
---|
| 244 | KCFLAGS += -D'SITEMCRREV="$(SITEMCRREV_ARG)"' |
---|
| 245 | |
---|
| 246 | mmfslinux: $(LINUX_CUSTOM) $(GPL_LIB_DIR)/libarch-gpl_cust.a mmwrap.ko tracedev |
---|
| 247 | $(RM) $@ |
---|
| 248 | $(BARELD) -r -o $@ $(LINUX_CUSTOM) $(GPL_LIB_DIR)/libarch-gpl_cust.a \ |
---|
| 249 | -Map $@.map --cref $(MMLDFLAGS) \ |
---|
| 250 | mmwrap.ko $$($(C_COMP) -print-libgcc-file-name) |
---|
| 251 | #if (LINUX_KERNEL_VERSION > 2060000) |
---|
| 252 | $(call handle_modpost,$@,tracedev.symvers) |
---|
| 253 | mv -f $@ $@.tmp |
---|
| 254 | $(BARELD) -r -o $@ -Map $@.map --cref $(MMLDFLAGS) $@.tmp $@.mod.o $$($(C_COMP) -print-libgcc-file-name) |
---|
| 255 | mv -f $@.mod.c $@.mod.c.saved |
---|
| 256 | rm -f $@.tmp |
---|
| 257 | #endif |
---|
| 258 | |
---|
| 259 | #if (LINUX_KERNEL_VERSION > 2060000) |
---|
| 260 | mmfs26: $(DESTDIR)/bin/$(MMFS) mmfsmod.ko mmwrap.ko |
---|
| 261 | $(RM) $@ |
---|
| 262 | $(BARELD) -r -o $@ $(DESTDIR)/bin/$(MMFS) mmfsmod.ko -Map $@.map \ |
---|
| 263 | --cref $(MMLDFLAGS) mmwrap.ko \ |
---|
| 264 | $$($(C_COMP) -print-libgcc-file-name) |
---|
| 265 | $(call handle_modpost,$@,mmfslinux.symvers) |
---|
| 266 | mv -f $@ $@.tmp |
---|
| 267 | $(BARELD) -r -o $@ -Map $@.map --cref $(MMLDFLAGS) $@.tmp $@.mod.o $$($(C_COMP) -print-libgcc-file-name) |
---|
| 268 | mv -f $@.mod.c $@.mod.c.saved |
---|
| 269 | #endif |
---|
| 270 | |
---|
| 271 | #if (LINUX_KERNEL_VERSION < 2060000) |
---|
| 272 | MMFS_KEXTS += mmfs24 |
---|
| 273 | |
---|
| 274 | mmfs24: $(DESTDIR)/bin/$(MMFS) ibmInitWrap.ko |
---|
| 275 | $(RM) $@ |
---|
| 276 | $(BARELD) -r -o $@ $(DESTDIR)/bin/$(MMFS) ibmInitWrap.ko \ |
---|
| 277 | $(MMLDFLAGS) -Map $@.map |
---|
| 278 | |
---|
| 279 | ibmInitWrap.ko: ibmInitWrap.C |
---|
| 280 | $(RM) $@ |
---|
| 281 | $(C_COMP) -o $@ -c $(KCFLAGS) ibmInitWrap.C |
---|
| 282 | #endif |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | clean:: ; $(RM) $(MMFS_KEXTS) $(ROOT_CMDS) tracedev *.symvers *.mod.c |
---|
| 286 | |
---|
| 287 | MkdirTarget($(GPL_HEADER_DIR)) |
---|
| 288 | InstallHeaders($(HEADERS), $(GPL_HEADER_DIR)) |
---|
| 289 | |
---|
| 290 | InstallRootPrograms($(MMFS_KEXTS), $(DESTDIR)/bin) |
---|
| 291 | |
---|
| 292 | /* Special rule for kdump so we get stabs info */ |
---|
| 293 | kdump-kern.ko: kdump-kern.c kdump.h |
---|
| 294 | $(RM) $@ |
---|
| 295 | $(C_COMP) -o $@ -c $(KDUMPCFLAGS) -DNOSTABS $*.c |
---|
| 296 | |
---|
| 297 | kdump-kern-stabs.ko: kdump-kern.c kdump.h |
---|
| 298 | $(RM) $@ |
---|
| 299 | $(C_COMP) -o $@ -c $(KDUMPCFLAGS) -gstabs+ kdump-kern.c |
---|
| 300 | |
---|
| 301 | KDUMP = kdump.o kdump-kern.ko kdump-kern-stabs.ko |
---|
| 302 | ProgramTarget(kdump, $(KDUMP), , ) |
---|
| 303 | |
---|
| 304 | #ifdef MOUNT_HELPER |
---|
| 305 | MNTHELP = MountHelper.o update_mtab.o |
---|
| 306 | ProgramTarget(umount.gpfs, $(MNTHELP), , -L $(DESTDIR)/lib -lgpfs ) |
---|
| 307 | InstallFiles(umount.gpfs, $(INSTSHELLFLAGS), $(DESTDIR)/bin) |
---|
| 308 | #endif |
---|
| 309 | #if (LINUX_KERNEL_VERSION > 2060000) |
---|
| 310 | ProgramTarget(lxtrace, lxtrace.o, , $(PTHREADS) -lrt ) |
---|
| 311 | #else |
---|
| 312 | ProgramTarget(lxtrace, lxtrace.o, , $(PTHREADS)) |
---|
| 313 | #endif |
---|
| 314 | ProgramTarget(dumpconv, dumpconv.o, , ) |
---|
| 315 | |
---|
| 316 | InstallFiles(tracedev, $(INSTSHELLFLAGS), $(DESTDIR)/bin) |
---|
| 317 | #ifndef SRC_BUILD |
---|
| 318 | InstallFiles(lxtrace.sial, $(INSTSHELLFLAGS), $(DESTDIR)/bin) |
---|
| 319 | InstallFiles(mmdumpfilocks.sial, $(INSTSHELLFLAGS), $(DESTDIR)/bin) |
---|
| 320 | #endif |
---|
| 321 | |
---|
| 322 | InstallRootPrograms($(ROOT_CMDS), $(DESTDIR)/bin) |
---|
| 323 | |
---|
| 324 | /* RPM source build option to install images for kernel modules */ |
---|
| 325 | BUILD_DESTDIR = /usr/lpp/mmfs/bin |
---|
| 326 | BUILD_INSTALL = $(MMFS_KEXTS) $(ROOT_CMDS) tracedev |
---|
| 327 | |
---|
| 328 | InstallImages:: $(BUILD_INSTALL) |
---|
| 329 | @(case '$(MAKEFLAGS)' in *[ik]*) set +e;; esac; \ |
---|
| 330 | for i in $(BUILD_INSTALL); do \ |
---|
| 331 | (echo $$i; $(INSTALL) $(INSTROOTFLAGS) $$i $(BUILD_DESTDIR)/$$i) done) |
---|
| 332 | #ifdef MOUNT_HELPER |
---|
| 333 | $(INSTALL) $(INSTROOTFLAGS) umount.gpfs /sbin/umount.gpfs |
---|
| 334 | #endif |
---|
| 335 | |
---|
| 336 | TRACELIST = gplInit.c block.c dir.c file.c inode.c super.c \ |
---|
| 337 | cxiVFSStats.c cxiSystem.c cxiIOBuffer.c kx.c ss.c \ |
---|
| 338 | mmap.c acl.c |
---|
| 339 | |
---|
| 340 | TraceTarget(gpl-linux, $(TRACELIST)) |
---|
| 341 | |
---|
| 342 | DependTargetPK() |
---|