Change localhost into a fully qualified name; remove OpenWrt alias to 127.0.0.1
[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)/prereq.mk
10
11 -include ./config
12 ifneq ($(CONFIG_ATM),)
13 FEATURES += atm
14 endif
15 ifneq ($(CONFIG_PCI),)
16 FEATURES += pci
17 endif
18 ifneq ($(CONFIG_USB),)
19 FEATURES += usb
20 endif
21 ifneq ($(CONFIG_PCMCIA),)
22 FEATURES += pcmcia
23 endif
24 ifneq ($(CONFIG_VIDEO_DEV),)
25 FEATURES += video
26 endif
27
28 # remove duplicates
29 FEATURES:=$(sort $(FEATURES))
30
31 # For target profile selection - the default set
32 DEFAULT_PACKAGES:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd kmod-ipt-nathelper
33
34 ifeq ($(DUMP),1)
35 all: dumpinfo
36 else
37 all: compile
38 endif
39
40 include $(INCLUDE_DIR)/kernel-version.mk
41 include $(INCLUDE_DIR)/host.mk
42 include $(INCLUDE_DIR)/kernel.mk
43
44 LINUX_CONFIG:=./config
45
46 ifneq (,$(findstring uml,$(BOARD)))
47 LINUX_KARCH:=um
48 else
49 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
50 -e 's/mipsel/mips/' \
51 -e 's/mipseb/mips/' \
52 -e 's/powerpc/ppc/' \
53 -e 's/sh[234]/sh/' \
54 -e 's/armeb/arm/' \
55 )
56 endif
57
58 KERNELNAME=
59 ifneq (,$(findstring x86,$(BOARD)))
60 KERNELNAME="bzImage"
61 endif
62 ifneq (,$(findstring rdc,$(BOARD)))
63 KERNELNAME="bzImage"
64 endif
65 ifneq (,$(findstring ppc,$(BOARD)))
66 KERNELNAME="uImage"
67 endif
68
69
70 define Kernel/Prepare/Default
71 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
72 if [ -d $(GENERIC_PLATFORM_DIR)/patches ]; then $(PATCH) $(LINUX_DIR) $(GENERIC_PLATFORM_DIR)/patches; fi
73 if [ -d ./files ]; then $(CP) ./files/* $(LINUX_DIR)/; fi
74 if [ -d ./patches ]; then $(PATCH) $(LINUX_DIR) ./patches; fi
75 endef
76 define Kernel/Prepare
77 $(call Kernel/Prepare/Default)
78 endef
79
80 KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
81 CROSS_COMPILE="$(KERNEL_CROSS)" \
82 ARCH="$(LINUX_KARCH)" \
83 CONFIG_SHELL="$(BASH)"
84
85 define Kernel/Configure/2.4
86 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
87 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig include/linux/compile.h include/linux/version.h
88 $(MAKE) $(KERNEL_MAKEOPTS) dep
89 endef
90 define Kernel/Configure/2.6
91 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig prepare scripts
92 endef
93 define Kernel/Configure/Default
94 @$(CP) $(LINUX_CONFIG) $(LINUX_DIR)/.config
95 $(call Kernel/Configure/$(KERNEL))
96 endef
97 define Kernel/Configure
98 $(call Kernel/Configure/Default)
99 endef
100
101
102 define Kernel/CompileModules/Default
103 $(MAKE) -j$(CONFIG_JLEVEL) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" modules
104 $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" DEPMOD=true INSTALL_MOD_PATH=$(KERNEL_BUILD_DIR)/modules modules_install
105 endef
106 define Kernel/CompileModules
107 $(call Kernel/CompileModules/Default)
108 endef
109
110
111 ifeq ($(KERNEL),2.6)
112 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
113 define Kernel/SetInitramfs
114 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
115 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
116 echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
117 echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
118 echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
119 mkdir -p $(BUILD_DIR)/root/etc/init.d
120 $(CP) $(GENERIC_PLATFORM_DIR)/files/init $(BUILD_DIR)/root/
121 endef
122 else
123 define Kernel/SetInitramfs
124 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
125 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
126 rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs
127 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
128 endef
129 endif
130 endif
131 define Kernel/CompileImage/Default
132 $(call Kernel/SetInitramfs)
133 $(MAKE) -j$(CONFIG_JLEVEL) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" $(KERNELNAME)
134 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
135 endef
136 define Kernel/CompileImage
137 $(call Kernel/CompileImage/Default)
138 endef
139
140 define Kernel/Clean/Default
141 rm -f $(LINUX_DIR)/.linux-compile
142 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
143 rm -f $(LINUX_KERNEL)
144 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
145 endef
146
147 define Kernel/Clean
148 $(call Kernel/Clean/Default)
149 endef
150
151 define BuildKernel
152 ifneq ($(LINUX_SITE),)
153 $(DL_DIR)/$(LINUX_SOURCE):
154 -mkdir -p $(DL_DIR)
155 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
156 endif
157
158 $(LINUX_DIR)/.prepared: $(DL_DIR)/$(LINUX_SOURCE)
159 -rm -rf $(KERNEL_BUILD_DIR)
160 -mkdir -p $(KERNEL_BUILD_DIR)
161 $(call Kernel/Prepare)
162 touch $$@
163
164 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.prepared $(LINUX_CONFIG)
165 $(call Kernel/Configure)
166 touch $$@
167
168 $(LINUX_DIR)/.modules: $(LINUX_DIR)/.configured
169 rm -rf $(KERNEL_BUILD_DIR)/modules
170 @rm -f $(BUILD_DIR)/linux
171 ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
172 $(call Kernel/CompileModules)
173 touch $$@
174
175 $(LINUX_DIR)/.image: $(LINUX_DIR)/.configured FORCE
176 $(call Kernel/CompileImage)
177 touch $$@
178
179 mostlyclean: FORCE
180 $(call Kernel/Clean)
181
182 ifeq ($(DUMP),1)
183 dumpinfo:
184 @echo 'Target: $(BOARD)-$(KERNEL)'
185 @echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
186 @echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
187 @echo 'Target-Arch: $(ARCH)'
188 @echo 'Target-Features: $(FEATURES)'
189 @echo 'Linux-Version: $(LINUX_VERSION)'
190 @echo 'Linux-Release: $(LINUX_RELEASE)'
191 @echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
192 @echo 'Target-Description:'
193 @getvar $(call shvar,Target/Description)
194 @echo '@@'
195 @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
196 ifneq ($(DUMPINFO),)
197 @$(DUMPINFO)
198 endif
199 endif
200
201 define BuildKernel
202 endef
203 endef
204
205 define Profile/Default
206 NAME:=
207 PACKAGES:=
208 endef
209
210 define Profile
211 $(eval $(call Profile/Default))
212 $(eval $(call Profile/$(1)))
213 $(eval $(call shexport,Profile/$(1)/Description))
214 DUMPINFO += \
215 echo "Target-Profile: $(1)"; \
216 echo "Target-Profile-Name: $(NAME)"; \
217 echo "Target-Profile-Packages: $(PACKAGES)"; \
218 echo "Target-Profile-Description:"; \
219 getvar "$(call shvar,Profile/$(1)/Description)"; \
220 echo "@@"; \
221 echo;
222 endef
223
224 $(eval $(call shexport,Target/Description))
225
226 download: $(DL_DIR)/$(LINUX_SOURCE)
227 prepare: $(LINUX_DIR)/.configured $(TMP_DIR)/.kernel.mk
228 compile: $(LINUX_DIR)/.modules
229 install: $(LINUX_DIR)/.image
230
231 clean: FORCE
232 rm -f $(STAMP_DIR)/.linux-compile
233 rm -rf $(KERNEL_BUILD_DIR)
234
235 rebuild: FORCE
236 @$(MAKE) mostlyclean
237 @if [ -f $(LINUX_KERNEL) ]; then \
238 $(MAKE) clean; \
239 fi
240 @$(MAKE) compile
241
242
This page took 0.051448 seconds and 5 git commands to generate.