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.
7 include $(INCLUDE_DIR
)/host.mk
8 -include $(INCLUDE_DIR
)/modules-
$(KERNEL
).mk
10 LINUX_SOURCE
:=linux-
$(LINUX_VERSION
).
tar.bz2
11 LINUX_SITE
=http
://www.us.kernel.org
/pub
/linux
/kernel
/v
$(KERNEL
) \
12 http
://www.us.kernel.org
/pub
/linux
/kernel
/v
$(KERNEL
) \
13 http
://www.kernel.org
/pub
/linux
/kernel
/v
$(KERNEL
) \
14 http
://www.de.kernel.org
/pub
/linux
/kernel
/v
$(KERNEL
)
16 KERNEL_IDIR
:=$(KERNEL_BUILD_DIR
)/kernel-ipkg
17 KERNEL_IPKG
:=$(KERNEL_BUILD_DIR
)/kernel_
$(LINUX_VERSION
)-$(BOARD
)-$(LINUX_RELEASE
)_
$(ARCH
).ipk
18 TARGETS
+= $(KERNEL_IPKG
)
19 INSTALL_TARGETS
+= $(KERNEL_IPKG
)
21 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
30 $(TARGETS
): $(PACKAGE_DIR
)
35 $(DL_DIR
)/$(LINUX_SOURCE
):
37 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
)
39 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
40 -mkdir
-p
$(KERNEL_BUILD_DIR
)
41 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
45 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
46 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
47 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/compile.h
include/linux
/version.h
50 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
51 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" ARCH
=$(LINUX_KARCH
) dep
54 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
56 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
57 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig prepare scripts
61 ramdisk-config
: $(LINUX_DIR
)/.configured FORCE
62 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
63 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
64 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
65 echo
'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR
)/.config
66 echo
'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR
)/.config
67 echo
'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR
)/.config
68 mkdir
-p
$(BUILD_DIR
)/root
/etc
/init.d
69 $(CP
) ..
/generic-2.6
/files
/init
$(BUILD_DIR
)/root
/
71 rm -f
$(BUILD_DIR
)/root
/init
$(BUILD_DIR
)/root
/etc
/init.d
/S00initramfs
72 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
75 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.linux-compile pkg-install ramdisk-config
76 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) $(KERNELNAME
)
78 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
79 $(KERNEL_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
80 touch
-c
$(LINUX_KERNEL
)
82 $(LINUX_DIR
)/.modules_done
:
83 rm -rf
$(KERNEL_BUILD_DIR
)/modules
84 $(MAKE
) -C
"$(LINUX_DIR)" CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) modules
85 $(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
86 touch
$(LINUX_DIR
)/.modules_done
88 modules
: $(LINUX_DIR
)/.modules_done
91 $(LINUX_DIR
)/.linux-compile
:
92 @
rm -f
$(BUILD_DIR
)/linux
93 ln
-sf
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(BUILD_DIR
)/linux
99 mkdir
-p
$(KERNEL_IDIR
)/etc
100 $(SCRIPT_DIR
)/make-ipkg-dir.sh
$(KERNEL_IDIR
) ..
/control
/kernel.control
$(LINUX_VERSION
)-$(BOARD
)-$(LINUX_RELEASE
) $(ARCH
)
101 if
[ -f .
/config
/$(BOARD
).modules
]; then \
102 cp .
/config
/$(BOARD
).modules
$(KERNEL_IDIR
)/etc
/modules
; \
104 $(IPKG_BUILD
) $(KERNEL_IDIR
) $(KERNEL_BUILD_DIR
)
106 $(TOPDIR
)/.kernel.mk
: $(TOPDIR
)/target
/linux
/$(BOARD
)-$(KERNEL
)/Makefile
107 echo
"CONFIG_BOARD:=$(BOARD)" > $@
108 echo
"CONFIG_KERNEL:=$(KERNEL)" >> $@
109 echo
"CONFIG_LINUX_VERSION:=$(LINUX_VERSION)" >> $@
110 echo
"CONFIG_LINUX_RELEASE:=$(LINUX_RELEASE)" >> $@
111 echo
"CONFIG_LINUX_KARCH:=$(LINUX_KARCH)" >> $@
114 @for pkg in
$(INSTALL_TARGETS
); do \
115 $(IPKG
) install $$pkg || echo
; \
118 download
: $(DL_DIR
)/$(LINUX_SOURCE
)
119 prepare
: $(LINUX_DIR
)/.configured
120 @mkdir
-p
$(LINUX_DIR
) $(PACKAGE_DIR
)
122 compile
: prepare
$(LINUX_DIR
)/.linux-compile
125 install: compile
$(LINUX_KERNEL
)
128 rm -f
$(LINUX_DIR
)/.linux-compile
129 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.modules_done
130 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.drivers-unpacked
131 $(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
132 rm -f
$(LINUX_KERNEL
)
136 if
[ -f
$(LINUX_KERNEL
) ]; then \
139 $(MAKE
) compile
$(MAKE_TRACE
)
142 rm -f
$(STAMP_DIR
)/.linux-compile
143 rm -rf
$(KERNEL_BUILD_DIR
)