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