major target cleanup. it is now possible to have subtargets that can override many...
[openwrt/staging/florian.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 override MAKEFLAGS=
12 endif
13
14 ifneq ($(DUMP),1)
15 all: compile
16 endif
17
18 STAMP_PREPARED:=$(LINUX_DIR)/.prepared
19 STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
20 include $(INCLUDE_DIR)/quilt.mk
21 include $(INCLUDE_DIR)/kernel-defaults.mk
22
23 define Kernel/Prepare
24 $(call Kernel/Prepare/Default)
25 endef
26
27 define Kernel/Configure
28 $(call Kernel/Configure/Default)
29 endef
30
31 define Kernel/CompileModules
32 $(call Kernel/CompileModules/Default)
33 endef
34
35 define Kernel/CompileImage
36 $(call Kernel/CompileImage/Default)
37 endef
38
39 define Kernel/Clean
40 $(call Kernel/Clean/Default)
41 endef
42
43 define BuildKernel
44 ifneq ($(LINUX_SITE),)
45 $(DL_DIR)/$(LINUX_SOURCE):
46 -mkdir -p $(DL_DIR)
47 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
48 endif
49
50 $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
51 -rm -rf $(KERNEL_BUILD_DIR)
52 -mkdir -p $(KERNEL_BUILD_DIR)
53 $(Kernel/Prepare)
54 touch $$@
55
56 $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_CONFIG) $(GENERIC_LINUX_CONFIG) $(TOPDIR)/.config
57 $(Kernel/Configure)
58 touch $$@
59
60 $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
61 $(Kernel/CompileModules)
62 touch $$@
63
64 $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) FORCE
65 $(Kernel/CompileImage)
66 touch $$@
67
68 mostlyclean: FORCE
69 $(Kernel/Clean)
70
71 define BuildKernel
72 endef
73
74 download: $(DL_DIR)/$(LINUX_SOURCE)
75 prepare: $(STAMP_CONFIGURED)
76 compile: $(LINUX_DIR)/.modules
77 $(MAKE) -C image compile TARGET_BUILD=
78
79 oldconfig menuconfig: $(STAMP_PREPARED) FORCE
80 $(Kernel/Configure)
81 $(LINUX_CONFCMD) > $(LINUX_DIR)/.config
82 $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $@
83 $(SCRIPT_DIR)/kconfig.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG)
84
85 install: $(LINUX_DIR)/.image
86 TARGET_BUILD="" $(MAKE) -C image compile install
87
88 clean: FORCE
89 rm -rf $(KERNEL_BUILD_DIR)
90
91 rebuild: FORCE
92 @$(MAKE) mostlyclean
93 @if [ -f $(LINUX_KERNEL) ]; then \
94 $(MAKE) clean; \
95 fi
96 @$(MAKE) compile
97
98 image-prereq:
99 $(SUBMAKE) -s -C image prereq TARGET_BUILD=
100
101 prereq: image-prereq
102
103 endef