1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2018 Intel Corporation
6 WARN_CROSS_COMPILE='Need "kernel_dir" option for kmod compilation when cross-compiling'
7 WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers installed?'
9 # if we are cross-compiling we need kernel_dir specified
10 # NOTE: warning() function only available from version 0.44 onwards
11 if get_option('kernel_dir') == '' and meson.is_cross_build()
12 if meson.version().version_compare('>=0.44')
13 warning(WARN_CROSS_COMPILE)
15 message('WARNING: ' + WARN_CROSS_COMPILE)
19 kernel_dir = get_option('kernel_dir')
21 # use default path for native builds
22 kernel_version = run_command('uname', '-r').stdout().strip()
23 kernel_dir = '/lib/modules/' + kernel_version + '/build'
26 # test running make in kernel directory, using "make kernelversion"
27 make_returncode = run_command('make', '-sC', kernel_dir,
28 'kernelversion').returncode()
29 if make_returncode != 0
30 if meson.version().version_compare('>=0.44')
31 warning(WARN_NO_HEADERS)
33 message('WARNING: ' + WARN_NO_HEADERS)
35 else # returncode == 0
37 # DO ACTUAL MODULE BUILDING