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+ SPDX-License-Identifier: LGPL-2.1+
--> -->
<refentry id="nss-myhostname" conditional='ENABLE_MYHOSTNAME'> <refentry id="nss-myhostname" conditional='ENABLE_NSS_MYHOSTNAME'>
<refentryinfo> <refentryinfo>
<title>nss-myhostname</title> <title>nss-myhostname</title>

View file

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

View file

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

View file

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

View file

@ -1216,7 +1216,6 @@ foreach term : ['utmp',
'networkd', 'networkd',
'timedated', 'timedated',
'timesyncd', 'timesyncd',
'myhostname',
'firstboot', 'firstboot',
'randomseed', 'randomseed',
'backlight', 'backlight',
@ -1233,12 +1232,39 @@ foreach term : ['utmp',
'smack', 'smack',
'gshadow', 'gshadow',
'idn', 'idn',
'nss-myhostname',
'nss-systemd'] 'nss-systemd']
have = get_option(term) have = get_option(term)
name = 'ENABLE_' + term.underscorify().to_upper() name = 'ENABLE_' + term.underscorify().to_upper()
conf.set10(name, have) conf.set10(name, have)
endforeach 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')) conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
want_tests = get_option('tests') want_tests = get_option('tests')
@ -1417,10 +1443,10 @@ test_dlopen = executable(
link_with : [libbasic], link_with : [libbasic],
dependencies : [libdl]) dependencies : [libdl])
foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'], foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
['systemd', 'ENABLE_NSS_SYSTEMD'], ['systemd', 'ENABLE_NSS_SYSTEMD'],
['mymachines', 'ENABLE_MACHINED'], ['mymachines', 'ENABLE_NSS_MYMACHINES'],
['resolve', 'ENABLE_RESOLVE']] ['resolve', 'ENABLE_NSS_RESOLVE']]
condition = tuple[1] == '' or conf.get(tuple[1]) == 1 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
if condition if condition
@ -2946,7 +2972,6 @@ foreach tuple : [
['idn'], ['idn'],
['libidn2'], ['libidn2'],
['libidn'], ['libidn'],
['nss-systemd'],
['libiptc'], ['libiptc'],
['elfutils'], ['elfutils'],
['binfmt'], ['binfmt'],
@ -2981,7 +3006,10 @@ foreach tuple : [
['blkid'], ['blkid'],
['dbus'], ['dbus'],
['glib'], ['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'], ['hwdb'],
['tpm'], ['tpm'],
['man pages', want_man], ['man pages', want_man],

View file

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

View file

@ -645,7 +645,7 @@ tests += [
[['src/test/test-nss.c'], [['src/test/test-nss.c'],
[], [],
[libdl], [libdl],
'', 'manual'], 'ENABLE_NSS', 'manual'],
[['src/test/test-umount.c', [['src/test/test-umount.c',
'src/core/mount-setup.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); modules = strv_new(argv[1], NULL);
else else
modules = strv_new( modules = strv_new(
#if ENABLE_MYHOSTNAME #if ENABLE_NSS_MYHOSTNAME
"myhostname", "myhostname",
#endif #endif
#if ENABLE_RESOLVE #if ENABLE_NSS_RESOLVE
"resolve", "resolve",
#endif #endif
#if ENABLE_MACHINED #if ENABLE_NSS_MYMACHINES
"mymachines", "mymachines",
#endif #endif
"dns", "dns",