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 ifneq (,$(findstring uml
,$(BOARD
)))
21 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
31 ifneq (,$(findstring x86
,$(BOARD
)))
34 ifneq (,$(findstring ppc
,$(BOARD
)))
39 $(DL_DIR
)/$(LINUX_SOURCE
):
41 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
)
43 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
44 -mkdir
-p
$(KERNEL_BUILD_DIR
)
45 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
49 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
$(LINUX_DIR
)/.config
50 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
51 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/compile.h
include/linux
/version.h
54 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
55 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" ARCH
=$(LINUX_KARCH
) dep
58 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
60 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
61 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig prepare scripts
65 ramdisk-config
: $(LINUX_DIR
)/.configured FORCE
66 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
67 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
68 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
69 echo
'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR
)/.config
70 echo
'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR
)/.config
71 echo
'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR
)/.config
72 mkdir
-p
$(BUILD_DIR
)/root
/etc
/init.d
73 $(CP
) ..
/generic-2.6
/files
/init
$(BUILD_DIR
)/root
/
75 rm -f
$(BUILD_DIR
)/root
/init
$(BUILD_DIR
)/root
/etc
/init.d
/S00initramfs
76 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
79 $(LINUX_DIR
)/vmlinux
: ramdisk-config
80 $(MAKE
) -j
$(CONFIG_JLEVEL
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) $(KERNELNAME
)
82 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
83 $(KERNEL_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
84 touch
-c
$(LINUX_KERNEL
)
86 $(LINUX_DIR
)/.modules_done
: $(LINUX_DIR
)/.config
87 rm -rf
$(KERNEL_BUILD_DIR
)/modules
88 $(MAKE
) -j
$(CONFIG_JLEVEL
) -C
"$(LINUX_DIR)" CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) modules
89 $(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
90 touch
$(LINUX_DIR
)/.modules_done
92 $(LINUX_DIR
)/.linux-compile
: $(LINUX_DIR
)/.modules_done
93 @
rm -f
$(BUILD_DIR
)/linux
94 ln
-sf
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(BUILD_DIR
)/linux
97 $(TOPDIR
)/.kernel.mk
: $(TOPDIR
)/target
/linux
/$(BOARD
)-$(KERNEL
)/Makefile
98 echo
"CONFIG_BOARD:=$(BOARD)" > $@
99 echo
"CONFIG_KERNEL:=$(KERNEL)" >> $@
100 echo
"CONFIG_LINUX_VERSION:=$(LINUX_VERSION)" >> $@
101 echo
"CONFIG_LINUX_RELEASE:=$(LINUX_RELEASE)" >> $@
102 echo
"CONFIG_LINUX_KARCH:=$(LINUX_KARCH)" >> $@
104 download
: $(DL_DIR
)/$(LINUX_SOURCE
)
105 prepare
: $(LINUX_DIR
)/.configured
106 @mkdir
-p
$(LINUX_DIR
)
108 compile
: prepare
$(LINUX_DIR
)/.linux-compile
109 install: compile
$(LINUX_KERNEL
)
112 rm -f
$(LINUX_DIR
)/.linux-compile
113 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.modules_done
114 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.drivers-unpacked
115 $(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
116 rm -f
$(LINUX_KERNEL
)
120 if
[ -f
$(LINUX_KERNEL
) ]; then \
123 $(MAKE
) compile
$(MAKE_TRACE
)
126 rm -f
$(STAMP_DIR
)/.linux-compile
127 rm -rf
$(KERNEL_BUILD_DIR
)