xref: /openbmc/phosphor-user-manager/meson.build (revision a1a754c22305421e859b4ffeeee49909cf11a2fa)
1project(
2    'phosphor-user-manager',
3    'cpp',
4    version: '0.1',
5    meson_version: '>=1.1.1',
6    default_options: [
7        'warning_level=3',
8        'werror=true',
9        'cpp_std=c++23',
10        'buildtype=debugoptimized',
11    ],
12)
13
14if get_option('root_user_mgmt').allowed()
15    add_project_arguments('-DENABLE_ROOT_USER_MGMT', language: 'cpp')
16endif
17
18conf_data = configuration_data()
19
20conf_data.set_quoted(
21    'USER_MANAGER_BUSNAME',
22    'xyz.openbmc_project.User.Manager',
23    description: 'The DBus busname to own.',
24)
25
26conf_data.set(
27    'CLASS_VERSION',
28    1,
29    description: 'Class version to register with Cereal.',
30)
31
32conf_data.set_quoted(
33    'LDAP_CONFIG_FILE',
34    '/etc/nslcd.conf',
35    description: 'Path of LDAP configuration file.',
36)
37
38conf_data.set_quoted(
39    'TLS_CACERT_PATH',
40    '/etc/ssl/certs/authority',
41    description: 'Path of LDAP server CA certificate.',
42)
43
44conf_data.set_quoted(
45    'TLS_CERT_FILE',
46    '/etc/nslcd/certs/cert.pem',
47    description: 'Path of LDAP client certificate.',
48)
49
50conf_data.set_quoted(
51    'LDAP_CONFIG_ROOT',
52    '/xyz/openbmc_project/user/ldap',
53    description: 'LDAP configuration root.',
54)
55
56conf_data.set_quoted(
57    'LDAP_CONFIG_DBUS_OBJ_PATH',
58    '/xyz/openbmc_project/user/ldap/config',
59    description: 'D-Bus path of LDAP config object.',
60)
61
62conf_data.set_quoted(
63    'LDAP_CONFIG_BUSNAME',
64    'xyz.openbmc_project.Ldap.Config',
65    description: 'D-Bus busname of LDAP config service.',
66)
67
68conf_data.set_quoted(
69    'LDAP_CONF_PERSIST_PATH',
70    '/var/lib/phosphor-ldap-conf',
71    description: 'path of directory having persisted LDAP configuration enabled property.',
72)
73
74conf_header = configure_file(output: 'config.h', configuration: conf_data)
75
76phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
77sdbusplus_dep = dependency('sdbusplus')
78phosphor_logging_dep = dependency('phosphor-logging')
79systemd_dep = dependency('systemd')
80
81cpp = meson.get_compiler('cpp')
82
83boost_dep = dependency('boost')
84
85# Get Cereal dependency.
86cereal_dep = dependency('cereal', required: false)
87has_cereal = cpp.has_header_symbol(
88    'cereal/cereal.hpp',
89    'cereal::specialize',
90    dependencies: cereal_dep,
91    required: false,
92)
93if not has_cereal
94    cereal_opts = import('cmake').subproject_options()
95    cereal_opts.add_cmake_defines(
96        {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'},
97    )
98    cereal_proj = import('cmake').subproject(
99        'cereal',
100        options: cereal_opts,
101        required: false,
102    )
103    assert(cereal_proj.found(), 'cereal is required')
104    cereal_dep = cereal_proj.dependency('cereal')
105endif
106pam_dep = dependency('pam')
107user_manager_src = ['mainapp.cpp', 'user_mgr.cpp', 'users.cpp']
108
109
110user_manager_deps = [
111    boost_dep,
112    pam_dep,
113    sdbusplus_dep,
114    phosphor_logging_dep,
115    phosphor_dbus_interfaces_dep,
116]
117
118user_manager_lib = static_library(
119    'phosphor-user-manager',
120    ['user_mgr.cpp', 'users.cpp'],
121    dependencies: user_manager_deps,
122)
123
124user_manager_dep = declare_dependency(
125    link_with: user_manager_lib,
126    dependencies: user_manager_deps,
127)
128
129executable(
130    'phosphor-user-manager',
131    'mainapp.cpp',
132    dependencies: user_manager_dep,
133    link_args: ['-lcrypt'],
134    cpp_args: [
135        '-DBOOST_ALL_NO_LIB',
136        '-DBOOST_SYSTEM_NO_DEPRECATED',
137        '-DBOOST_ERROR_CODE_HEADER_ONLY',
138    ],
139    install: true,
140)
141
142
143systemd_system_unit_dir = systemd_dep.get_variable('systemdsystemunitdir')
144
145install_data(
146    'phosphor-nslcd-cert-config.conf',
147    install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
148)
149
150install_data(
151    'nslcd',
152    install_dir: get_option('datadir') / 'phosphor-certificate-manager',
153)
154
155install_data('mfa_pam', install_dir: '/etc/pam.d/')
156
157# Figure out how to use install_symlink to install symlink to a file of another
158# recipe
159#install_symlink(
160#      'phosphor-certificate-manager@nslcd.service',
161#      install_dir: systemd_system_unit_dir / 'multi-user.target.wants',
162#      pointing_to: systemd_system_unit_dir / 'phosphor-certificate-manager@.service',
163#  )
164meson.add_install_script(
165    'sh',
166    '-c',
167    'mkdir -p $(dirname $DESTDIR/@0@/@1@)'.format(
168        systemd_system_unit_dir,
169        'multi-user.target.wants/phosphor-certificate-manager@nslcd.service',
170    ),
171)
172meson.add_install_script(
173    'sh',
174    '-c',
175    'ln -s @0@ $DESTDIR/@1@/@2@'.format(
176        '../phosphor-certificate-manager@.service',
177        systemd_system_unit_dir,
178        'multi-user.target.wants/phosphor-certificate-manager@nslcd.service',
179    ),
180)
181
182subdir('phosphor-ldap-config')
183
184if get_option('tests').allowed()
185    subdir('test')
186endif
187