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 INITRAMFS_EXTRA_FILES ?
= $(GENERIC_PLATFORM_DIR
)/image
/initramfs-base-files.txt
28 KERNEL_MAKEOPTS
+= CC
="$(KERNEL_CC)"
32 Kernel
/Patch
:=$(Kernel
/Patch
/Default
)
33 ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE
)),"")
34 ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI
)),"")
35 define Kernel
/Prepare
/Default
36 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
$(TAR
) -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
38 touch
$(LINUX_DIR
)/.quilt_used
41 ifeq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY
)),"")
42 define Kernel
/Prepare
/Default
43 git clone
$(CONFIG_KERNEL_GIT_CLONE_URI
) $(LINUX_DIR
)
46 define Kernel
/Prepare
/Default
47 git clone
--reference
$(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY
) $(CONFIG_KERNEL_GIT_CLONE_URI
) $(LINUX_DIR
)
52 define Kernel
/Prepare
/Default
53 mkdir
-p
$(KERNEL_BUILD_DIR
)
54 if
[ -d
$(LINUX_DIR
) ]; then \
57 ln
-s
$(CONFIG_EXTERNAL_KERNEL_TREE
) $(LINUX_DIR
)
62 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
63 define Kernel
/SetInitramfs
64 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
65 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
66 echo
'CONFIG_INITRAMFS_SOURCE="$(strip $(TARGET_DIR) $(INITRAMFS_EXTRA_FILES))"' >> $(LINUX_DIR
)/.config
67 echo
'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR
)/.config
68 echo
'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR
)/.config
69 echo
'CONFIG_INITRAMFS_COMPRESSION_NONE=y' >> $(LINUX_DIR
)/.config
70 echo
'# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set' >> $(LINUX_DIR
)/.config
73 define Kernel
/SetInitramfs
74 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
75 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
76 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
81 define Kernel
/Configure
/2.4
82 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
83 $(_SINGLE
)$(MAKE
) $(KERNEL_MAKEOPTS
) oldconfig
include/linux
/compile.h
include/linux
/version.h
84 $(_SINGLE
)$(MAKE
) $(KERNEL_MAKEOPTS
) dep
86 define Kernel
/Configure
/2.6
87 -$(_SINGLE
)$(MAKE
) $(KERNEL_MAKEOPTS
) oldconfig prepare scripts
89 define Kernel
/Configure
/Default
90 $(LINUX_CONFCMD
) > $(LINUX_DIR
)/.config.target
91 echo
"$(if $(CONFIG_KERNEL_KALLSYMS),CONFIG_KALLSYMS=y,# CONFIG_KALLSYMS is not set)" >> $(LINUX_DIR
)/.config.target
92 echo
"$(if $(CONFIG_KERNEL_PROFILING),CONFIG_PROFILING=y,# CONFIG_PROFILING is not set)" >> $(LINUX_DIR
)/.config.target
93 echo
"# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR
)/.config.target
94 echo
"# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR
)/.config.target
95 echo
"# CONFIG_KPROBES is not set" >> $(LINUX_DIR
)/.config.target
96 $(SED
) 's,.*CONFIG_AEABI.*,$(if $(CONFIG_EABI_SUPPORT),CONFIG_AEABI=y,# CONFIG_AEABI is not set),' $(LINUX_DIR
)/.config.target
97 $(if
$(CONFIG_EABI_SUPPORT
),echo
'# CONFIG_OABI_COMPAT is not set' >> $(LINUX_DIR
)/.config.target
)
98 $(SCRIPT_DIR
)/metadata.pl kconfig
$(TMP_DIR
)/.packageinfo
$(TOPDIR
)/.config
> $(LINUX_DIR
)/.config.
override
99 $(SCRIPT_DIR
)/kconfig.pl
'm+' $(LINUX_DIR
)/.config.target
$(LINUX_DIR
)/.config.
override > $(LINUX_DIR
)/.config
100 $(call Kernel
/SetInitramfs
)
101 $(call Kernel
/Configure
/$(KERNEL
))
102 rm -rf
$(KERNEL_BUILD_DIR
)/modules
105 define Kernel
/CompileModules
/Default
106 rm -f
$(LINUX_DIR
)/vmlinux
$(LINUX_DIR
)/System.map
107 +$(MAKE
) $(KERNEL_MAKEOPTS
) modules
110 OBJCOPY_STRIP
= -R .reginfo
-R .notes
-R .note
-R .comment
-R .mdebug
-R .note.gnu.build-id
112 define Kernel
/CompileImage
/Default
113 $(if
$(CONFIG_TARGET_ROOTFS_INITRAMFS
),,rm -f
$(TARGET_DIR
)/init
)
114 +$(MAKE
) $(KERNEL_MAKEOPTS
) $(KERNELNAME
)
115 $(KERNEL_CROSS
)objcopy
-O binary
$(OBJCOPY_STRIP
) -S
$(LINUX_DIR
)/vmlinux
$(LINUX_KERNEL
)
116 $(KERNEL_CROSS
)objcopy
$(OBJCOPY_STRIP
) -S
$(LINUX_DIR
)/vmlinux
$(KERNEL_BUILD_DIR
)/vmlinux.elf
119 define Kernel
/Clean
/Default
120 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.configured
121 rm -f
$(LINUX_KERNEL
)
122 $(_SINGLE
)$(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean