meson: allow building resolved and machined without nss modules

This adds -Dnss-resolve= and -Dnss-mymachines= meson options.
By using this option, e.g., resolved can be built without nss-resolve.
When no nss modules are built, then test-nss is neither built.

Also, This changes the option name -Dmyhostname= to -Dnss-myhostname=
for consistency to other nss related options.

Closes #9596.
This commit is contained in:
Yu Watanabe 2018-07-18 09:25:57 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent a0cb8078b1
commit 08540a9591
8 changed files with 52 additions and 20 deletions

View File

@ -6,7 +6,7 @@
SPDX-License-Identifier: LGPL-2.1+
-->
<refentry id="nss-myhostname" conditional='ENABLE_MYHOSTNAME'>
<refentry id="nss-myhostname" conditional='ENABLE_NSS_MYHOSTNAME'>
<refentryinfo>
<title>nss-myhostname</title>

View File

@ -6,7 +6,7 @@
SPDX-License-Identifier: LGPL-2.1+
-->
<refentry id="nss-mymachines" conditional='ENABLE_MACHINED'>
<refentry id="nss-mymachines" conditional='ENABLE_NSS_MYMACHINES'>
<refentryinfo>
<title>nss-mymachines</title>

View File

@ -6,7 +6,7 @@
SPDX-License-Identifier: LGPL-2.1+
-->
<refentry id="nss-resolve" conditional='ENABLE_RESOLVE'>
<refentry id="nss-resolve" conditional='ENABLE_NSS_RESOLVE'>
<refentryinfo>
<title>nss-resolve</title>

View File

@ -37,9 +37,9 @@ manpages = [
['modules-load.d', '5', [], 'HAVE_KMOD'],
['networkctl', '1', [], 'ENABLE_NETWORKD'],
['networkd.conf', '5', ['networkd.conf.d'], 'ENABLE_NETWORKD'],
['nss-myhostname', '8', ['libnss_myhostname.so.2'], 'ENABLE_MYHOSTNAME'],
['nss-mymachines', '8', ['libnss_mymachines.so.2'], 'ENABLE_MACHINED'],
['nss-resolve', '8', ['libnss_resolve.so.2'], 'ENABLE_RESOLVE'],
['nss-myhostname', '8', ['libnss_myhostname.so.2'], 'ENABLE_NSS_MYHOSTNAME'],
['nss-mymachines', '8', ['libnss_mymachines.so.2'], 'ENABLE_NSS_MYMACHINES'],
['nss-resolve', '8', ['libnss_resolve.so.2'], 'ENABLE_NSS_RESOLVE'],
['nss-systemd', '8', ['libnss_systemd.so.2'], 'ENABLE_NSS_SYSTEMD'],
['os-release', '5', [], ''],
['pam_systemd', '8', [], 'HAVE_PAM'],

View File

@ -1216,7 +1216,6 @@ foreach term : ['utmp',
'networkd',
'timedated',
'timesyncd',
'myhostname',
'firstboot',
'randomseed',
'backlight',
@ -1233,12 +1232,39 @@ foreach term : ['utmp',
'smack',
'gshadow',
'idn',
'nss-myhostname',
'nss-systemd']
have = get_option(term)
name = 'ENABLE_' + term.underscorify().to_upper()
conf.set10(name, have)
endforeach
foreach tuple : [['nss-mymachines', 'machined'],
['nss-resolve', 'resolve']]
want = get_option(tuple[0])
if want != 'false'
have = get_option(tuple[1])
if want == 'true' and not have
error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
endif
else
have = false
endif
name = 'ENABLE_' + tuple[0].underscorify().to_upper()
conf.set10(name, have)
endforeach
enable_nss = false
foreach term : ['ENABLE_NSS_MYHOSTNAME',
'ENABLE_NSS_MYMACHINES',
'ENABLE_NSS_RESOLVE',
'ENABLE_NSS_SYSTEMD']
if conf.get(term) == 1
enable_nss = true
endif
endforeach
conf.set10('ENABLE_NSS', enable_nss)
conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
want_tests = get_option('tests')
@ -1417,10 +1443,10 @@ test_dlopen = executable(
link_with : [libbasic],
dependencies : [libdl])
foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
['systemd', 'ENABLE_NSS_SYSTEMD'],
['mymachines', 'ENABLE_MACHINED'],
['resolve', 'ENABLE_RESOLVE']]
['mymachines', 'ENABLE_NSS_MYMACHINES'],
['resolve', 'ENABLE_NSS_RESOLVE']]
condition = tuple[1] == '' or conf.get(tuple[1]) == 1
if condition
@ -2946,7 +2972,6 @@ foreach tuple : [
['idn'],
['libidn2'],
['libidn'],
['nss-systemd'],
['libiptc'],
['elfutils'],
['binfmt'],
@ -2981,7 +3006,10 @@ foreach tuple : [
['blkid'],
['dbus'],
['glib'],
['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
['nss-myhostname', conf.get('ENABLE_NSS_MYHOSTNAME') == 1],
['nss-mymachines', conf.get('ENABLE_NSS_MYMACHINES') == 1],
['nss-resolve', conf.get('ENABLE_NSS_RESOLVE') == 1],
['nss-systemd', conf.get('ENABLE_NSS_SYSTEMD') == 1],
['hwdb'],
['tpm'],
['man pages', want_man],

View File

@ -88,8 +88,14 @@ option('timesyncd', type : 'boolean',
description : 'install the systemd-timesyncd daemon')
option('remote', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'support for "journal over the network"')
option('myhostname', type : 'boolean',
description : 'nss-myhostname support')
option('nss-myhostname', type : 'boolean',
description : 'install nss-myhostname module')
option('nss-mymachines', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'install nss-mymachines module')
option('nss-resolve', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'install nss-resolve module')
option('nss-systemd', type : 'boolean',
description : 'install nss-systemd module')
option('firstboot', type : 'boolean',
description : 'support for firstboot mechanism')
option('randomseed', type : 'boolean',
@ -246,8 +252,6 @@ option('libidn2', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'libidn2 support')
option('libidn', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'libidn support')
option('nss-systemd', type : 'boolean',
description : 'enable nss-systemd')
option('libiptc', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'libiptc support')
option('qrencode', type : 'combo', choices : ['auto', 'true', 'false'],

View File

@ -645,7 +645,7 @@ tests += [
[['src/test/test-nss.c'],
[],
[libdl],
'', 'manual'],
'ENABLE_NSS', 'manual'],
[['src/test/test-umount.c',
'src/core/mount-setup.c',

View File

@ -431,13 +431,13 @@ static int parse_argv(int argc, char **argv,
modules = strv_new(argv[1], NULL);
else
modules = strv_new(
#if ENABLE_MYHOSTNAME
#if ENABLE_NSS_MYHOSTNAME
"myhostname",
#endif
#if ENABLE_RESOLVE
#if ENABLE_NSS_RESOLVE
"resolve",
#endif
#if ENABLE_MACHINED
#if ENABLE_NSS_MYMACHINES
"mymachines",
#endif
"dns",