2 # Copyright (C) 2006-2011 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 KERNEL_MAKEOPTS
:= -C
$(LINUX_DIR
) \
9 CROSS_COMPILE
="$(KERNEL_CROSS)" \
10 ARCH
="$(LINUX_KARCH)" \
12 CONFIG_SHELL
="$(BASH)"
14 ifdef CONFIG_STRIP_KERNEL_EXPORTS
16 EXTRA_LDSFLAGS
="-I$(KERNEL_BUILD_DIR) -include symtab.h"
19 INITRAMFS_EXTRA_FILES ?
= $(GENERIC_PLATFORM_DIR
)/image
/initramfs-base-files.txt
22 KERNEL_MAKEOPTS
+= CC
="$(KERNEL_CC)"
26 Kernel
/Patch
:=$(Kernel
/Patch
/Default
)
27 ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE
)),"")
28 ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI
)),"")
29 define Kernel
/Prepare
/Default
30 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
$(TAR
) -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
32 touch
$(LINUX_DIR
)/.quilt_used
35 ifeq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY
)),"")
36 define Kernel
/Prepare
/Default
37 git clone
$(CONFIG_KERNEL_GIT_CLONE_URI
) $(LINUX_DIR
)
40 define Kernel
/Prepare
/Default
41 git clone
--reference
$(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY
) $(CONFIG_KERNEL_GIT_CLONE_URI
) $(LINUX_DIR
)
46 define Kernel
/Prepare
/Default
47 mkdir
-p
$(KERNEL_BUILD_DIR
)
48 if
[ -d
$(LINUX_DIR
) ]; then \
51 ln
-s
$(CONFIG_EXTERNAL_KERNEL_TREE
) $(LINUX_DIR
)
55 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
56 define Kernel
/SetInitramfs
57 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
58 grep
-v
-e INITRAMFS
-e CONFIG_RD_
-e CONFIG_BLK_DEV_INITRD
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
59 echo
'CONFIG_BLK_DEV_INITRD=y' >> $(LINUX_DIR
)/.config
60 echo
'CONFIG_INITRAMFS_SOURCE="$(strip $(TARGET_DIR) $(INITRAMFS_EXTRA_FILES))"' >> $(LINUX_DIR
)/.config
61 echo
'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR
)/.config
62 echo
'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR
)/.config
63 echo
"$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE),CONFIG_INITRAMFS_COMPRESSION_NONE=y,# CONFIG_INITRAMFS_COMPRESSION_NONE is not set)" >> $(LINUX_DIR
)/.config
64 echo
-e
"$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),CONFIG_INITRAMFS_COMPRESSION_GZIP=y\nCONFIG_RD_GZIP=y,# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set\n# CONFIG_RD_GZIP is not set)" >> $(LINUX_DIR
)/.config
65 echo
-e
"$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),CONFIG_INITRAMFS_COMPRESSION_BZIP2=y\nCONFIG_RD_BZIP2=y,# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set\n# CONFIG_RD_BZIP2 is not set)" >> $(LINUX_DIR
)/.config
66 echo
-e
"$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA),CONFIG_INITRAMFS_COMPRESSION_LZMA=y\nCONFIG_RD_LZMA=y,# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set\n# CONFIG_RD_LZMA is not set)" >> $(LINUX_DIR
)/.config
67 echo
-e
"$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO),CONFIG_INITRAMFS_COMPRESSION_LZO=y\nCONFIG_RD_LZO=y,# CONFIG_INITRAMFS_COMPRESSION_LZO is not set\n# CONFIG_RD_LZO is not set)" >> $(LINUX_DIR
)/.config
68 echo
-e
"$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),CONFIG_INITRAMFS_COMPRESSION_XZ=y\nCONFIG_RD_XZ=y,# CONFIG_INITRAMFS_COMPRESSION_XZ is not set\n# CONFIG_RD_XZ is not set)" >> $(LINUX_DIR
)/.config
71 define Kernel
/SetInitramfs
72 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
73 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
74 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
78 define Kernel
/Configure
/Default
79 $(LINUX_CONF_CMD
) > $(LINUX_DIR
)/.config.target
80 # copy CONFIG_KERNEL_* settings over to .config.target
81 awk
'/^(#[[:space:]]+)?CONFIG_KERNEL/{sub("CONFIG_KERNEL_","CONFIG_");print}' $(TOPDIR
)/.config
>> $(LINUX_DIR
)/.config.target
82 echo
"# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR
)/.config.target
83 echo
"# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR
)/.config.target
84 echo
"# CONFIG_KPROBES is not set" >> $(LINUX_DIR
)/.config.target
85 $(SCRIPT_DIR
)/metadata.pl kconfig
$(TMP_DIR
)/.packageinfo
$(TOPDIR
)/.config
> $(LINUX_DIR
)/.config.
override
86 $(SCRIPT_DIR
)/kconfig.pl
'm+' '+' $(LINUX_DIR
)/.config.target
/dev
/null
$(LINUX_DIR
)/.config.
override > $(LINUX_DIR
)/.config
87 $(call Kernel
/SetInitramfs
)
88 -$(_SINGLE
)$(MAKE
) $(KERNEL_MAKEOPTS
) oldconfig prepare scripts
89 rm -rf
$(KERNEL_BUILD_DIR
)/modules
92 define Kernel
/CompileModules
/Default
93 rm -f
$(LINUX_DIR
)/vmlinux
$(LINUX_DIR
)/System.map
94 +$(MAKE
) $(KERNEL_MAKEOPTS
) modules
97 OBJCOPY_STRIP
= -R .reginfo
-R .notes
-R .note
-R .comment
-R .mdebug
-R .note.gnu.build-id
99 define Kernel
/CompileImage
/Default
100 $(if
$(CONFIG_TARGET_ROOTFS_INITRAMFS
),,rm -f
$(TARGET_DIR
)/init
)
101 +$(MAKE
) $(KERNEL_MAKEOPTS
) $(KERNELNAME
)
102 $(KERNEL_CROSS
)objcopy
-O binary
$(OBJCOPY_STRIP
) -S
$(LINUX_DIR
)/vmlinux
$(LINUX_KERNEL
)
103 $(KERNEL_CROSS
)objcopy
$(OBJCOPY_STRIP
) -S
$(LINUX_DIR
)/vmlinux
$(KERNEL_BUILD_DIR
)/vmlinux.elf
106 define Kernel
/Clean
/Default
107 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.configured
108 rm -f
$(LINUX_KERNEL
)
109 $(_SINGLE
)$(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean