add lzma kernel compression support for au1000
[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 KernelPackage/Defaults))
79 $(eval $(call KernelPackage/$(1)))
80 $(eval $(call KernelPackage/$(1)/$(KERNEL)))
81 $(eval $(call KernelPackage/$(1)/$(BOARD)-$(KERNEL)))
82
83 define Package/kmod-$(1)
84 TITLE:=$(TITLE)
85 SECTION:=kernel
86 CATEGORY:=Kernel modules
87 DEFAULT:=$(KMOD_DEFAULT)
88 DESCRIPTION:=$(DESCRIPTION)
89 EXTRA_DEPENDS:='kernel (=$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE))'
90 $(call KernelPackage/$(1))
91 $(call KernelPackage/$(1)/$(KERNEL))
92 $(call KernelPackage/$(1)/$(BOARD)-$(KERNEL))
93 endef
94
95 ifeq ($(findstring m,$(KCONFIG)),m)
96 ifneq ($(strip $(FILES)),)
97 define Package/kmod-$(1)/install
98 mkdir -p $$(1)/lib/modules/$(LINUX_VERSION)
99 $(CP) $$(FILES) $$(1)/lib/modules/$(LINUX_VERSION)/
100 $(call ModuleAutoLoad,$(1),$$(1),$(AUTOLOAD))
101 $(call KernelPackage/$(1)/install,$$(1))
102 endef
103 endif
104 endif
105 $$(eval $$(call BuildPackage,kmod-$(1)))
106 endef
107
108 define AutoLoad
109 add_module $(1) "$(2)";
110 endef
111
This page took 0.064556 seconds and 5 git commands to generate.