blob: 7f248a175c9d4b7294ce90fdeb766fe2e1ecc0df [file] [log] [blame]
Doug Andersonf291dba2012-01-19 14:26:10 -08001# 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 Jamesd4130ab2013-09-19 11:26:39 -07006# 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.
Olof Johansson2721cbc2014-05-29 18:21:29 -07009inherit binutils-funcs cros-board linux-info toolchain-funcs versionator
Doug Andersonf291dba2012-01-19 14:26:10 -080010
11HOMEPAGE="http://www.chromium.org/"
12LICENSE="GPL-2"
13SLOT="0"
14
15DEPEND="sys-apps/debianutils
Doug Andersonf291dba2012-01-19 14:26:10 -080016 initramfs? ( chromeos-base/chromeos-initramfs )
Vic Yang9aabf9c2013-01-23 20:47:59 +080017 netboot_ramfs? ( chromeos-base/chromeos-initramfs )
Julius Wernerb0247eb2014-02-21 15:48:00 -080018 t124_xusb_fw? ( sys-kernel/xhci-firmware )
Doug Andersonf291dba2012-01-19 14:26:10 -080019"
20
Toshi Kikuchiabbf5d72014-09-02 18:02:16 -070021WIRELESS_VERSIONS=( 3.4 3.8 3.16 )
Paul Stewarted938492013-11-21 10:25:32 -080022WIRELESS_SUFFIXES=( ${WIRELESS_VERSIONS[@]/.} )
23
24IUSE="
25 -device_tree
26 -kernel_sources
27 nfc
28 ${WIRELESS_SUFFIXES[@]/#/-wireless}
29 -wifi_testbed_ap
Albert Chaulke6c32572014-02-12 13:40:53 -080030 -boot_dts_device_tree
Paul Stewartb8a0ea02014-03-24 15:01:59 -070031 -wifi_debug
Gaurav Shah1f6229d2014-05-14 16:42:07 -070032 -nowerror
Bertrand SIMONNET23cfeac2014-05-12 14:24:11 -070033 -ppp
Paul Stewarted938492013-11-21 10:25:32 -080034"
Doug Andersonf291dba2012-01-19 14:26:10 -080035STRIP_MASK="/usr/lib/debug/boot/vmlinux"
Josh Triplett4c035592012-12-05 15:46:46 -080036
Mike Frysinger05d52c72014-04-08 16:26:53 -040037# Ignore files under /lib/modules/ as we like to install vdso objects in there.
38MULTILIB_STRICT_EXEMPT+="|modules"
39
Josh Triplett4c035592012-12-05 15:46:46 -080040# Build out-of-tree and incremental by default, but allow an ebuild inheriting
41# this eclass to explicitly build in-tree.
42: ${CROS_WORKON_OUTOFTREE_BUILD:=1}
43: ${CROS_WORKON_INCREMENTAL_BUILD:=1}
Doug Andersonf291dba2012-01-19 14:26:10 -080044
Dominik Behr2ef00fc2014-10-13 20:32:17 -070045# Config fragments selected by USE flags. _config fragments are mandatory,
46# _config_disable fragments are optional and will be appended to kernel config
47# if use flag is not set.
Doug Anderson010887c2012-02-04 22:42:54 -080048# ...fragments will have the following variables substitutions
49# applied later (needs to be done later since these values
50# aren't reliable when used in a global context like this):
51# %ROOT% => ${ROOT}
Doug Andersonf291dba2012-01-19 14:26:10 -080052
53CONFIG_FRAGMENTS=(
Sameer Nanda92adc932014-10-23 09:35:17 -070054 acpi_ac_off
Doug Andersonf291dba2012-01-19 14:26:10 -080055 blkdevram
Dylan Reidf0666ff2012-07-01 21:42:38 -070056 ca0132
Micah Catlin0dc2b972012-08-01 17:44:24 -070057 cifs
Sonny Rao964708e2013-05-22 18:18:07 -070058 dyndebug
Doug Andersonf291dba2012-01-19 14:26:10 -080059 fbconsole
Ben Chane0654d22012-05-12 00:09:53 -070060 gdmwimax
Ben Chana179ebb2012-10-11 01:02:35 -070061 gobi
Doug Andersonf291dba2012-01-19 14:26:10 -080062 highmem
Vic Yang1541a702013-01-10 17:36:06 +080063 i2cdev
Doug Andersonf291dba2012-01-19 14:26:10 -080064 initramfs
Doug Andersondd0f35f2013-04-15 10:57:54 -070065 kgdb
Ronald G. Minnich6d888d42012-02-16 13:45:58 -080066 kvm
Ben Chan412abea2013-06-26 11:04:17 -070067 mbim
Vic Yang9aabf9c2013-01-23 20:47:59 +080068 netboot_ramfs
Arman Uguray3b75b6c32013-10-04 17:27:11 -070069 nfc
Doug Andersonf291dba2012-01-19 14:26:10 -080070 nfs
Gaurav Shah1f6229d2014-05-14 16:42:07 -070071 nowerror
Doug Andersonf291dba2012-01-19 14:26:10 -080072 pcserial
Bertrand SIMONNET23cfeac2014-05-12 14:24:11 -070073 ppp
Ben Chana179ebb2012-10-11 01:02:35 -070074 qmi
Dave Parker9fb68c92012-05-04 10:34:00 -070075 realtekpstor
Vic Yange0d659e2013-01-22 21:44:41 +080076 samsung_serial
Mike Frysingercd3e6872014-03-04 14:54:38 -050077 socketmon
Doug Andersonf291dba2012-01-19 14:26:10 -080078 systemtap
Julius Wernerb0247eb2014-02-21 15:48:00 -080079 t124_xusb_fw
Vic Yange0d659e2013-01-22 21:44:41 +080080 tpm
Vic Yang7cc29a92012-05-18 14:12:10 +080081 vfat
Ben Chanacc34ec22014-03-05 15:07:36 -080082 vlan
Dominik Behr2ef00fc2014-10-13 20:32:17 -070083 vtconsole
Paul Stewart23ead5f2013-04-24 22:32:17 -070084 wifi_testbed_ap
Paul Stewartb8a0ea02014-03-24 15:01:59 -070085 wifi_debug
Olof Johansson7921a5b2013-05-15 13:36:34 -070086 wireless34
Mike Frysinger34a55122013-02-05 14:01:39 -050087 x32
Doug Andersonf291dba2012-01-19 14:26:10 -080088)
89
Sameer Nanda92adc932014-10-23 09:35:17 -070090acpi_ac_off_desc="Turn off ACPI AC"
91acpi_ac_off_config="
92# CONFIG_ACPI_AC is not set
93"
94
Doug Andersonf291dba2012-01-19 14:26:10 -080095blkdevram_desc="ram block device"
96blkdevram_config="
97CONFIG_BLK_DEV_RAM=y
98CONFIG_BLK_DEV_RAM_COUNT=16
99CONFIG_BLK_DEV_RAM_SIZE=16384
100"
101
Dylan Reidf0666ff2012-07-01 21:42:38 -0700102ca0132_desc="CA0132 ALSA codec"
103ca0132_config="
104CONFIG_SND_HDA_CODEC_CA0132=y
Chih-Chung Chang2306b492012-09-04 19:52:18 +0800105CONFIG_SND_HDA_DSP_LOADER=y
Dylan Reidf0666ff2012-07-01 21:42:38 -0700106"
107
Micah Catlin0dc2b972012-08-01 17:44:24 -0700108cifs_desc="Samba/CIFS Support"
109cifs_config="
110CONFIG_CIFS=m
111"
112
Sonny Rao964708e2013-05-22 18:18:07 -0700113dyndebug_desc="Enable Dynamic Debug"
114dyndebug_config="
115CONFIG_DYNAMIC_DEBUG=y
116"
117
Doug Andersonf291dba2012-01-19 14:26:10 -0800118fbconsole_desc="framebuffer console"
119fbconsole_config="
120CONFIG_FRAMEBUFFER_CONSOLE=y
121"
Dominik Behr2ef00fc2014-10-13 20:32:17 -0700122fbconsole_config_disable="
123CONFIG_FRAMEBUFFER_CONSOLE=n
124"
Doug Andersonf291dba2012-01-19 14:26:10 -0800125
Ben Chane0654d22012-05-12 00:09:53 -0700126gdmwimax_desc="GCT GDM72xx WiMAX support"
127gdmwimax_config="
128CONFIG_WIMAX_GDM72XX=m
Ben Chane0654d22012-05-12 00:09:53 -0700129CONFIG_WIMAX_GDM72XX_USB=y
130CONFIG_WIMAX_GDM72XX_USB_PM=y
131"
132
Ben Chana179ebb2012-10-11 01:02:35 -0700133gobi_desc="Qualcomm Gobi modem driver"
134gobi_config="
135CONFIG_USB_NET_GOBI=m
136"
137
Doug Andersonf291dba2012-01-19 14:26:10 -0800138highmem_desc="highmem"
139highmem_config="
140CONFIG_HIGHMEM64G=y
141"
142
Vic Yang1541a702013-01-10 17:36:06 +0800143i2cdev_desc="I2C device interface"
144i2cdev_config="
145CONFIG_I2C_CHARDEV=y
146"
147
Doug Andersondd0f35f2013-04-15 10:57:54 -0700148kgdb_desc="Enable kgdb"
149kgdb_config="
Doug Andersoncbcd4a42014-04-21 17:07:58 -0700150CONFIG_DEBUG_KERNEL=y
151CONFIG_DEBUG_INFO=y
152CONFIG_FRAME_POINTER=y
Doug Andersondd0f35f2013-04-15 10:57:54 -0700153CONFIG_KGDB=y
154CONFIG_KGDB_KDB=y
Prathmesh Prabhu61427e42014-06-05 18:03:32 -0700155# CONFIG_RANDOMIZE_BASE is not set
156# CONFIG_WATCHDOG is not set
Doug Andersondd0f35f2013-04-15 10:57:54 -0700157"""
158
Arman Uguray3b75b6c32013-10-04 17:27:11 -0700159nfc_desc="Enable NFC support"
160nfc_config="
161CONFIG_NFC=m
162CONFIG_NFC_HCI=m
163CONFIG_NFC_LLCP=y
164CONFIG_NFC_NCI=m
165CONFIG_NFC_PN533=m
166CONFIG_NFC_PN544=m
167CONFIG_NFC_PN544_I2C=m
168CONFIG_NFC_SHDLC=y
169"
170
Vic Yange0d659e2013-01-22 21:44:41 +0800171tpm_desc="TPM support"
172tpm_config="
173CONFIG_TCG_TPM=y
174CONFIG_TCG_TIS=y
175"
176
Vic Yang9aabf9c2013-01-23 20:47:59 +0800177initramfs_desc="Initramfs for factory install shim and recovery image"
178initramfs_config='
179CONFIG_INITRAMFS_SOURCE="%ROOT%/var/lib/misc/initramfs.cpio.xz"
Anush Elangovanf9b66d92012-12-20 12:16:15 -0800180CONFIG_INITRAMFS_COMPRESSION_XZ=y
Vic Yang9aabf9c2013-01-23 20:47:59 +0800181'
182
183netboot_ramfs_desc="Network boot install initramfs"
184netboot_ramfs_config='
185CONFIG_INITRAMFS_SOURCE="%ROOT%/var/lib/misc/netboot_ramfs.cpio.xz"
186CONFIG_INITRAMFS_COMPRESSION_XZ=y
187'
Vic Yang7cc29a92012-05-18 14:12:10 +0800188
189vfat_desc="vfat"
190vfat_config="
Doug Andersonf291dba2012-01-19 14:26:10 -0800191CONFIG_NLS_CODEPAGE_437=y
192CONFIG_NLS_ISO8859_1=y
193CONFIG_FAT_FS=y
194CONFIG_VFAT_FS=y
195"
196
Ronald G. Minnich6d888d42012-02-16 13:45:58 -0800197kvm_desc="KVM"
198kvm_config="
199CONFIG_HAVE_KVM=y
200CONFIG_HAVE_KVM_IRQCHIP=y
201CONFIG_HAVE_KVM_EVENTFD=y
202CONFIG_KVM_APIC_ARCHITECTURE=y
203CONFIG_KVM_MMIO=y
204CONFIG_KVM_ASYNC_PF=y
205CONFIG_KVM=m
206CONFIG_KVM_INTEL=m
207# CONFIG_KVM_AMD is not set
208# CONFIG_KVM_MMU_AUDIT is not set
209CONFIG_VIRTIO=m
210CONFIG_VIRTIO_BLK=m
211CONFIG_VIRTIO_NET=m
212CONFIG_VIRTIO_CONSOLE=m
213CONFIG_VIRTIO_RING=m
214CONFIG_VIRTIO_PCI=m
215"
216
Ben Chan412abea2013-06-26 11:04:17 -0700217# TODO(benchan): Remove the 'mbim' use flag and unconditionally enable the
218# CDC MBIM driver once Chromium OS fully supports MBIM.
219mbim_desc="CDC MBIM driver"
220mbim_config="
221CONFIG_USB_NET_CDC_MBIM=m
222"
223
Doug Andersonf291dba2012-01-19 14:26:10 -0800224nfs_desc="NFS"
225nfs_config="
226CONFIG_USB_NET_AX8817X=y
227CONFIG_DNOTIFY=y
228CONFIG_DNS_RESOLVER=y
229CONFIG_LOCKD=y
230CONFIG_LOCKD_V4=y
231CONFIG_NETWORK_FILESYSTEMS=y
232CONFIG_NFSD=m
233CONFIG_NFSD_V3=y
234CONFIG_NFSD_V4=y
235CONFIG_NFS_COMMON=y
236CONFIG_NFS_FS=y
237CONFIG_NFS_USE_KERNEL_DNS=y
238CONFIG_NFS_V3=y
239CONFIG_NFS_V4=y
240CONFIG_ROOT_NFS=y
241CONFIG_RPCSEC_GSS_KRB5=y
242CONFIG_SUNRPC=y
243CONFIG_SUNRPC_GSS=y
244CONFIG_USB_USBNET=y
245CONFIG_IP_PNP=y
246CONFIG_IP_PNP_DHCP=y
247"
248
249pcserial_desc="PC serial"
250pcserial_config="
251CONFIG_SERIAL_8250=y
252CONFIG_SERIAL_8250_CONSOLE=y
253CONFIG_SERIAL_8250_PCI=y
254CONFIG_PARPORT=y
255CONFIG_PARPORT_PC=y
256CONFIG_PARPORT_SERIAL=y
257"
258
Bertrand SIMONNET23cfeac2014-05-12 14:24:11 -0700259ppp_desc="PPPoE and ppp support"
260ppp_config="
261CONFIG_PPPOE=m
262CONFIG_PPP=m
263CONFIG_PPP_BSDCOMP=m
264CONFIG_PPP_DEFLATE=m
265CONFIG_PPP_MPPE=m
266CONFIG_PPP_SYNC_TTY=m
267"
268
Ben Chana179ebb2012-10-11 01:02:35 -0700269qmi_desc="QMI WWAN driver"
270qmi_config="
271CONFIG_USB_NET_QMI_WWAN=m
272"
273
Mike Frysingercd3e6872014-03-04 14:54:38 -0500274realtekpstor_desc="Realtek PCI card reader"
275realtekpstor_config="
276CONFIG_RTS_PSTOR=m
277"
278
Olof Johansson08268b0c2012-08-01 00:12:00 -0700279samsung_serial_desc="Samsung serialport"
280samsung_serial_config="
281CONFIG_SERIAL_SAMSUNG=y
282CONFIG_SERIAL_SAMSUNG_CONSOLE=y
283"
284
Mike Frysingercd3e6872014-03-04 14:54:38 -0500285socketmon_desc="INET socket monitoring interface (for iproute2 ss)"
286socketmon_config="
287CONFIG_INET_DIAG=y
288CONFIG_INET_TCP_DIAG=y
289CONFIG_INET_UDP_DIAG=y
Dave Parker9fb68c92012-05-04 10:34:00 -0700290"
291
Doug Andersonf291dba2012-01-19 14:26:10 -0800292systemtap_desc="systemtap support"
293systemtap_config="
294CONFIG_KPROBES=y
295CONFIG_DEBUG_INFO=y
296"
297
Julius Wernerb0247eb2014-02-21 15:48:00 -0800298t124_xusb_fw_desc="Embed Tegra 5 XHCI controller firmware in kernel binary"
299t124_xusb_fw_config="
Andrew Chew112ca9582014-09-24 18:30:43 -0700300CONFIG_EXTRA_FIRMWARE=\"nvidia/tegra124/xusb.bin\"
Julius Wernerb0247eb2014-02-21 15:48:00 -0800301CONFIG_EXTRA_FIRMWARE_DIR=\"%ROOT%/lib/firmware\"
302"
303
Ben Chanacc34ec22014-03-05 15:07:36 -0800304vlan_desc="802.1Q VLAN"
305vlan_config="
306CONFIG_VLAN_8021Q=m
307"
308
Paul Stewart23ead5f2013-04-24 22:32:17 -0700309wifi_testbed_ap_desc="Defer ath9k EEPROM regulatory"
310wifi_testbed_ap_warning="
311Don't use the wifi_testbed_ap flag unless you know what you are doing!
312An image built with this flag set must never be run outside a
313sealed RF chamber!
314"
315wifi_testbed_ap_config="
316CONFIG_ATH_DEFER_EEPROM_REGULATORY=y
317"
318
Paul Stewartb8a0ea02014-03-24 15:01:59 -0700319wifi_debug_desc="Enable extra debug flags for WiFi"
320wifi_debug_config="
321CONFIG_IWL7000_XVT=m
322"
323
Mike Frysinger34a55122013-02-05 14:01:39 -0500324x32_desc="x32 ABI support"
325x32_config="
326CONFIG_X86_X32=y
327"
328
Olof Johansson7921a5b2013-05-15 13:36:34 -0700329wireless34_desc="Wireless 3.4 stack"
330wireless34_config="
331CONFIG_ATH9K_BTCOEX=m
332CONFIG_ATH9K_BTCOEX_COMMON=m
333CONFIG_ATH9K_BTCOEX_HW=m
334"
335
Dominik Behr2ef00fc2014-10-13 20:32:17 -0700336vtconsole_desc="VT console"
337vtconsole_config="
338CONFIG_VT=y
339CONFIG_VT_CONSOLE=y
340"
341vtconsole_config_disable="
342CONFIG_VT=n
343CONFIG_VT_CONSOLE=n
344"
345
Gaurav Shah1f6229d2014-05-14 16:42:07 -0700346nowerror_desc="Don't build with -Werror (warnings aren't fatal)."
347nowerror_config="
348CONFIG_ERROR_ON_WARNING=n
349"
350
Doug Andersonf291dba2012-01-19 14:26:10 -0800351# Add all config fragments as off by default
352IUSE="${IUSE} ${CONFIG_FRAGMENTS[@]}"
Vic Yang9aabf9c2013-01-23 20:47:59 +0800353REQUIRED_USE="
354 initramfs? ( !netboot_ramfs )
355 netboot_ramfs? ( !initramfs )
356 initramfs? ( i2cdev tpm )
357 netboot_ramfs? ( i2cdev tpm )
358"
Doug Andersonf291dba2012-01-19 14:26:10 -0800359
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700360# If an overlay has eclass overrides, but doesn't actually override this
361# eclass, we'll have ECLASSDIR pointing to the active overlay's
362# eclass/ dir, but this eclass is still in the main chromiumos tree. So
363# add a check to locate the cros-kernel/ regardless of what's going on.
364ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*}
365defconfig_dir() {
J. Richard Barnette9fb57c42013-09-09 18:02:49 -0700366 local d="${ECLASSDIR}/cros-kernel"
367 if [[ ! -d ${d} ]] ; then
368 d="${ECLASSDIR_LOCAL}/cros-kernel"
369 fi
370 echo "${d}"
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700371}
372
Josh Triplett6df77a72013-04-26 17:25:37 -0700373# @FUNCTION: kernelrelease
Mike Frysinger330c0232013-01-09 17:47:04 -0500374# @DESCRIPTION:
375# Returns the current compiled kernel version.
376# Note: Only valid after src_configure has finished running.
Josh Triplett6df77a72013-04-26 17:25:37 -0700377kernelrelease() {
378 kmake -s --no-print-directory kernelrelease
Mike Frysinger330c0232013-01-09 17:47:04 -0500379}
380
Doug Andersonf291dba2012-01-19 14:26:10 -0800381# @FUNCTION: install_kernel_sources
382# @DESCRIPTION:
383# Installs the kernel sources into ${D}/usr/src/${P} and fixes symlinks.
384# The package must have already installed a directory under ${D}/lib/modules.
385install_kernel_sources() {
Josh Triplett6df77a72013-04-26 17:25:37 -0700386 local version=$(kernelrelease)
Doug Andersonf291dba2012-01-19 14:26:10 -0800387 local dest_modules_dir=lib/modules/${version}
388 local dest_source_dir=usr/src/${P}
389 local dest_build_dir=${dest_source_dir}/build
390
391 # Fix symlinks in lib/modules
392 ln -sfvT "../../../${dest_build_dir}" \
393 "${D}/${dest_modules_dir}/build" || die
394 ln -sfvT "../../../${dest_source_dir}" \
395 "${D}/${dest_modules_dir}/source" || die
396
397 einfo "Installing kernel source tree"
398 dodir "${dest_source_dir}"
399 local f
400 for f in "${S}"/*; do
401 [[ "$f" == "${S}/build" ]] && continue
402 cp -pPR "${f}" "${D}/${dest_source_dir}" ||
403 die "Failed to copy kernel source tree"
404 done
405
406 dosym "${P}" "/usr/src/linux"
407
408 einfo "Installing kernel build tree"
409 dodir "${dest_build_dir}"
Mike Frysinger833d5f72012-08-07 18:11:59 -0400410 cp -pPR "$(cros-workon_get_build_dir)"/{.config,.version,Makefile,Module.symvers,include} \
Doug Andersonf291dba2012-01-19 14:26:10 -0800411 "${D}/${dest_build_dir}" || die
412
413 # Modify Makefile to use the ROOT environment variable if defined.
414 # This path needs to be absolute so that the build directory will
415 # still work if copied elsewhere.
416 sed -i -e "s@${S}@\$(ROOT)/${dest_source_dir}@" \
417 "${D}/${dest_build_dir}/Makefile" || die
418}
419
Doug Andersonf291dba2012-01-19 14:26:10 -0800420get_build_cfg() {
Mike Frysinger833d5f72012-08-07 18:11:59 -0400421 echo "$(cros-workon_get_build_dir)/.config"
Doug Andersonf291dba2012-01-19 14:26:10 -0800422}
423
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700424get_build_arch() {
425 if [ "${ARCH}" = "arm" ] ; then
426 case "${CHROMEOS_KERNEL_SPLITCONFIG}" in
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700427 *exynos*)
428 echo "exynos5"
429 ;;
Doug Andersone2c3d032014-07-01 15:29:49 -0700430 *rockchip*)
431 echo "rockchip"
432 ;;
433 *tegra*)
434 echo "tegra"
435 ;;
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700436 *)
437 echo "arm"
438 ;;
439 esac
Stephen Barber4deac522014-10-22 17:11:18 -0700440 elif [ "${ARCH}" = "x86" ] ; then
441 case "${CHROMEOS_KERNEL_SPLITCONFIG}" in
442 *i386*)
443 echo "i386"
444 ;;
445 *x86_64*)
446 echo "x86_64"
447 ;;
448 *)
449 echo "x86"
450 ;;
451 esac
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700452 else
Mike Frysingerdde5f6a2013-09-25 22:08:25 -0400453 tc-arch-kernel
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700454 fi
455}
456
Chris Masone6e9b8212013-01-14 11:03:02 -0800457# @FUNCTION: cros_chkconfig_present
458# @USAGE: <option to check config for>
459# @DESCRIPTION:
460# Returns success of the provided option is present in the build config.
461cros_chkconfig_present() {
462 local config=$1
463 grep -q "^CONFIG_$1=[ym]$" "$(get_build_cfg)"
464}
465
Mike Frysinger3f4eaee2012-07-24 17:47:28 -0400466cros-kernel2_pkg_setup() {
Simon Que715e54f32012-12-20 15:53:13 -0800467 # This is needed for running src_test(). The kernel code will need to
468 # be rebuilt with `make check`. If incremental build were enabled,
469 # `make check` would have nothing left to build.
Simon Que6324b6f2013-02-01 14:56:05 -0800470 use test && export CROS_WORKON_INCREMENTAL_BUILD=0
Mike Frysinger833d5f72012-08-07 18:11:59 -0400471 cros-workon_pkg_setup
Mike Frysingerb5ebdb52013-02-10 03:25:44 -0500472 linux-info_pkg_setup
Mike Frysinger3f4eaee2012-07-24 17:47:28 -0400473}
474
Olof Johanssonb62cf892012-04-27 14:50:24 -0700475# @FUNCTION: emit_its_script
Doug Andersonf2bb2882012-12-06 15:56:21 -0800476# @USAGE: <output file> <boot_dir> <dtb_dir> <device trees>
Olof Johanssonb62cf892012-04-27 14:50:24 -0700477# @DESCRIPTION:
478# Emits the its script used to build the u-boot fitImage kernel binary
479# that contains the kernel as well as device trees used when booting
480# it.
481
482emit_its_script() {
Olof Johansson765508f2014-08-07 09:57:53 -0700483 local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)}
484 local image_name="zImage"
Olof Johanssonb62cf892012-04-27 14:50:24 -0700485 local iter=1
486 local its_out=${1}
487 shift
Olof Johansson765508f2014-08-07 09:57:53 -0700488 local kernel_path=${1}
Doug Andersonf2bb2882012-12-06 15:56:21 -0800489 shift
490 local dtb_dir=${1}
491 shift
Olof Johansson765508f2014-08-07 09:57:53 -0700492
493 if [ "${kernel_arch}" = "arm64" ] ; then
494 image_name="Image"
495 fi
496
Olof Johanssonb62cf892012-04-27 14:50:24 -0700497 cat > "${its_out}" <<-EOF || die
498 /dts-v1/;
499
500 / {
501 description = "Chrome OS kernel image with one or more FDT blobs";
502 #address-cells = <1>;
503
504 images {
505 kernel@1 {
Olof Johansson765508f2014-08-07 09:57:53 -0700506 data = /incbin/("${kernel_path}/${image_name}");
Doug Anderson21b44202013-06-24 14:31:18 -0700507 type = "kernel_noload";
Olof Johansson765508f2014-08-07 09:57:53 -0700508 arch = "${kernel_arch}";
Olof Johanssonb62cf892012-04-27 14:50:24 -0700509 os = "linux";
510 compression = "none";
Doug Anderson21b44202013-06-24 14:31:18 -0700511 load = <0>;
512 entry = <0>;
Olof Johanssonb62cf892012-04-27 14:50:24 -0700513 };
514 EOF
515
516 local dtb
517 for dtb in "$@" ; do
518 cat >> "${its_out}" <<-EOF || die
519 fdt@${iter} {
520 description = "$(basename ${dtb})";
Doug Andersonf2bb2882012-12-06 15:56:21 -0800521 data = /incbin/("${dtb_dir}/${dtb}");
Olof Johanssonb62cf892012-04-27 14:50:24 -0700522 type = "flat_dt";
Olof Johansson765508f2014-08-07 09:57:53 -0700523 arch = "${kernel_arch}";
Olof Johanssonb62cf892012-04-27 14:50:24 -0700524 compression = "none";
525 hash@1 {
526 algo = "sha1";
527 };
528 };
529 EOF
530 ((++iter))
531 done
532
Stephen Barberf3c839f2014-07-25 23:04:48 -0700533 cat <<-EOF >>"${its_out}"
Olof Johanssonb62cf892012-04-27 14:50:24 -0700534 };
535 configurations {
536 default = "conf@1";
537 EOF
538
539 local i
540 for i in $(seq 1 $((iter-1))) ; do
541 cat >> "${its_out}" <<-EOF || die
542 conf@${i} {
543 kernel = "kernel@1";
544 fdt = "fdt@${i}";
545 };
546 EOF
547 done
548
549 echo " };" >> "${its_out}"
550 echo "};" >> "${its_out}"
551}
552
Doug Andersonf291dba2012-01-19 14:26:10 -0800553kmake() {
Paul Stewarted938492013-11-21 10:25:32 -0800554 local wifi_version
555 local v
556 for v in ${WIRELESS_VERSIONS[@]}; do
557 if use wireless${v/.} ; then
558 [ -n "${wifi_version}" ] &&
559 die "Wireless ${v} AND ${wifi_version} both set"
560 wifi_version=${v}
561 set -- "$@" WIFIVERSION="-${v}"
562 fi
563 done
Olof Johanssonc0f8a5d2013-04-11 18:36:40 -0700564
Olof Johansson8ae933a2014-02-10 14:39:38 -0800565 # Allow override of kernel arch.
566 local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)}
Kees Cookaaff8412013-07-12 10:46:50 -0700567
Olof Johansson8ae933a2014-02-10 14:39:38 -0800568 # Support 64bit kernels w/32bit userlands.
569 local cross=${CHOST}
570 case ${ARCH}:${kernel_arch} in
571 x86:x86_64)
572 cross="x86_64-cros-linux-gnu"
573 ;;
574 arm:arm64)
575 cross="aarch64-cros-linux-gnu"
576 ;;
577 esac
Kees Cookaaff8412013-07-12 10:46:50 -0700578
Olof Johansson8ae933a2014-02-10 14:39:38 -0800579 CHOST=${cross} tc-export CC CXX LD STRIP OBJCOPY
580 local binutils_path=$(LD=${cross}-ld get_binutils_path_ld)
Doug Andersonf291dba2012-01-19 14:26:10 -0800581
Kees Cookaaff8412013-07-12 10:46:50 -0700582 set -- \
583 LD="${binutils_path}/ld $(usex x32 '-m elf_x86_64' '')" \
584 CC="${CC} -B${binutils_path}" \
585 CXX="${CXX} -B${binutils_path}" \
586 "$@"
587
Mike Frysingera8ef3cd2012-11-01 18:42:18 -0400588 cw_emake \
Doug Andersonf291dba2012-01-19 14:26:10 -0800589 ARCH=${kernel_arch} \
590 LDFLAGS="$(raw-ldflags)" \
Olof Johansson8ae933a2014-02-10 14:39:38 -0800591 CROSS_COMPILE="${cross}-" \
Mike Frysinger833d5f72012-08-07 18:11:59 -0400592 O="$(cros-workon_get_build_dir)" \
Doug Andersonf291dba2012-01-19 14:26:10 -0800593 "$@"
594}
595
Josh Triplett4c035592012-12-05 15:46:46 -0800596cros-kernel2_src_prepare() {
597 cros-workon_src_prepare
598}
599
Doug Andersonf291dba2012-01-19 14:26:10 -0800600cros-kernel2_src_configure() {
Doug Andersonf291dba2012-01-19 14:26:10 -0800601 # Use a single or split kernel config as specified in the board or variant
602 # make.conf overlay. Default to the arch specific split config if an
603 # overlay or variant does not set either CHROMEOS_KERNEL_CONFIG or
604 # CHROMEOS_KERNEL_SPLITCONFIG. CHROMEOS_KERNEL_CONFIG is set relative
605 # to the root of the kernel source tree.
606 local config
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700607 local cfgarch="$(get_build_arch)"
608
Doug Andersonf291dba2012-01-19 14:26:10 -0800609 if [ -n "${CHROMEOS_KERNEL_CONFIG}" ]; then
Chris Masonef888c382013-03-19 14:19:41 -0700610 case ${CHROMEOS_KERNEL_CONFIG} in
611 /*)
612 config="${CHROMEOS_KERNEL_CONFIG}"
613 ;;
614 *)
615 config="${S}/${CHROMEOS_KERNEL_CONFIG}"
616 ;;
617 esac
Doug Andersonf291dba2012-01-19 14:26:10 -0800618 else
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700619 config=${CHROMEOS_KERNEL_SPLITCONFIG:-"chromiumos-${cfgarch}"}
Doug Andersonf291dba2012-01-19 14:26:10 -0800620 fi
621
622 elog "Using kernel config: ${config}"
623
Mike Frysinger3f4eaee2012-07-24 17:47:28 -0400624 # Keep a handle on the old .config in case it hasn't changed. This way
625 # we can keep the old timestamp which will avoid regenerating stuff that
626 # hasn't actually changed.
627 local temp_config="${T}/old-kernel-config"
628 if [[ -e $(get_build_cfg) ]] ; then
629 cp -a "$(get_build_cfg)" "${temp_config}"
630 else
631 rm -f "${temp_config}"
632 fi
633
Doug Andersonf291dba2012-01-19 14:26:10 -0800634 if [ -n "${CHROMEOS_KERNEL_CONFIG}" ]; then
635 cp -f "${config}" "$(get_build_cfg)" || die
636 else
Olof Johanssoncd9c9fe2012-06-27 20:58:10 -0700637 if [ -e chromeos/scripts/prepareconfig ] ; then
638 chromeos/scripts/prepareconfig ${config} \
639 "$(get_build_cfg)" || die
640 else
641 config="$(defconfig_dir)/${cfgarch}_defconfig"
642 ewarn "Can't prepareconfig, falling back to default " \
643 "${config}"
644 cp "${config}" "$(get_build_cfg)" || die
645 fi
Doug Andersonf291dba2012-01-19 14:26:10 -0800646 fi
647
648 local fragment
649 for fragment in ${CONFIG_FRAGMENTS[@]}; do
Dominik Behr2ef00fc2014-10-13 20:32:17 -0700650 local config="${fragment}_config"
651 local status
652
653 if [[ ${!config+set} != "set" ]]; then
654 die "'${fragment}' listed in CONFIG_FRAGMENTS, but ${config} is not set up"
655 fi
656
657 if use ${fragment}; then
658 status="enabling"
659 else
660 config="${fragment}_config_disable"
661 status="disabling"
662 if [[ -z "${!config}" ]]; then
663 continue
664 fi
665 fi
Doug Andersonf291dba2012-01-19 14:26:10 -0800666
667 local msg="${fragment}_desc"
Dominik Behr2ef00fc2014-10-13 20:32:17 -0700668 elog " - ${status} ${!msg} config"
Paul Stewart23ead5f2013-04-24 22:32:17 -0700669 local warning="${fragment}_warning"
670 local warning_msg="${!warning}"
671 if [[ -n "${warning_msg}" ]] ; then
672 ewarn "${warning_msg}"
673 fi
Doug Anderson010887c2012-02-04 22:42:54 -0800674
675 echo "${!config}" | \
676 sed -e "s|%ROOT%|${ROOT}|g" \
677 >> "$(get_build_cfg)" || die
Doug Andersonf291dba2012-01-19 14:26:10 -0800678 done
679
680 # Use default for any options not explitly set in splitconfig
Olof Johansson998533f2014-02-11 12:47:37 -0800681 # Note: oldnoconfig is a misleading name -- it picks the default
682 # value for new options, not 'n'.
683 kmake oldnoconfig
Mike Frysinger3f4eaee2012-07-24 17:47:28 -0400684
685 # Restore the old config if it is unchanged.
686 if cmp -s "$(get_build_cfg)" "${temp_config}" ; then
687 touch -r "${temp_config}" "$(get_build_cfg)"
688 fi
Doug Andersonf291dba2012-01-19 14:26:10 -0800689}
690
Doug Andersonf2bb2882012-12-06 15:56:21 -0800691# @FUNCTION: get_dtb_name
692# @USAGE: <dtb_dir>
693# @DESCRIPTION:
694# Get the name(s) of the device tree binary file(s) to include.
695
Olof Johanssonb62cf892012-04-27 14:50:24 -0700696get_dtb_name() {
Doug Andersonf2bb2882012-12-06 15:56:21 -0800697 local dtb_dir=${1}
David Jamesd4130ab2013-09-19 11:26:39 -0700698 local f
699 for f in ${dtb_dir}/*.dtb ; do
700 basename ${f}
701 done
Doug Andersonf291dba2012-01-19 14:26:10 -0800702}
703
704cros-kernel2_src_compile() {
Chris Masone6e9b8212013-01-14 11:03:02 -0800705 local build_targets=() # use make default target
David Rileyb1793e42014-06-12 17:45:22 -0700706 local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)}
707 case ${kernel_arch} in
Ben Chanc5ed8652014-06-24 18:33:58 -0700708 arm)
David Rileyb1793e42014-06-12 17:45:22 -0700709 build_targets=(
710 $(usex device_tree 'zImage dtbs' uImage)
711 $(usex boot_dts_device_tree dtbs '')
712 $(cros_chkconfig_present MODULES && echo "modules")
713 )
714 ;;
Ben Chanc5ed8652014-06-24 18:33:58 -0700715 mips)
716 build_targets=(
717 vmlinuz
718 $(cros_chkconfig_present MODULES && echo "modules")
719 )
720 ;;
David Rileyb1793e42014-06-12 17:45:22 -0700721 esac
Doug Andersonf291dba2012-01-19 14:26:10 -0800722
Simon Que715e54f32012-12-20 15:53:13 -0800723 local src_dir="$(cros-workon_get_build_dir)/source"
Simon Que715e54f32012-12-20 15:53:13 -0800724 SMATCH_ERROR_FILE="${src_dir}/chromeos/check/smatch_errors.log"
725
Doug Anderson1d421452014-01-22 09:10:28 -0800726 # If a .dts file is deleted from the source code it won't disappear
727 # from the output in the next incremental build. Nuke all dtbs so we
728 # don't include stale files. We use 'find' to handle old and new
729 # locations (see comments in install below).
730 find "$(cros-workon_get_build_dir)/arch" -name '*.dtb' -delete
731
Simon Que6324b6f2013-02-01 14:56:05 -0800732 if use test && [[ -e "${SMATCH_ERROR_FILE}" ]]; then
Simon Que715e54f32012-12-20 15:53:13 -0800733 local make_check_cmd="smatch -p=kernel"
734 local test_options=(
735 CHECK="${make_check_cmd}"
736 C=1
737 )
738 SMATCH_LOG_FILE="$(cros-workon_get_build_dir)/make.log"
739
740 # The path names in the log file are build-dependent. Strip out
741 # the part of the path before "kernel/files" and retains what
742 # comes after it: the file, line number, and error message.
Chris Masone6e9b8212013-01-14 11:03:02 -0800743 kmake -k ${build_targets[@]} "${test_options[@]}" |& \
Simon Que715e54f32012-12-20 15:53:13 -0800744 tee "${SMATCH_LOG_FILE}"
745 else
Chris Masone6e9b8212013-01-14 11:03:02 -0800746 kmake -k ${build_targets[@]}
Simon Que715e54f32012-12-20 15:53:13 -0800747 fi
Doug Andersonf291dba2012-01-19 14:26:10 -0800748}
749
Simon Que715e54f32012-12-20 15:53:13 -0800750cros-kernel2_src_test() {
Simon Que715e54f32012-12-20 15:53:13 -0800751 [[ -e ${SMATCH_ERROR_FILE} ]] || \
752 die "smatch whitelist file ${SMATCH_ERROR_FILE} not found!"
753 [[ -e ${SMATCH_LOG_FILE} ]] || \
754 die "Log file from src_compile() ${SMATCH_LOG_FILE} not found!"
755
Paul Taysom98a54362013-06-12 16:30:25 -0700756 local prefix="$(realpath "${S}")/"
757 grep -w error: "${SMATCH_LOG_FILE}" | grep -o "${prefix}.*" \
758 | sed s:"${prefix}"::g > "${SMATCH_LOG_FILE}.errors"
Simon Que715e54f32012-12-20 15:53:13 -0800759 local num_errors=$(wc -l < "${SMATCH_LOG_FILE}.errors")
760 local num_warnings=$(egrep -wc "warn:|warning:" "${SMATCH_LOG_FILE}")
761 einfo "smatch found ${num_errors} errors and ${num_warnings} warnings."
762
763 # Create a version of the error database that doesn't have line numbers,
764 # since line numbers will shift as code is added or removed.
765 local build_dir="$(cros-workon_get_build_dir)"
766 local no_line_numbers_file="${build_dir}/no_line_numbers.log"
Chih-Chung Changf28e76e2013-04-08 11:53:29 +0800767 sed -r -e "s/(:[0-9]+){1,2}//" \
768 -e "s/\(see line [0-9]+\)//" \
769 "${SMATCH_ERROR_FILE}" > "${no_line_numbers_file}"
Simon Que715e54f32012-12-20 15:53:13 -0800770
771 # For every smatch error that came up during the build, check if it is
772 # in the error database file.
773 local num_unknown_errors=0
774 local line=""
775 while read line; do
Simon Quefc5fc9d2013-01-28 15:19:38 -0800776 local no_line_num=$(echo "${line}" | \
Chih-Chung Changf28e76e2013-04-08 11:53:29 +0800777 sed -r -e "s/(:[0-9]+){1,2}//" \
778 -e "s/\(see line [0-9]+\)//")
Simon Que715e54f32012-12-20 15:53:13 -0800779 if ! fgrep -q "${no_line_num}" "${no_line_numbers_file}"; then
780 eerror "Non-whitelisted error found: \"${line}\""
781 : $(( ++num_unknown_errors ))
782 fi
783 done < "${SMATCH_LOG_FILE}.errors"
784
785 [[ ${num_unknown_errors} -eq 0 ]] || \
786 die "smatch found ${num_unknown_errors} unknown errors."
787}
788
Doug Andersonf291dba2012-01-19 14:26:10 -0800789cros-kernel2_src_install() {
Doug Andersone3a867e2013-06-24 16:26:43 -0700790 local build_targets=(
791 install
792 firmware_install
793 $(cros_chkconfig_present MODULES && echo "modules_install")
794 )
795
Doug Andersonf291dba2012-01-19 14:26:10 -0800796 dodir /boot
Doug Andersone3a867e2013-06-24 16:26:43 -0700797 kmake INSTALL_PATH="${D}/boot" INSTALL_MOD_PATH="${D}" \
798 "${build_targets[@]}"
Doug Andersonf291dba2012-01-19 14:26:10 -0800799
Josh Triplett6df77a72013-04-26 17:25:37 -0700800 local version=$(kernelrelease)
Ben Chanc5ed8652014-06-24 18:33:58 -0700801 local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)}
802 local kernel_bin="${D}/boot/vmlinuz-${version}"
803 if use arm; then
Olof Johansson8f4316a2014-02-10 16:31:59 -0800804 local boot_dir="$(cros-workon_get_build_dir)/arch/${kernel_arch}/boot"
Doug Andersonf291dba2012-01-19 14:26:10 -0800805 local zimage_bin="${D}/boot/zImage-${version}"
David Rileyb1793e42014-06-12 17:45:22 -0700806 local image_bin="${D}/boot/Image-${version}"
Doug Andersonf2bb2882012-12-06 15:56:21 -0800807 local dtb_dir="${boot_dir}"
808
809 # Newer kernels (after linux-next 12/3/12) put dtbs in the dts
810 # dir. Use that if we we find no dtbs directly in boot_dir.
811 # Note that we try boot_dir first since the newer kernel will
812 # actually rm ${boot_dir}/*.dtb so we'll have no stale files.
813 if ! ls "${dtb_dir}"/*.dtb &> /dev/null; then
814 dtb_dir="${boot_dir}/dts"
815 fi
816
Doug Andersonf291dba2012-01-19 14:26:10 -0800817 if use device_tree; then
Mike Frysinger833d5f72012-08-07 18:11:59 -0400818 local its_script="$(cros-workon_get_build_dir)/its_script"
Doug Andersonf2bb2882012-12-06 15:56:21 -0800819 emit_its_script "${its_script}" "${boot_dir}" \
820 "${dtb_dir}" $(get_dtb_name "${dtb_dir}")
Isaac Simha4a2c1b52013-07-05 16:15:26 -0700821 mkimage -D "-I dts -O dtb -p 1024" -f "${its_script}" "${kernel_bin}" || die
David Rileyb1793e42014-06-12 17:45:22 -0700822 elif [[ "${kernel_arch}" != "arm64" ]]; then
Gaurav Shah3ea7e452014-05-21 19:19:55 -0700823 cp "${boot_dir}/uImage" "${kernel_bin}" || die
Albert Chaulke6c32572014-02-12 13:40:53 -0800824 if use boot_dts_device_tree; then
825 # For boards where the device tree .dtb file is stored
J. Richard Barnette9fb57c42013-09-09 18:02:49 -0700826 # under /boot/dts, loaded into memory, and then
Albert Chaulke6c32572014-02-12 13:40:53 -0800827 # passed on the 'bootm' command line, make sure they're
828 # all installed.
J. Richard Barnette9fb57c42013-09-09 18:02:49 -0700829 #
830 # We install more .dtb files than we need, but it's
831 # less work than a hard-coded list that gets out of
832 # date.
833 #
Albert Chaulke6c32572014-02-12 13:40:53 -0800834 # TODO(jrbarnette): Really, this should use a
J. Richard Barnette9fb57c42013-09-09 18:02:49 -0700835 # FIT image, same as other boards.
836 insinto /boot/dts
837 doins "${dtb_dir}"/*.dtb
838 fi
Doug Andersonf291dba2012-01-19 14:26:10 -0800839 fi
David Rileyb1793e42014-06-12 17:45:22 -0700840 case ${kernel_arch} in
841 arm)
842 cp -a "${boot_dir}/zImage" "${zimage_bin}" || die
843 ;;
844 arm64)
845 cp -a "${boot_dir}/Image" "${image_bin}" || die
846 ;;
847 esac
Ben Chanc5ed8652014-06-24 18:33:58 -0700848 fi
849 if use arm || use mips; then
Doug Andersonf291dba2012-01-19 14:26:10 -0800850 # TODO(vbendeb): remove the below .uimg link creation code
851 # after the build scripts have been modified to use the base
852 # image name.
853 cd $(dirname "${kernel_bin}")
854 ln -sf $(basename "${kernel_bin}") vmlinux.uimg || die
Ben Chanc5ed8652014-06-24 18:33:58 -0700855 if use arm; then
856 ln -sf $(basename "${zimage_bin}") zImage || die
857 fi
Doug Andersonf291dba2012-01-19 14:26:10 -0800858 fi
859 if [ ! -e "${D}/boot/vmlinuz" ]; then
860 ln -sf "vmlinuz-${version}" "${D}/boot/vmlinuz" || die
861 fi
862
Vic Yang40fff212012-05-14 10:43:11 +0800863 # Check the size of kernel image and issue warning when image size is near
Vic Yang9aabf9c2013-01-23 20:47:59 +0800864 # the limit. For factory install initramfs, we don't care about kernel
865 # size limit as the image is downloaded over network.
Vic Yang40fff212012-05-14 10:43:11 +0800866 local kernel_image_size=$(stat -c '%s' -L "${D}"/boot/vmlinuz)
867 einfo "Kernel image size is ${kernel_image_size} bytes."
Vic Yang9aabf9c2013-01-23 20:47:59 +0800868 if use netboot_ramfs; then
869 # No need to check kernel image size.
870 true
Olof Johansson2721cbc2014-05-29 18:21:29 -0700871 else
872 if version_is_at_least 3.14 ; then
873 kern_max=16
874 kern_warn=12
875 else
876 kern_max=8
877 kern_warn=7
878 fi
879
880 if [[ ${kernel_image_size} -gt $((kern_max * 1024 * 1024)) ]]; then
881 die "Kernel image is larger than ${kern_max} MB."
882 elif [[ ${kernel_image_size} -gt $((kern_warn * 1024 * 1024)) ]]; then
883 ewarn "Kernel image is larger than ${kern_warn} MB. Limit is ${kern_max} MB."
884 fi
Vic Yang40fff212012-05-14 10:43:11 +0800885 fi
886
Doug Andersonf291dba2012-01-19 14:26:10 -0800887 # Install uncompressed kernel for debugging purposes.
888 insinto /usr/lib/debug/boot
Mike Frysinger833d5f72012-08-07 18:11:59 -0400889 doins "$(cros-workon_get_build_dir)/vmlinux"
Doug Andersonf291dba2012-01-19 14:26:10 -0800890
Mike Frysingerdde5f6a2013-09-25 22:08:25 -0400891 # Also install the vdso shared ELFs for crash reporting.
Mike Frysinger02d20012013-09-26 17:00:20 -0400892 # We use slightly funky filenames so as to better integrate with
893 # debugging processes (crash reporter/gdb/etc...). The basename
894 # will be the SONAME (what the runtime process sees), but since
895 # that is not unique among all inputs, we also install into a dir
896 # with the original filename. e.g. we will install:
897 # /lib/modules/3.8.11/vdso/vdso32-syscall.so/linux-gate.so
Mike Frysingerdde5f6a2013-09-25 22:08:25 -0400898 if use x86 || use amd64; then
Mike Frysinger02d20012013-09-26 17:00:20 -0400899 local d f soname
900 # Use the debug versions (.so.dbg) so portage can run splitdebug on them.
901 for f in "$(cros-workon_get_build_dir)/arch/x86/vdso"/vdso*.so.dbg; do
902 d="/lib/modules/${version}/vdso/${f##*/}"
903
904 exeinto "${d}"
905 newexe "${f}" "linux-gate.so"
906
907 soname=$(scanelf -qF'%S#f' "${f}")
908 dosym "linux-gate.so" "${d}/${soname}"
Mike Frysingerdde5f6a2013-09-25 22:08:25 -0400909 done
910 fi
911
Doug Andersonf291dba2012-01-19 14:26:10 -0800912 if use kernel_sources; then
913 install_kernel_sources
Mike Frysingerb5ebdb52013-02-10 03:25:44 -0500914 else
915 dosym "$(cros-workon_get_build_dir)" "/usr/src/linux"
Doug Andersonf291dba2012-01-19 14:26:10 -0800916 fi
917}
918
Simon Que715e54f32012-12-20 15:53:13 -0800919EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile src_test src_install