Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Cloud:OTC:Drivers
scsi_ep_front
Makefile-kbuild.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File Makefile-kbuild.diff of Package scsi_ep_front
Index: scsi_ep_front/scsi_ep_front/Makefile =================================================================== --- scsi_ep_front.orig/scsi_ep_front/Makefile +++ scsi_ep_front/scsi_ep_front/Makefile @@ -1,6 +1,10 @@ # Comment/uncomment the following line to enable/disable debugging #DEBUG = y +ifeq (,$(BUILD_KERNEL)) +BUILD_KERNEL=$(shell uname -r) +endif + # for driver version begin DRV_BUILD_TIME := $(shell date +"%Y-%m-%d %H:%M:%S") ifeq ($(DRV_BUILD_TIME), ) @@ -28,91 +32,280 @@ ifeq ($(DEBUG),y) else DEBFLAGS = -O2 endif + EXTRA_CFLAGS += $(DEBFLAGS) -I$(LDDINC) -CFILES := epfront_transfer.o \ - epfront_main.o \ - epfront_sysfs.o +CFILES := epfront_transfer.c \ + epfront_main.c \ + epfront_sysfs.c DRIVER_NAME := scsi_ep_front -#KERNELDIR ?= /lib/modules/$(shell uname -r)/build -#KERNELDIR ?= /usr1/f00346856/3.0.101-63-default/ -#KERNELDIR ?= /usr1/f00346856/2.6.32-504.el6.x86_64/build/ -KERNELDIR ?= /usr1/f00346856/2.6.32-573.el6.x86_64/ -ifneq ($(KERNELRELEASE),) +# All the places we look for kernel source +KSP := /lib/modules/$(BUILD_KERNEL)/build \ + /lib/modules/$(BUILD_KERNEL)/source \ + /usr/src/linux-$(BUILD_KERNEL) \ + /usr/src/linux-$($(BUILD_KERNEL) | sed 's/-.*//') \ + /usr/src/kernel-headers-$(BUILD_KERNEL) \ + /usr/src/kernel-source-$(BUILD_KERNEL) \ + /usr/src/linux-$($(BUILD_KERNEL) | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \ + /usr/src/linux + +# prune the list down to only values that exist +# and have an include/linux sub-directory +test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir)) +KSP := $(foreach dir, $(KSP), $(test_dir)) + +# we will use this first valid entry in the search path +ifeq (,$(KSRC)) + KSRC := $(firstword $(KSP)) +endif -$(DRIVER_NAME)-objs := $(CFILES:.c=.o) -obj-m += $(DRIVER_NAME).o - +ifeq (,$(KSRC)) + $(warning *** Kernel header files not in any of the expected locations.) + $(warning *** Install the appropriate kernel development package, e.g.) + $(error kernel-devel, for building kernel modules and try again) +else +ifeq (/lib/modules/$(BUILD_KERNEL)/source, $(KSRC)) + KOBJ := /lib/modules/$(BUILD_KERNEL)/build else -PWD := $(shell pwd) + KOBJ := $(KSRC) +endif +endif -modules: - $(MAKE) ARCH=x86_64 CROSS_COMPILE= -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD) modules +# Version file Search Path +VSP := $(KOBJ)/include/generated/utsrelease.h \ + $(KOBJ)/include/linux/utsrelease.h \ + $(KOBJ)/include/linux/version.h \ + $(KOBJ)/include/generated/uapi/linux/version.h \ + /boot/vmlinuz.version.h + +# Config file Search Path +CSP := $(KOBJ)/include/generated/autoconf.h \ + $(KOBJ)/include/linux/autoconf.h \ + /boot/vmlinuz.autoconf.h + +# prune the lists down to only files that exist +test_file = $(shell [ -f $(file) ] && echo $(file)) +VSP := $(foreach file, $(VSP), $(test_file)) +CSP := $(foreach file, $(CSP), $(test_file)) + +# and use the first valid entry in the Search Paths +ifeq (,$(VERSION_FILE)) + VERSION_FILE := $(firstword $(VSP)) +endif +ifeq (,$(CONFIG_FILE)) + CONFIG_FILE := $(firstword $(CSP)) +endif + +ifeq (,$(wildcard $(VERSION_FILE))) + $(error Linux kernel source not configured - missing version header file) +endif +ifeq (,$(wildcard $(CONFIG_FILE))) + $(error Linux kernel source not configured - missing autoconf.h) +endif + +# pick a compiler +ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version))) + CC := kgcc gcc cc +else + CC := gcc cc +endif +test_cc = $(shell $(cc) --version > /dev/null 2>&1 && echo $(cc)) +CC := $(foreach cc, $(CC), $(test_cc)) +CC := $(firstword $(CC)) +ifeq (,$(CC)) + $(error Compiler not found) +endif + +# we need to know what platform the driver is being built on +# some additional features are only built on Intel platforms +ARCH := $(shell uname -m | sed 's/i.86/i386/') +ifeq ($(ARCH),alpha) + EXTRA_CFLAGS += -ffixed-8 -mno-fp-regs +endif +ifeq ($(ARCH),x86_64) + EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone +endif +ifeq ($(ARCH),ppc) + EXTRA_CFLAGS += -msoft-float +endif +ifeq ($(ARCH),ppc64) + EXTRA_CFLAGS += -m64 -msoft-float + LDFLAGS += -melf64ppc +endif + +RHC := $(KSRC)/include/linux/rhconfig.h +ifneq (,$(wildcard $(RHC))) + # 7.3 typo in rhconfig.h + ifneq (,$(shell $(CC) $(CFLAGS) -E -dM $(RHC) | grep __module__bigmem)) + EXTRA_CFLAGS += -D__module_bigmem + endif +endif + +# get the kernel version - we use this to find the correct install path +KVER := $(shell $(CC) $(EXTRA_CFLAGS) -E -dM $(VERSION_FILE) | grep UTS_RELEASE | \ + awk '{ print $$3 }' | sed 's/\"//g') + +# assume source symlink is the same as build, otherwise adjust KOBJ +ifneq (,$(wildcard /lib/modules/$(KVER)/build)) +ifneq ($(KSRC),$(shell readlink /lib/modules/$(KVER)/build)) + KOBJ=/lib/modules/$(KVER)/build +endif +endif + +#KVER_CODE := $(shell $(CC) $(EXTRA_CFLAGS) -E -dM $(VSP) 2>/dev/null |\ +# grep -m 1 LINUX_VERSION_CODE | awk '{ print $$3 }' | sed 's/\"//g') +KVER_CODE := $(shell grep -m 1 LINUX_VERSION_CODE $(VSP) | awk '{ print $$3 }' | sed 's/\"//g') + +# abort the build on kernels older than 2.4.0 +ifneq (1,$(shell [ $(KVER_CODE) -ge 132096 ] && echo 1 || echo 0)) + $(error *** Aborting the build. \ + *** This driver is not supported on kernel versions older than 2.4.0) endif -TARGET := $(DRIVER_NAME).ko # set the install path -#KERNELINST := /lib/modules/$(shell uname -r)/ -#KERNELINST ?= /lib/modules/3.0.101-63-default/ -#KERNELINST ?= /lib/modules/2.6.32-504.el6.x86_64/ -KERNELINST ?= /lib/modules/2.6.32-573.el6.x86_64/ - -INSTDIR := $(KERNELINST)/kernel/drivers/scsi/$(DRIVER_NAME) -#INSTDIR := $(KERNELDIR)/kernel/drivers/scsi/ -MODPROBE_CONF_DIR := /etc/modprobe.d/ -ABSOLUTE_MOD_INSTDIR := $(INSTALL_MOD_PATH)$(INSTDIR) -ABOSULTE_MODPROBE_CONF_DIR := $(INSTALL_MOD_PATH)$(MODPROBE_CONF_DIR) -MODPROBE_CONF_FILE := $(ABOSULTE_MODPROBE_CONF_DIR)/$(DRIVER_NAME).conf +INSTDIR := /lib/modules/$(KVER)/kernel/drivers/scsi/$(DRIVER_NAME) -# depmod version -DEPVER := $(shell /sbin/depmod -V 2>/dev/null | awk 'BEGIN {FS="."} NR==1 {print $$2}') +# look for SMP in config.h +SMP := $(shell $(CC) $(EXTRA_CFLAGS) -E -dM $(CONFIG_FILE) | \ + grep -w CONFIG_SMP | awk '{ print $$3 }') +ifneq ($(SMP),1) + SMP := 0 +endif -install: - # remove all old versions of the driver - find $(INSTALL_MOD_PATH)/$(KERNELINST) -name $(TARGET) -exec rm -f {} \; || true +ifneq ($(SMP),$(shell uname -a | grep SMP > /dev/null 2>&1 && echo 1 || echo 0)) + $(warning ***) + ifeq ($(SMP),1) + $(warning *** Warning: kernel source configuration (SMP)) + $(warning *** does not match running kernel (UP)) + else + $(warning *** Warning: kernel source configuration (UP)) + $(warning *** does not match running kernel (SMP)) + endif + $(warning *** Continuing with build,) + $(warning *** resulting driver may not be what you want) + $(warning ***) +endif - # create directory for the module - if [ ! -d $(ABSOLUTE_MOD_INSTDIR) ] ; then \ - mkdir -p $(ABSOLUTE_MOD_INSTDIR) ; \ - fi - if [ ! -d $(ABOSULTE_MODPROBE_CONF_DIR) ] ; then \ - mkdir -p $(ABOSULTE_MODPROBE_CONF_DIR) ; \ - fi +ifeq ($(SMP),1) + EXTRA_CFLAGS += -D__SMP__ +endif + + +########################################################################### +# Kernel Version Specific rules + +ifeq (1,$(shell [ $(KVER_CODE) -ge 132352 ] && echo 1 || echo 0)) + +# Makefile for 2.5.x and newer kernel +TARGET = $(DRIVER_NAME).ko + +ifneq ($(PATCHLEVEL),) +EXTRA_CFLAGS += $(CFLAGS_EXTRA) +obj-m += $(DRIVER_NAME).o +$(DRIVER_NAME)-objs := $(CFILES:.c=.o) +else +default: +ifeq ($(KOBJ),$(KSRC)) + $(MAKE) -C $(KSRC) SUBDIRS=$(shell pwd) modules +else + $(MAKE) -C $(KSRC) O=$(KOBJ) SUBDIRS=$(shell pwd) modules +endif +endif - # install the modules - install -D -m 644 $(TARGET) $(ABSOLUTE_MOD_INSTDIR)/$(TARGET) - echo "install $(DRIVER_NAME) /sbin/modprobe --ignore-install $(DRIVER_NAME)" > $(MODPROBE_CONF_FILE) - -ifeq (,$(INSTALL_MOD_PATH) ) -/sbin/depmod -a || true -else -ifeq ($(DEPVER),1) -/sbin/depmod -r $(INSTALL_MOD_PATH) -a || true -#else -#/sbin/depmod -b $(INSTALL_MOD_PATH) -a -n $(KVERSION) > /dev/null || true +# Get rid of compile warnings in kernel header files from SuSE +ifneq (,$(wildcard /etc/SuSE-release)) + EXTRA_CFLAGS += -Wno-sign-compare -fno-strict-aliasing endif + +# Get rid of compile warnings in kernel header files from fedora +ifneq (,$(wildcard /etc/fedora-release)) + EXTRA_CFLAGS += -fno-strict-aliasing +endif + +#CFLAGS += $(EXTRA_CFLAGS) + +.SILENT: $(TARGET) +$(TARGET): $(filter-out $(TARGET), $(CFILES:.c=.o)) + $(LD) $(LDFLAGS) -r $^ -o $@ + echo; echo + echo "**************************************************" + echo "** $(TARGET) built for $(KVER)" + echo -n "** SMP " + if [ "$(SMP)" = "1" ]; \ + then echo "Enabled"; else echo "Disabled"; fi + echo "**************************************************" + echo + +$(CFILES:.c=.o): $(HFILES) Makefile +default: + $(MAKE) + +endif # ifeq (1,$(shell [ $(KVER_CODE) -ge 132352 ] && echo 1 || echo 0)) + + +# extra flags for module builds +EXTRA_CFLAGS += -DDRIVER_$(shell echo $(DRIVER_NAME) | tr '[a-z]' '[A-Z]') +EXTRA_CFLAGS += -DDRIVER_NAME=$(DRIVER_NAME) +EXTRA_CFLAGS += -DDRIVER_NAME_CAPS=$(shell echo $(DRIVER_NAME) | tr '[a-z]' '[A-Z]') +# standard flags for module builds +EXTRA_CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall +EXTRA_CFLAGS += -I$(KSRC)/include -I. +EXTRA_CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \ + echo "-DMODVERSIONS -DEXPORT_SYMTAB \ + -include $(KSRC)/include/linux/modversions.h") + +EXTRA_CFLAGS += $(CFLAGS_EXTRA) + +# depmod version for rpm builds +DEPVER := $(shell /sbin/depmod -V 2>/dev/null | \ + awk 'BEGIN {FS="."} NR==1 {print $$2}') + + +install: default + # remove all old versions of the driver + find $(INSTALL_MOD_PATH)/lib/modules/$(KVER) -name $(TARGET) -exec rm -f {} \; || true + find $(INSTALL_MOD_PATH)/lib/modules/$(KVER) -name $(TARGET).gz -exec rm -f {} \; || true + install -D -m 644 $(TARGET) $(INSTALL_MOD_PATH)$(INSTDIR)/$(TARGET) +ifeq (,$(INSTALL_MOD_PATH)) + /sbin/depmod -a $(KVER) || true +else + ifeq ($(DEPVER),1 ) + /sbin/depmod -r $(INSTALL_MOD_PATH) -a $(KVER) || true + else + /sbin/depmod -b $(INSTALL_MOD_PATH) -a -n $(KVER) > /dev/null || true + endif endif uninstall: - if [ -e $(ABSOLUTE_MOD_INSTDIR)/$(TARGET) ] ; then \ - rm -f $(ABSOLUTE_MOD_INSTDIR)/$(TARGET) ; \ + if [ -e $(INSTDIR)/$(TARGET) ] ; then \ + rm -f $(INSTDIR)/$(TARGET) ; \ fi - - rmdir $(ABSOLUTE_MOD_INSTDIR) 2&> /dev/null || true - - rm -f $(MODPROBE_CONF_FILE) ; /sbin/depmod -a + if [ -e $(MANDIR)/man$(MANSECTION)/$(MANFILE).gz ] ; then \ + rm -f $(MANDIR)/man$(MANSECTION)/$(MANFILE).gz ; \ + fi + +.PHONY: clean install + +clean: +ifeq ($(KOBJ),$(KSRC)) + $(MAKE) -C $(KSRC) SUBDIRS=$(shell pwd) clean +else + $(MAKE) -C $(KSRC) O=$(KOBJ) SUBDIRS=$(shell pwd) clean +endif + rm -rf $(TARGET) $(TARGET:.ko=.o) $(TARGET:.ko=.mod.c) $(TARGET:.ko=.mod.o) $(CFILES:.c=.o) $(MANFILE).gz .*cmd .tmp_versions + + +############## HUAWEI ####################### srpm: @sh create_srpm.sh $(DRIVER_NAME) -clean: - rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions *.ko.unsigned *.order *.symvers *.ko *.rpm x86_64 depend .depend dep: $(CC) $(EXTRA_CFLAGS) -M *.c > .depend
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor