check for empty patch directories
[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 # oops, old .kernel.config; rebuild it (hiding the misleading errors this produces)
23 $(warning rebuilding .kernel.mk)
24 $(TOPDIR)/.kernel.mk: FORCE
25 @$(MAKE) -C $(TOPDIR)/target/linux/$(BOARD)-$(KERNEL) $@ &>/dev/null
26 endif
27
28 ifeq ($(KERNEL),2.6)
29 LINUX_KMOD_SUFFIX=ko
30 else
31 LINUX_KMOD_SUFFIX=o
32 endif
33
34 KERNELNAME=
35 ifneq (,$(findstring x86,$(BOARD)))
36 KERNELNAME="bzImage"
37 endif
38 ifneq (,$(findstring ppc,$(BOARD)))
39 KERNELNAME="uImage"
40 endif
41
42 ifneq (,$(findstring uml,$(BOARD)))
43 LINUX_KARCH:=um
44 KERNEL_CC:=$(HOSTCC)
45 KERNEL_CROSS:=
46 else
47 KERNEL_CC:=$(TARGET_CC)
48 KERNEL_CROSS:=$(TARGET_CROSS)
49 endif
50
51 KERNEL_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
52 LINUX_DIR := $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
53
54 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
55 MODULES_DIR := $(KERNEL_BUILD_DIR)/modules/$(MODULES_SUBDIR)
56 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
57 KMOD_BUILD_DIR := $(KERNEL_BUILD_DIR)/linux-modules
58
59 LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
60 endif
61
62 # FIXME: remove this crap
63 define KMOD_template
64 ifeq ($$(strip $(4)),)
65 KDEPEND_$(1):=m
66 else
67 KDEPEND_$(1):=$($(4))
68 endif
69
70 IDEPEND_$(1):=kernel ($(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)) $(foreach pkg,$(5),", $(pkg)")
71
72 PKG_$(1) := $(PACKAGE_DIR)/kmod-$(2)_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
73 I_$(1) := $(KMOD_BUILD_DIR)/ipkg/$(2)
74
75 ifeq ($$(KDEPEND_$(1)),m)
76 ifneq ($$(CONFIG_PACKAGE_KMOD_$(1)),)
77 TARGETS += $$(PKG_$(1))
78 endif
79 ifeq ($$(CONFIG_PACKAGE_KMOD_$(1)),y)
80 INSTALL_TARGETS += $$(PKG_$(1))
81 endif
82 endif
83
84 $$(PKG_$(1)): $(LINUX_DIR)/.modules_done
85 rm -rf $$(I_$(1))
86 $(SCRIPT_DIR)/make-ipkg-dir.sh $$(I_$(1)) ../control/kmod-$(2).control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
87 echo "Depends: $$(IDEPEND_$(1))" >> $$(I_$(1))/CONTROL/control
88 ifneq ($(strip $(3)),)
89 mkdir -p $$(I_$(1))/lib/modules/$(LINUX_VERSION)
90 $(CP) $(3) $$(I_$(1))/lib/modules/$(LINUX_VERSION)
91 endif
92 ifneq ($(6),)
93 mkdir -p $$(I_$(1))/etc/modules.d
94 for module in $(7); do \
95 echo $$$$module >> $$(I_$(1))/etc/modules.d/$(6)-$(2); \
96 done
97 echo "#!/bin/sh" >> $$(I_$(1))/CONTROL/postinst
98 echo "[ -z \"\$$$$IPKG_INSTROOT\" ] || exit" >> $$(I_$(1))/CONTROL/postinst
99 echo ". /etc/functions.sh" >> $$(I_$(1))/CONTROL/postinst
100 echo "load_modules /etc/modules.d/$(6)-$(2)" >> $$(I_$(1))/CONTROL/postinst
101 chmod 0755 $$(I_$(1))/CONTROL/postinst
102 endif
103 $(8)
104 $(IPKG_BUILD) $$(I_$(1)) $(PACKAGE_DIR)
105 endef
106
This page took 0.065436 seconds and 5 git commands to generate.