tar: Switch to INC_PR and fix native builds.
[openembedded.git] / classes / kernel.bbclass
blob5f8bc8a905899e94c8a157b4cc62479d1d91efee
1 inherit linux-kernel-base module_strip
3 PROVIDES += "virtual/kernel"
4 DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}depmod-${@get_kernelmajorversion('${PV}')} virtual/${TARGET_PREFIX}gcc${KERNEL_CCSUFFIX} update-modules"
6 # we include gcc above, we dont need virtual/libc
7 INHIBIT_DEFAULT_DEPS = "1"
9 KERNEL_IMAGETYPE ?= "zImage"
11 # Add dependency on mkimage for kernels that build a uImage
13 python __anonymous () {
14     kerneltype = bb.data.getVar('KERNEL_IMAGETYPE', d, 1) or ''
15     if kerneltype == 'uImage':
16         depends = bb.data.getVar("DEPENDS", d, 1)
17         depends = "%s u-boot-mkimage-native" % depends
18         bb.data.setVar("DEPENDS", depends, d)
20     image = bb.data.getVar('INITRAMFS_IMAGE', d, True)
21     if image != '' and image is not None:
22         bb.data.setVar('INITRAMFS_TASK', '${INITRAMFS_IMAGE}:do_rootfs', d)
24     machine_kernel_pr = bb.data.getVar('MACHINE_KERNEL_PR', d, True)
26     if machine_kernel_pr:
27        bb.data.setVar('PR', machine_kernel_pr, d)
30 INITRAMFS_IMAGE ?= ""
31 INITRAMFS_TASK ?= ""
33 inherit kernel-arch
35 PACKAGES_DYNAMIC += "kernel-module-*"
36 PACKAGES_DYNAMIC += "kernel-image-*"
37 PACKAGES_DYNAMIC += "kernel-firmware-*"
39 export OS = "${TARGET_OS}"
40 export CROSS_COMPILE = "${TARGET_PREFIX}"
42 KERNEL_PRIORITY = "${@bb.data.getVar('PV',d,1).split('-')[0].split('.')[-1]}"
44 KERNEL_RELEASE ?= "${KERNEL_VERSION}"
46 KERNEL_CCSUFFIX ?= ""
47 KERNEL_LDSUFFIX ?= ""
49 # Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
50 # specific options necessary for building the kernel and modules.
51 #FIXME: should be this: TARGET_CC_KERNEL_ARCH ?= "${TARGET_CC_ARCH}"
52 TARGET_CC_KERNEL_ARCH ?= ""
53 HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
54 TARGET_LD_KERNEL_ARCH ?= ""
55 HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
57 KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}"
58 KERNEL_LD = "${LD}${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
60 # Where built kernel lies in the kernel tree
61 KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
62 KERNEL_IMAGEDEST = "boot"
65 # configuration
67 export CMDLINE_CONSOLE = "console=${@bb.data.getVar("KERNEL_CONSOLE",d,1) or "ttyS0"}"
69 KERNEL_VERSION = "${@get_kernelversion('${B}')}"
70 KERNEL_MAJOR_VERSION = "${@get_kernelmajorversion('${KERNEL_VERSION}')}"
72 KERNEL_LOCALVERSION ?= ""
74 # kernels are generally machine specific
75 PACKAGE_ARCH = "${MACHINE_ARCH}"
77 # U-Boot support
78 UBOOT_ENTRYPOINT ?= "20008000"
79 UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
81 # For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE.
82 # We don't want to override kernel Makefile variables from the environment
83 EXTRA_OEMAKE = ""
85 kernel_do_compile() {
86         unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
87         oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
88         if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
89                 oe_runmake dep CC="${KERNEL_CC}" LD="${KERNEL_LD}"
90         fi
91         oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
92         if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
93                 oe_runmake modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
94         else
95                 oenote "no modules to compile"
96         fi
99 kernel_do_install() {
100         unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
101         if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
102                 oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" modules_install
103         else
104                 oenote "no modules to install"
105         fi
106         
107         install -d ${D}/${KERNEL_IMAGEDEST}
108         install -d ${D}/boot
109         install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}
110         install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
111         install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
112         install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
113         [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION}
114         install -d ${D}/etc/modutils
115         if [ "${KERNEL_MAJOR_VERSION}" = "2.6" ]; then
116                 install -d ${D}/etc/modprobe.d
117         fi
118         
119         # Check if scripts/genksyms exists and if so, build it
120         if [ -e scripts/genksyms/ ]; then
121                 oe_runmake SUBDIRS="scripts/genksyms"
122         fi
124         kerneldir=${D}/kernel/
126         if [ -e include/asm ] ; then
127                 # This link is generated only in kernel before 2.6.33-rc1, don't stage it for newer kernels
128                 ASMDIR=`readlink include/asm`
130                 mkdir -p $kerneldir/include/$ASMDIR
131                 cp -fR include/$ASMDIR/* $kerneldir/include/$ASMDIR/
132         fi
134         # Kernel 2.6.27 moved headers from includes/asm-${ARCH} to arch/${ARCH}/include/asm     
135         if [ -e arch/${ARCH}/include/asm/ ] ; then 
136                 if [ -e include/asm ] ; then
137                         cp -fR arch/${ARCH}/include/asm/* $kerneldir/include/$ASMDIR/
138                 fi
139                 install -d $kerneldir/arch/${ARCH}/include
140                 cp -fR arch/${ARCH}/* $kerneldir/arch/${ARCH}/  
142         # Check for arch/x86 on i386
143         elif [ -d arch/x86/include/asm/ ]; then
144                 mkdir -p $kerneldir/include/asm-x86/
145                 cp -fR arch/x86/include/asm/* $kerneldir/include/asm-x86/
146                 install -d $kerneldir/arch/x86/include
147                 cp -fR arch/x86/* $kerneldir/arch/x86/
148         fi
150         if [ -e include/asm ] ; then
151                 rm -f $kerneldir/include/asm
152                 ln -sf $ASMDIR $kerneldir/include/asm
153         fi
155         mkdir -p $kerneldir/include/asm-generic
156         cp -fR include/asm-generic/* $kerneldir/include/asm-generic/
158         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 include/mtd include/rdma include/drm include/xen; do
159                 if [ -d $entry ]; then
160                         mkdir -p $kerneldir/$entry
161                         cp -fR $entry/* $kerneldir/$entry/
162                 fi
163         done
164         if [ -f include/Kbuild ]; then
165                 cp -fR include/Kbuild $kerneldir/include
166         fi
168         if [ -d drivers/sound ]; then
169                 # 2.4 alsa needs some headers from this directory
170                 mkdir -p $kerneldir/include/drivers/sound
171                 cp -fR drivers/sound/*.h $kerneldir/include/drivers/sound/
172         fi
174         install -m 0644 .config $kerneldir/config-${KERNEL_VERSION}
175         ln -sf config-${KERNEL_VERSION} $kerneldir/.config
176         ln -sf config-${KERNEL_VERSION} $kerneldir/kernel-config
177         echo "${KERNEL_VERSION}" >$kerneldir/kernel-abiversion
178         echo "${S}" >$kerneldir/kernel-source
179         echo "${KERNEL_CCSUFFIX}" >$kerneldir/kernel-ccsuffix
180         echo "${KERNEL_LDSUFFIX}" >$kerneldir/kernel-ldsuffix
181         [ -e Rules.make ] && install -m 0644 Rules.make $kerneldir/
182         [ -e Makefile ] && install -m 0644 Makefile $kerneldir/
183         
184         # Check if arch/${ARCH}/Makefile exists and install it
185         if [ -e arch/${ARCH}/Makefile ]; then
186                 install -d $kerneldir/arch/${ARCH}
187                 install -m 0644 arch/${ARCH}/Makefile* $kerneldir/arch/${ARCH}
188         # Otherwise check arch/x86/Makefile for i386 and x86_64 on kernels >= 2.6.24
189         elif [ -e arch/x86/Makefile ]; then
190                 install -d $kerneldir/arch/x86
191                 install -m 0644 arch/x86/Makefile* $kerneldir/arch/x86
192         fi
193         cp -fR include/config* $kerneldir/include/      
194         # Install kernel images and system.map to staging
195         [ -e vmlinux ] && install -m 0644 vmlinux $kerneldir/   
196         install -m 0644 ${KERNEL_OUTPUT} $kerneldir/${KERNEL_IMAGETYPE}
197         install -m 0644 System.map $kerneldir/System.map-${KERNEL_VERSION}
198         [ -e Module.symvers ] && install -m 0644 Module.symvers $kerneldir/
200         cp -fR scripts $kerneldir/
203 sysroot_stage_all_append() {
204         sysroot_stage_dir ${D}/kernel ${SYSROOT_DESTDIR}${STAGING_KERNEL_DIR}
205         cp -fpPR ${D}/kernel/.config ${SYSROOT_DESTDIR}${STAGING_KERNEL_DIR}
208 kernel_do_configure() {
209         yes '' | oe_runmake oldconfig
210         if [ ! -z "${INITRAMFS_IMAGE}" ]; then
211                 for img in cpio.gz cpio.lzo cpio.lzma; do
212                 if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
213                         cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" initramfs.$img
214                 fi
215                 done
216         fi
218 # XXX: Once we depend on bitbake 1.10.1 or newer this can be kernel_do_...
219 do_configure[depends] += "${INITRAMFS_TASK}"
221 do_menuconfig() {
222         export TERMWINDOWTITLE="${PN} Kernel Configuration"
223         export SHELLCMDS="make menuconfig"
224         ${TERMCMDRUN}
225         if [ $? -ne 0 ]; then
226                 echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable."
227                 exit 1
228         fi
230 do_menuconfig[nostamp] = "1"
231 addtask menuconfig after do_configure
233 pkg_postinst_kernel () {
234         cd /${KERNEL_IMAGEDEST}; update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
237 pkg_postrm_kernel () {
238         cd /${KERNEL_IMAGEDEST}; update-alternatives --remove ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} || true
241 inherit cml1
243 EXPORT_FUNCTIONS do_compile do_install do_configure
245 # kernel-base becomes kernel-${KERNEL_VERSION}
246 # kernel-image becomes kernel-image-${KERNEL_VERISON}
247 PACKAGES = "kernel kernel-base kernel-image kernel-dev kernel-vmlinux"
248 FILES = ""
249 FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}*"
250 FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config*"
251 FILES_kernel-vmlinux = "/boot/vmlinux*"
252 RDEPENDS_kernel = "kernel-base"
253 # Allow machines to override this dependency if kernel image files are 
254 # not wanted in images as standard
255 RDEPENDS_kernel-base ?= "kernel-image"
256 PKG_kernel-image = "kernel-image-${KERNEL_VERSION}"
257 PKG_kernel-base = "kernel-${KERNEL_VERSION}"
258 ALLOW_EMPTY_kernel = "1"
259 ALLOW_EMPTY_kernel-base = "1"
260 ALLOW_EMPTY_kernel-image = "1"
262 # Userspace workarounds for kernel modules issues
263 # This is shame, fix the kernel instead!
264 DEPENDS_kernel-module-dtl1-cs = "bluez-dtl1-workaround"
265 RDEPENDS_kernel-module-dtl1-cs = "bluez-dtl1-workaround"
267 # renamed modules
268 RPROVIDES_kernel-module-aes-generic = "kernel-module-aes"
270 pkg_postinst_kernel-image () {
271 if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
272         mkdir -p $D/lib/modules/${KERNEL_VERSION}
274 if [ -n "$D" ]; then
275         ${HOST_PREFIX}depmod-${KERNEL_MAJOR_VERSION} -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
276 else
277         depmod -a ${KERNEL_VERSION}
281 pkg_postinst_modules () {
282 if [ -n "$D" ]; then
283         ${HOST_PREFIX}depmod-${KERNEL_MAJOR_VERSION} -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
284 else
285         depmod -a ${KERNEL_VERSION}
286         update-modules || true
290 pkg_postrm_modules () {
291 update-modules || true
294 autoload_postinst_fragment() {
295 if [ x"$D" = "x" ]; then
296         modprobe %s || true
300 # autoload defaults (alphabetically sorted)
301 module_autoload_hidp = "hidp"
302 module_autoload_ipv6 = "ipv6"
303 module_autoload_ipsec = "ipsec"
304 module_autoload_ircomm-tty = "ircomm-tty"
305 module_autoload_rfcomm = "rfcomm"
306 module_autoload_sa1100-rtc = "sa1100-rtc"
307 # sa1100-rtc was renamed in 2.6.23 onwards
308 module_autoload_rtc-sa1100 = "rtc-sa1100"
310 # alias defaults (alphabetically sorted)
311 module_conf_af_packet = "alias net-pf-17 af_packet"
312 module_conf_bluez = "alias net-pf-31 bluez"
313 module_conf_bnep = "alias bt-proto-4 bnep"
314 module_conf_hci_uart = "alias tty-ldisc-15 hci_uart"
315 module_conf_l2cap = "alias bt-proto-0 l2cap"
316 module_conf_sco = "alias bt-proto-2 sco"
317 module_conf_rfcomm = "alias bt-proto-3 rfcomm"
319 python populate_packages_prepend () {
320         import os
321         def extract_modinfo(file):
322                 import tempfile, re
323                 tempfile.tempdir = bb.data.getVar("WORKDIR", d, 1)
324                 tf = tempfile.mkstemp()
325                 tmpfile = tf[1]
326                 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)
327                 os.system(cmd)
328                 f = open(tmpfile)
329                 l = f.read().split("\000")
330                 f.close()
331                 os.close(tf[0])
332                 os.unlink(tmpfile)
333                 exp = re.compile("([^=]+)=(.*)")
334                 vals = {}
335                 for i in l:
336                         m = exp.match(i)
337                         if not m:
338                                 continue
339                         vals[m.group(1)] = m.group(2)
340                 return vals
341         
342         def parse_depmod():
343                 import re
345                 dvar = bb.data.getVar('PKGD', d, 1)
346                 if not dvar:
347                         bb.error("PKGD not defined")
348                         return
350                 kernelver = bb.data.getVar('KERNEL_VERSION', d, 1)
351                 kernelver_stripped = kernelver
352                 m = re.match('^(.*-hh.*)[\.\+].*$', kernelver)
353                 if m:
354                         kernelver_stripped = m.group(1)
355                 path = bb.data.getVar("PATH", d, 1)
356                 host_prefix = bb.data.getVar("HOST_PREFIX", d, 1) or ""
357                 major_version = bb.data.getVar('KERNEL_MAJOR_VERSION', d, 1)
359                 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)
360                 f = os.popen(cmd, 'r')
362                 deps = {}
363                 pattern0 = "^(.*\.k?o):..*$"
364                 pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$"
365                 pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$"
366                 pattern3 = "^\t(.*\.k?o)\s*\\\$"
367                 pattern4 = "^\t(.*\.k?o)\s*$"
369                 line = f.readline()
370                 while line:
371                         if not re.match(pattern0, line):
372                                 line = f.readline()
373                                 continue
374                         m1 = re.match(pattern1, line)
375                         if m1:
376                                 deps[m1.group(1)] = m1.group(2).split()
377                         else:
378                                 m2 = re.match(pattern2, line)
379                                 if m2:
380                                         deps[m2.group(1)] = m2.group(2).split()
381                                         line = f.readline()
382                                         m3 = re.match(pattern3, line)
383                                         while m3:
384                                                 deps[m2.group(1)].extend(m3.group(1).split())
385                                                 line = f.readline()
386                                                 m3 = re.match(pattern3, line)
387                                         m4 = re.match(pattern4, line)
388                                         deps[m2.group(1)].extend(m4.group(1).split())
389                         line = f.readline()
390                 f.close()
391                 return deps
392         
393         def get_dependencies(file, pattern, format):
394                 file = file.replace(bb.data.getVar('PKGD', d, 1) or '', '', 1)
396                 if module_deps.has_key(file):
397                         import re
398                         dependencies = []
399                         for i in module_deps[file]:
400                                 m = re.match(pattern, os.path.basename(i))
401                                 if not m:
402                                         continue
403                                 on = legitimize_package_name(m.group(1))
404                                 dependency_pkg = format % on
405                                 dependencies.append(dependency_pkg)
406                         return dependencies
407                 return []
409         def frob_metadata(file, pkg, pattern, format, basename):
410                 import re
411                 vals = extract_modinfo(file)
413                 dvar = bb.data.getVar('PKGD', d, 1)
415                 # If autoloading is requested, output /etc/modutils/<name> and append
416                 # appropriate modprobe commands to the postinst
417                 autoload = bb.data.getVar('module_autoload_%s' % basename, d, 1)
418                 if not autoload:
419                     # Also, try canonical name with dashes
420                     autoload = bb.data.getVar('module_autoload_%s' % basename.replace('_', '-'), d, 1)
421                 if autoload:
422                         name = '%s/etc/modutils/%s' % (dvar, basename)
423                         f = open(name, 'w')
424                         for m in autoload.split():
425                                 f.write('%s\n' % m)
426                         f.close()
427                         postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1)
428                         if not postinst:
429                                 bb.fatal("pkg_postinst_%s not defined" % pkg)
430                         postinst += bb.data.getVar('autoload_postinst_fragment', d, 1) % autoload
431                         bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
433                 # Write out any modconf fragment
434                 modconf = bb.data.getVar('module_conf_%s' % basename, d, 1)
435                 if modconf:
436                         if bb.data.getVar("KERNEL_MAJOR_VERSION", d, 1) == "2.6":
437                                 name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
438                         else:
439                                 name = '%s/etc/modutils/%s.conf' % (dvar, basename)
440                         f = open(name, 'w')
441                         f.write("%s\n" % modconf)
442                         f.close()
444                 files = bb.data.getVar('FILES_%s' % pkg, d, 1)
445                 files = "%s /etc/modutils/%s /etc/modutils/%s.conf /etc/modprobe.d/%s.conf" % (files, basename, basename, basename)
446                 bb.data.setVar('FILES_%s' % pkg, files, d)
448                 if vals.has_key("description"):
449                         old_desc = bb.data.getVar('DESCRIPTION_' + pkg, d, 1) or ""
450                         bb.data.setVar('DESCRIPTION_' + pkg, old_desc + "; " + vals["description"], d)
452                 rdepends_str = bb.data.getVar('RDEPENDS_' + pkg, d, 1)
453                 if rdepends_str:
454                         rdepends = rdepends_str.split()
455                 else:
456                         rdepends = []
457                 rdepends.extend(get_dependencies(file, pattern, format))
458                 bb.data.setVar('RDEPENDS_' + pkg, ' '.join(rdepends), d)
460         module_deps = parse_depmod()
461         module_regex = '^(.*)\.k?o$'
462         module_pattern = 'kernel-module-%s'
464         postinst = bb.data.getVar('pkg_postinst_modules', d, 1)
465         postrm = bb.data.getVar('pkg_postrm_modules', d, 1)
467         maybe_update_modules = "update-modules "
468         if bb.data.getVar("ONLINE_PACKAGE_MANAGEMENT", d) == "none":
469                 maybe_update_modules = ""
470         
471         do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
472         do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
473         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)))
475         import re
476         metapkg = "kernel-modules"
477         bb.data.setVar('ALLOW_EMPTY_' + metapkg, "1", d)
478         bb.data.setVar('FILES_' + metapkg, "", d)
479         blacklist = [ 'kernel-dev', 'kernel-image', 'kernel-base', 'kernel-vmlinux' ]
480         depchains = (d.getVar("DEPCHAIN_POST", True) or "").split()
481         for l in module_deps.values():
482                 for i in l:
483                         pkg = module_pattern % legitimize_package_name(re.match(module_regex, os.path.basename(i)).group(1))
484                         blacklist.append(pkg)
485         metapkg_rdepends = []
486         packages = bb.data.getVar('PACKAGES', d, 1).split()
487         for pkg in packages[1:]:
488                 if not pkg in blacklist and not pkg in metapkg_rdepends and not any(pkg.endswith(post) for post in depchains):
489                         metapkg_rdepends.append(pkg)
490         bb.data.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends), d)
491         bb.data.setVar('DESCRIPTION_' + metapkg, 'Kernel modules meta package', d)
492         packages.append(metapkg)
493         bb.data.setVar('PACKAGES', ' '.join(packages), d)
496 # Support checking the kernel size since some kernels need to reside in partitions
497 # with a fixed length or there is a limit in transferring the kernel to memory
498 do_sizecheck() {
499         if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
500                 size=`ls -l ${KERNEL_OUTPUT} | awk '{ print $5}'`
501                 if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
502                         rm ${KERNEL_OUTPUT}
503                         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."
504                 fi
505         fi
508 addtask sizecheck before do_install after do_compile
510 do_uboot_mkimage() {
511     if test "x${KERNEL_IMAGETYPE}" = "xuImage" ; then 
512         ENTRYPOINT=${UBOOT_ENTRYPOINT}
513         if test -n "${UBOOT_ENTRYSYMBOL}"; then
514             ENTRYPOINT=`${HOST_PREFIX}nm ${S}/vmlinux | \
515                    awk '$3=="${UBOOT_ENTRYSYMBOL}" {print $1}'`
516         fi
517         if test -e arch/${ARCH}/boot/compressed/vmlinux ; then
518             ${OBJCOPY} -O binary -R .note -R .comment -S arch/${ARCH}/boot/compressed/vmlinux linux.bin
519             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
520             rm -f linux.bin
521         else
522             ${OBJCOPY} -O binary -R .note -R .comment -S vmlinux linux.bin
523             rm -f linux.bin.gz
524             gzip -9 linux.bin
525             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
526             rm -f linux.bin.gz
527         fi
528     fi
531 addtask uboot_mkimage before do_install after do_compile
533 KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PV}-${PR}-${MACHINE}"
534 KERNEL_IMAGE_SYMLINK_NAME ?= "${KERNEL_IMAGETYPE}-${MACHINE}"
535 MODULES_IMAGE_BASE_NAME ?= modules-${PV}-${PR}-${MACHINE}
537 do_deploy() {
538         install -d ${DEPLOY_DIR_IMAGE}
539         install -m 0644 ${KERNEL_OUTPUT} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
540         package_stagefile_shell ${S}/${KERNEL_OUTPUT}
541         package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
543         if [ -d "${PKGD}/lib" ]; then
544                 fakeroot tar -cvzf ${DEPLOY_DIR_IMAGE}/${MODULES_IMAGE_BASE_NAME}.tgz -C ${PKGD} lib
545                 package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${MODULES_IMAGE_BASE_NAME}.tgz
546         fi
548         cd ${DEPLOY_DIR_IMAGE}
549         rm -f ${KERNEL_IMAGE_SYMLINK_NAME}.bin
550         ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${KERNEL_IMAGE_SYMLINK_NAME}.bin
551         package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_SYMLINK_NAME}.bin
554 do_deploy[dirs] = "${S}"
555 do_deploy[depends] += "fakeroot-native:do_populate_sysroot"
557 addtask deploy before do_build after do_package