add git checkout support
[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 CONFIG_SHELL="$(BASH)"
26
27 INITRAMFS_EXTRA_FILES ?= $(GENERIC_PLATFORM_DIR)/image/initramfs-base-files.txt
28
29 ifneq (,$(KERNEL_CC))
30 KERNEL_MAKEOPTS += CC="$(KERNEL_CC)"
31 endif
32
33 # defined in quilt.mk
34 Kernel/Patch:=$(Kernel/Patch/Default)
35 define Kernel/Prepare/Default
36 bzcat $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
37 $(Kernel/Patch)
38 $(if $(QUILT),touch $(LINUX_DIR)/.quilt_used)
39 endef
40
41 define Kernel/Configure/2.4
42 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
43 $(MAKE) $(KERNEL_MAKEOPTS) oldconfig include/linux/compile.h include/linux/version.h
44 $(MAKE) $(KERNEL_MAKEOPTS) dep
45 endef
46 define Kernel/Configure/2.6
47 -$(MAKE) $(KERNEL_MAKEOPTS) oldconfig prepare scripts
48 endef
49 define Kernel/Configure/Default
50 $(LINUX_CONFCMD) > $(LINUX_DIR)/.config.target
51 $(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config > $(LINUX_DIR)/.config.override
52 $(SCRIPT_DIR)/kconfig.pl 'm+' $(LINUX_DIR)/.config.target $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config
53 $(call Kernel/Configure/$(KERNEL))
54 rm -rf $(KERNEL_BUILD_DIR)/modules
55 endef
56
57 define Kernel/CompileModules/Default
58 rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map
59 $(MAKE) $(KERNEL_MAKEOPTS) modules
60 endef
61
62 ifeq ($(KERNEL),2.6)
63 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
64 define Kernel/SetInitramfs
65 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
66 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
67 echo 'CONFIG_INITRAMFS_SOURCE="$(strip $(TARGET_DIR) $(INITRAMFS_EXTRA_FILES))"' >> $(LINUX_DIR)/.config
68 echo 'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR)/.config
69 echo 'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR)/.config
70 endef
71 else
72 define Kernel/SetInitramfs
73 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
74 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
75 rm -f $(TARGET_DIR)/init
76 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
77 endef
78 endif
79 endif
80 define Kernel/CompileImage/Default
81 $(call Kernel/SetInitramfs)
82 $(MAKE) $(KERNEL_MAKEOPTS) $(KERNELNAME)
83 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
84 $(KERNEL_CROSS)objcopy -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
85 endef
86
87 define Kernel/Clean/Default
88 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
89 rm -f $(LINUX_KERNEL)
90 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
91 endef
92
93
This page took 0.057138 seconds and 5 git commands to generate.