move $(MAKE) packages from .linux-compile: to compile:
[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 else
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
25 endif
26
27 ifeq ($(KERNEL),2.6)
28 LINUX_KMOD_SUFFIX=ko
29 else
30 LINUX_KMOD_SUFFIX=o
31 endif
32
33 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
34 -e 's/mipsel/mips/' \
35 -e 's/mipseb/mips/' \
36 -e 's/powerpc/ppc/' \
37 -e 's/sh[234]/sh/' \
38 -e 's/armeb/arm/' \
39 )
40
41 KERNELNAME=
42 ifneq (,$(findstring x86,$(BOARD)))
43 KERNELNAME="bzImage"
44 endif
45 ifneq (,$(findstring ppc,$(BOARD)))
46 KERNELNAME="uImage"
47 endif
48
49 ifneq (,$(findstring uml,$(BOARD)))
50 LINUX_KARCH:=um
51 KERNEL_CC:=$(HOSTCC)
52 KERNEL_CROSS:=
53 else
54 KERNEL_CC:=$(TARGET_CC)
55 KERNEL_CROSS:=$(TARGET_CROSS)
56 endif
57
58 KERNEL_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
59 LINUX_DIR := $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
60
61 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
62 MODULES_DIR := $(KERNEL_BUILD_DIR)/modules/$(MODULES_SUBDIR)
63 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
64 KMOD_BUILD_DIR := $(KERNEL_BUILD_DIR)/linux-modules
65
66 LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
67 endif
68
69 # FIXME: remove this crap
70 define KMOD_template
71 ifeq ($$(strip $(4)),)
72 KDEPEND_$(1):=m
73 else
74 KDEPEND_$(1):=$($(4))
75 endif
76
77 IDEPEND_$(1):=kernel ($(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)) $(foreach pkg,$(5),", $(pkg)")
78
79 PKG_$(1) := $(PACKAGE_DIR)/kmod-$(2)_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
80 I_$(1) := $(KMOD_BUILD_DIR)/ipkg/$(2)
81
82 ifeq ($$(KDEPEND_$(1)),m)
83 ifneq ($$(CONFIG_PACKAGE_KMOD_$(1)),)
84 TARGETS += $$(PKG_$(1))
85 endif
86 ifeq ($$(CONFIG_PACKAGE_KMOD_$(1)),y)
87 INSTALL_TARGETS += $$(PKG_$(1))
88 endif
89 endif
90
91 $$(PKG_$(1)): $(LINUX_DIR)/.modules_done
92 rm -rf $$(I_$(1))
93 $(SCRIPT_DIR)/make-ipkg-dir.sh $$(I_$(1)) ../control/kmod-$(2).control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
94 echo "Depends: $$(IDEPEND_$(1))" >> $$(I_$(1))/CONTROL/control
95 ifneq ($(strip $(3)),)
96 mkdir -p $$(I_$(1))/lib/modules/$(LINUX_VERSION)
97 $(CP) $(3) $$(I_$(1))/lib/modules/$(LINUX_VERSION)
98 endif
99 ifneq ($(6),)
100 mkdir -p $$(I_$(1))/etc/modules.d
101 for module in $(7); do \
102 echo $$$$module >> $$(I_$(1))/etc/modules.d/$(6)-$(2); \
103 done
104 echo "#!/bin/sh" >> $$(I_$(1))/CONTROL/postinst
105 echo "[ -z \"\$$$$IPKG_INSTROOT\" ] || exit" >> $$(I_$(1))/CONTROL/postinst
106 echo ". /etc/functions.sh" >> $$(I_$(1))/CONTROL/postinst
107 echo "load_modules /etc/modules.d/$(6)-$(2)" >> $$(I_$(1))/CONTROL/postinst
108 chmod 0755 $$(I_$(1))/CONTROL/postinst
109 endif
110 $(8)
111 $(IPKG_BUILD) $$(I_$(1)) $(PACKAGE_DIR)
112 endef
113
This page took 0.042063 seconds and 5 git commands to generate.