move jffs2 end-of-filesystem detection to the generic 2.6 patches
[openwrt.git] / include / kernel.mk
1 ifneq ($(DUMP),1)
2 include $(TOPDIR)/.kernel.mk
3
4 KERNEL:=unknown
5 ifneq (,$(findstring 2.4.,$(LINUX_VERSION)))
6 KERNEL:=2.4
7 LINUX_KMOD_SUFFIX=o
8 endif
9 ifneq (,$(findstring 2.6.,$(LINUX_VERSION)))
10 KERNEL:=2.6
11 LINUX_KMOD_SUFFIX=ko
12 endif
13
14 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
15 -e 's/mipsel/mips/' \
16 -e 's/mipseb/mips/' \
17 -e 's/powerpc/ppc/' \
18 -e 's/sh[234]/sh/' \
19 -e 's/armeb/arm/' \
20 )
21
22 KERNEL_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
23 LINUX_DIR := $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
24
25 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
26 MODULES_DIR := $(KERNEL_BUILD_DIR)/modules/$(MODULES_SUBDIR)
27 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
28 KMOD_BUILD_DIR := $(KERNEL_BUILD_DIR)/linux-modules
29
30 LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
31 endif
32
33 # FIXME: remove this crap
34 define KMOD_template
35 ifeq ($$(strip $(4)),)
36 KDEPEND_$(1):=m
37 else
38 KDEPEND_$(1):=$($(4))
39 endif
40
41 IDEPEND_$(1):=kernel ($(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)) $(foreach pkg,$(5),", $(pkg)")
42
43 PKG_$(1) := $(PACKAGE_DIR)/kmod-$(2)_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
44 I_$(1) := $(KMOD_BUILD_DIR)/ipkg/$(2)
45
46 ifeq ($$(KDEPEND_$(1)),m)
47 ifneq ($(CONFIG_PACKAGE_KMOD_$(1)),)
48 TARGETS += $$(PKG_$(1))
49 endif
50 ifeq ($(CONFIG_PACKAGE_KMOD_$(1)),y)
51 INSTALL_TARGETS += $$(PKG_$(1))
52 endif
53 endif
54
55 $$(PKG_$(1)): $(LINUX_DIR)/.modules_done
56 rm -rf $$(I_$(1))
57 $(SCRIPT_DIR)/make-ipkg-dir.sh $$(I_$(1)) ../control/kmod-$(2).control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
58 echo "Depends: $$(IDEPEND_$(1))" >> $$(I_$(1))/CONTROL/control
59 ifneq ($(strip $(3)),)
60 mkdir -p $$(I_$(1))/lib/modules/$(LINUX_VERSION)
61 $(CP) $(3) $$(I_$(1))/lib/modules/$(LINUX_VERSION)
62 endif
63 ifneq ($(6),)
64 mkdir -p $$(I_$(1))/etc/modules.d
65 for module in $(7); do \
66 echo $$$$module >> $$(I_$(1))/etc/modules.d/$(6)-$(2); \
67 done
68 echo "#!/bin/sh" >> $$(I_$(1))/CONTROL/postinst
69 echo "[ -z \"\$$$$IPKG_INSTROOT\" ] || exit" >> $$(I_$(1))/CONTROL/postinst
70 echo ". /etc/functions.sh" >> $$(I_$(1))/CONTROL/postinst
71 echo "load_modules /etc/modules.d/$(6)-$(2)" >> $$(I_$(1))/CONTROL/postinst
72 chmod 0755 $$(I_$(1))/CONTROL/postinst
73 endif
74 $(8)
75 $(IPKG_BUILD) $$(I_$(1)) $(PACKAGE_DIR)
76 endef
77
This page took 0.051681 seconds and 5 git commands to generate.