libvirt/build-aux/meson.build
Andrea Bolognani 6a023e943e meson: Print custom message when GNU grep is not installed
Currently, if GNU grep is not installed on a FreeBSD system the
configuration step will fail with

  Program grep found: YES (/usr/bin/grep)
  Program /usr/local/bin/grep found: NO

  ERROR: Program '/usr/local/bin/grep' not found

which is confusing and not very useful; after this change, the
message will be

  Program grep found: YES (/usr/bin/grep)
  Program /usr/local/bin/grep found: NO

  ERROR: Problem encountered: GNU grep not found

instead, which should do a better job helping the user figure
out that they need to install GNU grep from ports to proceed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-04-01 14:14:20 +02:00

67 lines
1.6 KiB
Meson

syntax_check_conf = configuration_data()
syntax_check_conf.set('top_srcdir', meson.source_root())
syntax_check_conf.set('top_builddir', meson.build_root())
flake8_path = ''
if flake8_prog.found()
flake8_path = flake8_prog.path()
endif
syntax_check_conf.set('flake8_path', flake8_path)
syntax_check_conf.set('runutf8', ' '.join(runutf8))
syntax_check_conf.set('PYTHON3', python3_prog.path())
grep_prog = find_program('grep')
if host_machine.system() == 'freebsd'
make_prog = find_program('gmake')
grep_cmd = run_command(grep_prog, '--version')
if grep_cmd.stdout().startswith('grep (BSD grep')
grep_prog = find_program('/usr/local/bin/grep', required: false)
if not grep_prog.found()
error('GNU grep not found')
endif
grep_cmd = run_command(grep_prog, '--version')
if grep_cmd.stdout().startswith('grep (BSD grep')
error('GNU grep not found')
endif
endif
else
make_prog = find_program('make')
endif
syntax_check_conf.set('GREP', grep_prog.path())
configure_file(
input: 'Makefile.in',
output: '@BASENAME@',
configuration: syntax_check_conf,
)
rc = run_command(
'sed', '-n',
's/^\\(sc_[a-zA-Z0-9_-]*\\):.*/\\1/p',
meson.current_source_dir() / 'syntax-check.mk',
check: true,
)
sc_tests = rc.stdout().strip().split()
# Skip syntax-check if not building from git because we get the list of files
# to check using git commands and it fails if we are not in git repository.
if git
foreach target : sc_tests
test(
target,
make_prog,
args: [ '-C', meson.current_build_dir(), target ],
depends: [
potfiles_dep,
],
suite: 'syntax-check',
)
endforeach
endif