one more instance of r13005
[openwrt.git] / include / kernel-defaults.mk
1 #
2 # Copyright (C) 2006-2007 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 KERNELNAME=
9 ifneq (,$(findstring x86,$(BOARD)))
10 KERNELNAME="bzImage"
11 endif
12 ifneq (,$(findstring rdc,$(BOARD)))
13 KERNELNAME="bzImage"
14 endif
15 ifneq (,$(findstring ppc,$(BOARD)))
16 KERNELNAME="uImage"
17 endif
18 ifneq (,$(findstring avr32,$(BOARD)))
19 KERNELNAME="uImage"
20 endif
21
22 KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
23 CROSS_COMPILE="$(KERNEL_CROSS)" \
24 ARCH="$(LINUX_KARCH)" \
25 KBUILD_HAVE_NLS=no \
26 CONFIG_SHELL="$(BASH)"
27
28 INITRAMFS_EXTRA_FILES ?= $(GENERIC_PLATFORM_DIR)/image/initramfs-base-files.txt
29
30 ifneq (,$(KERNEL_CC))
31 KERNEL_MAKEOPTS += CC="$(KERNEL_CC)"
32 endif
33
34 # defined in quilt.mk
35 Kernel/Patch:=$(Kernel/Patch/Default)
36 ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE)),"")
37 ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"")
38 define Kernel/Prepare/Default
39 bzcat $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
40 $(Kernel/Patch)
41 touch $(LINUX_DIR)/.quilt_used
42 endef
43 else
44 ifeq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)),"")
45 define Kernel/Prepare/Default
46 git clone $(CONFIG_KERNEL_GIT_CLONE_URI) $(LINUX_DIR)
47 endef
48 else
49 define Kernel/Prepare/Default
50 git clone --reference $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY) $(CONFIG_KERNEL_GIT_CLONE_URI) $(LINUX_DIR)
51 endef
52 endif
53 endif
54 else
55 define Kernel/Prepare/Default
56 mkdir -p $(KERNEL_BUILD_DIR)
57 if [ -d $(LINUX_DIR) ]; then \
58 rmdir $(LINUX_DIR); \
59 fi
60 ln -s $(CONFIG_EXTERNAL_KERNEL_TREE) $(LINUX_DIR)
61 endef
62 endif
63
64 ifeq ($(KERNEL),2.6)
65 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
66 define Kernel/SetInitramfs
67 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
68 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
69 echo 'CONFIG_INITRAMFS_SOURCE="$(strip $(TARGET_DIR) $(INITRAMFS_EXTRA_FILES))"' >> $(LINUX_DIR)/.config
70 echo 'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR)/.config
71 echo 'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR)/.config
72 endef
73 else
74 define Kernel/SetInitramfs
75 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
76 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
77 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
78 endef
79 endif
80 endif
81
82 define Kernel/Configure/2.4
83 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
84 $(_SINGLE)$(MAKE) $(KERNEL_MAKEOPTS) oldconfig include/linux/compile.h include/linux/version.h
85 $(_SINGLE)$(MAKE) $(KERNEL_MAKEOPTS) dep
86 endef
87 define Kernel/Configure/2.6
88 -$(_SINGLE)$(MAKE) $(KERNEL_MAKEOPTS) oldconfig prepare scripts
89 endef
90 define Kernel/Configure/Default
91 $(LINUX_CONFCMD) > $(LINUX_DIR)/.config.target
92 $(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config > $(LINUX_DIR)/.config.override
93 $(SCRIPT_DIR)/kconfig.pl 'm+' $(LINUX_DIR)/.config.target $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config
94 $(call Kernel/SetInitramfs)
95 $(call Kernel/Configure/$(KERNEL))
96 rm -rf $(KERNEL_BUILD_DIR)/modules
97 endef
98
99 define Kernel/CompileModules/Default
100 rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map
101 +$(MAKE) $(KERNEL_MAKEOPTS) modules
102 endef
103
104 define Kernel/CompileImage/Default
105 $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),,rm -f $(TARGET_DIR)/init)
106 +$(MAKE) $(KERNEL_MAKEOPTS) $(KERNELNAME)
107 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
108 $(KERNEL_CROSS)objcopy -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
109 endef
110
111 define Kernel/Clean/Default
112 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
113 rm -f $(LINUX_KERNEL)
114 $(_SINGLE)$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
115 endef
116
117
This page took 0.044947 seconds and 5 git commands to generate.