2 # Copyright (C) 2006 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)/prereq.mk
12 ifneq ($(CONFIG_ATM),)
15 ifneq ($(CONFIG_PCI),)
18 ifneq ($(CONFIG_USB),)
21 ifneq ($(CONFIG_PCMCIA),)
24 ifneq ($(CONFIG_VIDEO_DEV),)
29 FEATURES:=$(sort $(FEATURES))
31 # For target profile selection - the default set
32 DEFAULT_PACKAGES:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd kmod-ipt-nathelper
40 include $(INCLUDE_DIR)/kernel-version.mk
41 include $(INCLUDE_DIR)/host.mk
42 include $(INCLUDE_DIR)/kernel.mk
44 LINUX_CONFIG:=./config
46 ifneq (,$(findstring uml,$(BOARD)))
49 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
59 ifneq (,$(findstring x86,$(BOARD)))
62 ifneq (,$(findstring rdc,$(BOARD)))
65 ifneq (,$(findstring ppc,$(BOARD)))
70 define Kernel/Prepare/Default
71 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
72 if [ -d $(GENERIC_PLATFORM_DIR)/patches ]; then $(PATCH) $(LINUX_DIR) $(GENERIC_PLATFORM_DIR)/patches; fi
73 if [ -d ./files ]; then $(CP) ./files/* $(LINUX_DIR)/; fi
74 if [ -d ./patches ]; then $(PATCH) $(LINUX_DIR) ./patches; fi
77 $(call Kernel/Prepare/Default)
80 KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
81 CROSS_COMPILE="$(KERNEL_CROSS)" \
82 ARCH="$(LINUX_KARCH)" \
83 CONFIG_SHELL="$(BASH)"
85 define Kernel/Configure/2.4
86 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
87 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig include/linux/compile.h include/linux/version.h
88 $(MAKE) $(KERNEL_MAKEOPTS) dep
90 define Kernel/Configure/2.6
91 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig prepare scripts
93 define Kernel/Configure/Default
94 @$(CP) $(LINUX_CONFIG) $(LINUX_DIR)/.config
96 define Kernel/Configure
97 $(call Kernel/Configure/Default)
101 define Kernel/CompileModules/Default
102 $(MAKE) -j$(CONFIG_JLEVEL) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" modules
103 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" DEPMOD=true INSTALL_MOD_PATH=$(KERNEL_BUILD_DIR)/modules modules_install
105 define Kernel/CompileModules
106 $(call Kernel/CompileModules/Default)
111 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
112 define Kernel/SetInitramfs
113 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
114 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
115 echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
116 echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
117 echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
118 mkdir -p $(BUILD_DIR)/root/etc/init.d
119 $(CP) $(GENERIC_PLATFORM_DIR)/files/init $(BUILD_DIR)/root/
122 define Kernel/SetInitramfs
123 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
124 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
125 rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs
126 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
130 define Kernel/CompileImage/Default
131 $(call Kernel/SetInitramfs)
132 $(MAKE) -j$(CONFIG_JLEVEL) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" $(KERNELNAME)
133 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
135 define Kernel/CompileImage
136 $(call Kernel/CompileImage/Default)
139 define Kernel/Clean/Default
140 rm -f $(LINUX_DIR)/.linux-compile
141 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
142 rm -f $(LINUX_KERNEL)
143 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
147 $(call Kernel/Clean/Default)
151 ifneq ($(LINUX_SITE),)
152 $(DL_DIR)/$(LINUX_SOURCE):
154 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
157 $(LINUX_DIR)/.prepared: $(DL_DIR)/$(LINUX_SOURCE)
158 -rm -rf $(KERNEL_BUILD_DIR)
159 -mkdir -p $(KERNEL_BUILD_DIR)
160 $(call Kernel/Prepare)
163 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.prepared $(LINUX_CONFIG)
164 $(call Kernel/Configure)
165 $(call Kernel/Configure/$(KERNEL))
168 $(LINUX_DIR)/.modules: $(LINUX_DIR)/.configured
169 rm -rf $(KERNEL_BUILD_DIR)/modules
170 @rm -f $(BUILD_DIR)/linux
171 ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
172 $(call Kernel/CompileModules)
175 $(LINUX_DIR)/.image: $(LINUX_DIR)/.configured FORCE
176 $(call Kernel/CompileImage)
184 @echo 'Target: $(BOARD)-$(KERNEL)'
185 @echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
186 @echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
187 @echo 'Target-Arch: $(ARCH)'
188 @echo 'Target-Features: $(FEATURES)'
189 @echo 'Linux-Version: $(LINUX_VERSION)'
190 @echo 'Linux-Release: $(LINUX_RELEASE)'
191 @echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
192 @echo 'Target-Description:'
193 @getvar $(call shvar,Target/Description)
195 @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
205 define Profile/Default
211 $(eval $(call Profile/Default))
212 $(eval $(call Profile/$(1)))
213 $(eval $(call shexport,Profile/$(1)/Description))
215 echo "Target-Profile: $(1)"; \
216 echo "Target-Profile-Name: $(NAME)"; \
217 echo "Target-Profile-Packages: $(PACKAGES)"; \
218 echo "Target-Profile-Description:"; \
219 getvar "$(call shvar,Profile/$(1)/Description)"; \
224 $(eval $(call shexport,Target/Description))
226 download: $(DL_DIR)/$(LINUX_SOURCE)
227 prepare: $(LINUX_DIR)/.configured $(TMP_DIR)/.kernel.mk
228 compile: $(LINUX_DIR)/.modules
229 menuconfig: $(LINUX_DIR)/.prepared FORCE
230 $(call Kernel/Configure)
231 $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) menuconfig
232 $(SCRIPT_DIR)/config.pl $(LINUX_DIR)/.config > $(PLATFORM_DIR)/config
234 $(SCRIPT_DIR)/config.pl '>' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_DIR)/.config > $(PLATFORM_DIR)/config-diff
237 install: $(LINUX_DIR)/.image
240 rm -f $(STAMP_DIR)/.linux-compile
241 rm -rf $(KERNEL_BUILD_DIR)
245 @if [ -f $(LINUX_KERNEL) ]; then \