remove obsolete file
[openwrt.git] / include / kernel-build.mk
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 KERNEL_BUILD:=1
8
9 include $(INCLUDE_DIR)/host.mk
10 include $(INCLUDE_DIR)/kernel.mk
11
12 LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.bz2
13 LINUX_SITE:=http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
14 http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
15 http://www.kernel.org/pub/linux/kernel/v$(KERNEL) \
16 http://www.de.kernel.org/pub/linux/kernel/v$(KERNEL)
17
18 LINUX_CONFIG:=./config
19
20 ifneq (,$(findstring uml,$(BOARD)))
21 LINUX_KARCH:=um
22 else
23 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
24 -e 's/mipsel/mips/' \
25 -e 's/mipseb/mips/' \
26 -e 's/powerpc/ppc/' \
27 -e 's/sh[234]/sh/' \
28 -e 's/armeb/arm/' \
29 )
30 endif
31
32 KERNELNAME=
33 ifneq (,$(findstring x86,$(BOARD)))
34 KERNELNAME="bzImage"
35 endif
36 ifneq (,$(findstring ppc,$(BOARD)))
37 KERNELNAME="uImage"
38 endif
39
40
41 define Kernel/Prepare/Default
42 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
43 [ -d ../generic-$(KERNEL)/patches ] && $(PATCH) $(LINUX_DIR) ../generic-$(KERNEL)/patches
44 [ -d ./patches ] && $(PATCH) $(LINUX_DIR) ./patches
45 endef
46 define Kernel/Prepare
47 $(call Kernel/Prepare/Default)
48 endef
49
50
51 define Kernel/Configure/2.4
52 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
53 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig include/linux/compile.h include/linux/version.h
54 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) dep
55 endef
56 define Kernel/Configure/2.6
57 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig prepare scripts
58 endef
59 define Kernel/Configure/Default
60 @$(CP) $(LINUX_CONFIG) $(LINUX_DIR)/.config
61 $(call Kernel/Configure/$(KERNEL))
62 endef
63 define Kernel/Configure
64 $(call Kernel/Configure/Default)
65 endef
66
67
68 define Kernel/CompileModules/Default
69 $(MAKE) -j$(CONFIG_JLEVEL) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) modules
70 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) DEPMOD=true INSTALL_MOD_PATH=$(KERNEL_BUILD_DIR)/modules modules_install
71 endef
72 define Kernel/CompileModules
73 $(call Kernel/CompileModules/Default)
74 endef
75
76
77 ifeq ($(KERNEL),2.6)
78 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
79 define Kernel/SetInitramfs
80 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
81 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
82 echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
83 echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
84 echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
85 mkdir -p $(BUILD_DIR)/root/etc/init.d
86 $(CP) ../generic-2.6/files/init $(BUILD_DIR)/root/
87 endef
88 else
89 define Kernel/SetInitramfs
90 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
91 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
92 rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs
93 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
94 endef
95 endif
96 endif
97 define Kernel/CompileImage/Default
98 $(call Kernel/SetInitramfs)
99 $(MAKE) -j$(CONFIG_JLEVEL) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) $(KERNELNAME)
100 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
101 endef
102 define Kernel/CompileImage
103 $(call Kernel/CompileImage/Default)
104 endef
105
106 define Kernel/Clean/Default
107 rm -f $(LINUX_DIR)/.linux-compile
108 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
109 rm -f $(LINUX_KERNEL)
110 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
111 endef
112
113 define Kernel/Clean
114 $(call Kernel/Clean/Default)
115 endef
116
117 define BuildKernel
118 ifneq ($(LINUX_SITE),)
119 $(DL_DIR)/$(LINUX_SOURCE):
120 -mkdir -p $(DL_DIR)
121 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
122 endif
123
124 $(LINUX_DIR)/.prepared: $(DL_DIR)/$(LINUX_SOURCE)
125 -rm -rf $(KERNEL_BUILD_DIR)
126 -mkdir -p $(KERNEL_BUILD_DIR)
127 $(call Kernel/Prepare)
128 touch $$@
129
130 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.prepared $(LINUX_CONFIG)
131 $(call Kernel/Configure)
132 touch $$@
133
134 $(LINUX_DIR)/.modules: $(LINUX_DIR)/.configured
135 rm -rf $(KERNEL_BUILD_DIR)/modules
136 @rm -f $(BUILD_DIR)/linux
137 ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
138 $(call Kernel/CompileModules)
139 touch $$@
140
141 $(LINUX_DIR)/.image: $(LINUX_DIR)/.configured FORCE
142 $(call Kernel/CompileImage)
143 touch $$@
144
145 mostlyclean: FORCE
146 $(call Kernel/Clean)
147
148 define BuildKernel
149 endef
150 endef
151
152
153 download: $(DL_DIR)/$(LINUX_SOURCE)
154 prepare: $(LINUX_DIR)/.configured $(TOPDIR)/.kernel.mk
155 compile: $(LINUX_DIR)/.modules
156 install: $(LINUX_DIR)/.image
157
158 clean: FORCE
159 rm -f $(STAMP_DIR)/.linux-compile
160 rm -rf $(KERNEL_BUILD_DIR)
161
162 rebuild: FORCE
163 @$(MAKE) mostlyclean
164 @if [ -f $(LINUX_KERNEL) ]; then \
165 $(MAKE) clean; \
166 fi
167 @$(MAKE) compile
168
169 $(TOPDIR)/.kernel.mk: Makefile
170 echo "CONFIG_BOARD:=$(BOARD)" > $@
171 echo "CONFIG_KERNEL:=$(KERNEL)" >> $@
172 echo "CONFIG_LINUX_VERSION:=$(LINUX_VERSION)" >> $@
173 echo "CONFIG_LINUX_RELEASE:=$(LINUX_RELEASE)" >> $@
174 echo "CONFIG_LINUX_KARCH:=$(LINUX_KARCH)" >> $@
175
176
This page took 0.050682 seconds and 5 git commands to generate.