Use current UID for initramfs root user:group
[openwrt/svn-archive/archive.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 # default device type
9 DEVICE_TYPE?=router
10
11 # Default packages - the really basic set
12 DEFAULT_PACKAGES:=base-files libgcc uclibc busybox dropbear mtd mtd
13 # For router targets
14 DEFAULT_PACKAGES.router:=dnsmasq iptables ppp ppp-mod-pppoe iptables kmod-ipt-nathelper bridge
15
16 # Additional packages for Linux 2.6
17 ifneq ($(KERNEL),2.4)
18 DEFAULT_PACKAGES += udevtrigger hotplug2
19 endif
20
21 # Add device specific packages
22 DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE))
23
24 KERNELNAME=
25 ifneq (,$(findstring x86,$(BOARD)))
26 KERNELNAME="bzImage"
27 endif
28 ifneq (,$(findstring rdc,$(BOARD)))
29 KERNELNAME="bzImage"
30 endif
31 ifneq (,$(findstring ppc,$(BOARD)))
32 KERNELNAME="uImage"
33 endif
34 ifneq (,$(findstring avr32,$(BOARD)))
35 KERNELNAME="uImage"
36 endif
37
38 KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
39 CROSS_COMPILE="$(KERNEL_CROSS)" \
40 ARCH="$(LINUX_KARCH)" \
41 CONFIG_SHELL="$(BASH)"
42
43 ifneq (,$(KERNEL_CC))
44 KERNEL_MAKEOPTS += CC="$(KERNEL_CC)"
45 endif
46
47 # defined in quilt.mk
48 Kernel/Patch:=$(Kernel/Patch/Default)
49 define Kernel/Prepare/Default
50 bzcat $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
51 $(Kernel/Patch)
52 $(if $(QUILT),touch $(LINUX_DIR)/.quilt_used)
53 endef
54
55 define Kernel/Configure/2.4
56 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
57 $(MAKE) $(KERNEL_MAKEOPTS) oldconfig include/linux/compile.h include/linux/version.h
58 $(MAKE) $(KERNEL_MAKEOPTS) dep
59 endef
60 define Kernel/Configure/2.6
61 -$(MAKE) $(KERNEL_MAKEOPTS) oldconfig prepare scripts
62 endef
63 define Kernel/Configure/Default
64 $(LINUX_CONFCMD) > $(LINUX_DIR)/.config.target
65 $(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config > $(LINUX_DIR)/.config.override
66 $(SCRIPT_DIR)/kconfig.pl 'm+' $(LINUX_DIR)/.config.target $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config
67 $(call Kernel/Configure/$(KERNEL))
68 rm -rf $(KERNEL_BUILD_DIR)/modules
69 endef
70
71 define Kernel/CompileModules/Default
72 rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map
73 $(MAKE) $(KERNEL_MAKEOPTS) modules
74 endef
75
76 ifeq ($(KERNEL),2.6)
77 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
78 define Kernel/SetInitramfs
79 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
80 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
81 echo 'CONFIG_INITRAMFS_SOURCE="$(TARGET_DIR)"' >> $(LINUX_DIR)/.config
82 echo 'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR)/.config
83 echo 'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR)/.config
84 endef
85 else
86 define Kernel/SetInitramfs
87 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
88 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
89 rm -f $(TARGET_DIR)/init
90 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
91 endef
92 endif
93 endif
94 define Kernel/CompileImage/Default
95 $(call Kernel/SetInitramfs)
96 $(MAKE) $(KERNEL_MAKEOPTS) $(KERNELNAME)
97 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
98 $(KERNEL_CROSS)objcopy -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
99 endef
100
101 define Kernel/Clean/Default
102 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
103 rm -f $(LINUX_KERNEL)
104 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
105 endef
106
107