x86/ep80579: switch to 3.3
[openwrt/svn-archive/archive.git] / include / kernel-defaults.mk
1 #
2 # Copyright (C) 2006-2011 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 KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
9 CROSS_COMPILE="$(KERNEL_CROSS)" \
10 ARCH="$(LINUX_KARCH)" \
11 KBUILD_HAVE_NLS=no \
12 CONFIG_SHELL="$(BASH)" \
13 $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
14
15 ifdef CONFIG_STRIP_KERNEL_EXPORTS
16 KERNEL_MAKEOPTS += \
17 EXTRA_LDSFLAGS="-I$(KERNEL_BUILD_DIR) -include symtab.h"
18 endif
19
20 INITRAMFS_EXTRA_FILES ?= $(GENERIC_PLATFORM_DIR)/image/initramfs-base-files.txt
21
22 ifneq (,$(KERNEL_CC))
23 KERNEL_MAKEOPTS += CC="$(KERNEL_CC)"
24 endif
25
26 export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include
27
28 # defined in quilt.mk
29 Kernel/Patch:=$(Kernel/Patch/Default)
30 ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE)),"")
31 ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"")
32 define Kernel/Prepare/Default
33 bzcat $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
34 $(Kernel/Patch)
35 touch $(LINUX_DIR)/.quilt_used
36 endef
37 else
38 ifeq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)),"")
39 define Kernel/Prepare/Default
40 git clone $(CONFIG_KERNEL_GIT_CLONE_URI) $(LINUX_DIR)
41 endef
42 else
43 define Kernel/Prepare/Default
44 git clone --reference $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY) $(CONFIG_KERNEL_GIT_CLONE_URI) $(LINUX_DIR)
45 endef
46 endif
47 endif
48 else
49 define Kernel/Prepare/Default
50 mkdir -p $(KERNEL_BUILD_DIR)
51 if [ -d $(LINUX_DIR) ]; then \
52 rmdir $(LINUX_DIR); \
53 fi
54 ln -s $(CONFIG_EXTERNAL_KERNEL_TREE) $(LINUX_DIR)
55 endef
56 endif
57
58 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
59 ifeq ($(strip $(CONFIG_EXTERNAL_CPIO)),"")
60 define Kernel/SetInitramfs
61 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
62 grep -v -e INITRAMFS -e CONFIG_RD_ -e CONFIG_BLK_DEV_INITRD $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
63 echo 'CONFIG_BLK_DEV_INITRD=y' >> $(LINUX_DIR)/.config
64 echo 'CONFIG_INITRAMFS_SOURCE="$(strip $(TARGET_DIR) $(INITRAMFS_EXTRA_FILES))"' >> $(LINUX_DIR)/.config
65 echo 'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR)/.config
66 echo 'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR)/.config
67 echo "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE),CONFIG_INITRAMFS_COMPRESSION_NONE=y,# CONFIG_INITRAMFS_COMPRESSION_NONE is not set)" >> $(LINUX_DIR)/.config
68 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
69 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
70 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
71 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
72 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
73 endef
74 else
75 define Kernel/SetInitramfs
76 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
77 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
78 echo 'CONFIG_INITRAMFS_SOURCE="$(call qstrip,$(CONFIG_EXTERNAL_CPIO))"' >> $(LINUX_DIR)/.config
79 echo 'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR)/.config
80 echo 'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR)/.config
81 echo "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE),CONFIG_INITRAMFS_COMPRESSION_NONE=y,# CONFIG_INITRAMFS_COMPRESSION_NONE is not set)" >> $(LINUX_DIR)/.config
82 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
83 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
84 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
85 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
86 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
87 endef
88 endif
89 else
90 define Kernel/SetInitramfs
91 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
92 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
93 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
94 endef
95 endif
96
97 define Kernel/Configure/Default
98 $(LINUX_CONF_CMD) > $(LINUX_DIR)/.config.target
99 # copy CONFIG_KERNEL_* settings over to .config.target
100 awk '/^(#[[:space:]]+)?CONFIG_KERNEL/{sub("CONFIG_KERNEL_","CONFIG_");print}' $(TOPDIR)/.config >> $(LINUX_DIR)/.config.target
101 echo "# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR)/.config.target
102 echo "# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR)/.config.target
103 echo "# CONFIG_KPROBES is not set" >> $(LINUX_DIR)/.config.target
104 $(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config > $(LINUX_DIR)/.config.override
105 $(SCRIPT_DIR)/kconfig.pl 'm+' '+' $(LINUX_DIR)/.config.target /dev/null $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config
106 $(call Kernel/SetInitramfs)
107 -$(_SINGLE)$(MAKE) $(KERNEL_MAKEOPTS) oldconfig prepare scripts
108 rm -rf $(KERNEL_BUILD_DIR)/modules
109 $(MAKE) $(KERNEL_MAKEOPTS) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install
110 $(SH_FUNC) grep '=[ym]' $(LINUX_DIR)/.config | LC_ALL=C sort | md5s > $(LINUX_DIR)/.vermagic
111 endef
112
113 define Kernel/CompileModules/Default
114 rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map
115 +$(MAKE) $(KERNEL_MAKEOPTS) modules
116 endef
117
118 OBJCOPY_STRIP = -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id
119
120 define Kernel/CompileImage/Default
121 $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),,rm -f $(TARGET_DIR)/init)
122 +$(MAKE) $(KERNEL_MAKEOPTS) $(KERNELNAME)
123 $(KERNEL_CROSS)objcopy -O binary $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
124 $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
125 endef
126
127 define Kernel/Clean/Default
128 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
129 rm -f $(LINUX_KERNEL)
130 $(_SINGLE)$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
131 endef
132
133