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