Add automake-1.4 host tool dependency to linux-atm (#910)
[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 ifeq ($(DUMP),1)
8 KERNEL:=<KERNEL>
9 BOARD:=<BOARD>
10 LINUX_VERSION:=<LINUX_VERSION>
11 else
12
13 include $(TOPDIR)/.kernel.mk
14 include $(INCLUDE_DIR)/target.mk
15
16 # check to see if .kernel.mk matches target.mk
17 ifeq ($(CONFIG_BOARD)-$(CONFIG_KERNEL),$(BOARD)-$(KERNEL))
18 LINUX_VERSION:=$(CONFIG_LINUX_VERSION)
19 LINUX_RELEASE:=$(CONFIG_LINUX_RELEASE)
20 LINUX_KARCH:=$(CONFIG_LINUX_KARCH)
21 else
22 ifneq ($(KERNEL_BUILD),1)
23 # oops, old .kernel.config; rebuild it (hiding the misleading errors this produces)
24 $(warning rebuilding .kernel.mk)
25 $(TOPDIR)/.kernel.mk: FORCE
26 @$(MAKE) -C $(TOPDIR)/target/linux/$(BOARD)-$(KERNEL) $@ &>/dev/null
27 endif
28 endif
29
30 ifeq ($(KERNEL),2.6)
31 LINUX_KMOD_SUFFIX=ko
32 else
33 LINUX_KMOD_SUFFIX=o
34 endif
35
36 ifneq (,$(findstring uml,$(BOARD)))
37 KERNEL_CC:=$(HOSTCC)
38 KERNEL_CROSS:=
39 else
40 KERNEL_CC:=$(TARGET_CC)
41 KERNEL_CROSS:=$(TARGET_CROSS)
42 endif
43
44 KERNEL_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
45 LINUX_DIR := $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
46
47 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
48 MODULES_DIR := $(KERNEL_BUILD_DIR)/modules/$(MODULES_SUBDIR)
49 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
50
51 LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
52 endif
53
54
55 define KernelPackage/Defaults
56 FILES:=
57 KCONFIG:=m
58 AUTOLOAD:=
59 endef
60
61 define ModuleAutoLoad
62 export modules=; \
63 add_module() { \
64 mkdir -p $(2)/etc/modules.d; \
65 ( \
66 for mod in $$$$$$$$2; do \
67 getvar mod; \
68 done \
69 ) > $(2)/etc/modules.d/$$$$$$$$1-$(1); \
70 modules="$$$$$$$${modules:+$$$$$$$$modules }$$$$$$$$1-$(1)"; \
71 }; \
72 $(3) \
73 if [ -n "$$$$$$$$modules" ]; then \
74 mkdir -p $(2)/etc/modules.d; \
75 echo "#!/bin/sh" > $(2)/CONTROL/postinst; \
76 echo "[ -z \"\$$$$$$$$IPKG_INSTROOT\" ] || exit 0" >> $(2)/CONTROL/postinst; \
77 echo ". /etc/functions.sh" >> $(2)/CONTROL/postinst; \
78 echo "load_modules $$$$$$$$modules" >> $(2)/CONTROL/postinst; \
79 chmod 0755 $(2)/CONTROL/postinst; \
80 fi
81 endef
82
83
84 define KernelPackage
85 NAME:=$(1)
86 $(eval $(call KernelPackage/Defaults))
87 $(eval $(call KernelPackage/$(1)))
88 $(eval $(call KernelPackage/$(1)/$(KERNEL)))
89 $(eval $(call KernelPackage/$(1)/$(BOARD)-$(KERNEL)))
90
91 define Package/kmod-$(1)
92 TITLE:=$(TITLE)
93 SECTION:=kernel
94 CATEGORY:=Kernel modules
95 DEFAULT:=m
96 DESCRIPTION:=$(DESCRIPTION)
97 EXTRA_DEPENDS:='kernel (=$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE))'
98 $(call KernelPackage/$(1))
99 $(call KernelPackage/$(1)/$(KERNEL))
100 $(call KernelPackage/$(1)/$(BOARD)-$(KERNEL))
101 endef
102
103 ifeq ($(findstring m,$(KCONFIG)),m)
104 ifneq ($(strip $(FILES)),)
105 define Package/kmod-$(1)/install
106 mkdir -p $$(1)/lib/modules/$(LINUX_VERSION)
107 $(CP) $$(FILES) $$(1)/lib/modules/$(LINUX_VERSION)/
108 $(call ModuleAutoLoad,$(1),$$(1),$(AUTOLOAD))
109 $(call KernelPackage/$(1)/install,$$(1))
110 endef
111 endif
112 endif
113 $$(eval $$(call BuildPackage,kmod-$(1)))
114 endef
115
116 define AutoLoad
117 add_module $(1) "$(2)";
118 endef
119
This page took 0.056596 seconds and 5 git commands to generate.