/* $Id: Imakefile,v 1.122.2.10 2006/10/25 18:34:21 mcnabb Exp $ */ /***** THIS MUST BE INCLUDED WITH IMAKE FILES *****/ /* Only include kernel and cxi headers in this layer */ SetGplIncludePath() /***** THIS MUST BE INCLUDED WITH IMAKE FILES *****/ CheckLinuxDistribution() PTHREADS = -lpthread INSTROOTFLAGS = -c -m 0500 #if (LINUX_KERNEL_VERSION >= 2060000) /* * The linux 2.6 kernel adds a new component called "modpost", to all the * kernel modules. Typically, this is done automatically by the linux kernel * build infrastructure (kbuild). But the kbuild infrastructure is quite cryptic * to be used by modules like GPFS. Hence, we bypass the linux kbuild * infrastructure and do the modpost work ourselves. * * Here is the summary of what we do: * If the ".c" file exports a function to the linux kernel then we add the * CRC of all such functions to the object. This is done to detect version * mismatch between modules/kernel. * If a ".c" file exports a function, then its object would have a "__ksymtab" * section. * For all such ".c" files, we recompile it with -E -D__GENKSYMS__ defined and * feed the output to "genksyms" program, which calculates the CRC for all * such functions. We then put this information into the object file so that * the corresponding modpost file contains the CRCs required for the module. * (The modpost work is done in the Imakefile for the "gpl-linux" directory.) */ OBJDUMP = /usr/bin/objdump GENKSYMS = $(KERNEL_BUILD_DIR)/scripts/genksyms/genksyms handle_linux_sym = @if [ ! -f $(GENKSYMS) ]; then \ @@\ echo "$(GENKSYMS) not found. Check the value of KERNEL_BUILD_DIR in site.mcr";\ @@\ exit 1; \ @@\ fi; \ @@\ $(OBJDUMP) -h $1 | grep -q __ksymtab; \ @@\ if [ $$? -eq 0 ]; then \ @@\ $(C_COMP) -E -D__GENKSYMS__ $(KCFLAGS) $2 | $(GENKSYMS) > $1.ver; \ @@\ mv $1 $1.tmp; \ @@\ $(BARELD) -r -o $1 $1.tmp -T $1.ver; \ @@\ rm -f $1.tmp; \ @@\ fi #endif /* LINUX_KERNEL_VERSION */ #if (LINUX_KERNEL_VERSION >= 2060000) #ifdef LinuxKernelObjectRule #undef LinuxKernelObjectRule #define LinuxKernelObjectRule() @@\ .c.ko: @@\ $(RM) $@ @@\ $(C_COMP) -o $@ -c $(KCFLAGS) $*.c @@\ $(call handle_linux_sym,$@,$*.c) #endif /* LinuxKernelObjectRule */ #endif /* LINUX_KERNEL_VERSION */ NormalObjectRule() #define IHaveSubdirs #ifdef GPFS_ARCH_POWER SUBDIRS = power #endif #ifdef GPFS_ARCH_I386 #undef i386 SUBDIRS = i386 #endif #ifdef GPFS_ARCH_IA64 SUBDIRS = "ia64" #endif #ifdef GPFS_ARCH_PPC64 SUBDIRS = ppc64 #endif #ifdef GPFS_ARCH_X86_64 SUBDIRS = x86_64 #endif #ifdef GPFS_ARCH_POWER STD_KINCLUDES += -I$(KERNEL_HEADER_DIR)/../arch/ppc #endif #ifdef GPFS_ARCH_I386 STD_KINCLUDES += -I$(KERNEL_HEADER_DIR)/../arch/$(SUBDIRS)/mach-generic \ -I$(KERNEL_HEADER_DIR)/asm-$(SUBDIRS)/mach-default #endif #if (LINUX_KERNEL_VERSION > 2060000) KCFLAGS += $(shell $(DESTDIR)/bin/getupdatelevel) #endif #if (LINUX_KERNEL_VERSION >= 2061600) comma = , name-fix = $(subst $(comma),_,$(subst -,_,$1)) basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))" KCFLAGS += -D"KBUILD_STR(s)=\#s" $(basename_flags) #if (LINUX_KERNEL_VERSION >= 2061900) STD_KINCLUDES += -include $(KERNEL_HEADER_DIR)/linux/autoconf.h #endif #endif HEADERS = Shark-gpl.h prelinux.h postlinux.h linux2gpfs.h verdep.h \ Logger-gpl.h arch-gpl.h #ifdef SMB_LOCKS HEADERS += oplock.h #endif LINUX_VFS = opsdeclare.ko gpl-ksyms.ko \ gplInit.ko block.ko file.ko inode.ko dir.ko \ super.ko cxiSystem.ko cxiVFSStats.ko cxiIOBuffer.ko \ kx.ko mmap.ko ss.ko acl.ko LINUX_CUSTOM = cfiles_cust.ko #if defined(GPFS_ARCH_I386) && (LINUX_KERNEL_VERSION > 2060500) && !defined(NOKREGPARMS) MMLDFLAGS += --wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3 MMFS = mmfs-i386r /* kdump must have regparms turned off */ KDUMPCFLAGS = $(KCFLAGS) -mregparm=0 #else #if defined(GPFS_ARCH_IA64) && (LINUX_KERNEL_VERSION > 2060500) /* Need to include additional code sections with ia64 2.6 kernel modules */ MMLDFLAGS = -T /usr/src/linux/arch/ia64/module.lds #else MMLDFLAGS = #endif MMFS = mmfs KDUMPCFLAGS = $(KCFLAGS) #endif #if defined(GPFS_ARCH_PPC64) && (LINUX_KERNEL_VERSION > 2060900) MMFS = mmfs-ppc64-rh4 #endif #if (LINUX_KERNEL_VERSION > 2060000) /* * The default value for KERNEL_BUILD_DIR in site.mcr contains backquotes, * which the "make" does not understand. So, we call the shell to expand it */ KERNEL_BUILD_DIR := $(call shell, echo "$(KERNEL_BUILD_DIR)") #ifdef PCE_26_PCE MODPOST := $(KERNEL_BUILD_DIR)/scripts/mod/modpost #else MODPOST := $(if $(wildcard $(KERNEL_BUILD_DIR)/scripts/mod/modpost), \ $(KERNEL_BUILD_DIR)/scripts/mod/modpost, \ $(KERNEL_BUILD_DIR)/scripts/modpost) #endif SYSVERFILE := $(KERNEL_BUILD_DIR)/Module.symvers ifeq ($(LINUX_DISTRIBUTION), REDHAT_AS_LINUX) MODPOST_FLAG := -m else /* The modpost program on SLES9 does not recognize '-m' flag. The modversioning seems to be turned on by default. But on SLES10, this program requires the '-m' flag. */ #if (LINUX_KERNEL_VERSION >= 2061600) MODPOST_FLAG := -m #else MODPOST_FLAG := #endif endif #if (LINUX_KERNEL_VERSION >= 2061600 ) gpfs_module_name = -DKBUILD_MODNAME=\"$1\" #else gpfs_module_name = -DKBUILD_MODNAME=$1 #endif /* * For Linux kernel 2.6, we handle the modpost work ourselves. This way, we can * use the kernel modversioning to detect module/kernel mismatch. * To achieve this we do the folloing things: * (1) Recompile all the ".c" files which export functions to the linux kernel. * - the ".c" files are recompiled with -E -D__GENKSYMS__ and its output is * is feeded to the "genksyms" program, which calculates the CRC for * the function signature (for MODVERSION). * This part is done in the "imake.tmpl" file. * (2) Inovke the "modpost" script to generate "tracedev.mod.c" and * "mmfslinux.mod.c" files and relinking it to the corresponding module. * * Note that for mmfs26 module, we continue to use the modpost.c file in the * gpl-linux directory. */ #ifdef PCE_26_PCE /* * Experimental: * 2.6.16 code seems to want the module name quoted in order to compile. */ handle_modpost = @if [ ! -f $(MODPOST) ] ; then \ @@\ echo "$(MODPOST) not found. Check the value of \ @@\ KERNEL_BUILD_DIR in site.mcr file."; \ @@\ exit 1; \ @@\ fi; \ @@\ $(MODPOST) $(MODPOST_FLAG) -i $2 -o $1.symvers $(PWD)/$1 ; \ @@\ $(C_COMP) -o $1.mod.o -c $(KCFLAGS) -DKBUILD_MODNAME=\"$1\" $1.mod.c #else handle_modpost = @if [ ! -f $(MODPOST) ] ; then \ @@\ echo "$(MODPOST) not found. Check the value of \ @@\ KERNEL_BUILD_DIR in site.mcr file."; \ @@\ exit 1; \ @@\ fi; \ @@\ $(MODPOST) $(MODPOST_FLAG) -i $2 -o $1.symvers $(PWD)/$1 ; \ @@\ $(C_COMP) -o $1.mod.o -c $(KCFLAGS) $(call gpfs_module_name,$1) $1.mod.c #endif #endif SharedObjectTarget(libgpfs_gpl.so, tscalls.o, -lc) InstallFiles(libgpfs_gpl.so, $(INSTPROGFLAGS), $(GPL_LIB_DIR)) tracedev: tracedev.ko tracedev-ksyms.ko $(RM) $@ $(BARELD) -r -o $@ -Map $@.map --cref $(MMLDFLAGS) $^ #if (LINUX_KERNEL_VERSION > 2060000) @if [ ! -f $(SYSVERFILE) ]; then \ @@\ echo "WARNING: $(SYSVERFILE) file not found. Check the value of KERNEL_BUILD_DIR \ @@\ in site.mcr file"; \ @@\ fi $(call handle_modpost,$@,$(SYSVERFILE)) mv -f $@ $@.tmp $(BARELD) -r -o $@ -Map $@.map --cref $(MMLDFLAGS) $@.tmp $@.mod.o $$($(C_COMP) -print-libgcc-file-name) mv -f $@.mod.c $@.mod.c.saved rm -f $@.tmp #endif MMFS_KEXTS = mmfslinux #if (LINUX_KERNEL_VERSION > 2060000) MMFS_KEXTS += mmfs26 #endif #ifdef MOUNT_HELPER ROOT_CMDS = lxtrace dumpconv umount.gpfs #else ROOT_CMDS = lxtrace dumpconv #endif SITEMCRREV_ARG = $(filter 1.%,$(SITEMCRREV_RAW)) KCFLAGS += -D'SITEMCRREV="$(SITEMCRREV_ARG)"' mmfslinux: $(LINUX_CUSTOM) $(GPL_LIB_DIR)/libarch-gpl_cust.a mmwrap.ko tracedev $(RM) $@ $(BARELD) -r -o $@ $(LINUX_CUSTOM) $(GPL_LIB_DIR)/libarch-gpl_cust.a \ -Map $@.map --cref $(MMLDFLAGS) \ mmwrap.ko $$($(C_COMP) -print-libgcc-file-name) #if (LINUX_KERNEL_VERSION > 2060000) $(call handle_modpost,$@,tracedev.symvers) mv -f $@ $@.tmp $(BARELD) -r -o $@ -Map $@.map --cref $(MMLDFLAGS) $@.tmp $@.mod.o $$($(C_COMP) -print-libgcc-file-name) mv -f $@.mod.c $@.mod.c.saved rm -f $@.tmp #endif #if (LINUX_KERNEL_VERSION > 2060000) mmfs26: $(DESTDIR)/bin/$(MMFS) mmfsmod.ko mmwrap.ko $(RM) $@ $(BARELD) -r -o $@ $(DESTDIR)/bin/$(MMFS) mmfsmod.ko -Map $@.map \ --cref $(MMLDFLAGS) mmwrap.ko \ $$($(C_COMP) -print-libgcc-file-name) $(call handle_modpost,$@,mmfslinux.symvers) mv -f $@ $@.tmp $(BARELD) -r -o $@ -Map $@.map --cref $(MMLDFLAGS) $@.tmp $@.mod.o $$($(C_COMP) -print-libgcc-file-name) mv -f $@.mod.c $@.mod.c.saved #endif #if (LINUX_KERNEL_VERSION < 2060000) MMFS_KEXTS += mmfs24 mmfs24: $(DESTDIR)/bin/$(MMFS) ibmInitWrap.ko $(RM) $@ $(BARELD) -r -o $@ $(DESTDIR)/bin/$(MMFS) ibmInitWrap.ko \ $(MMLDFLAGS) -Map $@.map ibmInitWrap.ko: ibmInitWrap.C $(RM) $@ $(C_COMP) -o $@ -c $(KCFLAGS) ibmInitWrap.C #endif clean:: ; $(RM) $(MMFS_KEXTS) $(ROOT_CMDS) tracedev *.symvers *.mod.c MkdirTarget($(GPL_HEADER_DIR)) InstallHeaders($(HEADERS), $(GPL_HEADER_DIR)) InstallRootPrograms($(MMFS_KEXTS), $(DESTDIR)/bin) /* Special rule for kdump so we get stabs info */ kdump-kern.ko: kdump-kern.c kdump.h $(RM) $@ $(C_COMP) -o $@ -c $(KDUMPCFLAGS) -DNOSTABS $*.c kdump-kern-stabs.ko: kdump-kern.c kdump.h $(RM) $@ $(C_COMP) -o $@ -c $(KDUMPCFLAGS) -gstabs+ kdump-kern.c KDUMP = kdump.o kdump-kern.ko kdump-kern-stabs.ko ProgramTarget(kdump, $(KDUMP), , ) #ifdef MOUNT_HELPER MNTHELP = MountHelper.o update_mtab.o ProgramTarget(umount.gpfs, $(MNTHELP), , -L $(DESTDIR)/lib -lgpfs ) InstallFiles(umount.gpfs, $(INSTSHELLFLAGS), $(DESTDIR)/bin) #endif #if (LINUX_KERNEL_VERSION > 2060000) ProgramTarget(lxtrace, lxtrace.o, , $(PTHREADS) -lrt ) #else ProgramTarget(lxtrace, lxtrace.o, , $(PTHREADS)) #endif ProgramTarget(dumpconv, dumpconv.o, , ) InstallFiles(tracedev, $(INSTSHELLFLAGS), $(DESTDIR)/bin) #ifndef SRC_BUILD InstallFiles(lxtrace.sial, $(INSTSHELLFLAGS), $(DESTDIR)/bin) InstallFiles(mmdumpfilocks.sial, $(INSTSHELLFLAGS), $(DESTDIR)/bin) #endif InstallRootPrograms($(ROOT_CMDS), $(DESTDIR)/bin) /* RPM source build option to install images for kernel modules */ BUILD_DESTDIR = /usr/lpp/mmfs/bin BUILD_INSTALL = $(MMFS_KEXTS) $(ROOT_CMDS) tracedev InstallImages:: $(BUILD_INSTALL) @(case '$(MAKEFLAGS)' in *[ik]*) set +e;; esac; \ for i in $(BUILD_INSTALL); do \ (echo $$i; $(INSTALL) $(INSTROOTFLAGS) $$i $(BUILD_DESTDIR)/$$i) done) #ifdef MOUNT_HELPER $(INSTALL) $(INSTROOTFLAGS) umount.gpfs /sbin/umount.gpfs #endif TRACELIST = gplInit.c block.c dir.c file.c inode.c super.c \ cxiVFSStats.c cxiSystem.c cxiIOBuffer.c kx.c ss.c \ mmap.c acl.c TraceTarget(gpl-linux, $(TRACELIST)) DependTargetPK()