2 # Copyright (C) 2006-2007 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
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
16 GENERIC_LINUX_CONFIG:=$(GENERIC_PLATFORM_DIR)/config-$(shell [ -f "$(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER)" ] && echo "$(KERNEL_PATCHVER)" || echo template )
17 LINUX_CONFIG_DIR ?= ./config$(shell [ -d "./config-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
18 LINUX_CONFIG ?= $(LINUX_CONFIG_DIR)/default
21 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(BOARD)-$(KERNEL)
22 $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG)
23 $(SCRIPT_DIR)/config.pl + $^ > $@
24 -include $(TMP_CONFIG)
25 .SILENT: $(TMP_CONFIG)
28 ifneq ($(CONFIG_PCI),)
31 ifneq ($(CONFIG_USB),)
34 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
39 FEATURES:=$(sort $(FEATURES))
47 ifneq (,$(findstring uml,$(BOARD)))
50 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
59 STAMP_PREPARED:=$(LINUX_DIR)/.prepared
60 STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
61 include $(INCLUDE_DIR)/quilt.mk
62 include $(INCLUDE_DIR)/kernel-defaults.mk
65 $(call Kernel/Prepare/Default)
68 define Kernel/Configure
69 $(call Kernel/Configure/Default)
72 define Kernel/CompileModules
73 $(call Kernel/CompileModules/Default)
76 define Kernel/CompileImage
77 $(call Kernel/CompileImage/Default)
81 $(call Kernel/Clean/Default)
85 ifneq ($(LINUX_SITE),)
86 $(DL_DIR)/$(LINUX_SOURCE):
88 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
91 $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
92 -rm -rf $(KERNEL_BUILD_DIR)
93 -mkdir -p $(KERNEL_BUILD_DIR)
94 $(call Kernel/Prepare)
97 $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_CONFIG) $(GENERIC_LINUX_CONFIG) $(TOPDIR)/.config
98 $(call Kernel/Configure)
101 $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
102 $(call Kernel/CompileModules)
105 $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) FORCE
106 $(call Kernel/CompileImage)
114 @echo 'Target: $(BOARD)-$(KERNEL)'
115 @echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
116 @echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
117 @echo 'Target-Arch: $(ARCH)'
118 @echo 'Target-Features: $(FEATURES)'
119 @echo 'Linux-Version: $(LINUX_VERSION)'
120 @echo 'Linux-Release: $(LINUX_RELEASE)'
121 @echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
122 @echo 'Target-Description:'
123 @getvar $(call shvar,Target/Description)
125 @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
135 define Profile/Default
140 confname=$(subst .,_,$(subst -,_,$(1)))
142 $(eval $(call Profile/Default))
143 $(eval $(call Profile/$(1)))
144 $(eval $(call shexport,Profile/$(1)/Config))
145 $(eval $(call shexport,Profile/$(1)/Description))
147 echo "Target-Profile: $(1)"; \
148 echo "Target-Profile-Name: $(NAME)"; \
149 echo "Target-Profile-Packages: $(PACKAGES)"; \
150 if [ -f ./config/profile-$(1) ]; then \
151 echo "Target-Profile-Kconfig: yes"; \
153 echo "Target-Profile-Config: "; \
154 getvar "$(call shvar,Profile/$(1)/Config)"; \
156 echo "Target-Profile-Description:"; \
157 getvar "$(call shvar,Profile/$(1)/Description)"; \
160 ifeq ($(CONFIG_LINUX_$(call confname,$(KERNEL)_$(1))),y)
165 $(eval $(call shexport,Target/Description))
167 download: $(DL_DIR)/$(LINUX_SOURCE)
168 prepare: $(STAMP_CONFIGURED)
169 compile: $(LINUX_DIR)/.modules
170 oldconfig menuconfig: $(STAMP_PREPARED) FORCE
171 $(call Kernel/Configure)
172 $(SCRIPT_DIR)/config.pl '+' $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) > $(LINUX_DIR)/.config
173 $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $@
174 $(SCRIPT_DIR)/config.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG)
176 install: $(LINUX_DIR)/.image
177 $(MAKE) -C image install
180 rm -f $(STAMP_DIR)/.linux-compile
181 rm -rf $(KERNEL_BUILD_DIR)
185 @if [ -f $(LINUX_KERNEL) ]; then \
191 $(MAKE) -C image prereq