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