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),)
26 FEATURES:=$(sort $(FEATURES))
28 # For target profile selection - the default set
29 DEFAULT_PACKAGES:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd
36 KERNEL:=2.$(word 2,$(subst ., ,$(strip $(LINUX_VERSION))))
38 include $(INCLUDE_DIR)/host.mk
39 include $(INCLUDE_DIR)/kernel.mk
41 LINUX_CONFIG:=./config
43 ifneq (,$(findstring uml,$(BOARD)))
46 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
56 ifneq (,$(findstring x86,$(BOARD)))
59 ifneq (,$(findstring ppc,$(BOARD)))
64 define Kernel/Prepare/Default
65 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
66 [ -d ../generic-$(KERNEL)/patches ] && $(PATCH) $(LINUX_DIR) $(GENERIC_PLATFORM_DIR)/patches
67 [ -d ./patches ] && $(PATCH) $(LINUX_DIR) ./patches
70 $(call Kernel/Prepare/Default)
73 KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
74 CROSS_COMPILE="$(KERNEL_CROSS)" \
75 ARCH="$(LINUX_KARCH)" \
76 CONFIG_SHELL="$(BASH)"
78 define Kernel/Configure/2.4
79 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
80 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig include/linux/compile.h include/linux/version.h
81 $(MAKE) $(KERNEL_MAKEOPTS) dep
83 define Kernel/Configure/2.6
84 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig prepare scripts
86 define Kernel/Configure/Default
87 @$(CP) $(LINUX_CONFIG) $(LINUX_DIR)/.config
88 $(call Kernel/Configure/$(KERNEL))
90 define Kernel/Configure
91 $(call Kernel/Configure/Default)
95 define Kernel/CompileModules/Default
96 $(MAKE) -j$(CONFIG_JLEVEL) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" modules
97 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" DEPMOD=true INSTALL_MOD_PATH=$(KERNEL_BUILD_DIR)/modules modules_install
99 define Kernel/CompileModules
100 $(call Kernel/CompileModules/Default)
105 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
106 define Kernel/SetInitramfs
107 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
108 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
109 echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
110 echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
111 echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
112 mkdir -p $(BUILD_DIR)/root/etc/init.d
113 $(CP) $(GENERIC_PLATFORM_DIR)/files/init $(BUILD_DIR)/root/
116 define Kernel/SetInitramfs
117 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
118 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
119 rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs
120 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
124 define Kernel/CompileImage/Default
125 $(call Kernel/SetInitramfs)
126 $(MAKE) -j$(CONFIG_JLEVEL) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" $(KERNELNAME)
127 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
129 define Kernel/CompileImage
130 $(call Kernel/CompileImage/Default)
133 define Kernel/Clean/Default
134 rm -f $(LINUX_DIR)/.linux-compile
135 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
136 rm -f $(LINUX_KERNEL)
137 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
141 $(call Kernel/Clean/Default)
145 ifneq ($(LINUX_SITE),)
146 $(DL_DIR)/$(LINUX_SOURCE):
148 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
151 $(LINUX_DIR)/.prepared: $(DL_DIR)/$(LINUX_SOURCE)
152 -rm -rf $(KERNEL_BUILD_DIR)
153 -mkdir -p $(KERNEL_BUILD_DIR)
154 $(call Kernel/Prepare)
157 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.prepared $(LINUX_CONFIG)
158 $(call Kernel/Configure)
161 $(LINUX_DIR)/.modules: $(LINUX_DIR)/.configured
162 rm -rf $(KERNEL_BUILD_DIR)/modules
163 @rm -f $(BUILD_DIR)/linux
164 ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
165 $(call Kernel/CompileModules)
168 $(LINUX_DIR)/.image: $(LINUX_DIR)/.configured FORCE
169 $(call Kernel/CompileImage)
177 @echo 'Target: $(BOARD)-$(KERNEL)'
178 @echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
179 @echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
180 @echo 'Target-Arch: $(ARCH)'
181 @echo 'Target-Features: $(FEATURES)'
182 @echo 'Linux-Version: $(LINUX_VERSION)'
183 @echo 'Linux-Release: $(LINUX_RELEASE)'
184 @echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
185 @echo 'Target-Description:'
186 @getvar $(call shvar,Target/Description)
188 @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
198 define Profile/Default
204 $(eval $(call Profile/Default))
205 $(eval $(call Profile/$(1)))
207 echo "Target-Profile: $(1)"; \
208 echo "Target-Profile-Name: $(NAME)"; \
209 echo "Target-Profile-Packages: $(PACKAGES)";
212 $(eval $(call shexport,Target/Description))
214 download: $(DL_DIR)/$(LINUX_SOURCE)
215 prepare: $(LINUX_DIR)/.configured $(TMP_DIR)/.kernel.mk
216 compile: $(LINUX_DIR)/.modules
217 install: $(LINUX_DIR)/.image
220 rm -f $(STAMP_DIR)/.linux-compile
221 rm -rf $(KERNEL_BUILD_DIR)
225 @if [ -f $(LINUX_KERNEL) ]; then \