bugfix
[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 # For target profile selection - the default set
9 DEFAULT_PACKAGES:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd kmod-ipt-nathelper
10 ifneq ($(KERNEL),2.4)
11 DEFAULT_PACKAGES+=udevtrigger hotplug2
12 endif
13
14 KERNELNAME=
15 ifneq (,$(findstring x86,$(BOARD)))
16 KERNELNAME="bzImage"
17 endif
18 ifneq (,$(findstring rdc,$(BOARD)))
19 KERNELNAME="bzImage"
20 endif
21 ifneq (,$(findstring ppc,$(BOARD)))
22 KERNELNAME="uImage"
23 endif
24
25 KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
26 CROSS_COMPILE="$(KERNEL_CROSS)" \
27 ARCH="$(LINUX_KARCH)" \
28 CONFIG_SHELL="$(BASH)"
29
30 define Kernel/Prepare/Default
31 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
32 if [ -d $(GENERIC_PLATFORM_DIR)/files ]; then $(CP) $(GENERIC_PLATFORM_DIR)/files/* $(LINUX_DIR)/; fi
33 if [ -d $(GENERIC_PLATFORM_DIR)/patches ]; then $(PATCH) $(LINUX_DIR) $(GENERIC_PLATFORM_DIR)/patches; fi
34 if [ -d ./files ]; then $(CP) ./files/* $(LINUX_DIR)/; fi
35 if [ -d ./patches ]; then $(PATCH) $(LINUX_DIR) ./patches; fi
36 endef
37
38 define Kernel/Configure/2.4
39 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
40 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig include/linux/compile.h include/linux/version.h
41 $(MAKE) $(KERNEL_MAKEOPTS) dep
42 endef
43 define Kernel/Configure/2.6
44 -$(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig prepare scripts
45 endef
46 define Kernel/Configure/Default
47 @if [ -f "./config/profile-$(PROFILE)" ]; then \
48 $(SCRIPT_DIR)/config.pl '+' $(GENERIC_PLATFORM_DIR)/config-template '+' $(LINUX_CONFIG) ./config/profile-$(PROFILE) > $(LINUX_DIR)/.config; \
49 else \
50 $(SCRIPT_DIR)/config.pl '+' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_CONFIG) > $(LINUX_DIR)/.config; \
51 fi
52 $(call Kernel/Configure/$(KERNEL))
53 rm -rf $(KERNEL_BUILD_DIR)/modules
54 @rm -f $(BUILD_DIR)/linux
55 ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
56 endef
57
58 define Kernel/CompileModules/Default
59 rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map
60 $(MAKE) -j$(CONFIG_JLEVEL) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" modules
61 endef
62
63 ifeq ($(KERNEL),2.6)
64 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
65 define Kernel/SetInitramfs
66 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
67 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
68 echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
69 echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
70 echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
71 endef
72 else
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 rm -f $(BUILD_DIR)/root/init
77 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
78 endef
79 endif
80 endif
81 define Kernel/CompileImage/Default
82 $(call Kernel/SetInitramfs)
83 $(MAKE) -j$(CONFIG_JLEVEL) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" $(KERNELNAME)
84 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
85 $(KERNEL_CROSS)objcopy -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
86 endef
87
88 define Kernel/Clean/Default
89 rm -f $(LINUX_DIR)/.linux-compile
90 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
91 rm -f $(LINUX_KERNEL)
92 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
93 endef
94
95
This page took 0.052676 seconds and 5 git commands to generate.