Skip to content
This repository
tree: f71dd61933
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 71 lines (56 sloc) 2.276 kb
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
COMMIT_REV ?= $(shell git describe --always --abbrev=12)
KERNEL_SOURCE_VERSION ?= $(shell uname -r)
KERNEL_TREE ?= /lib/modules/$(KERNEL_SOURCE_VERSION)/build

EXTRA_CFLAGS += -I$(KERNEL_TREE)/drivers/md -I./ -DCOMMIT_REV="\"$(COMMIT_REV)\""
EXTRA_CFLAGS += -I$(KERNEL_TREE)/include/ -I$(KERNEL_TREE)/include/linux

# Check for RHEL/CentOS
RHEL5_VER ?= $(shell if [ -e /etc/redhat-release ]; then grep 5.[0-9] /etc/redhat-release; else false; fi)
RHEL5_SETUP :=
ifneq "$(RHEL5_VER)" ""
RHEL5_SETUP := rhel5-setup
RHEL5_SPEC := /usr/src/redhat/SPECS/kernel.spec
RHEL5_TREE := /usr/src/redhat/BUILD/kernel-2.6.18/linux-$(shell uname -r).$(shell uname -i)
RHEL5_SRC := /usr/src/kernels/$(shell uname -r)-$(shell uname -i)
KERNEL_TREE := $(RHEL5_TREE)
endif

# Check for OpenVZ (/proc/vz)
OPENVZ_VER ?= $(shell if [ -e /proc/vz ]; then grep 5.[0-9] /etc/redhat-release; else false; fi)
ifneq "$(OPENVZ_VER)" ""
        RHEL5_SPEC := /usr/src/redhat/SPECS/kernel-ovz.spec
        RHEL5_TREE := /usr/src/redhat/BUILD/ovzkernel-2.6.18/linux-$(shell uname -r).$(shell uname -i)
        KERNEL_TREE := $(RHEL5_TREE)
endif

obj-m += flashcache.o
flashcache-objs := flashcache_conf.o flashcache_main.o flashcache_subr.o flashcache_ioctl.o flashcache_procfs.o

.PHONY: all
all: modules utils

.PHONY: modules
modules: $(RHEL5_SETUP)
make -C $(KERNEL_TREE) M=$(PWD) modules V=0

.PHONY: utils
utils:
make -C utils all

.PHONY: modules_install
modules_install: modules
install -o root -g root -m 0755 -d $(DESTDIR)/lib/modules/$(KERNEL_SOURCE_VERSION)/extra/flashcache/
install -o root -g root -m 0755 flashcache.ko $(DESTDIR)/lib/modules/$(KERNEL_SOURCE_VERSION)/extra/flashcache/
depmod -a

.PHONY: utils_install
utils_install: utils
make -C utils install

.PHONY: ocf_install
ocf_install:
make -C ocf install

.PHONY: install
install: modules_install utils_install ocf_install

.PHONY: clean
clean:
make -C $(KERNEL_TREE) M=$(PWD) clean
make -C utils clean

.PHONY: rhel5-setup
rhel5-setup: $(RHEL5_TREE)
make -C $(RHEL5_TREE) oldconfig ; \
make -C $(RHEL5_TREE) prepare modules_prepare
ln -s -f $(RHEL5_SRC)/Module.symvers $(RHEL5_TREE)/Module.symvers

$(RHEL5_TREE):
rpmbuild -bp --target=`uname -m` $(RHEL5_SPEC) 2>&1 | tee `dirname $(RHEL5_SPEC)`/prep.log
Something went wrong with that request. Please try again.