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