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 # For target profile selection - the default set
10 DEFAULT_PACKAGES
:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd
17 KERNEL
:=2.
$(word 2,$(subst .
, ,$(strip $(LINUX_VERSION
))))
19 include $(INCLUDE_DIR
)/host.mk
20 include $(INCLUDE_DIR
)/kernel.mk
22 LINUX_CONFIG
:=.
/config
24 ifneq (,$(findstring uml
,$(BOARD
)))
27 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
37 ifneq (,$(findstring x86
,$(BOARD
)))
40 ifneq (,$(findstring ppc
,$(BOARD
)))
45 define Kernel
/Prepare
/Default
46 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
47 [ -d ..
/generic-
$(KERNEL
)/patches
] && $(PATCH
) $(LINUX_DIR
) ..
/generic-
$(KERNEL
)/patches
48 [ -d .
/patches
] && $(PATCH
) $(LINUX_DIR
) .
/patches
51 $(call Kernel
/Prepare
/Default
)
55 define Kernel
/Configure
/2.4
56 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
57 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/compile.h
include/linux
/version.h
58 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" ARCH
=$(LINUX_KARCH
) dep
60 define Kernel
/Configure
/2.6
61 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig prepare scripts
63 define Kernel
/Configure
/Default
64 @
$(CP
) $(LINUX_CONFIG
) $(LINUX_DIR
)/.config
65 $(call Kernel
/Configure
/$(KERNEL
))
67 define Kernel
/Configure
68 $(call Kernel
/Configure
/Default
)
72 define Kernel
/CompileModules
/Default
73 $(MAKE
) -j
$(CONFIG_JLEVEL
) -C
"$(LINUX_DIR)" CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) modules
74 $(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
76 define Kernel
/CompileModules
77 $(call Kernel
/CompileModules
/Default
)
82 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
83 define Kernel
/SetInitramfs
84 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
85 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
86 echo
'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR
)/.config
87 echo
'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR
)/.config
88 echo
'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR
)/.config
89 mkdir
-p
$(BUILD_DIR
)/root
/etc
/init.d
90 $(CP
) ..
/generic-2.6
/files
/init
$(BUILD_DIR
)/root
/
93 define Kernel
/SetInitramfs
94 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
95 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
96 rm -f
$(BUILD_DIR
)/root
/init
$(BUILD_DIR
)/root
/etc
/init.d
/S00initramfs
97 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
101 define Kernel
/CompileImage
/Default
102 $(call Kernel
/SetInitramfs
)
103 $(MAKE
) -j
$(CONFIG_JLEVEL
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) $(KERNELNAME
)
104 $(KERNEL_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$(LINUX_DIR
)/vmlinux
$(LINUX_KERNEL
)
106 define Kernel
/CompileImage
107 $(call Kernel
/CompileImage
/Default
)
110 define Kernel
/Clean
/Default
111 rm -f
$(LINUX_DIR
)/.linux-compile
112 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.configured
113 rm -f
$(LINUX_KERNEL
)
114 $(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
118 $(call Kernel
/Clean
/Default
)
122 ifneq ($(LINUX_SITE
),)
123 $(DL_DIR
)/$(LINUX_SOURCE
):
125 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
)
128 $(LINUX_DIR
)/.prepared
: $(DL_DIR
)/$(LINUX_SOURCE
)
129 -rm -rf
$(KERNEL_BUILD_DIR
)
130 -mkdir
-p
$(KERNEL_BUILD_DIR
)
131 $(call Kernel
/Prepare
)
134 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.prepared
$(LINUX_CONFIG
)
135 $(call Kernel
/Configure
)
138 $(LINUX_DIR
)/.modules
: $(LINUX_DIR
)/.configured
139 rm -rf
$(KERNEL_BUILD_DIR
)/modules
140 @
rm -f
$(BUILD_DIR
)/linux
141 ln
-sf
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(BUILD_DIR
)/linux
142 $(call Kernel
/CompileModules
)
145 $(LINUX_DIR
)/.image
: $(LINUX_DIR
)/.configured FORCE
146 $(call Kernel
/CompileImage
)
154 @echo
'Target: $(BOARD)-$(KERNEL)'
155 @echo
'Target-Name: $(BOARDNAME) [$(KERNEL)]'
156 @echo
'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
157 @echo
'Target-Arch: $(ARCH)'
158 @echo
'Target-Features: $(FEATURES)'
159 @echo
'Linux-Version: $(LINUX_VERSION)'
160 @echo
'Linux-Release: $(LINUX_RELEASE)'
161 @echo
'Linux-Kernel-Arch: $(LINUX_KARCH)'
162 @echo
'Target-Description:'
163 @getvar
$(call shvar
,Target
/Description
)
165 @echo
'Default-Packages: $(DEFAULT_PACKAGES)'
175 define Profile
/Default
181 $(eval
$(call Profile
/Default
))
182 $(eval
$(call Profile
/$(1)))
184 echo
"Target-Profile: $(1)"; \
185 echo
"Target-Profile-Name: $(NAME)"; \
186 echo
"Target-Profile-Packages: $(PACKAGES)";
189 $(eval
$(call shexport
,Target
/Description
))
191 download
: $(DL_DIR
)/$(LINUX_SOURCE
)
192 prepare
: $(LINUX_DIR
)/.configured
$(TMP_DIR
)/.kernel.mk
193 compile
: $(LINUX_DIR
)/.modules
194 install: $(LINUX_DIR
)/.image
197 rm -f
$(STAMP_DIR
)/.linux-compile
198 rm -rf
$(KERNEL_BUILD_DIR
)
202 @if
[ -f
$(LINUX_KERNEL
) ]; then \