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
),)
26 FEATURES
:=$(sort $(FEATURES
))
28 # For target profile selection - the default set
29 DEFAULT_PACKAGES
:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd
37 include $(INCLUDE_DIR
)/kernel-version.mk
38 include $(INCLUDE_DIR
)/host.mk
39 include $(INCLUDE_DIR
)/kernel.mk
41 LINUX_CONFIG
:=.
/config
43 ifneq (,$(findstring uml
,$(BOARD
)))
46 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
56 ifneq (,$(findstring x86
,$(BOARD
)))
59 ifneq (,$(findstring rdc
,$(BOARD
)))
62 ifneq (,$(findstring ppc
,$(BOARD
)))
67 define Kernel
/Prepare
/Default
68 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
69 [ -d
$(GENERIC_PLATFORM_DIR
)/patches
] && $(PATCH
) $(LINUX_DIR
) $(GENERIC_PLATFORM_DIR
)/patches
70 [ -d .
/patches
] && $(PATCH
) $(LINUX_DIR
) .
/patches
73 $(call Kernel
/Prepare
/Default
)
76 KERNEL_MAKEOPTS
:= -C
$(LINUX_DIR
) \
77 CROSS_COMPILE
="$(KERNEL_CROSS)" \
78 ARCH
="$(LINUX_KARCH)" \
79 CONFIG_SHELL
="$(BASH)"
81 define Kernel
/Configure
/2.4
82 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
83 $(MAKE
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" oldconfig
include/linux
/compile.h
include/linux
/version.h
84 $(MAKE
) $(KERNEL_MAKEOPTS
) dep
86 define Kernel
/Configure
/2.6
87 $(MAKE
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" oldconfig prepare scripts
89 define Kernel
/Configure
/Default
90 @
$(CP
) $(LINUX_CONFIG
) $(LINUX_DIR
)/.config
91 $(call Kernel
/Configure
/$(KERNEL
))
93 define Kernel
/Configure
94 $(call Kernel
/Configure
/Default
)
98 define Kernel
/CompileModules
/Default
99 $(MAKE
) -j
$(CONFIG_JLEVEL
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" modules
100 $(MAKE
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" DEPMOD
=true INSTALL_MOD_PATH
=$(KERNEL_BUILD_DIR
)/modules modules_install
102 define Kernel
/CompileModules
103 $(call Kernel
/CompileModules
/Default
)
108 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
109 define Kernel
/SetInitramfs
110 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
111 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
112 echo
'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR
)/.config
113 echo
'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR
)/.config
114 echo
'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR
)/.config
115 mkdir
-p
$(BUILD_DIR
)/root
/etc
/init.d
116 $(CP
) $(GENERIC_PLATFORM_DIR
)/files
/init
$(BUILD_DIR
)/root
/
119 define Kernel
/SetInitramfs
120 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
121 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
122 rm -f
$(BUILD_DIR
)/root
/init
$(BUILD_DIR
)/root
/etc
/init.d
/S00initramfs
123 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
127 define Kernel
/CompileImage
/Default
128 $(call Kernel
/SetInitramfs
)
129 $(MAKE
) -j
$(CONFIG_JLEVEL
) $(KERNEL_MAKEOPTS
) CC
="$(KERNEL_CC)" $(KERNELNAME
)
130 $(KERNEL_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$(LINUX_DIR
)/vmlinux
$(LINUX_KERNEL
)
132 define Kernel
/CompileImage
133 $(call Kernel
/CompileImage
/Default
)
136 define Kernel
/Clean
/Default
137 rm -f
$(LINUX_DIR
)/.linux-compile
138 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.configured
139 rm -f
$(LINUX_KERNEL
)
140 $(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
144 $(call Kernel
/Clean
/Default
)
148 ifneq ($(LINUX_SITE
),)
149 $(DL_DIR
)/$(LINUX_SOURCE
):
151 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
)
154 $(LINUX_DIR
)/.prepared
: $(DL_DIR
)/$(LINUX_SOURCE
)
155 -rm -rf
$(KERNEL_BUILD_DIR
)
156 -mkdir
-p
$(KERNEL_BUILD_DIR
)
157 $(call Kernel
/Prepare
)
160 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.prepared
$(LINUX_CONFIG
)
161 $(call Kernel
/Configure
)
164 $(LINUX_DIR
)/.modules
: $(LINUX_DIR
)/.configured
165 rm -rf
$(KERNEL_BUILD_DIR
)/modules
166 @
rm -f
$(BUILD_DIR
)/linux
167 ln
-sf
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(BUILD_DIR
)/linux
168 $(call Kernel
/CompileModules
)
171 $(LINUX_DIR
)/.image
: $(LINUX_DIR
)/.configured FORCE
172 $(call Kernel
/CompileImage
)
180 @echo
'Target: $(BOARD)-$(KERNEL)'
181 @echo
'Target-Name: $(BOARDNAME) [$(KERNEL)]'
182 @echo
'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
183 @echo
'Target-Arch: $(ARCH)'
184 @echo
'Target-Features: $(FEATURES)'
185 @echo
'Linux-Version: $(LINUX_VERSION)'
186 @echo
'Linux-Release: $(LINUX_RELEASE)'
187 @echo
'Linux-Kernel-Arch: $(LINUX_KARCH)'
188 @echo
'Target-Description:'
189 @getvar
$(call shvar
,Target
/Description
)
191 @echo
'Default-Packages: $(DEFAULT_PACKAGES)'
201 define Profile
/Default
207 $(eval
$(call Profile
/Default
))
208 $(eval
$(call Profile
/$(1)))
210 echo
"Target-Profile: $(1)"; \
211 echo
"Target-Profile-Name: $(NAME)"; \
212 echo
"Target-Profile-Packages: $(PACKAGES)";
215 $(eval
$(call shexport
,Target
/Description
))
217 download
: $(DL_DIR
)/$(LINUX_SOURCE
)
218 prepare
: $(LINUX_DIR
)/.configured
$(TMP_DIR
)/.kernel.mk
219 compile
: $(LINUX_DIR
)/.modules
220 install: $(LINUX_DIR
)/.image
223 rm -f
$(STAMP_DIR
)/.linux-compile
224 rm -rf
$(KERNEL_BUILD_DIR
)
228 @if
[ -f
$(LINUX_KERNEL
) ]; then \