reorganize nat helper packages, move ftp and irc nat to a package that is enabled...
[openwrt.git] / include / kernel.mk
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 ifeq ($(DUMP),1)
9 KERNEL?=<KERNEL>
10 BOARD?=<BOARD>
11 LINUX_VERSION?=<LINUX_VERSION>
12 else
13 include $(INCLUDE_DIR)/target.mk
14
15 ifeq ($(KERNEL),2.6)
16 LINUX_KMOD_SUFFIX=ko
17 else
18 LINUX_KMOD_SUFFIX=o
19 endif
20
21 ifneq (,$(findstring uml,$(BOARD)))
22 KERNEL_CC:=$(HOSTCC)
23 KERNEL_CROSS:=
24 else
25 KERNEL_CC:=$(TARGET_CC)
26 KERNEL_CROSS:=$(TARGET_CROSS)
27 endif
28
29 KERNEL_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
30 LINUX_DIR := $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
31
32 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
33 MODULES_DIR := $(KERNEL_BUILD_DIR)/modules/$(MODULES_SUBDIR)
34 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
35
36 LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
37
38 LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.bz2
39 LINUX_SITE:=http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
40 http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
41 http://www.kernel.org/pub/linux/kernel/v$(KERNEL) \
42 http://www.de.kernel.org/pub/linux/kernel/v$(KERNEL)
43
44 endif
45
46
47 define KernelPackage/Defaults
48 FILES:=
49 KCONFIG:=m
50 AUTOLOAD:=
51 endef
52
53 define ModuleAutoLoad
54 export modules=; \
55 add_module() { \
56 mkdir -p $(2)/etc/modules.d; \
57 ( \
58 for mod in $$$$$$$$2; do \
59 getvar mod; \
60 done \
61 ) > $(2)/etc/modules.d/$$$$$$$$1-$(1); \
62 modules="$$$$$$$${modules:+$$$$$$$$modules }$$$$$$$$1-$(1)"; \
63 }; \
64 $(3) \
65 if [ -n "$$$$$$$$modules" ]; then \
66 mkdir -p $(2)/etc/modules.d; \
67 echo "#!/bin/sh" > $(2)/CONTROL/postinst; \
68 echo "[ -z \"\$$$$$$$$IPKG_INSTROOT\" ] || exit 0" >> $(2)/CONTROL/postinst; \
69 echo ". /etc/functions.sh" >> $(2)/CONTROL/postinst; \
70 echo "load_modules $$$$$$$$modules" >> $(2)/CONTROL/postinst; \
71 chmod 0755 $(2)/CONTROL/postinst; \
72 fi
73 endef
74
75
76 define KernelPackage
77 NAME:=$(1)
78 $(eval $(call Package/Default))
79 $(eval $(call KernelPackage/Defaults))
80 $(eval $(call KernelPackage/$(1)))
81 $(eval $(call KernelPackage/$(1)/$(KERNEL)))
82 $(eval $(call KernelPackage/$(1)/$(BOARD)-$(KERNEL)))
83
84 define Package/kmod-$(1)
85 TITLE:=$(TITLE)
86 SECTION:=kernel
87 CATEGORY:=Kernel modules
88 DEFAULT:=$(KMOD_DEFAULT)
89 DESCRIPTION:=$(DESCRIPTION)
90 EXTRA_DEPENDS:='kernel (=$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE))'
91 $(call KernelPackage/$(1))
92 $(call KernelPackage/$(1)/$(KERNEL))
93 $(call KernelPackage/$(1)/$(BOARD)-$(KERNEL))
94 endef
95
96 ifeq ($(findstring m,$(KCONFIG)),m)
97 ifneq ($(strip $(FILES)),)
98 define Package/kmod-$(1)/install
99 mkdir -p $$(1)/lib/modules/$(LINUX_VERSION)
100 $(CP) $$(FILES) $$(1)/lib/modules/$(LINUX_VERSION)/
101 $(call ModuleAutoLoad,$(1),$$(1),$(AUTOLOAD))
102 $(call KernelPackage/$(1)/install,$$(1))
103 endef
104 endif
105 endif
106 $$(eval $$(call BuildPackage,kmod-$(1)))
107 endef
108
109 define AutoLoad
110 add_module $(1) "$(2)";
111 endef
112
This page took 0.047096 seconds and 5 git commands to generate.