2 # Copyright (C) 2006-2007 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
9 ifneq (,$(findstring x86
,$(BOARD
)))
12 ifneq (,$(findstring rdc
,$(BOARD
)))
15 ifneq (,$(findstring avr32
,$(BOARD
)))
19 KERNEL_MAKEOPTS
:= -C
$(LINUX_DIR
) \
20 CROSS_COMPILE
="$(KERNEL_CROSS)" \
21 ARCH
="$(LINUX_KARCH)" \
23 CONFIG_SHELL
="$(BASH)"
25 ifdef CONFIG_STRIP_KERNEL_EXPORTS
27 EXTRA_LDSFLAGS
="-I$(KERNEL_BUILD_DIR) -include symtab.h"
30 INITRAMFS_EXTRA_FILES ?
= $(GENERIC_PLATFORM_DIR
)/image
/initramfs-base-files.txt
33 KERNEL_MAKEOPTS
+= CC
="$(KERNEL_CC)"
37 Kernel
/Patch
:=$(Kernel
/Patch
/Default
)
38 ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE
)),"")
39 ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI
)),"")
40 define Kernel
/Prepare
/Default
41 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
$(TAR
) -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
43 touch
$(LINUX_DIR
)/.quilt_used
46 ifeq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY
)),"")
47 define Kernel
/Prepare
/Default
48 git clone
$(CONFIG_KERNEL_GIT_CLONE_URI
) $(LINUX_DIR
)
51 define Kernel
/Prepare
/Default
52 git clone
--reference
$(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY
) $(CONFIG_KERNEL_GIT_CLONE_URI
) $(LINUX_DIR
)
57 define Kernel
/Prepare
/Default
58 mkdir
-p
$(KERNEL_BUILD_DIR
)
59 if
[ -d
$(LINUX_DIR
) ]; then \
62 ln
-s
$(CONFIG_EXTERNAL_KERNEL_TREE
) $(LINUX_DIR
)
67 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
68 define Kernel
/SetInitramfs
69 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
70 grep
-v
-e INITRAMFS
-e CONFIG_RD_
-e CONFIG_BLK_DEV_INITRD
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
71 echo
'CONFIG_BLK_DEV_INITRD=y' >> $(LINUX_DIR
)/.config
72 echo
'CONFIG_INITRAMFS_SOURCE="$(strip $(TARGET_DIR) $(INITRAMFS_EXTRA_FILES))"' >> $(LINUX_DIR
)/.config
73 echo
'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR
)/.config
74 echo
'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR
)/.config
75 echo
"$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE),CONFIG_INITRAMFS_COMPRESSION_NONE=y,# CONFIG_INITRAMFS_COMPRESSION_NONE is not set)" >> $(LINUX_DIR
)/.config
76 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
77 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
78 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
79 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
82 define Kernel
/SetInitramfs
83 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
84 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
85 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
90 define Kernel
/Configure
/2.4
91 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
92 $(_SINGLE
)$(MAKE
) $(KERNEL_MAKEOPTS
) oldconfig
include/linux
/compile.h
include/linux
/version.h
93 $(_SINGLE
)$(MAKE
) $(KERNEL_MAKEOPTS
) dep
95 define Kernel
/Configure
/2.6
96 -$(_SINGLE
)$(MAKE
) $(KERNEL_MAKEOPTS
) oldconfig prepare scripts
98 define Kernel
/Configure
/Default
99 $(LINUX_CONFCMD
) > $(LINUX_DIR
)/.config.target
100 echo
"$(if $(CONFIG_KERNEL_KALLSYMS),CONFIG_KALLSYMS=y,# CONFIG_KALLSYMS is not set)" >> $(LINUX_DIR
)/.config.target
101 echo
"$(if $(CONFIG_KERNEL_PROFILING),CONFIG_PROFILING=y,# CONFIG_PROFILING is not set)" >> $(LINUX_DIR
)/.config.target
102 echo
"$(if $(CONFIG_KERNEL_DEBUG_FS),CONFIG_DEBUG_FS=y,# CONFIG_DEBUG_FS is not set)" >> $(LINUX_DIR
)/.config.target
103 echo
"# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR
)/.config.target
104 echo
"# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR
)/.config.target
105 echo
"# CONFIG_KPROBES is not set" >> $(LINUX_DIR
)/.config.target
106 $(SED
) 's,.*CONFIG_AEABI.*,$(if $(CONFIG_EABI_SUPPORT),CONFIG_AEABI=y,# CONFIG_AEABI is not set),' $(LINUX_DIR
)/.config.target
107 $(if
$(CONFIG_EABI_SUPPORT
),echo
'# CONFIG_OABI_COMPAT is not set' >> $(LINUX_DIR
)/.config.target
)
108 $(SCRIPT_DIR
)/metadata.pl kconfig
$(TMP_DIR
)/.packageinfo
$(TOPDIR
)/.config
> $(LINUX_DIR
)/.config.
override
109 $(SCRIPT_DIR
)/kconfig.pl
'm+' '+' $(LINUX_DIR
)/.config.target
/dev
/null
$(LINUX_DIR
)/.config.
override > $(LINUX_DIR
)/.config
110 $(call Kernel
/SetInitramfs
)
111 $(call Kernel
/Configure
/$(KERNEL
))
112 rm -rf
$(KERNEL_BUILD_DIR
)/modules
115 define Kernel
/CompileModules
/Default
116 rm -f
$(LINUX_DIR
)/vmlinux
$(LINUX_DIR
)/System.map
117 +$(MAKE
) $(KERNEL_MAKEOPTS
) modules
120 OBJCOPY_STRIP
= -R .reginfo
-R .notes
-R .note
-R .comment
-R .mdebug
-R .note.gnu.build-id
122 define Kernel
/CompileImage
/Default
123 $(if
$(CONFIG_TARGET_ROOTFS_INITRAMFS
),,rm -f
$(TARGET_DIR
)/init
)
124 +$(MAKE
) $(KERNEL_MAKEOPTS
) $(KERNELNAME
)
125 $(KERNEL_CROSS
)objcopy
-O binary
$(OBJCOPY_STRIP
) -S
$(LINUX_DIR
)/vmlinux
$(LINUX_KERNEL
)
126 $(KERNEL_CROSS
)objcopy
$(OBJCOPY_STRIP
) -S
$(LINUX_DIR
)/vmlinux
$(KERNEL_BUILD_DIR
)/vmlinux.elf
129 define Kernel
/Clean
/Default
130 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.configured
131 rm -f
$(LINUX_KERNEL
)
132 $(_SINGLE
)$(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean