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
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
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)
26 ifneq ($(CONFIG_ATM),)
29 ifneq ($(CONFIG_PCI),)
32 ifneq ($(CONFIG_USB),)
35 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
38 ifneq ($(CONFIG_VIDEO_DEV),)
43 FEATURES:=$(sort $(FEATURES))
51 ifneq (,$(findstring uml,$(BOARD)))
54 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
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
69 $(call Kernel/Prepare/Default)
72 define Kernel/Configure
73 $(call Kernel/Configure/Default)
76 define Kernel/CompileModules
77 $(call Kernel/CompileModules/Default)
80 define Kernel/CompileImage
81 $(call Kernel/CompileImage/Default)
85 $(call Kernel/Clean/Default)
89 ifneq ($(LINUX_SITE),)
90 $(DL_DIR)/$(LINUX_SOURCE):
92 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
95 $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
96 -rm -rf $(KERNEL_BUILD_DIR)
97 -mkdir -p $(KERNEL_BUILD_DIR)
98 $(call Kernel/Prepare)
101 $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_CONFIG) $(GENERIC_LINUX_CONFIG)
102 $(call Kernel/Configure)
105 $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
106 $(call Kernel/CompileModules)
109 $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) FORCE
110 $(call Kernel/CompileImage)
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)
129 @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
139 define Profile/Default
144 confname=$(subst .,_,$(subst -,_,$(1)))
146 $(eval $(call Profile/Default))
147 $(eval $(call Profile/$(1)))
148 $(eval $(call shexport,Profile/$(1)/Config))
149 $(eval $(call shexport,Profile/$(1)/Description))
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"; \
157 echo "Target-Profile-Config: "; \
158 getvar "$(call shvar,Profile/$(1)/Config)"; \
160 echo "Target-Profile-Description:"; \
161 getvar "$(call shvar,Profile/$(1)/Description)"; \
164 ifeq ($(CONFIG_LINUX_$(call confname,$(KERNEL)_$(1))),y)
169 $(eval $(call shexport,Target/Description))
171 download: $(DL_DIR)/$(LINUX_SOURCE)
172 prepare: $(STAMP_CONFIGURED)
173 compile: $(LINUX_DIR)/.modules
174 oldconfig menuconfig: $(STAMP_PREPARED) FORCE
175 $(SCRIPT_DIR)/config.pl '+' $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) > $(LINUX_DIR)/.config
176 $(call Kernel/Configure)
177 $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $@
178 $(SCRIPT_DIR)/config.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG)
180 install: $(LINUX_DIR)/.image
183 rm -f $(STAMP_DIR)/.linux-compile
184 rm -rf $(KERNEL_BUILD_DIR)
188 @if [ -f $(LINUX_KERNEL) ]; then \