xref: /openbmc/phosphor-user-manager/meson.build (revision a335311fc3417489d0cfe09712546db248e65f2f)
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_data.set(
75    'MAX_PASSWORD_LENGTH',
76    get_option('MAX_PASSWORD_LENGTH'),
77    description: 'Maximum password length',
78)
79
80conf_header = configure_file(output: 'config.h', configuration: conf_data)
81
82cpp = meson.get_compiler('cpp')
83
84boost_dep = dependency('boost')
85ldap_dep = cpp.find_library('ldap', required: false)
86pam_dep = dependency('pam')
87phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
88phosphor_logging_dep = dependency('phosphor-logging')
89sdbusplus_dep = dependency('sdbusplus')
90systemd_dep = dependency('systemd')
91
92# Get Cereal dependency.
93cereal_dep = dependency('cereal', required: false)
94has_cereal = cpp.has_header_symbol(
95    'cereal/cereal.hpp',
96    'cereal::specialize',
97    dependencies: cereal_dep,
98    required: false,
99)
100if not has_cereal
101    cereal_opts = import('cmake').subproject_options()
102    cereal_opts.add_cmake_defines(
103        {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'},
104    )
105    cereal_proj = import('cmake').subproject(
106        'cereal',
107        options: cereal_opts,
108        required: false,
109    )
110    assert(cereal_proj.found(), 'cereal is required')
111    cereal_dep = cereal_proj.dependency('cereal')
112endif
113user_manager_src = ['mainapp.cpp', 'user_mgr.cpp', 'users.cpp']
114
115
116user_manager_deps = [
117    boost_dep,
118    pam_dep,
119    sdbusplus_dep,
120    phosphor_logging_dep,
121    phosphor_dbus_interfaces_dep,
122]
123
124user_manager_lib = static_library(
125    'phosphor-user-manager',
126    ['user_mgr.cpp', 'users.cpp'],
127    dependencies: user_manager_deps,
128)
129
130user_manager_dep = declare_dependency(
131    link_with: user_manager_lib,
132    dependencies: user_manager_deps,
133)
134
135executable(
136    'phosphor-user-manager',
137    'mainapp.cpp',
138    dependencies: user_manager_dep,
139    link_args: ['-lcrypt'],
140    cpp_args: [
141        '-DBOOST_ALL_NO_LIB',
142        '-DBOOST_SYSTEM_NO_DEPRECATED',
143        '-DBOOST_ERROR_CODE_HEADER_ONLY',
144    ],
145    install: true,
146)
147
148
149systemd_system_unit_dir = systemd_dep.get_variable('systemdsystemunitdir')
150
151install_data(
152    'phosphor-nslcd-cert-config.conf',
153    install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
154)
155
156install_data(
157    'nslcd',
158    install_dir: get_option('datadir') / 'phosphor-certificate-manager',
159)
160
161install_data('mfa_pam', install_dir: '/etc/pam.d/')
162
163# Figure out how to use install_symlink to install symlink to a file of another
164# recipe
165#install_symlink(
166#      'phosphor-certificate-manager@nslcd.service',
167#      install_dir: systemd_system_unit_dir / 'multi-user.target.wants',
168#      pointing_to: systemd_system_unit_dir / 'phosphor-certificate-manager@.service',
169#  )
170meson.add_install_script(
171    'sh',
172    '-c',
173    'mkdir -p $(dirname $DESTDIR/@0@/@1@)'.format(
174        systemd_system_unit_dir,
175        'multi-user.target.wants/phosphor-certificate-manager@nslcd.service',
176    ),
177)
178meson.add_install_script(
179    'sh',
180    '-c',
181    'ln -s @0@ $DESTDIR/@1@/@2@'.format(
182        '../phosphor-certificate-manager@.service',
183        systemd_system_unit_dir,
184        'multi-user.target.wants/phosphor-certificate-manager@nslcd.service',
185    ),
186)
187
188if ldap_dep.found()
189    subdir('phosphor-ldap-config')
190endif
191
192if get_option('tests').allowed()
193    subdir('test')
194endif
195