Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | |
| 4 | [[ ${EAPI} != "4" ]] && die "Only EAPI=4 is supported" |
| 5 | |
David James | d4130ab | 2013-09-19 11:26:39 -0700 | [diff] [blame] | 6 | # Since we use CHROMEOS_KERNEL_CONFIG and CHROMEOS_KERNEL_SPLITCONFIG here, |
| 7 | # it is not safe to reuse the kernel prebuilts across different boards. Inherit |
| 8 | # the cros-board eclass to make sure that doesn't happen. |
| 9 | inherit binutils-funcs cros-board linux-info toolchain-funcs |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 10 | |
| 11 | HOMEPAGE="http://www.chromium.org/" |
| 12 | LICENSE="GPL-2" |
| 13 | SLOT="0" |
| 14 | |
| 15 | DEPEND="sys-apps/debianutils |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 16 | initramfs? ( chromeos-base/chromeos-initramfs ) |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 17 | netboot_ramfs? ( chromeos-base/chromeos-initramfs ) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 18 | " |
| 19 | |
Paul Stewart | 23ead5f | 2013-04-24 22:32:17 -0700 | [diff] [blame] | 20 | IUSE="-device_tree -kernel_sources -wireless34 -wifi_testbed_ap" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 21 | STRIP_MASK="/usr/lib/debug/boot/vmlinux" |
Josh Triplett | 4c03559 | 2012-12-05 15:46:46 -0800 | [diff] [blame] | 22 | |
| 23 | # Build out-of-tree and incremental by default, but allow an ebuild inheriting |
| 24 | # this eclass to explicitly build in-tree. |
| 25 | : ${CROS_WORKON_OUTOFTREE_BUILD:=1} |
| 26 | : ${CROS_WORKON_INCREMENTAL_BUILD:=1} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 27 | |
| 28 | # Config fragments selected by USE flags |
Doug Anderson | 010887c | 2012-02-04 22:42:54 -0800 | [diff] [blame] | 29 | # ...fragments will have the following variables substitutions |
| 30 | # applied later (needs to be done later since these values |
| 31 | # aren't reliable when used in a global context like this): |
| 32 | # %ROOT% => ${ROOT} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 33 | |
| 34 | CONFIG_FRAGMENTS=( |
| 35 | blkdevram |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 36 | ca0132 |
Micah Catlin | 0dc2b97 | 2012-08-01 17:44:24 -0700 | [diff] [blame] | 37 | cifs |
Sonny Rao | 964708e | 2013-05-22 18:18:07 -0700 | [diff] [blame] | 38 | dyndebug |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 39 | fbconsole |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 40 | gdmwimax |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 41 | gobi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 42 | highmem |
Vic Yang | 1541a70 | 2013-01-10 17:36:06 +0800 | [diff] [blame] | 43 | i2cdev |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 44 | initramfs |
Doug Anderson | dd0f35f | 2013-04-15 10:57:54 -0700 | [diff] [blame] | 45 | kgdb |
Ronald G. Minnich | 6d888d4 | 2012-02-16 13:45:58 -0800 | [diff] [blame] | 46 | kvm |
Ben Chan | 412abea | 2013-06-26 11:04:17 -0700 | [diff] [blame] | 47 | mbim |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 48 | netboot_ramfs |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 49 | nfs |
| 50 | pcserial |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 51 | qmi |
Dave Parker | 9fb68c9 | 2012-05-04 10:34:00 -0700 | [diff] [blame] | 52 | realtekpstor |
Vic Yang | e0d659e | 2013-01-22 21:44:41 +0800 | [diff] [blame] | 53 | samsung_serial |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 54 | systemtap |
Vic Yang | e0d659e | 2013-01-22 21:44:41 +0800 | [diff] [blame] | 55 | tpm |
Vic Yang | 7cc29a9 | 2012-05-18 14:12:10 +0800 | [diff] [blame] | 56 | vfat |
Paul Stewart | 23ead5f | 2013-04-24 22:32:17 -0700 | [diff] [blame] | 57 | wifi_testbed_ap |
Olof Johansson | 7921a5b | 2013-05-15 13:36:34 -0700 | [diff] [blame] | 58 | wireless34 |
Mike Frysinger | 34a5512 | 2013-02-05 14:01:39 -0500 | [diff] [blame] | 59 | x32 |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 60 | ) |
| 61 | |
| 62 | blkdevram_desc="ram block device" |
| 63 | blkdevram_config=" |
| 64 | CONFIG_BLK_DEV_RAM=y |
| 65 | CONFIG_BLK_DEV_RAM_COUNT=16 |
| 66 | CONFIG_BLK_DEV_RAM_SIZE=16384 |
| 67 | " |
| 68 | |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 69 | ca0132_desc="CA0132 ALSA codec" |
| 70 | ca0132_config=" |
| 71 | CONFIG_SND_HDA_CODEC_CA0132=y |
Chih-Chung Chang | 2306b49 | 2012-09-04 19:52:18 +0800 | [diff] [blame] | 72 | CONFIG_SND_HDA_DSP_LOADER=y |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 73 | " |
| 74 | |
Micah Catlin | 0dc2b97 | 2012-08-01 17:44:24 -0700 | [diff] [blame] | 75 | cifs_desc="Samba/CIFS Support" |
| 76 | cifs_config=" |
| 77 | CONFIG_CIFS=m |
| 78 | " |
| 79 | |
Sonny Rao | 964708e | 2013-05-22 18:18:07 -0700 | [diff] [blame] | 80 | dyndebug_desc="Enable Dynamic Debug" |
| 81 | dyndebug_config=" |
| 82 | CONFIG_DYNAMIC_DEBUG=y |
| 83 | " |
| 84 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 85 | fbconsole_desc="framebuffer console" |
| 86 | fbconsole_config=" |
| 87 | CONFIG_FRAMEBUFFER_CONSOLE=y |
| 88 | " |
| 89 | |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 90 | gdmwimax_desc="GCT GDM72xx WiMAX support" |
| 91 | gdmwimax_config=" |
| 92 | CONFIG_WIMAX_GDM72XX=m |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 93 | CONFIG_WIMAX_GDM72XX_USB=y |
| 94 | CONFIG_WIMAX_GDM72XX_USB_PM=y |
| 95 | " |
| 96 | |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 97 | gobi_desc="Qualcomm Gobi modem driver" |
| 98 | gobi_config=" |
| 99 | CONFIG_USB_NET_GOBI=m |
| 100 | " |
| 101 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 102 | highmem_desc="highmem" |
| 103 | highmem_config=" |
| 104 | CONFIG_HIGHMEM64G=y |
| 105 | " |
| 106 | |
Vic Yang | 1541a70 | 2013-01-10 17:36:06 +0800 | [diff] [blame] | 107 | i2cdev_desc="I2C device interface" |
| 108 | i2cdev_config=" |
| 109 | CONFIG_I2C_CHARDEV=y |
| 110 | " |
| 111 | |
Doug Anderson | dd0f35f | 2013-04-15 10:57:54 -0700 | [diff] [blame] | 112 | kgdb_desc="Enable kgdb" |
| 113 | kgdb_config=" |
| 114 | CONFIG_KGDB=y |
| 115 | CONFIG_KGDB_KDB=y |
| 116 | """ |
| 117 | |
Vic Yang | e0d659e | 2013-01-22 21:44:41 +0800 | [diff] [blame] | 118 | tpm_desc="TPM support" |
| 119 | tpm_config=" |
| 120 | CONFIG_TCG_TPM=y |
| 121 | CONFIG_TCG_TIS=y |
| 122 | " |
| 123 | |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 124 | initramfs_desc="Initramfs for factory install shim and recovery image" |
| 125 | initramfs_config=' |
| 126 | CONFIG_INITRAMFS_SOURCE="%ROOT%/var/lib/misc/initramfs.cpio.xz" |
Anush Elangovan | f9b66d9 | 2012-12-20 12:16:15 -0800 | [diff] [blame] | 127 | CONFIG_INITRAMFS_COMPRESSION_XZ=y |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 128 | ' |
| 129 | |
| 130 | netboot_ramfs_desc="Network boot install initramfs" |
| 131 | netboot_ramfs_config=' |
| 132 | CONFIG_INITRAMFS_SOURCE="%ROOT%/var/lib/misc/netboot_ramfs.cpio.xz" |
| 133 | CONFIG_INITRAMFS_COMPRESSION_XZ=y |
| 134 | ' |
Vic Yang | 7cc29a9 | 2012-05-18 14:12:10 +0800 | [diff] [blame] | 135 | |
| 136 | vfat_desc="vfat" |
| 137 | vfat_config=" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 138 | CONFIG_NLS_CODEPAGE_437=y |
| 139 | CONFIG_NLS_ISO8859_1=y |
| 140 | CONFIG_FAT_FS=y |
| 141 | CONFIG_VFAT_FS=y |
| 142 | " |
| 143 | |
Ronald G. Minnich | 6d888d4 | 2012-02-16 13:45:58 -0800 | [diff] [blame] | 144 | kvm_desc="KVM" |
| 145 | kvm_config=" |
| 146 | CONFIG_HAVE_KVM=y |
| 147 | CONFIG_HAVE_KVM_IRQCHIP=y |
| 148 | CONFIG_HAVE_KVM_EVENTFD=y |
| 149 | CONFIG_KVM_APIC_ARCHITECTURE=y |
| 150 | CONFIG_KVM_MMIO=y |
| 151 | CONFIG_KVM_ASYNC_PF=y |
| 152 | CONFIG_KVM=m |
| 153 | CONFIG_KVM_INTEL=m |
| 154 | # CONFIG_KVM_AMD is not set |
| 155 | # CONFIG_KVM_MMU_AUDIT is not set |
| 156 | CONFIG_VIRTIO=m |
| 157 | CONFIG_VIRTIO_BLK=m |
| 158 | CONFIG_VIRTIO_NET=m |
| 159 | CONFIG_VIRTIO_CONSOLE=m |
| 160 | CONFIG_VIRTIO_RING=m |
| 161 | CONFIG_VIRTIO_PCI=m |
| 162 | " |
| 163 | |
Ben Chan | 412abea | 2013-06-26 11:04:17 -0700 | [diff] [blame] | 164 | # TODO(benchan): Remove the 'mbim' use flag and unconditionally enable the |
| 165 | # CDC MBIM driver once Chromium OS fully supports MBIM. |
| 166 | mbim_desc="CDC MBIM driver" |
| 167 | mbim_config=" |
| 168 | CONFIG_USB_NET_CDC_MBIM=m |
| 169 | " |
| 170 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 171 | nfs_desc="NFS" |
| 172 | nfs_config=" |
| 173 | CONFIG_USB_NET_AX8817X=y |
| 174 | CONFIG_DNOTIFY=y |
| 175 | CONFIG_DNS_RESOLVER=y |
| 176 | CONFIG_LOCKD=y |
| 177 | CONFIG_LOCKD_V4=y |
| 178 | CONFIG_NETWORK_FILESYSTEMS=y |
| 179 | CONFIG_NFSD=m |
| 180 | CONFIG_NFSD_V3=y |
| 181 | CONFIG_NFSD_V4=y |
| 182 | CONFIG_NFS_COMMON=y |
| 183 | CONFIG_NFS_FS=y |
| 184 | CONFIG_NFS_USE_KERNEL_DNS=y |
| 185 | CONFIG_NFS_V3=y |
| 186 | CONFIG_NFS_V4=y |
| 187 | CONFIG_ROOT_NFS=y |
| 188 | CONFIG_RPCSEC_GSS_KRB5=y |
| 189 | CONFIG_SUNRPC=y |
| 190 | CONFIG_SUNRPC_GSS=y |
| 191 | CONFIG_USB_USBNET=y |
| 192 | CONFIG_IP_PNP=y |
| 193 | CONFIG_IP_PNP_DHCP=y |
| 194 | " |
| 195 | |
| 196 | pcserial_desc="PC serial" |
| 197 | pcserial_config=" |
| 198 | CONFIG_SERIAL_8250=y |
| 199 | CONFIG_SERIAL_8250_CONSOLE=y |
| 200 | CONFIG_SERIAL_8250_PCI=y |
| 201 | CONFIG_PARPORT=y |
| 202 | CONFIG_PARPORT_PC=y |
| 203 | CONFIG_PARPORT_SERIAL=y |
| 204 | " |
| 205 | |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 206 | qmi_desc="QMI WWAN driver" |
| 207 | qmi_config=" |
| 208 | CONFIG_USB_NET_QMI_WWAN=m |
| 209 | " |
| 210 | |
Olof Johansson | 08268b0c | 2012-08-01 00:12:00 -0700 | [diff] [blame] | 211 | samsung_serial_desc="Samsung serialport" |
| 212 | samsung_serial_config=" |
| 213 | CONFIG_SERIAL_SAMSUNG=y |
| 214 | CONFIG_SERIAL_SAMSUNG_CONSOLE=y |
| 215 | " |
| 216 | |
Dave Parker | 9fb68c9 | 2012-05-04 10:34:00 -0700 | [diff] [blame] | 217 | realtekpstor_desc="Realtek PCI card reader" |
| 218 | realtekpstor_config=" |
| 219 | CONFIG_RTS_PSTOR=m |
| 220 | " |
| 221 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 222 | systemtap_desc="systemtap support" |
| 223 | systemtap_config=" |
| 224 | CONFIG_KPROBES=y |
| 225 | CONFIG_DEBUG_INFO=y |
| 226 | " |
| 227 | |
Paul Stewart | 23ead5f | 2013-04-24 22:32:17 -0700 | [diff] [blame] | 228 | wifi_testbed_ap_desc="Defer ath9k EEPROM regulatory" |
| 229 | wifi_testbed_ap_warning=" |
| 230 | Don't use the wifi_testbed_ap flag unless you know what you are doing! |
| 231 | An image built with this flag set must never be run outside a |
| 232 | sealed RF chamber! |
| 233 | " |
| 234 | wifi_testbed_ap_config=" |
| 235 | CONFIG_ATH_DEFER_EEPROM_REGULATORY=y |
| 236 | " |
| 237 | |
Mike Frysinger | 34a5512 | 2013-02-05 14:01:39 -0500 | [diff] [blame] | 238 | x32_desc="x32 ABI support" |
| 239 | x32_config=" |
| 240 | CONFIG_X86_X32=y |
| 241 | " |
| 242 | |
Olof Johansson | 7921a5b | 2013-05-15 13:36:34 -0700 | [diff] [blame] | 243 | wireless34_desc="Wireless 3.4 stack" |
| 244 | wireless34_config=" |
| 245 | CONFIG_ATH9K_BTCOEX=m |
| 246 | CONFIG_ATH9K_BTCOEX_COMMON=m |
| 247 | CONFIG_ATH9K_BTCOEX_HW=m |
| 248 | " |
| 249 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 250 | # Add all config fragments as off by default |
| 251 | IUSE="${IUSE} ${CONFIG_FRAGMENTS[@]}" |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 252 | REQUIRED_USE=" |
| 253 | initramfs? ( !netboot_ramfs ) |
| 254 | netboot_ramfs? ( !initramfs ) |
| 255 | initramfs? ( i2cdev tpm ) |
| 256 | netboot_ramfs? ( i2cdev tpm ) |
| 257 | " |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 258 | |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 259 | # If an overlay has eclass overrides, but doesn't actually override this |
| 260 | # eclass, we'll have ECLASSDIR pointing to the active overlay's |
| 261 | # eclass/ dir, but this eclass is still in the main chromiumos tree. So |
| 262 | # add a check to locate the cros-kernel/ regardless of what's going on. |
| 263 | ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*} |
| 264 | defconfig_dir() { |
Michael Spang | c4f2fc0 | 2013-09-18 12:17:32 -0400 | [diff] [blame] | 265 | local d="${ECLASSDIR}/cros-kernel" |
| 266 | if [[ ! -d ${d} ]] ; then |
| 267 | d="${ECLASSDIR_LOCAL}/cros-kernel" |
| 268 | fi |
| 269 | echo "${d}" |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Josh Triplett | 6df77a7 | 2013-04-26 17:25:37 -0700 | [diff] [blame] | 272 | # @FUNCTION: kernelrelease |
Mike Frysinger | 330c023 | 2013-01-09 17:47:04 -0500 | [diff] [blame] | 273 | # @DESCRIPTION: |
| 274 | # Returns the current compiled kernel version. |
| 275 | # Note: Only valid after src_configure has finished running. |
Josh Triplett | 6df77a7 | 2013-04-26 17:25:37 -0700 | [diff] [blame] | 276 | kernelrelease() { |
| 277 | kmake -s --no-print-directory kernelrelease |
Mike Frysinger | 330c023 | 2013-01-09 17:47:04 -0500 | [diff] [blame] | 278 | } |
| 279 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 280 | # @FUNCTION: install_kernel_sources |
| 281 | # @DESCRIPTION: |
| 282 | # Installs the kernel sources into ${D}/usr/src/${P} and fixes symlinks. |
| 283 | # The package must have already installed a directory under ${D}/lib/modules. |
| 284 | install_kernel_sources() { |
Josh Triplett | 6df77a7 | 2013-04-26 17:25:37 -0700 | [diff] [blame] | 285 | local version=$(kernelrelease) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 286 | local dest_modules_dir=lib/modules/${version} |
| 287 | local dest_source_dir=usr/src/${P} |
| 288 | local dest_build_dir=${dest_source_dir}/build |
| 289 | |
| 290 | # Fix symlinks in lib/modules |
| 291 | ln -sfvT "../../../${dest_build_dir}" \ |
| 292 | "${D}/${dest_modules_dir}/build" || die |
| 293 | ln -sfvT "../../../${dest_source_dir}" \ |
| 294 | "${D}/${dest_modules_dir}/source" || die |
| 295 | |
| 296 | einfo "Installing kernel source tree" |
| 297 | dodir "${dest_source_dir}" |
| 298 | local f |
| 299 | for f in "${S}"/*; do |
| 300 | [[ "$f" == "${S}/build" ]] && continue |
| 301 | cp -pPR "${f}" "${D}/${dest_source_dir}" || |
| 302 | die "Failed to copy kernel source tree" |
| 303 | done |
| 304 | |
| 305 | dosym "${P}" "/usr/src/linux" |
| 306 | |
| 307 | einfo "Installing kernel build tree" |
| 308 | dodir "${dest_build_dir}" |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 309 | cp -pPR "$(cros-workon_get_build_dir)"/{.config,.version,Makefile,Module.symvers,include} \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 310 | "${D}/${dest_build_dir}" || die |
| 311 | |
| 312 | # Modify Makefile to use the ROOT environment variable if defined. |
| 313 | # This path needs to be absolute so that the build directory will |
| 314 | # still work if copied elsewhere. |
| 315 | sed -i -e "s@${S}@\$(ROOT)/${dest_source_dir}@" \ |
| 316 | "${D}/${dest_build_dir}/Makefile" || die |
| 317 | } |
| 318 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 319 | get_build_cfg() { |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 320 | echo "$(cros-workon_get_build_dir)/.config" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 321 | } |
| 322 | |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 323 | get_build_arch() { |
| 324 | if [ "${ARCH}" = "arm" ] ; then |
| 325 | case "${CHROMEOS_KERNEL_SPLITCONFIG}" in |
| 326 | *tegra*) |
| 327 | echo "tegra" |
| 328 | ;; |
| 329 | *exynos*) |
| 330 | echo "exynos5" |
| 331 | ;; |
| 332 | *) |
| 333 | echo "arm" |
| 334 | ;; |
| 335 | esac |
| 336 | else |
Mike Frysinger | dde5f6a | 2013-09-25 22:08:25 -0400 | [diff] [blame] | 337 | tc-arch-kernel |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 338 | fi |
| 339 | } |
| 340 | |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 341 | # @FUNCTION: cros_chkconfig_present |
| 342 | # @USAGE: <option to check config for> |
| 343 | # @DESCRIPTION: |
| 344 | # Returns success of the provided option is present in the build config. |
| 345 | cros_chkconfig_present() { |
| 346 | local config=$1 |
| 347 | grep -q "^CONFIG_$1=[ym]$" "$(get_build_cfg)" |
| 348 | } |
| 349 | |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 350 | cros-kernel2_pkg_setup() { |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 351 | # This is needed for running src_test(). The kernel code will need to |
| 352 | # be rebuilt with `make check`. If incremental build were enabled, |
| 353 | # `make check` would have nothing left to build. |
Simon Que | 6324b6f | 2013-02-01 14:56:05 -0800 | [diff] [blame] | 354 | use test && export CROS_WORKON_INCREMENTAL_BUILD=0 |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 355 | cros-workon_pkg_setup |
Mike Frysinger | b5ebdb5 | 2013-02-10 03:25:44 -0500 | [diff] [blame] | 356 | linux-info_pkg_setup |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 357 | } |
| 358 | |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 359 | # @FUNCTION: emit_its_script |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 360 | # @USAGE: <output file> <boot_dir> <dtb_dir> <device trees> |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 361 | # @DESCRIPTION: |
| 362 | # Emits the its script used to build the u-boot fitImage kernel binary |
| 363 | # that contains the kernel as well as device trees used when booting |
| 364 | # it. |
| 365 | |
| 366 | emit_its_script() { |
| 367 | local iter=1 |
| 368 | local its_out=${1} |
| 369 | shift |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 370 | local boot_dir=${1} |
| 371 | shift |
| 372 | local dtb_dir=${1} |
| 373 | shift |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 374 | cat > "${its_out}" <<-EOF || die |
| 375 | /dts-v1/; |
| 376 | |
| 377 | / { |
| 378 | description = "Chrome OS kernel image with one or more FDT blobs"; |
| 379 | #address-cells = <1>; |
| 380 | |
| 381 | images { |
| 382 | kernel@1 { |
| 383 | data = /incbin/("${boot_dir}/zImage"); |
Doug Anderson | 21b4420 | 2013-06-24 14:31:18 -0700 | [diff] [blame] | 384 | type = "kernel_noload"; |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 385 | arch = "arm"; |
| 386 | os = "linux"; |
| 387 | compression = "none"; |
Doug Anderson | 21b4420 | 2013-06-24 14:31:18 -0700 | [diff] [blame] | 388 | load = <0>; |
| 389 | entry = <0>; |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 390 | }; |
| 391 | EOF |
| 392 | |
| 393 | local dtb |
| 394 | for dtb in "$@" ; do |
| 395 | cat >> "${its_out}" <<-EOF || die |
| 396 | fdt@${iter} { |
| 397 | description = "$(basename ${dtb})"; |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 398 | data = /incbin/("${dtb_dir}/${dtb}"); |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 399 | type = "flat_dt"; |
| 400 | arch = "arm"; |
| 401 | compression = "none"; |
| 402 | hash@1 { |
| 403 | algo = "sha1"; |
| 404 | }; |
| 405 | }; |
| 406 | EOF |
| 407 | ((++iter)) |
| 408 | done |
| 409 | |
| 410 | cat <<-EOF >>"${its_script}" |
| 411 | }; |
| 412 | configurations { |
| 413 | default = "conf@1"; |
| 414 | EOF |
| 415 | |
| 416 | local i |
| 417 | for i in $(seq 1 $((iter-1))) ; do |
| 418 | cat >> "${its_out}" <<-EOF || die |
| 419 | conf@${i} { |
| 420 | kernel = "kernel@1"; |
| 421 | fdt = "fdt@${i}"; |
| 422 | }; |
| 423 | EOF |
| 424 | done |
| 425 | |
| 426 | echo " };" >> "${its_out}" |
| 427 | echo "};" >> "${its_out}" |
| 428 | } |
| 429 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 430 | kmake() { |
| 431 | # Allow override of kernel arch. |
| 432 | local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)} |
| 433 | |
| 434 | local cross=${CHOST}- |
Olof Johansson | c0f8a5d | 2013-04-11 18:36:40 -0700 | [diff] [blame] | 435 | |
| 436 | if use wireless34 ; then |
| 437 | set -- "$@" WIFIVERSION="-3.4" |
| 438 | fi |
| 439 | |
Kees Cook | aaff841 | 2013-07-12 10:46:50 -0700 | [diff] [blame] | 440 | # TODO(raymes): Force GNU ld over gold. There are still some |
| 441 | # gold issues to iron out. See: 13209. |
| 442 | tc-export LD CC CXX |
| 443 | |
| 444 | local binutils_path=$(get_binutils_path_ld) |
| 445 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 446 | # Hack for using 64-bit kernel with 32-bit user-space |
Mike Frysinger | 0f008b2 | 2013-03-14 11:54:13 -0400 | [diff] [blame] | 447 | if [[ "${ARCH}" == "x86" && "${kernel_arch}" == "x86_64" ]]; then |
Sonny Rao | 5ebd89f | 2012-08-05 20:31:23 -0700 | [diff] [blame] | 448 | cross=x86_64-cros-linux-gnu- |
Kees Cook | aaff841 | 2013-07-12 10:46:50 -0700 | [diff] [blame] | 449 | binutils_path=$(echo "$binutils_path" | sed -e \ |
| 450 | 's/i686-pc-linux-gnu/x86_64-cros-linux-gnu/g') |
| 451 | LD=$(echo "$LD" | sed -e \ |
| 452 | 's/i686-pc-linux-gnu/x86_64-cros-linux-gnu/g') |
| 453 | CC=$(echo "$CC" | sed -e \ |
| 454 | 's/i686-pc-linux-gnu/x86_64-cros-linux-gnu/g') |
| 455 | CXX=$(echo "$CXX" | sed -e \ |
| 456 | 's/i686-pc-linux-gnu/x86_64-cros-linux-gnu/g') |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 457 | fi |
| 458 | |
Kees Cook | aaff841 | 2013-07-12 10:46:50 -0700 | [diff] [blame] | 459 | set -- \ |
| 460 | LD="${binutils_path}/ld $(usex x32 '-m elf_x86_64' '')" \ |
| 461 | CC="${CC} -B${binutils_path}" \ |
| 462 | CXX="${CXX} -B${binutils_path}" \ |
| 463 | "$@" |
| 464 | |
Mike Frysinger | a8ef3cd | 2012-11-01 18:42:18 -0400 | [diff] [blame] | 465 | cw_emake \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 466 | ARCH=${kernel_arch} \ |
| 467 | LDFLAGS="$(raw-ldflags)" \ |
| 468 | CROSS_COMPILE="${cross}" \ |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 469 | O="$(cros-workon_get_build_dir)" \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 470 | "$@" |
| 471 | } |
| 472 | |
Josh Triplett | 4c03559 | 2012-12-05 15:46:46 -0800 | [diff] [blame] | 473 | cros-kernel2_src_prepare() { |
| 474 | cros-workon_src_prepare |
| 475 | } |
| 476 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 477 | cros-kernel2_src_configure() { |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 478 | # Use a single or split kernel config as specified in the board or variant |
| 479 | # make.conf overlay. Default to the arch specific split config if an |
| 480 | # overlay or variant does not set either CHROMEOS_KERNEL_CONFIG or |
| 481 | # CHROMEOS_KERNEL_SPLITCONFIG. CHROMEOS_KERNEL_CONFIG is set relative |
| 482 | # to the root of the kernel source tree. |
| 483 | local config |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 484 | local cfgarch="$(get_build_arch)" |
| 485 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 486 | if [ -n "${CHROMEOS_KERNEL_CONFIG}" ]; then |
Chris Masone | f888c38 | 2013-03-19 14:19:41 -0700 | [diff] [blame] | 487 | case ${CHROMEOS_KERNEL_CONFIG} in |
| 488 | /*) |
| 489 | config="${CHROMEOS_KERNEL_CONFIG}" |
| 490 | ;; |
| 491 | *) |
| 492 | config="${S}/${CHROMEOS_KERNEL_CONFIG}" |
| 493 | ;; |
| 494 | esac |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 495 | else |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 496 | config=${CHROMEOS_KERNEL_SPLITCONFIG:-"chromiumos-${cfgarch}"} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 497 | fi |
| 498 | |
| 499 | elog "Using kernel config: ${config}" |
| 500 | |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 501 | # Keep a handle on the old .config in case it hasn't changed. This way |
| 502 | # we can keep the old timestamp which will avoid regenerating stuff that |
| 503 | # hasn't actually changed. |
| 504 | local temp_config="${T}/old-kernel-config" |
| 505 | if [[ -e $(get_build_cfg) ]] ; then |
| 506 | cp -a "$(get_build_cfg)" "${temp_config}" |
| 507 | else |
| 508 | rm -f "${temp_config}" |
| 509 | fi |
| 510 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 511 | if [ -n "${CHROMEOS_KERNEL_CONFIG}" ]; then |
| 512 | cp -f "${config}" "$(get_build_cfg)" || die |
| 513 | else |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 514 | if [ -e chromeos/scripts/prepareconfig ] ; then |
| 515 | chromeos/scripts/prepareconfig ${config} \ |
| 516 | "$(get_build_cfg)" || die |
| 517 | else |
| 518 | config="$(defconfig_dir)/${cfgarch}_defconfig" |
| 519 | ewarn "Can't prepareconfig, falling back to default " \ |
| 520 | "${config}" |
| 521 | cp "${config}" "$(get_build_cfg)" || die |
| 522 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 523 | fi |
| 524 | |
| 525 | local fragment |
| 526 | for fragment in ${CONFIG_FRAGMENTS[@]}; do |
| 527 | use ${fragment} || continue |
| 528 | |
| 529 | local msg="${fragment}_desc" |
| 530 | local config="${fragment}_config" |
| 531 | elog " - adding ${!msg} config" |
Paul Stewart | 23ead5f | 2013-04-24 22:32:17 -0700 | [diff] [blame] | 532 | local warning="${fragment}_warning" |
| 533 | local warning_msg="${!warning}" |
| 534 | if [[ -n "${warning_msg}" ]] ; then |
| 535 | ewarn "${warning_msg}" |
| 536 | fi |
Doug Anderson | 010887c | 2012-02-04 22:42:54 -0800 | [diff] [blame] | 537 | |
| 538 | echo "${!config}" | \ |
| 539 | sed -e "s|%ROOT%|${ROOT}|g" \ |
| 540 | >> "$(get_build_cfg)" || die |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 541 | done |
| 542 | |
| 543 | # Use default for any options not explitly set in splitconfig |
| 544 | yes "" | kmake oldconfig |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 545 | |
| 546 | # Restore the old config if it is unchanged. |
| 547 | if cmp -s "$(get_build_cfg)" "${temp_config}" ; then |
| 548 | touch -r "${temp_config}" "$(get_build_cfg)" |
| 549 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 550 | } |
| 551 | |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 552 | # @FUNCTION: get_dtb_name |
| 553 | # @USAGE: <dtb_dir> |
| 554 | # @DESCRIPTION: |
| 555 | # Get the name(s) of the device tree binary file(s) to include. |
| 556 | |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 557 | get_dtb_name() { |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 558 | local dtb_dir=${1} |
David James | d4130ab | 2013-09-19 11:26:39 -0700 | [diff] [blame] | 559 | local f |
| 560 | for f in ${dtb_dir}/*.dtb ; do |
| 561 | basename ${f} |
| 562 | done |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | cros-kernel2_src_compile() { |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 566 | local build_targets=() # use make default target |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 567 | if use arm; then |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 568 | build_targets=( |
Michael Spang | c4f2fc0 | 2013-09-18 12:17:32 -0400 | [diff] [blame] | 569 | $(usex device_tree 'zImage dtbs' uImage) |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 570 | $(cros_chkconfig_present MODULES && echo "modules") |
| 571 | ) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 572 | fi |
| 573 | |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 574 | local src_dir="$(cros-workon_get_build_dir)/source" |
| 575 | local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)} |
| 576 | SMATCH_ERROR_FILE="${src_dir}/chromeos/check/smatch_errors.log" |
| 577 | |
Simon Que | 6324b6f | 2013-02-01 14:56:05 -0800 | [diff] [blame] | 578 | if use test && [[ -e "${SMATCH_ERROR_FILE}" ]]; then |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 579 | local make_check_cmd="smatch -p=kernel" |
| 580 | local test_options=( |
| 581 | CHECK="${make_check_cmd}" |
| 582 | C=1 |
| 583 | ) |
| 584 | SMATCH_LOG_FILE="$(cros-workon_get_build_dir)/make.log" |
| 585 | |
| 586 | # The path names in the log file are build-dependent. Strip out |
| 587 | # the part of the path before "kernel/files" and retains what |
| 588 | # comes after it: the file, line number, and error message. |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 589 | kmake -k ${build_targets[@]} "${test_options[@]}" |& \ |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 590 | tee "${SMATCH_LOG_FILE}" |
| 591 | else |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 592 | kmake -k ${build_targets[@]} |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 593 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 594 | } |
| 595 | |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 596 | cros-kernel2_src_test() { |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 597 | [[ -e ${SMATCH_ERROR_FILE} ]] || \ |
| 598 | die "smatch whitelist file ${SMATCH_ERROR_FILE} not found!" |
| 599 | [[ -e ${SMATCH_LOG_FILE} ]] || \ |
| 600 | die "Log file from src_compile() ${SMATCH_LOG_FILE} not found!" |
| 601 | |
Paul Taysom | 98a5436 | 2013-06-12 16:30:25 -0700 | [diff] [blame] | 602 | local prefix="$(realpath "${S}")/" |
| 603 | grep -w error: "${SMATCH_LOG_FILE}" | grep -o "${prefix}.*" \ |
| 604 | | sed s:"${prefix}"::g > "${SMATCH_LOG_FILE}.errors" |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 605 | local num_errors=$(wc -l < "${SMATCH_LOG_FILE}.errors") |
| 606 | local num_warnings=$(egrep -wc "warn:|warning:" "${SMATCH_LOG_FILE}") |
| 607 | einfo "smatch found ${num_errors} errors and ${num_warnings} warnings." |
| 608 | |
| 609 | # Create a version of the error database that doesn't have line numbers, |
| 610 | # since line numbers will shift as code is added or removed. |
| 611 | local build_dir="$(cros-workon_get_build_dir)" |
| 612 | local no_line_numbers_file="${build_dir}/no_line_numbers.log" |
Chih-Chung Chang | f28e76e | 2013-04-08 11:53:29 +0800 | [diff] [blame] | 613 | sed -r -e "s/(:[0-9]+){1,2}//" \ |
| 614 | -e "s/\(see line [0-9]+\)//" \ |
| 615 | "${SMATCH_ERROR_FILE}" > "${no_line_numbers_file}" |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 616 | |
| 617 | # For every smatch error that came up during the build, check if it is |
| 618 | # in the error database file. |
| 619 | local num_unknown_errors=0 |
| 620 | local line="" |
| 621 | while read line; do |
Simon Que | fc5fc9d | 2013-01-28 15:19:38 -0800 | [diff] [blame] | 622 | local no_line_num=$(echo "${line}" | \ |
Chih-Chung Chang | f28e76e | 2013-04-08 11:53:29 +0800 | [diff] [blame] | 623 | sed -r -e "s/(:[0-9]+){1,2}//" \ |
| 624 | -e "s/\(see line [0-9]+\)//") |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 625 | if ! fgrep -q "${no_line_num}" "${no_line_numbers_file}"; then |
| 626 | eerror "Non-whitelisted error found: \"${line}\"" |
| 627 | : $(( ++num_unknown_errors )) |
| 628 | fi |
| 629 | done < "${SMATCH_LOG_FILE}.errors" |
| 630 | |
| 631 | [[ ${num_unknown_errors} -eq 0 ]] || \ |
| 632 | die "smatch found ${num_unknown_errors} unknown errors." |
| 633 | } |
| 634 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 635 | cros-kernel2_src_install() { |
Doug Anderson | e3a867e | 2013-06-24 16:26:43 -0700 | [diff] [blame] | 636 | local build_targets=( |
| 637 | install |
| 638 | firmware_install |
| 639 | $(cros_chkconfig_present MODULES && echo "modules_install") |
| 640 | ) |
| 641 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 642 | dodir /boot |
Doug Anderson | e3a867e | 2013-06-24 16:26:43 -0700 | [diff] [blame] | 643 | kmake INSTALL_PATH="${D}/boot" INSTALL_MOD_PATH="${D}" \ |
| 644 | "${build_targets[@]}" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 645 | |
Josh Triplett | 6df77a7 | 2013-04-26 17:25:37 -0700 | [diff] [blame] | 646 | local version=$(kernelrelease) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 647 | if use arm; then |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 648 | local boot_dir="$(cros-workon_get_build_dir)/arch/${ARCH}/boot" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 649 | local kernel_bin="${D}/boot/vmlinuz-${version}" |
| 650 | local zimage_bin="${D}/boot/zImage-${version}" |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 651 | local dtb_dir="${boot_dir}" |
| 652 | |
| 653 | # Newer kernels (after linux-next 12/3/12) put dtbs in the dts |
| 654 | # dir. Use that if we we find no dtbs directly in boot_dir. |
| 655 | # Note that we try boot_dir first since the newer kernel will |
| 656 | # actually rm ${boot_dir}/*.dtb so we'll have no stale files. |
| 657 | if ! ls "${dtb_dir}"/*.dtb &> /dev/null; then |
| 658 | dtb_dir="${boot_dir}/dts" |
| 659 | fi |
| 660 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 661 | if use device_tree; then |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 662 | local its_script="$(cros-workon_get_build_dir)/its_script" |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 663 | emit_its_script "${its_script}" "${boot_dir}" \ |
| 664 | "${dtb_dir}" $(get_dtb_name "${dtb_dir}") |
Isaac Simha | 4a2c1b5 | 2013-07-05 16:15:26 -0700 | [diff] [blame] | 665 | mkimage -D "-I dts -O dtb -p 1024" -f "${its_script}" "${kernel_bin}" || die |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 666 | else |
| 667 | cp -a "${boot_dir}/uImage" "${kernel_bin}" || die |
| 668 | fi |
| 669 | cp -a "${boot_dir}/zImage" "${zimage_bin}" || die |
| 670 | |
| 671 | # TODO(vbendeb): remove the below .uimg link creation code |
| 672 | # after the build scripts have been modified to use the base |
| 673 | # image name. |
| 674 | cd $(dirname "${kernel_bin}") |
| 675 | ln -sf $(basename "${kernel_bin}") vmlinux.uimg || die |
| 676 | ln -sf $(basename "${zimage_bin}") zImage || die |
| 677 | fi |
| 678 | if [ ! -e "${D}/boot/vmlinuz" ]; then |
| 679 | ln -sf "vmlinuz-${version}" "${D}/boot/vmlinuz" || die |
| 680 | fi |
| 681 | |
Vic Yang | 40fff21 | 2012-05-14 10:43:11 +0800 | [diff] [blame] | 682 | # Check the size of kernel image and issue warning when image size is near |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 683 | # the limit. For factory install initramfs, we don't care about kernel |
| 684 | # size limit as the image is downloaded over network. |
Vic Yang | 40fff21 | 2012-05-14 10:43:11 +0800 | [diff] [blame] | 685 | local kernel_image_size=$(stat -c '%s' -L "${D}"/boot/vmlinuz) |
| 686 | einfo "Kernel image size is ${kernel_image_size} bytes." |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 687 | if use netboot_ramfs; then |
| 688 | # No need to check kernel image size. |
| 689 | true |
| 690 | elif [[ ${kernel_image_size} -gt $((8 * 1024 * 1024)) ]]; then |
Olof Johansson | cbbe887 | 2012-07-30 08:43:31 -0700 | [diff] [blame] | 691 | die "Kernel image is larger than 8 MB." |
| 692 | elif [[ ${kernel_image_size} -gt $((7 * 1024 * 1024)) ]]; then |
| 693 | ewarn "Kernel image is larger than 7 MB. Limit is 8 MB." |
Vic Yang | 40fff21 | 2012-05-14 10:43:11 +0800 | [diff] [blame] | 694 | fi |
| 695 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 696 | # Install uncompressed kernel for debugging purposes. |
| 697 | insinto /usr/lib/debug/boot |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 698 | doins "$(cros-workon_get_build_dir)/vmlinux" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 699 | |
Mike Frysinger | dde5f6a | 2013-09-25 22:08:25 -0400 | [diff] [blame] | 700 | # Also install the vdso shared ELFs for crash reporting. |
Mike Frysinger | 02d2001 | 2013-09-26 17:00:20 -0400 | [diff] [blame^] | 701 | # We use slightly funky filenames so as to better integrate with |
| 702 | # debugging processes (crash reporter/gdb/etc...). The basename |
| 703 | # will be the SONAME (what the runtime process sees), but since |
| 704 | # that is not unique among all inputs, we also install into a dir |
| 705 | # with the original filename. e.g. we will install: |
| 706 | # /lib/modules/3.8.11/vdso/vdso32-syscall.so/linux-gate.so |
Mike Frysinger | dde5f6a | 2013-09-25 22:08:25 -0400 | [diff] [blame] | 707 | if use x86 || use amd64; then |
Mike Frysinger | 02d2001 | 2013-09-26 17:00:20 -0400 | [diff] [blame^] | 708 | local d f soname |
| 709 | # Use the debug versions (.so.dbg) so portage can run splitdebug on them. |
| 710 | for f in "$(cros-workon_get_build_dir)/arch/x86/vdso"/vdso*.so.dbg; do |
| 711 | d="/lib/modules/${version}/vdso/${f##*/}" |
| 712 | |
| 713 | exeinto "${d}" |
| 714 | newexe "${f}" "linux-gate.so" |
| 715 | |
| 716 | soname=$(scanelf -qF'%S#f' "${f}") |
| 717 | dosym "linux-gate.so" "${d}/${soname}" |
Mike Frysinger | dde5f6a | 2013-09-25 22:08:25 -0400 | [diff] [blame] | 718 | done |
| 719 | fi |
| 720 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 721 | if use kernel_sources; then |
| 722 | install_kernel_sources |
Mike Frysinger | b5ebdb5 | 2013-02-10 03:25:44 -0500 | [diff] [blame] | 723 | else |
| 724 | dosym "$(cros-workon_get_build_dir)" "/usr/src/linux" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 725 | fi |
| 726 | } |
| 727 | |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 728 | EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile src_test src_install |