move TARGET_* flags from ./include/package-default.mk to ./rules.mk, remove EXTRA_...
[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 KERNEL_BUILD:=1
8
9 include $(INCLUDE_DIR)/host.mk
10 include $(INCLUDE_DIR)/kernel.mk
11 include $(INCLUDE_DIR)/prereq.mk
12
13 override MAKEFLAGS=
14
15 GENERIC_LINUX_CONFIG:=$(GENERIC_PLATFORM_DIR)/config-$(shell [ -f "$(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER)" ] && echo "$(KERNEL_PATCHVER)" || echo template )
16 LINUX_CONFIG_DIR ?= ./config$(shell [ -d "./config-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
17 LINUX_CONFIG ?= $(LINUX_CONFIG_DIR)/default
18
19 ifneq ($(DUMP),)
20 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(BOARD)-$(KERNEL)
21 $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG)
22 $(SCRIPT_DIR)/config.pl + $^ > $@
23 -include $(TMP_CONFIG)
24 .SILENT: $(TMP_CONFIG)
25 endif
26
27 ifneq ($(CONFIG_PCI),)
28 FEATURES += pci
29 endif
30 ifneq ($(CONFIG_USB),)
31 FEATURES += usb
32 endif
33 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
34 FEATURES += pcmcia
35 endif
36
37 # remove duplicates
38 FEATURES:=$(sort $(FEATURES))
39
40 ifeq ($(DUMP),1)
41 all: dumpinfo
42 else
43 all: compile
44 endif
45
46 ifneq (,$(findstring uml,$(BOARD)))
47 LINUX_KARCH:=um
48 else
49 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
50 -e 's/mipsel/mips/' \
51 -e 's/mipseb/mips/' \
52 -e 's/powerpc/ppc/' \
53 -e 's/sh[234]/sh/' \
54 -e 's/armeb/arm/' \
55 )
56 endif
57
58 STAMP_PREPARED:=$(LINUX_DIR)/.prepared
59 STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
60 include $(INCLUDE_DIR)/quilt.mk
61 include $(INCLUDE_DIR)/kernel-defaults.mk
62
63 define Kernel/Prepare
64 $(call Kernel/Prepare/Default)
65 endef
66
67 define Kernel/Configure
68 $(call Kernel/Configure/Default)
69 endef
70
71 define Kernel/CompileModules
72 $(call Kernel/CompileModules/Default)
73 endef
74
75 define Kernel/CompileImage
76 $(call Kernel/CompileImage/Default)
77 endef
78
79 define Kernel/Clean
80 $(call Kernel/Clean/Default)
81 endef
82
83 define BuildKernel
84 ifneq ($(LINUX_SITE),)
85 $(DL_DIR)/$(LINUX_SOURCE):
86 -mkdir -p $(DL_DIR)
87 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
88 endif
89
90 $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
91 -rm -rf $(KERNEL_BUILD_DIR)
92 -mkdir -p $(KERNEL_BUILD_DIR)
93 $(call Kernel/Prepare)
94 touch $$@
95
96 $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_CONFIG) $(GENERIC_LINUX_CONFIG) $(TOPDIR)/.config
97 $(call Kernel/Configure)
98 touch $$@
99
100 $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
101 $(call Kernel/CompileModules)
102 touch $$@
103
104 $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) FORCE
105 $(call Kernel/CompileImage)
106 touch $$@
107
108 mostlyclean: FORCE
109 $(call Kernel/Clean)
110
111 ifeq ($(DUMP),1)
112 dumpinfo:
113 @echo 'Target: $(BOARD)-$(KERNEL)'
114 @echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
115 @echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
116 @echo 'Target-Arch: $(ARCH)'
117 @echo 'Target-Features: $(FEATURES)'
118 @echo 'Linux-Version: $(LINUX_VERSION)'
119 @echo 'Linux-Release: $(LINUX_RELEASE)'
120 @echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
121 @echo 'Target-Description:'
122 @getvar $(call shvar,Target/Description)
123 @echo '@@'
124 @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
125 ifneq ($(DUMPINFO),)
126 @$(DUMPINFO)
127 endif
128 endif
129
130 define BuildKernel
131 endef
132 endef
133
134 define Profile/Default
135 NAME:=
136 PACKAGES:=
137 endef
138
139 confname=$(subst .,_,$(subst -,_,$(1)))
140 define Profile
141 $(eval $(call Profile/Default))
142 $(eval $(call Profile/$(1)))
143 $(eval $(call shexport,Profile/$(1)/Config))
144 $(eval $(call shexport,Profile/$(1)/Description))
145 DUMPINFO += \
146 echo "Target-Profile: $(1)"; \
147 echo "Target-Profile-Name: $(NAME)"; \
148 echo "Target-Profile-Packages: $(PACKAGES)"; \
149 if [ -f ./config/profile-$(1) ]; then \
150 echo "Target-Profile-Kconfig: yes"; \
151 fi; \
152 echo "Target-Profile-Config: "; \
153 getvar "$(call shvar,Profile/$(1)/Config)"; \
154 echo "@@"; \
155 echo "Target-Profile-Description:"; \
156 getvar "$(call shvar,Profile/$(1)/Description)"; \
157 echo "@@"; \
158 echo;
159 ifeq ($(CONFIG_LINUX_$(call confname,$(KERNEL)_$(1))),y)
160 PROFILE=$(1)
161 endif
162 endef
163
164 $(eval $(call shexport,Target/Description))
165
166 download: $(DL_DIR)/$(LINUX_SOURCE)
167 prepare: $(STAMP_CONFIGURED)
168 compile: $(LINUX_DIR)/.modules
169 $(MAKE) -C image compile
170
171 oldconfig menuconfig: $(STAMP_PREPARED) FORCE
172 $(call Kernel/Configure)
173 $(SCRIPT_DIR)/config.pl '+' $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) > $(LINUX_DIR)/.config
174 $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $@
175 $(SCRIPT_DIR)/config.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG)
176
177 install: $(LINUX_DIR)/.image
178 $(MAKE) -C image compile install
179
180 clean: FORCE
181 rm -f $(STAMP_DIR)/.linux-compile
182 rm -rf $(KERNEL_BUILD_DIR)
183
184 rebuild: FORCE
185 @$(MAKE) mostlyclean
186 @if [ -f $(LINUX_KERNEL) ]; then \
187 $(MAKE) clean; \
188 fi
189 @$(MAKE) compile
190
191 image-prereq:
192 $(SUBMAKE) -s -C image prereq
193
194 prereq: image-prereq
This page took 0.050047 seconds and 5 git commands to generate.