Small changes to make linux/tip happy
[apc.git] / mod / Makefile
blob25fd15e700f846333b73697ef5e12bc3b87da6af
1 .PHONY: itc-all itc-build-module itc-install-module
3 itc-all:: itc-build-module
5 KVERSION ?= $(shell uname -r)
6 KDIR ?= /lib/modules/$(KVERSION)/build
7 OUTDIR ?= /lib/modules/$(KVERSION)/misc
9 MM := $(shell echo $(KVERSION) | cut -d. -f'1 2')
11 ifeq ($(MM),2.4)
12 KMOD_SUFFIX := .o
13 K24 := defined
14 else
15 ifeq ($(MM),2.6)
16 KMOD_SUFFIX := .ko
17 else
18 $(error Only 2.4 and 2.6 kernel series are supported. You have "$(KVERSION)")
19 endif
20 endif
22 itc-objs := itc-mod.o
24 hack := $(shell $(CC) -print-search-dirs | sed -n 's;^install: \(.*\);\1include;p;q')
25 export CPATH:=${CPATH}:${hack}
27 obj-m := itc.o
29 ifdef K24
30 itc.o: $(itc-objs)
31 $(LD) $(EXTRA_LDFLAGS) -o $@ -r $(itc-objs)
33 include $(KDIR)/Rules.make
34 endif
36 $(KDIR)/Makefile:
37 @echo Cannot build module, kernel sources are probably not installed
38 @exit 1
40 $(KDIR)/.config:
41 @echo Cannot build module, kernel is not configured
42 @exit 1
44 itc-build-module:: $(KDIR)/Makefile $(KDIR)/.config
45 $(MAKE) -C $(KDIR) modules SUBDIRS=$(CURDIR) M=$(CURDIR)
47 itc-install-module:: itc-build-module
48 mkdir -p $(OUTDIR)
49 install -m 0400 -o 0 -g 0 itc$(KMOD_SUFFIX) $(OUTDIR)