v0.95
[apc.git] / mod / Makefile
blobd8d74bb28bcdf4bcaf390b2a96fa923455ac1b27
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 ifdef TOPDIR
25 obj-m := itc.o
26 hack := $(shell $(CC) -print-search-dirs \
27 | sed -n 's;^install: \(.*\);\1/include;p;q')
28 export CPATH := ${CPATH}:${hack}
29 endif
31 ifdef K24
32 itc.o: $(itc-objs)
33 $(LD) $(EXTRA_LDFLAGS) -o $@ -r $(itc-objs)
35 include $(KDIR)/Rules.make
36 endif
38 $(KDIR)/Makefile:
39 @echo Cannot build module, kernel sources are probably not installed
40 @exit 1
42 $(KDIR)/.config:
43 @echo Cannot build module, kernel is not configured
44 @exit 1
46 itc-build-module:: $(KDIR)/Makefile $(KDIR)/.config
47 $(MAKE) -C $(KDIR) modules SUBDIRS=$(CURDIR) M=$(CURDIR)
49 itc-install-module:: itc-build-module
50 mkdir -p $(OUTDIR)
51 install -m 0400 -o 0 -g 0 itc$(KMOD_SUFFIX) $(OUTDIR)