2 # Copyright (C) 2006 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
9 include $(INCLUDE_DIR
)/prereq.mk
12 ifneq ($(CONFIG_ATM
),)
15 ifneq ($(CONFIG_PCI
),)
18 ifneq ($(CONFIG_USB
),)
21 ifneq ($(CONFIG_PCMCIA
),)
24 ifneq ($(CONFIG_VIDEO_DEV
),)
29 FEATURES
:=$(sort $(FEATURES
))
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
40 include $(INCLUDE_DIR
)/kernel-version.mk
41 include $(INCLUDE_DIR
)/host.mk
42 include $(INCLUDE_DIR
)/kernel.mk
44 LINUX_CONFIG
:=.
/config
46 ifneq (,$(findstring uml
,$(BOARD
)))
49 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
59 ifneq (,$(findstring x86
,$(BOARD
)))
62 ifneq (,$(findstring rdc
,$(BOARD
)))
65 ifneq (,$(findstring ppc
,$(BOARD
)))
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
77 $(call Kernel
/Prepare
/Default
)
80 KERNEL_MAKEOPTS
:= -C
$(LINUX_DIR
) \
81 CROSS_COMPILE
="$(KERNEL_CROSS)" \
82 ARCH
="$(LINUX_KARCH)" \
83 CONFIG_SHELL
="$(BASH)"
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
90 define Kernel
/Configure
/2.6
91 $(MAKE
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" oldconfig prepare scripts
93 define Kernel
/Configure
/Default
94 @
$(CP
) $(LINUX_CONFIG
) $(LINUX_DIR
)/.config
95 $(call Kernel
/Configure
/$(KERNEL
))
97 define Kernel
/Configure
98 $(call Kernel
/Configure
/Default
)
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
106 define Kernel
/CompileModules
107 $(call Kernel
/CompileModules
/Default
)
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
/
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
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
)
136 define Kernel
/CompileImage
137 $(call Kernel
/CompileImage
/Default
)
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
148 $(call Kernel
/Clean
/Default
)
152 ifneq ($(LINUX_SITE
),)
153 $(DL_DIR
)/$(LINUX_SOURCE
):
155 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
)
158 $(LINUX_DIR
)/.prepared
: $(DL_DIR
)/$(LINUX_SOURCE
)
159 -rm -rf
$(KERNEL_BUILD_DIR
)
160 -mkdir
-p
$(KERNEL_BUILD_DIR
)
161 $(call Kernel
/Prepare
)
164 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.prepared
$(LINUX_CONFIG
)
165 $(call Kernel
/Configure
)
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
)
175 $(LINUX_DIR
)/.image
: $(LINUX_DIR
)/.configured FORCE
176 $(call Kernel
/CompileImage
)
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
)
195 @echo
'Default-Packages: $(DEFAULT_PACKAGES)'
205 define Profile
/Default
211 $(eval
$(call Profile
/Default
))
212 $(eval
$(call Profile
/$(1)))
213 $(eval
$(call shexport
,Profile
/$(1)/Description
))
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)"; \
224 $(eval
$(call shexport
,Target
/Description
))
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
232 rm -f
$(STAMP_DIR
)/.linux-compile
233 rm -rf
$(KERNEL_BUILD_DIR
)
237 @if
[ -f
$(LINUX_KERNEL
) ]; then \