allow platform support directories to add and modify kernel module packages
[openwrt.git] / package / kernel / Makefile
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 # $Id$
8
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11
12 PKG_NAME:=kernel
13 PKG_VERSION:=$(LINUX_VERSION)-$(BOARD)
14 PKG_RELEASE:=$(LINUX_RELEASE)
15
16 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/packages
17
18 include $(INCLUDE_DIR)/package.mk
19 ifeq ($(DUMP),)
20 -include $(LINUX_DIR)/.config
21 NF_KMOD:=1
22 include $(INCLUDE_DIR)/netfilter.mk
23 endif
24
25 define Build/Prepare
26 mkdir -p $(PKG_BUILD_DIR)
27 endef
28
29 define Build/Compile
30 endef
31
32 define KernelPackage/Defaults
33 FILES:=
34 KCONFIG:=m
35 AUTOLOAD:=
36 endef
37
38 define ModuleAutoLoad
39 export modules=; \
40 add_module() { \
41 mkdir -p $(2)/etc/modules.d; \
42 echo "$$$$$$$$2" > $(2)/etc/modules.d/$$$$$$$$1-$(1); \
43 modules="$$$$$$$${modules:+$$$$$$$$modules }$$$$$$$$1-$(1)"; \
44 }; \
45 $(3) \
46 if [ -n "$$$$$$$$modules" ]; then \
47 mkdir -p $(2)/etc/modules.d; \
48 echo "#!/bin/sh" > $(2)/CONTROL/postinst; \
49 echo "[ -z \"\$$$$$$$$IPKG_INSTROOT\" ] || exit 0" >> $(2)/CONTROL/postinst; \
50 echo ". /etc/functions.sh" >> $(2)/CONTROL/postinst; \
51 echo "load_modules $$$$$$$$modules" >> $(2)/CONTROL/postinst; \
52 chmod 0755 $(2)/CONTROL/postinst; \
53 fi
54 endef
55
56
57 define KernelPackage
58 NAME:=$(1)
59 $(eval $(call KernelPackage/Defaults))
60 $(eval $(call KernelPackage/$(1)))
61 $(eval $(call KernelPackage/$(1)/$(KERNEL)))
62 $(eval $(call KernelPackage/$(1)/$(BOARD)-$(KERNEL)))
63
64 define Package/kmod-$(1)
65 TITLE:=$(TITLE)
66 SECTION:=kernel
67 CATEGORY:=Kernel modules
68 DEFAULT:=m
69 DESCRIPTION:=$(DESCRIPTION)
70 EXTRA_DEPENDS:='kernel (=$(PKG_VERSION)-$(PKG_RELEASE))'
71 $(call KernelPackage/$(1))
72 $(call KernelPackage/$(1)/$(KERNEL))
73 $(call KernelPackage/$(1)/$(BOARD)-$(KERNEL))
74 endef
75
76 ifeq ($(findstring m,$(KCONFIG)),m)
77 ifneq ($(strip $(FILES)),)
78 define Package/kmod-$(1)/install
79 mkdir -p $$(1)/lib/modules/$(LINUX_VERSION)
80 $(CP) $$(FILES) $$(1)/lib/modules/$(LINUX_VERSION)/
81 $(call ModuleAutoLoad,$(1),$$(1),$(AUTOLOAD))
82 endef
83 endif
84 endif
85 $$(eval $$(call BuildPackage,kmod-$(1)))
86 endef
87
88 define AutoLoad
89 add_module $(1) "$(2)";
90 endef
91
92 include $(TOPDIR)/target/linux/*/modules.mk
93 include ./modules/*.mk
This page took 0.042449 seconds and 5 git commands to generate.