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
)/host.mk
10 include $(INCLUDE_DIR
)/kernel.mk
12 LINUX_SOURCE
:=linux-
$(LINUX_VERSION
).
tar.bz2
13 LINUX_SITE
:=http
://www.us.kernel.org
/pub
/linux
/kernel
/v
$(KERNEL
) \
14 http
://www.us.kernel.org
/pub
/linux
/kernel
/v
$(KERNEL
) \
15 http
://www.kernel.org
/pub
/linux
/kernel
/v
$(KERNEL
) \
16 http
://www.de.kernel.org
/pub
/linux
/kernel
/v
$(KERNEL
)
18 LINUX_CONFIG
:=.
/config
20 ifneq (,$(findstring uml
,$(BOARD
)))
23 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
33 ifneq (,$(findstring x86
,$(BOARD
)))
36 ifneq (,$(findstring ppc
,$(BOARD
)))
41 define Kernel
/Prepare
/Default
42 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
43 [ -d ..
/generic-
$(KERNEL
)/patches
] && $(PATCH
) $(LINUX_DIR
) ..
/generic-
$(KERNEL
)/patches
44 [ -d .
/patches
] && $(PATCH
) $(LINUX_DIR
) .
/patches
47 $(call Kernel
/Prepare
/Default
)
51 define Kernel
/Configure
/2.4
52 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
53 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/compile.h
include/linux
/version.h
54 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" ARCH
=$(LINUX_KARCH
) dep
56 define Kernel
/Configure
/2.6
57 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig prepare scripts
59 define Kernel
/Configure
/Default
60 @
$(CP
) $(LINUX_CONFIG
) $(LINUX_DIR
)/.config
61 $(call Kernel
/Configure
/$(KERNEL
))
63 define Kernel
/Configure
64 $(call Kernel
/Configure
/Default
)
68 define Kernel
/CompileModules
/Default
69 $(MAKE
) -j
$(CONFIG_JLEVEL
) -C
"$(LINUX_DIR)" CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) modules
70 $(MAKE
) -C
"$(LINUX_DIR)" CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) DEPMOD
=true INSTALL_MOD_PATH
=$(KERNEL_BUILD_DIR
)/modules modules_install
72 define Kernel
/CompileModules
73 $(call Kernel
/CompileModules
/Default
)
78 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
79 define Kernel
/SetInitramfs
80 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
81 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
82 echo
'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR
)/.config
83 echo
'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR
)/.config
84 echo
'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR
)/.config
85 mkdir
-p
$(BUILD_DIR
)/root
/etc
/init.d
86 $(CP
) ..
/generic-2.6
/files
/init
$(BUILD_DIR
)/root
/
89 define Kernel
/SetInitramfs
90 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
91 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
92 rm -f
$(BUILD_DIR
)/root
/init
$(BUILD_DIR
)/root
/etc
/init.d
/S00initramfs
93 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
97 define Kernel
/CompileImage
/Default
98 $(call Kernel
/SetInitramfs
)
99 $(MAKE
) -j
$(CONFIG_JLEVEL
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) $(KERNELNAME
)
100 $(KERNEL_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$(LINUX_DIR
)/vmlinux
$(LINUX_KERNEL
)
102 define Kernel
/CompileImage
103 $(call Kernel
/CompileImage
/Default
)
106 define Kernel
/Clean
/Default
107 rm -f
$(LINUX_DIR
)/.linux-compile
108 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.configured
109 rm -f
$(LINUX_KERNEL
)
110 $(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
114 $(call Kernel
/Clean
/Default
)
118 ifneq ($(LINUX_SITE
),)
119 $(DL_DIR
)/$(LINUX_SOURCE
):
121 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
)
124 $(LINUX_DIR
)/.prepared
: $(DL_DIR
)/$(LINUX_SOURCE
)
125 -rm -rf
$(KERNEL_BUILD_DIR
)
126 -mkdir
-p
$(KERNEL_BUILD_DIR
)
127 $(call Kernel
/Prepare
)
130 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.prepared
$(LINUX_CONFIG
)
131 $(call Kernel
/Configure
)
134 $(LINUX_DIR
)/.modules
: $(LINUX_DIR
)/.configured
135 rm -rf
$(KERNEL_BUILD_DIR
)/modules
136 @
rm -f
$(BUILD_DIR
)/linux
137 ln
-sf
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(BUILD_DIR
)/linux
138 $(call Kernel
/CompileModules
)
141 $(LINUX_DIR
)/.image
: $(LINUX_DIR
)/.configured FORCE
142 $(call Kernel
/CompileImage
)
153 download
: $(DL_DIR
)/$(LINUX_SOURCE
)
154 prepare
: $(LINUX_DIR
)/.configured
$(TOPDIR
)/.kernel.mk
155 compile
: $(LINUX_DIR
)/.modules
156 install: $(LINUX_DIR
)/.image
159 rm -f
$(STAMP_DIR
)/.linux-compile
160 rm -rf
$(KERNEL_BUILD_DIR
)
164 @if
[ -f
$(LINUX_KERNEL
) ]; then \
169 $(TOPDIR
)/.kernel.mk
: Makefile
170 echo
"CONFIG_BOARD:=$(BOARD)" > $@
171 echo
"CONFIG_KERNEL:=$(KERNEL)" >> $@
172 echo
"CONFIG_LINUX_VERSION:=$(LINUX_VERSION)" >> $@
173 echo
"CONFIG_LINUX_RELEASE:=$(LINUX_RELEASE)" >> $@
174 echo
"CONFIG_LINUX_KARCH:=$(LINUX_KARCH)" >> $@