2 # Copyright (C) 2006 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
10 LINUX_VERSION:=<LINUX_VERSION>
13 include $(TOPDIR)/.kernel.mk
14 include $(INCLUDE_DIR)/target.mk
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 RELEASE:=$(CONFIG_RELEASE)
21 # oops, old .kernel.config; rebuild it (hiding the misleading errors this produces)
22 $(warning rebuilding .kernel.mk)
23 $(TOPDIR)/.kernel.mk: FORCE
24 @$(MAKE) -C $(TOPDIR)/target/linux/$(BOARD)-$(KERNEL) $@ &>/dev/null
33 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
42 ifneq (,$(findstring x86,$(BOARD)))
46 ifneq (,$(findstring uml,$(BOARD)))
51 KERNEL_CC:=$(TARGET_CC)
52 KERNEL_CROSS:=$(TARGET_CROSS)
55 KERNEL_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
56 LINUX_DIR := $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
58 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
59 MODULES_DIR := $(KERNEL_BUILD_DIR)/modules/$(MODULES_SUBDIR)
60 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
61 KMOD_BUILD_DIR := $(KERNEL_BUILD_DIR)/linux-modules
63 LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
66 # FIXME: remove this crap
68 ifeq ($$(strip $(4)),)
74 IDEPEND_$(1):=kernel ($(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)) $(foreach pkg,$(5),", $(pkg)")
76 PKG_$(1) := $(PACKAGE_DIR)/kmod-$(2)_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
77 I_$(1) := $(KMOD_BUILD_DIR)/ipkg/$(2)
79 ifeq ($$(KDEPEND_$(1)),m)
80 ifneq ($$(CONFIG_PACKAGE_KMOD_$(1)),)
81 TARGETS += $$(PKG_$(1))
83 ifeq ($$(CONFIG_PACKAGE_KMOD_$(1)),y)
84 INSTALL_TARGETS += $$(PKG_$(1))
88 $$(PKG_$(1)): $(LINUX_DIR)/.modules_done
90 $(SCRIPT_DIR)/make-ipkg-dir.sh $$(I_$(1)) ../control/kmod-$(2).control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
91 echo "Depends: $$(IDEPEND_$(1))" >> $$(I_$(1))/CONTROL/control
92 ifneq ($(strip $(3)),)
93 mkdir -p $$(I_$(1))/lib/modules/$(LINUX_VERSION)
94 $(CP) $(3) $$(I_$(1))/lib/modules/$(LINUX_VERSION)
97 mkdir -p $$(I_$(1))/etc/modules.d
98 for module in $(7); do \
99 echo $$$$module >> $$(I_$(1))/etc/modules.d/$(6)-$(2); \
101 echo "#!/bin/sh" >> $$(I_$(1))/CONTROL/postinst
102 echo "[ -z \"\$$$$IPKG_INSTROOT\" ] || exit" >> $$(I_$(1))/CONTROL/postinst
103 echo ". /etc/functions.sh" >> $$(I_$(1))/CONTROL/postinst
104 echo "load_modules /etc/modules.d/$(6)-$(2)" >> $$(I_$(1))/CONTROL/postinst
105 chmod 0755 $$(I_$(1))/CONTROL/postinst
108 $(IPKG_BUILD) $$(I_$(1)) $(PACKAGE_DIR)