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
)/kernel-version.mk
10 include $(INCLUDE_DIR
)/host.mk
11 include $(INCLUDE_DIR
)/kernel.mk
12 include $(INCLUDE_DIR
)/prereq.mk
14 LINUX_CONFIG ?
= .
/config
/default
16 -include $(TOPDIR
)/target
/linux
/generic-
$(KERNEL
)/config-template
17 -include $(LINUX_CONFIG
)
19 ifneq ($(CONFIG_ATM
),)
22 ifneq ($(CONFIG_PCI
),)
25 ifneq ($(CONFIG_USB
),)
28 ifneq ($(CONFIG_PCMCIA
),)
31 ifneq ($(CONFIG_VIDEO_DEV
),)
36 FEATURES
:=$(sort $(FEATURES
))
38 # For target profile selection - the default set
39 DEFAULT_PACKAGES
:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd kmod-ipt-nathelper
47 ifneq (,$(findstring uml
,$(BOARD
)))
50 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
60 ifneq (,$(findstring x86
,$(BOARD
)))
63 ifneq (,$(findstring rdc
,$(BOARD
)))
66 ifneq (,$(findstring ppc
,$(BOARD
)))
71 define Kernel
/Prepare
/Default
72 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
73 if
[ -d
$(GENERIC_PLATFORM_DIR
)/patches
]; then
$(PATCH
) $(LINUX_DIR
) $(GENERIC_PLATFORM_DIR
)/patches
; fi
74 if
[ -d .
/files
]; then
$(CP
) .
/files
/* $(LINUX_DIR
)/; fi
75 if
[ -d .
/patches
]; then
$(PATCH
) $(LINUX_DIR
) .
/patches
; fi
78 $(call Kernel
/Prepare
/Default
)
81 KERNEL_MAKEOPTS
:= -C
$(LINUX_DIR
) \
82 CROSS_COMPILE
="$(KERNEL_CROSS)" \
83 ARCH
="$(LINUX_KARCH)" \
84 CONFIG_SHELL
="$(BASH)"
86 define Kernel
/Configure
/2.4
87 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
88 $(MAKE
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" oldconfig
include/linux
/compile.h
include/linux
/version.h
89 $(MAKE
) $(KERNEL_MAKEOPTS
) dep
91 define Kernel
/Configure
/2.6
92 $(MAKE
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" oldconfig prepare scripts
94 define Kernel
/Configure
/Default
95 @if
[ -f
"./config/profile-$(PROFILE)" ]; then \
96 $(SCRIPT_DIR
)/config.pl
'+' $(GENERIC_PLATFORM_DIR
)/config-template
'+' $(LINUX_CONFIG
) .
/config
/profile-
$(PROFILE
) > $(LINUX_DIR
)/.config
; \
98 $(SCRIPT_DIR
)/config.pl
'+' $(GENERIC_PLATFORM_DIR
)/config-template
$(LINUX_CONFIG
) > $(LINUX_DIR
)/.config
; \
101 define Kernel
/Configure
102 $(call Kernel
/Configure
/Default
)
106 define Kernel
/CompileModules
/Default
107 $(MAKE
) -j
$(CONFIG_JLEVEL
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" modules
108 $(MAKE
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" DEPMOD
=true INSTALL_MOD_PATH
=$(KERNEL_BUILD_DIR
)/modules modules_install
110 define Kernel
/CompileModules
111 $(call Kernel
/CompileModules
/Default
)
116 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
117 define Kernel
/SetInitramfs
118 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
119 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
120 echo
'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR
)/.config
121 echo
'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR
)/.config
122 echo
'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR
)/.config
123 mkdir
-p
$(BUILD_DIR
)/root
/etc
/init.d
124 $(CP
) $(GENERIC_PLATFORM_DIR
)/files
/init
$(BUILD_DIR
)/root
/
127 define Kernel
/SetInitramfs
128 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
129 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
130 rm -f
$(BUILD_DIR
)/root
/init
$(BUILD_DIR
)/root
/etc
/init.d
/S00initramfs
131 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
135 define Kernel
/CompileImage
/Default
136 $(call Kernel
/SetInitramfs
)
137 $(MAKE
) -j
$(CONFIG_JLEVEL
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" $(KERNELNAME
)
138 $(KERNEL_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$(LINUX_DIR
)/vmlinux
$(LINUX_KERNEL
)
139 $(KERNEL_CROSS
)objcopy
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$(LINUX_DIR
)/vmlinux
$(KDIR
)/vmlinux.elf
141 define Kernel
/CompileImage
142 $(call Kernel
/CompileImage
/Default
)
145 define Kernel
/Clean
/Default
146 rm -f
$(LINUX_DIR
)/.linux-compile
147 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.configured
148 rm -f
$(LINUX_KERNEL
)
149 $(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
153 $(call Kernel
/Clean
/Default
)
157 ifneq ($(LINUX_SITE
),)
158 $(DL_DIR
)/$(LINUX_SOURCE
):
160 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
)
163 $(LINUX_DIR
)/.prepared
: $(DL_DIR
)/$(LINUX_SOURCE
)
164 -rm -rf
$(KERNEL_BUILD_DIR
)
165 -mkdir
-p
$(KERNEL_BUILD_DIR
)
166 $(call Kernel
/Prepare
)
169 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.prepared
$(LINUX_CONFIG
)
170 $(call Kernel
/Configure
)
171 $(call Kernel
/Configure
/$(KERNEL
))
174 $(LINUX_DIR
)/.modules
: $(LINUX_DIR
)/.configured
175 rm -rf
$(KERNEL_BUILD_DIR
)/modules
176 @
rm -f
$(BUILD_DIR
)/linux
177 ln
-sf
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(BUILD_DIR
)/linux
178 $(call Kernel
/CompileModules
)
181 $(LINUX_DIR
)/.image
: $(LINUX_DIR
)/.configured FORCE
182 $(call Kernel
/CompileImage
)
190 @echo
'Target: $(BOARD)-$(KERNEL)'
191 @echo
'Target-Name: $(BOARDNAME) [$(KERNEL)]'
192 @echo
'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
193 @echo
'Target-Arch: $(ARCH)'
194 @echo
'Target-Features: $(FEATURES)'
195 @echo
'Linux-Version: $(LINUX_VERSION)'
196 @echo
'Linux-Release: $(LINUX_RELEASE)'
197 @echo
'Linux-Kernel-Arch: $(LINUX_KARCH)'
198 @echo
'Target-Description:'
199 @getvar
$(call shvar
,Target
/Description
)
201 @echo
'Default-Packages: $(DEFAULT_PACKAGES)'
211 define Profile
/Default
216 confname
=$(subst .
,_
,$(subst -,_
,$(1)))
218 $(eval
$(call Profile
/Default
))
219 $(eval
$(call Profile
/$(1)))
220 $(eval
$(call shexport
,Profile
/$(1)/Description
))
222 echo
"Target-Profile: $(1)"; \
223 echo
"Target-Profile-Name: $(NAME)"; \
224 echo
"Target-Profile-Packages: $(PACKAGES)"; \
225 if
[ -f .
/config
/profile-
$(1) ]; then \
226 echo
"Target-Profile-Kconfig: yes"; \
228 echo
"Target-Profile-Description:"; \
229 getvar
"$(call shvar,Profile/$(1)/Description)"; \
232 ifeq ($(CONFIG_LINUX_
$(call confname
,$(KERNEL
)_
$(1))),y
)
237 $(eval
$(call shexport
,Target
/Description
))
239 download
: $(DL_DIR
)/$(LINUX_SOURCE
)
240 prepare
: $(LINUX_DIR
)/.configured
$(TMP_DIR
)/.kernel.mk
241 compile
: $(LINUX_DIR
)/.modules
242 menuconfig
: $(LINUX_DIR
)/.prepared FORCE
243 $(call Kernel
/Configure
)
244 $(SCRIPT_DIR
)/config.pl
'+' $(GENERIC_PLATFORM_DIR
)/config-template
$(LINUX_CONFIG
) > $(LINUX_DIR
)/.config
245 $(MAKE
) -C
$(LINUX_DIR
) $(KERNEL_MAKEOPTS
) menuconfig
246 $(SCRIPT_DIR
)/config.pl
'>' $(GENERIC_PLATFORM_DIR
)/config-template
$(LINUX_DIR
)/.config
> $(LINUX_CONFIG
)
248 install: $(LINUX_DIR
)/.image
251 rm -f
$(STAMP_DIR
)/.linux-compile
252 rm -rf
$(KERNEL_BUILD_DIR
)
256 @if
[ -f
$(LINUX_KERNEL
) ]; then \