ti-dsplink: Add support for DM6446 build (~ from Niclas)
[openembedded.git] / classes / kernel.bbclass
blob69ab422c437cfcbf244ad9e3300eaf6dd9c50b04
1 inherit linux-kernel-base module_strip
3 PROVIDES += "virtual/kernel"
4 DEPENDS += "virtual/${TARGET_PREFIX}depmod-${@get_kernelmajorversion('${PV}')} virtual/${TARGET_PREFIX}gcc${KERNEL_CCSUFFIX} update-modules"
6 KERNEL_IMAGETYPE ?= "zImage"
8 # Add dependency on mkimage for kernels that build a uImage
10 python __anonymous () {
11     kerneltype = bb.data.getVar('KERNEL_IMAGETYPE', d, 1) or ''
12     if kerneltype == 'uImage':
13         depends = bb.data.getVar("DEPENDS", d, 1)
14         depends = "%s u-boot-mkimage-openmoko-native" % depends
15         bb.data.setVar("DEPENDS", depends, d)
17     image = bb.data.getVar('INITRAMFS_IMAGE', d, True)
18     if image != '' and image is not None:
19         bb.data.setVar('INITRAMFS_TASK', '${INITRAMFS_IMAGE}:do_rootfs', d)
21     machine_kernel_pr = bb.data.getVar('MACHINE_KERNEL_PR', d, True)
23     if machine_kernel_pr:
24        bb.data.setVar('PR', machine_kernel_pr, d)
27 INITRAMFS_IMAGE ?= ""
28 INITRAMFS_TASK ?= ""
30 inherit kernel-arch
32 PACKAGES_DYNAMIC += "kernel-module-*"
33 PACKAGES_DYNAMIC += "kernel-image-*"
34 PACKAGES_DYNAMIC += "kernel-firmware-*"
36 export OS = "${TARGET_OS}"
37 export CROSS_COMPILE = "${TARGET_PREFIX}"
39 KERNEL_PRIORITY = "${@bb.data.getVar('PV',d,1).split('-')[0].split('.')[-1]}"
41 KERNEL_RELEASE ?= "${KERNEL_VERSION}"
43 KERNEL_CCSUFFIX ?= ""
44 KERNEL_LDSUFFIX ?= ""
46 # Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
47 # specific options necessary for building the kernel and modules.
48 #FIXME: should be this: TARGET_CC_KERNEL_ARCH ?= "${TARGET_CC_ARCH}"
49 TARGET_CC_KERNEL_ARCH ?= ""
50 HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
51 TARGET_LD_KERNEL_ARCH ?= ""
52 HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
54 KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}"
55 KERNEL_LD = "${LD}${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
57 # Where built kernel lies in the kernel tree
58 KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
59 KERNEL_IMAGEDEST = "boot"
62 # configuration
64 export CMDLINE_CONSOLE = "console=${@bb.data.getVar("KERNEL_CONSOLE",d,1) or "ttyS0"}"
66 KERNEL_VERSION = "${@get_kernelversion('${S}')}"
67 KERNEL_MAJOR_VERSION = "${@get_kernelmajorversion('${KERNEL_VERSION}')}"
69 KERNEL_LOCALVERSION ?= ""
71 # kernels are generally machine specific
72 PACKAGE_ARCH = "${MACHINE_ARCH}"
74 # U-Boot support
75 UBOOT_ENTRYPOINT ?= "20008000"
76 UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
78 # For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE.
79 # We don't want to override kernel Makefile variables from the environment
80 EXTRA_OEMAKE = ""
82 kernel_do_compile() {
83         unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
84         oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
85         if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
86                 oe_runmake dep CC="${KERNEL_CC}" LD="${KERNEL_LD}"
87         fi
88         oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
89         if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
90                 oe_runmake modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
91         else
92                 oenote "no modules to compile"
93         fi
95 kernel_do_compile[depends] = "${INITRAMFS_TASK}"
97 kernel_do_stage() {
98         if [ -e include/asm ] ; then
99                 # This link is generated only in kernel before 2.6.33-rc1, don't stage it for newer kernels
100                 ASMDIR=`readlink include/asm`
102                 mkdir -p ${STAGING_KERNEL_DIR}/include/$ASMDIR
103                 cp -fR include/$ASMDIR/* ${STAGING_KERNEL_DIR}/include/$ASMDIR/
104         fi
105         # Kernel 2.6.27 moved headers from includes/asm-${ARCH} to arch/${ARCH}/include/asm     
106         if [ -e arch/${ARCH}/include/asm/ ] ; then 
107                 if [ -e include/asm ] ; then
108                         cp -fR arch/${ARCH}/include/asm/* ${STAGING_KERNEL_DIR}/include/$ASMDIR/
109                 fi
110                 install -d ${STAGING_KERNEL_DIR}/arch/${ARCH}/include
111                 cp -fR arch/${ARCH}/* ${STAGING_KERNEL_DIR}/arch/${ARCH}/       
113         # Check for arch/x86 on i386
114         elif [ -d arch/x86/include/asm/ ]; then
115                 if [ -e include/asm ] ; then
116                         cp -fR arch/x86/include/asm/* ${STAGING_KERNEL_DIR}/include/asm-x86/
117                 fi
118                 install -d ${STAGING_KERNEL_DIR}/arch/x86/include
119                 cp -fR arch/x86/* ${STAGING_KERNEL_DIR}/arch/x86/
120         fi
122         if [ -e include/asm ] ; then
123                 rm -f ${STAGING_KERNEL_DIR}/include/asm
124                 ln -sf $ASMDIR ${STAGING_KERNEL_DIR}/include/asm
125         fi
127         mkdir -p ${STAGING_KERNEL_DIR}/include/asm-generic
128         cp -fR include/asm-generic/* ${STAGING_KERNEL_DIR}/include/asm-generic/
130         for entry in drivers/crypto drivers/media include/generated include/linux include/net include/pcmcia include/media include/acpi include/sound include/video include/scsi include/trace; do
131                 if [ -d $entry ]; then
132                         mkdir -p ${STAGING_KERNEL_DIR}/$entry
133                         cp -fR $entry/* ${STAGING_KERNEL_DIR}/$entry/
134                 fi
135         done
137         if [ -d drivers/sound ]; then
138                 # 2.4 alsa needs some headers from this directory
139                 mkdir -p ${STAGING_KERNEL_DIR}/include/drivers/sound
140                 cp -fR drivers/sound/*.h ${STAGING_KERNEL_DIR}/include/drivers/sound/
141         fi
143         install -m 0644 .config ${STAGING_KERNEL_DIR}/config-${KERNEL_VERSION}
144         ln -sf config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/.config
145         ln -sf config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/kernel-config
146         echo "${KERNEL_VERSION}" >${STAGING_KERNEL_DIR}/kernel-abiversion
147         echo "${S}" >${STAGING_KERNEL_DIR}/kernel-source
148         echo "${KERNEL_CCSUFFIX}" >${STAGING_KERNEL_DIR}/kernel-ccsuffix
149         echo "${KERNEL_LDSUFFIX}" >${STAGING_KERNEL_DIR}/kernel-ldsuffix
150         [ -e Rules.make ] && install -m 0644 Rules.make ${STAGING_KERNEL_DIR}/
151         [ -e Makefile ] && install -m 0644 Makefile ${STAGING_KERNEL_DIR}/
152         
153         # Check if arch/${ARCH}/Makefile exists and install it
154         if [ -e arch/${ARCH}/Makefile ]; then
155                 install -d ${STAGING_KERNEL_DIR}/arch/${ARCH}
156                 install -m 0644 arch/${ARCH}/Makefile* ${STAGING_KERNEL_DIR}/arch/${ARCH}
157         # Otherwise check arch/x86/Makefile for i386 and x86_64 on kernels >= 2.6.24
158         elif [ -e arch/x86/Makefile ]; then
159                 install -d ${STAGING_KERNEL_DIR}/arch/x86
160                 install -m 0644 arch/x86/Makefile* ${STAGING_KERNEL_DIR}/arch/x86
161         fi
162         cp -fR include/config* ${STAGING_KERNEL_DIR}/include/   
163         # Install kernel images and system.map to staging
164         [ -e vmlinux ] && install -m 0644 vmlinux ${STAGING_KERNEL_DIR}/        
165         install -m 0644 ${KERNEL_OUTPUT} ${STAGING_KERNEL_DIR}/${KERNEL_IMAGETYPE}
166         install -m 0644 System.map ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION}
167         [ -e Module.symvers ] && install -m 0644 Module.symvers ${STAGING_KERNEL_DIR}/
169         cp -fR scripts ${STAGING_KERNEL_DIR}/
172 kernel_do_install() {
173         unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
174         if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
175                 oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" modules_install
176         else
177                 oenote "no modules to install"
178         fi
179         
180         install -d ${D}/${KERNEL_IMAGEDEST}
181         install -d ${D}/boot
182         install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}
183         install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
184         install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
185         install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
186         [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION}
187         install -d ${D}/etc/modutils
188         if [ "${KERNEL_MAJOR_VERSION}" = "2.6" ]; then
189                 install -d ${D}/etc/modprobe.d
190         fi
191         
192         # Check if scripts/genksyms exists and if so, build it
193         if [ -e scripts/genksyms/ ]; then
194                 oe_runmake SUBDIRS="scripts/genksyms"
195         fi
197         install -d ${STAGING_KERNEL_DIR}
198         cp -fR scripts ${STAGING_KERNEL_DIR}/
201 kernel_do_configure() {
202         yes '' | oe_runmake oldconfig
203         if [ ! -z "${INITRAMFS_IMAGE}" ]; then
204                 for img in cpio.gz cpio.lzo cpio.lzma; do
205                 if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
206                         cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" initramfs.$img
207                 fi
208                 done
209         fi
212 do_menuconfig() {
213         export TERMWINDOWTITLE="${PN} Kernel Configuration"
214         export SHELLCMDS="make menuconfig"
215         ${TERMCMDRUN}
216         if [ $? -ne 0 ]; then
217                 echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable."
218                 exit 1
219         fi
221 do_menuconfig[nostamp] = "1"
222 addtask menuconfig after do_configure
224 pkg_postinst_kernel () {
225         cd /${KERNEL_IMAGEDEST}; update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
228 pkg_postrm_kernel () {
229         cd /${KERNEL_IMAGEDEST}; update-alternatives --remove ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} || true
232 inherit cml1
234 EXPORT_FUNCTIONS do_compile do_install do_stage do_configure
236 # kernel-base becomes kernel-${KERNEL_VERSION}
237 # kernel-image becomes kernel-image-${KERNEL_VERISON}
238 PACKAGES = "kernel kernel-base kernel-image kernel-dev kernel-vmlinux"
239 FILES = ""
240 FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}*"
241 FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config*"
242 FILES_kernel-vmlinux = "/boot/vmlinux*"
243 RDEPENDS_kernel = "kernel-base"
244 RRECOMMENDS_kernel-module-hostap-cs += '${@base_version_less_or_equal("KERNEL_VERSION", "2.6.17", "", "apm-wifi-suspendfix", d)}'
245 RRECOMMENDS_kernel-module-orinoco-cs += '${@base_version_less_or_equal("KERNEL_VERSION", "2.6.17", "", "apm-wifi-suspendfix", d)}'
246 # Allow machines to override this dependency if kernel image files are 
247 # not wanted in images as standard
248 RDEPENDS_kernel-base ?= "kernel-image"
249 PKG_kernel-image = "kernel-image-${KERNEL_VERSION}"
250 PKG_kernel-base = "kernel-${KERNEL_VERSION}"
251 ALLOW_EMPTY_kernel = "1"
252 ALLOW_EMPTY_kernel-base = "1"
253 ALLOW_EMPTY_kernel-image = "1"
255 # Userspace workarounds for kernel modules issues
256 # This is shame, fix the kernel instead!
257 DEPENDS_kernel-module-dtl1-cs = "bluez-dtl1-workaround"
258 RDEPENDS_kernel-module-dtl1-cs = "bluez-dtl1-workaround"
260 # renamed modules
261 RPROVIDES_kernel-module-aes-generic = "kernel-module-aes"
263 pkg_postinst_kernel-image () {
264 if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
265         mkdir -p $D/lib/modules/${KERNEL_VERSION}
267 if [ -n "$D" ]; then
268         ${HOST_PREFIX}depmod-${KERNEL_MAJOR_VERSION} -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
269 else
270         depmod -a ${KERNEL_VERSION}
274 pkg_postinst_modules () {
275 if [ -n "$D" ]; then
276         ${HOST_PREFIX}depmod-${KERNEL_MAJOR_VERSION} -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
277 else
278         depmod -a ${KERNEL_VERSION}
279         update-modules || true
283 pkg_postrm_modules () {
284 update-modules || true
287 autoload_postinst_fragment() {
288 if [ x"$D" = "x" ]; then
289         modprobe %s || true
293 # autoload defaults (alphabetically sorted)
294 module_autoload_hidp = "hidp"
295 module_autoload_ipv6 = "ipv6"
296 module_autoload_ipsec = "ipsec"
297 module_autoload_ircomm-tty = "ircomm-tty"
298 module_autoload_rfcomm = "rfcomm"
299 module_autoload_sa1100-rtc = "sa1100-rtc"
300 # sa1100-rtc was renamed in 2.6.23 onwards
301 module_autoload_rtc-sa1100 = "rtc-sa1100"
303 # alias defaults (alphabetically sorted)
304 module_conf_af_packet = "alias net-pf-17 af_packet"
305 module_conf_bluez = "alias net-pf-31 bluez"
306 module_conf_bnep = "alias bt-proto-4 bnep"
307 module_conf_hci_uart = "alias tty-ldisc-15 hci_uart"
308 module_conf_l2cap = "alias bt-proto-0 l2cap"
309 module_conf_sco = "alias bt-proto-2 sco"
310 module_conf_rfcomm = "alias bt-proto-3 rfcomm"
312 python populate_packages_prepend () {
313         import os
314         def extract_modinfo(file):
315                 import tempfile, re
316                 tempfile.tempdir = bb.data.getVar("WORKDIR", d, 1)
317                 tf = tempfile.mkstemp()
318                 tmpfile = tf[1]
319                 cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (bb.data.getVar("PATH", d, 1), bb.data.getVar("HOST_PREFIX", d, 1) or "", file, tmpfile)
320                 os.system(cmd)
321                 f = open(tmpfile)
322                 l = f.read().split("\000")
323                 f.close()
324                 os.close(tf[0])
325                 os.unlink(tmpfile)
326                 exp = re.compile("([^=]+)=(.*)")
327                 vals = {}
328                 for i in l:
329                         m = exp.match(i)
330                         if not m:
331                                 continue
332                         vals[m.group(1)] = m.group(2)
333                 return vals
334         
335         def parse_depmod():
336                 import re
338                 dvar = bb.data.getVar('PKGD', d, 1)
339                 if not dvar:
340                         bb.error("D not defined")
341                         return
343                 kernelver = bb.data.getVar('KERNEL_VERSION', d, 1)
344                 kernelver_stripped = kernelver
345                 m = re.match('^(.*-hh.*)[\.\+].*$', kernelver)
346                 if m:
347                         kernelver_stripped = m.group(1)
348                 path = bb.data.getVar("PATH", d, 1)
349                 host_prefix = bb.data.getVar("HOST_PREFIX", d, 1) or ""
350                 major_version = bb.data.getVar('KERNEL_MAJOR_VERSION', d, 1)
352                 cmd = "PATH=\"%s\" %sdepmod-%s -n -a -r -b %s -F %s/boot/System.map-%s %s" % (path, host_prefix, major_version, dvar, dvar, kernelver, kernelver_stripped)
353                 f = os.popen(cmd, 'r')
355                 deps = {}
356                 pattern0 = "^(.*\.k?o):..*$"
357                 pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$"
358                 pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$"
359                 pattern3 = "^\t(.*\.k?o)\s*\\\$"
360                 pattern4 = "^\t(.*\.k?o)\s*$"
362                 line = f.readline()
363                 while line:
364                         if not re.match(pattern0, line):
365                                 line = f.readline()
366                                 continue
367                         m1 = re.match(pattern1, line)
368                         if m1:
369                                 deps[m1.group(1)] = m1.group(2).split()
370                         else:
371                                 m2 = re.match(pattern2, line)
372                                 if m2:
373                                         deps[m2.group(1)] = m2.group(2).split()
374                                         line = f.readline()
375                                         m3 = re.match(pattern3, line)
376                                         while m3:
377                                                 deps[m2.group(1)].extend(m3.group(1).split())
378                                                 line = f.readline()
379                                                 m3 = re.match(pattern3, line)
380                                         m4 = re.match(pattern4, line)
381                                         deps[m2.group(1)].extend(m4.group(1).split())
382                         line = f.readline()
383                 f.close()
384                 return deps
385         
386         def get_dependencies(file, pattern, format):
387                 file = file.replace(bb.data.getVar('PKGD', d, 1) or '', '', 1)
389                 if module_deps.has_key(file):
390                         import re
391                         dependencies = []
392                         for i in module_deps[file]:
393                                 m = re.match(pattern, os.path.basename(i))
394                                 if not m:
395                                         continue
396                                 on = legitimize_package_name(m.group(1))
397                                 dependency_pkg = format % on
398                                 dependencies.append(dependency_pkg)
399                         return dependencies
400                 return []
402         def frob_metadata(file, pkg, pattern, format, basename):
403                 import re
404                 vals = extract_modinfo(file)
406                 dvar = bb.data.getVar('PKGD', d, 1)
408                 # If autoloading is requested, output /etc/modutils/<name> and append
409                 # appropriate modprobe commands to the postinst
410                 autoload = bb.data.getVar('module_autoload_%s' % basename, d, 1)
411                 if not autoload:
412                     # Also, try canonical name with dashes
413                     autoload = bb.data.getVar('module_autoload_%s' % basename.replace('_', '-'), d, 1)
414                 if autoload:
415                         name = '%s/etc/modutils/%s' % (dvar, basename)
416                         f = open(name, 'w')
417                         for m in autoload.split():
418                                 f.write('%s\n' % m)
419                         f.close()
420                         postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1)
421                         if not postinst:
422                                 bb.fatal("pkg_postinst_%s not defined" % pkg)
423                         postinst += bb.data.getVar('autoload_postinst_fragment', d, 1) % autoload
424                         bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
426                 # Write out any modconf fragment
427                 modconf = bb.data.getVar('module_conf_%s' % basename, d, 1)
428                 if modconf:
429                         if bb.data.getVar("KERNEL_MAJOR_VERSION", d, 1) == "2.6":
430                                 name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
431                         else:
432                                 name = '%s/etc/modutils/%s.conf' % (dvar, basename)
433                         f = open(name, 'w')
434                         f.write("%s\n" % modconf)
435                         f.close()
437                 files = bb.data.getVar('FILES_%s' % pkg, d, 1)
438                 files = "%s /etc/modutils/%s /etc/modutils/%s.conf /etc/modprobe.d/%s.conf" % (files, basename, basename, basename)
439                 bb.data.setVar('FILES_%s' % pkg, files, d)
441                 if vals.has_key("description"):
442                         old_desc = bb.data.getVar('DESCRIPTION_' + pkg, d, 1) or ""
443                         bb.data.setVar('DESCRIPTION_' + pkg, old_desc + "; " + vals["description"], d)
445                 rdepends_str = bb.data.getVar('RDEPENDS_' + pkg, d, 1)
446                 if rdepends_str:
447                         rdepends = rdepends_str.split()
448                 else:
449                         rdepends = []
450                 rdepends.extend(get_dependencies(file, pattern, format))
451                 bb.data.setVar('RDEPENDS_' + pkg, ' '.join(rdepends), d)
453         module_deps = parse_depmod()
454         module_regex = '^(.*)\.k?o$'
455         module_pattern = 'kernel-module-%s'
457         postinst = bb.data.getVar('pkg_postinst_modules', d, 1)
458         postrm = bb.data.getVar('pkg_postrm_modules', d, 1)
460         maybe_update_modules = "update-modules "
461         if bb.data.getVar("ONLINE_PACKAGE_MANAGEMENT", d) == "none":
462                 maybe_update_modules = ""
463         
464         do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
465         do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
466         do_split_packages(d, root='/lib/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%skernel-%s' % (maybe_update_modules, bb.data.getVar("KERNEL_VERSION", d, 1)))
468         import re
469         metapkg = "kernel-modules"
470         bb.data.setVar('ALLOW_EMPTY_' + metapkg, "1", d)
471         bb.data.setVar('FILES_' + metapkg, "", d)
472         blacklist = [ 'kernel-dev', 'kernel-image', 'kernel-base', 'kernel-vmlinux' ]
473         for l in module_deps.values():
474                 for i in l:
475                         pkg = module_pattern % legitimize_package_name(re.match(module_regex, os.path.basename(i)).group(1))
476                         blacklist.append(pkg)
477         metapkg_rdepends = []
478         packages = bb.data.getVar('PACKAGES', d, 1).split()
479         for pkg in packages[1:]:
480                 if not pkg in blacklist and not pkg in metapkg_rdepends:
481                         metapkg_rdepends.append(pkg)
482         bb.data.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends), d)
483         bb.data.setVar('DESCRIPTION_' + metapkg, 'Kernel modules meta package', d)
484         packages.append(metapkg)
485         bb.data.setVar('PACKAGES', ' '.join(packages), d)
488 # Support checking the kernel size since some kernels need to reside in partitions
489 # with a fixed length or there is a limit in transferring the kernel to memory
490 do_sizecheck() {
491         if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
492                 size=`ls -l ${KERNEL_OUTPUT} | awk '{ print $5}'`
493                 if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
494                         rm ${KERNEL_OUTPUT}
495                         die  "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."
496                 fi
497         fi
500 addtask sizecheck before do_install after do_compile
502 do_uboot_mkimage() {
503     if test "x${KERNEL_IMAGETYPE}" = "xuImage" ; then 
504         ENTRYPOINT=${UBOOT_ENTRYPOINT}
505         if test -n "${UBOOT_ENTRYSYMBOL}"; then
506             ENTRYPOINT=`${HOST_PREFIX}nm ${S}/vmlinux | \
507                    awk '$3=="${UBOOT_ENTRYSYMBOL}" {print $1}'`
508         fi
509         if test -e arch/${ARCH}/boot/compressed/vmlinux ; then
510             ${OBJCOPY} -O binary -R .note -R .comment -S arch/${ARCH}/boot/compressed/vmlinux linux.bin
511             uboot-mkimage -A ${UBOOT_ARCH} -O linux -T kernel -C none -a ${UBOOT_LOADADDRESS} -e $ENTRYPOINT -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin arch/${ARCH}/boot/uImage
512             rm -f linux.bin
513         else
514             ${OBJCOPY} -O binary -R .note -R .comment -S vmlinux linux.bin
515             rm -f linux.bin.gz
516             gzip -9 linux.bin
517             uboot-mkimage -A ${UBOOT_ARCH} -O linux -T kernel -C gzip -a ${UBOOT_LOADADDRESS} -e $ENTRYPOINT -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin.gz arch/${ARCH}/boot/uImage
518             rm -f linux.bin.gz
519         fi
520     fi
523 addtask uboot_mkimage before do_install after do_compile
525 KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PV}-${PR}-${MACHINE}"
526 KERNEL_IMAGE_SYMLINK_NAME ?= "${KERNEL_IMAGETYPE}-${MACHINE}"
527 MODULES_IMAGE_BASE_NAME ?= modules-${PV}-${PR}-${MACHINE}
529 do_deploy() {
530         install -d ${DEPLOY_DIR_IMAGE}
531         install -m 0644 ${KERNEL_OUTPUT} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
532         package_stagefile_shell ${S}/${KERNEL_OUTPUT}
533         package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
535         if [ -d "${PKGD}/lib" ]; then
536                 fakeroot tar -cvzf ${DEPLOY_DIR_IMAGE}/${MODULES_IMAGE_BASE_NAME}.tgz -C ${PKGD} lib
537                 package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${MODULES_IMAGE_BASE_NAME}.tgz
538         fi
540         cd ${DEPLOY_DIR_IMAGE}
541         rm -f ${KERNEL_IMAGE_SYMLINK_NAME}.bin
542         ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${KERNEL_IMAGE_SYMLINK_NAME}.bin
543         package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_SYMLINK_NAME}.bin
546 do_deploy[dirs] = "${S}"
547 do_deploy[depends] += "fakeroot-native:do_populate_staging"
549 addtask deploy before do_build after do_package