port generic and ixp4xx kernel patches to 2.6.27 (compiles except for iptables, but...
[openwrt/openwrt.git] / include / kernel-build.mk
1 #
2 # Copyright (C) 2006-2007 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(INCLUDE_DIR)/host.mk
8 include $(INCLUDE_DIR)/prereq.mk
9
10 ifneq ($(DUMP),1)
11 all: compile
12 endif
13
14 export QUILT=1
15 STAMP_PREPARED:=$(LINUX_DIR)/.prepared
16 STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
17 include $(INCLUDE_DIR)/download.mk
18 include $(INCLUDE_DIR)/quilt.mk
19 include $(INCLUDE_DIR)/kernel-defaults.mk
20
21 define Kernel/Prepare
22 $(call Kernel/Prepare/Default)
23 endef
24
25 define Kernel/Configure
26 $(call Kernel/Configure/Default)
27 endef
28
29 define Kernel/CompileModules
30 $(call Kernel/CompileModules/Default)
31 endef
32
33 define Kernel/CompileImage
34 $(call Kernel/CompileImage/Default)
35 endef
36
37 define Kernel/Clean
38 $(call Kernel/Clean/Default)
39 endef
40
41 define Download/kernel
42 URL:=$(LINUX_SITE)
43 FILE:=$(LINUX_SOURCE)
44 MD5SUM:=$(LINUX_KERNEL_MD5SUM)
45 endef
46
47 define BuildKernel
48 $(if $(QUILT),$(Build/Quilt))
49 $(if $(LINUX_SITE),$(call Download,kernel))
50
51 $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
52 -rm -rf $(KERNEL_BUILD_DIR)
53 -mkdir -p $(KERNEL_BUILD_DIR)
54 $(Kernel/Prepare)
55 touch $$@
56
57 $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_CONFIG) $(GENERIC_LINUX_CONFIG) $(TOPDIR)/.config
58 $(Kernel/Configure)
59 touch $$@
60
61 $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
62 $(Kernel/CompileModules)
63 touch $$@
64
65 $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) FORCE
66 $(Kernel/CompileImage)
67 touch $$@
68
69 mostlyclean: FORCE
70 $(Kernel/Clean)
71
72 define BuildKernel
73 endef
74
75 download: $(DL_DIR)/$(LINUX_SOURCE)
76 prepare: $(STAMP_CONFIGURED)
77 compile: $(LINUX_DIR)/.modules
78 $(MAKE) -C image compile TARGET_BUILD=
79
80 oldconfig menuconfig: $(STAMP_PREPARED) FORCE
81 [ -e "$(LINUX_CONFIG)" ] || touch "$(LINUX_CONFIG)"
82 $(LINUX_CONFCMD) > $(LINUX_DIR)/.config
83 touch $(LINUX_CONFIG)
84 $(_SINGLE)$(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $$@
85 $(SCRIPT_DIR)/kconfig.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(if $(LINUX_SUBCONFIG),$(LINUX_SUBCONFIG),$(LINUX_CONFIG))
86 $(Kernel/Configure)
87
88 install: $(LINUX_DIR)/.image
89 +$(MAKE) -C image compile install TARGET_BUILD=
90
91 clean: FORCE
92 rm -rf $(KERNEL_BUILD_DIR)
93
94 image-prereq:
95 @+$(NO_TRACE_MAKE) -s -C image prereq TARGET_BUILD=
96
97 prereq: image-prereq
98
99 endef