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
11 # For target profile selection - the default set
12 DEFAULT_PACKAGES
:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd
19 KERNEL
:=2.
$(word 2,$(subst .
, ,$(strip $(LINUX_VERSION
))))
21 include $(INCLUDE_DIR
)/host.mk
22 include $(INCLUDE_DIR
)/kernel.mk
24 LINUX_CONFIG
:=.
/config
26 ifneq (,$(findstring uml
,$(BOARD
)))
29 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
39 ifneq (,$(findstring x86
,$(BOARD
)))
42 ifneq (,$(findstring ppc
,$(BOARD
)))
47 define Kernel
/Prepare
/Default
48 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(KERNEL_BUILD_DIR
) $(TAR_OPTIONS
)
49 [ -d ..
/generic-
$(KERNEL
)/patches
] && $(PATCH
) $(LINUX_DIR
) ..
/generic-
$(KERNEL
)/patches
50 [ -d .
/patches
] && $(PATCH
) $(LINUX_DIR
) .
/patches
53 $(call Kernel
/Prepare
/Default
)
57 define Kernel
/Configure
/2.4
58 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
59 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/compile.h
include/linux
/version.h
60 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" ARCH
=$(LINUX_KARCH
) dep
62 define Kernel
/Configure
/2.6
63 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) oldconfig prepare scripts
65 define Kernel
/Configure
/Default
66 @
$(CP
) $(LINUX_CONFIG
) $(LINUX_DIR
)/.config
67 $(call Kernel
/Configure
/$(KERNEL
))
69 define Kernel
/Configure
70 $(call Kernel
/Configure
/Default
)
74 define Kernel
/CompileModules
/Default
75 $(MAKE
) -j
$(CONFIG_JLEVEL
) -C
"$(LINUX_DIR)" CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) modules
76 $(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
78 define Kernel
/CompileModules
79 $(call Kernel
/CompileModules
/Default
)
84 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
85 define Kernel
/SetInitramfs
86 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
87 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
88 echo
'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR
)/.config
89 echo
'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR
)/.config
90 echo
'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR
)/.config
91 mkdir
-p
$(BUILD_DIR
)/root
/etc
/init.d
92 $(CP
) ..
/generic-2.6
/files
/init
$(BUILD_DIR
)/root
/
95 define Kernel
/SetInitramfs
96 mv
$(LINUX_DIR
)/.config
$(LINUX_DIR
)/.config.old
97 grep
-v INITRAMFS
$(LINUX_DIR
)/.config.old
> $(LINUX_DIR
)/.config
98 rm -f
$(BUILD_DIR
)/root
/init
$(BUILD_DIR
)/root
/etc
/init.d
/S00initramfs
99 echo
'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR
)/.config
103 define Kernel
/CompileImage
/Default
104 $(call Kernel
/SetInitramfs
)
105 $(MAKE
) -j
$(CONFIG_JLEVEL
) -C
$(LINUX_DIR
) CROSS_COMPILE
="$(KERNEL_CROSS)" CC
="$(KERNEL_CC)" ARCH
=$(LINUX_KARCH
) $(KERNELNAME
)
106 $(KERNEL_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$(LINUX_DIR
)/vmlinux
$(LINUX_KERNEL
)
108 define Kernel
/CompileImage
109 $(call Kernel
/CompileImage
/Default
)
112 define Kernel
/Clean
/Default
113 rm -f
$(LINUX_DIR
)/.linux-compile
114 rm -f
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.configured
115 rm -f
$(LINUX_KERNEL
)
116 $(MAKE
) -C
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
120 $(call Kernel
/Clean
/Default
)
124 ifneq ($(LINUX_SITE
),)
125 $(DL_DIR
)/$(LINUX_SOURCE
):
127 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
)
130 $(LINUX_DIR
)/.prepared
: $(DL_DIR
)/$(LINUX_SOURCE
)
131 -rm -rf
$(KERNEL_BUILD_DIR
)
132 -mkdir
-p
$(KERNEL_BUILD_DIR
)
133 $(call Kernel
/Prepare
)
136 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.prepared
$(LINUX_CONFIG
)
137 $(call Kernel
/Configure
)
140 $(LINUX_DIR
)/.modules
: $(LINUX_DIR
)/.configured
141 rm -rf
$(KERNEL_BUILD_DIR
)/modules
142 @
rm -f
$(BUILD_DIR
)/linux
143 ln
-sf
$(KERNEL_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(BUILD_DIR
)/linux
144 $(call Kernel
/CompileModules
)
147 $(LINUX_DIR
)/.image
: $(LINUX_DIR
)/.configured FORCE
148 $(call Kernel
/CompileImage
)
156 @echo
'Target: $(BOARD)-$(KERNEL)'
157 @echo
'Target-Name: $(BOARDNAME) [$(KERNEL)]'
158 @echo
'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
159 @echo
'Target-Arch: $(ARCH)'
160 @echo
'Target-Features: $(FEATURES)'
161 @echo
'Linux-Version: $(LINUX_VERSION)'
162 @echo
'Linux-Release: $(LINUX_RELEASE)'
163 @echo
'Linux-Kernel-Arch: $(LINUX_KARCH)'
164 @echo
'Target-Description:'
165 @getvar
$(call shvar
,Target
/Description
)
167 @echo
'Default-Packages: $(DEFAULT_PACKAGES)'
177 define Profile
/Default
183 $(eval
$(call Profile
/Default
))
184 $(eval
$(call Profile
/$(1)))
186 echo
"Target-Profile: $(1)"; \
187 echo
"Target-Profile-Name: $(NAME)"; \
188 echo
"Target-Profile-Packages: $(PACKAGES)";
191 $(eval
$(call shexport
,Target
/Description
))
193 download
: $(DL_DIR
)/$(LINUX_SOURCE
)
194 prepare
: $(LINUX_DIR
)/.configured
$(TMP_DIR
)/.kernel.mk
195 compile
: $(LINUX_DIR
)/.modules
196 install: $(LINUX_DIR
)/.image
199 rm -f
$(STAMP_DIR
)/.linux-compile
200 rm -rf
$(KERNEL_BUILD_DIR
)
204 @if
[ -f
$(LINUX_KERNEL
) ]; then \