forked from thkukuk/lastlog2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
157 lines (137 loc) · 4.35 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
project(
'lastlog2',
'c',
meson_version : '>= 0.53.0',
default_options : [
'prefix=/usr',
'sysconfdir=/etc',
'localstatedir=/var',
'buildtype=debugoptimized',
'default_library=shared',
'b_pie=true',
'warning_level=2',],
license : ['BSD-2-Clause',],
version : '1.1.0',
)
cc = meson.get_compiler('c')
pkg = import('pkgconfig')
inc = include_directories('include')
add_project_arguments(['-D_GNU_SOURCE=1',
'-DXTSTRINGDEFINES',
'-D_FORTIFY_SOURCE=2',
'-D_FILE_OFFSET_BITS=64',
'-D_TIME_BITS=64',
'-DPROJECT_VERSION="@0@"'.format(meson.project_version()) ], language : 'c')
possible_cc_flags = [
'-flto=auto',
'-ffat-lto-objects',
'-fstack-protector-strong',
'-funwind-tables',
'-fasynchronous-unwind-tables',
'-fstack-clash-protection',
'-Werror=return-type',
'-Wbad-function-cast',
'-Wcast-align',
'-Wcast-qual',
'-Wformat-security',
'-Winline',
'-Wmissing-declarations',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wshadow',
'-Wstrict-prototypes',
'-Wundef',
]
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
fs = import('fs')
if get_option('split-usr') == 'auto'
split_usr = not fs.is_symlink('/bin')
else
split_usr = get_option('split-usr') == 'true'
endif
rootprefixdir = get_option('rootprefix')
rootprefix_default = split_usr ? '/' : '/usr'
if rootprefixdir == ''
rootprefixdir = rootprefix_default
endif
rootlibdir = get_option('rootlibdir')
if rootlibdir == ''
# This will be a relative path if libdir is in prefix.
rootlibdir = get_option('libdir')
endif
if not rootlibdir.startswith('/')
# If we have a relative path, add rootprefixdir to the front.
rootlibdir = rootprefixdir / rootlibdir
endif
pamlibdir = get_option('pamlibdir')
if pamlibdir == ''
pamlibdir = rootlibdir / 'security'
endif
# Meson ignores the preceding arguments when joining paths if an absolute
# component is encountered, so this should canonicalize various paths when they
# are absolute or relative.
prefixdir = get_option('prefix')
if not prefixdir.startswith('/')
error('Prefix is not absolute: "@0@"'.format(prefixdir))
endif
if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(rootprefixdir, prefixdir))
endif
systemunitdir = prefixdir / 'lib/systemd/system'
tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
libpam = cc.find_library('pam')
libsqlite3 = cc.find_library('sqlite3')
liblastlog2_c = files('lib/lastlog2.c')
liblastlog2_map = 'lib/liblastlog2.map'
liblastlog2_map_version = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), liblastlog2_map)
pam_lastlog2_c = files('src/pam_lastlog2.c')
pam_lastlog2_map = 'src/pam_lastlog2.map'
pam_lastlog2_map_version = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), pam_lastlog2_map)
liblastlog2 = shared_library(
'lastlog2',
liblastlog2_c,
include_directories : inc,
link_args : ['-shared',
liblastlog2_map_version],
link_depends : liblastlog2_map,
dependencies : [libsqlite3],
install : true,
version : meson.project_version(),
soversion : '1'
)
install_headers('include/lastlog2.h')
pkg.generate(
liblastlog2,
name : 'liblastlog2',
description : 'library to manage last login data',
version : meson.project_version(),
)
pam_lastlog2 = shared_library(
'pam_lastlog2',
pam_lastlog2_c,
name_prefix : '',
include_directories : inc,
link_args : ['-shared', pam_lastlog2_map_version],
link_depends : pam_lastlog2_map,
link_with : liblastlog2,
dependencies : [libpam],
install : true,
install_dir : pamlibdir
)
lastlog2_c = ['src/lastlog2.c']
executable('lastlog2',
lastlog2_c,
include_directories : inc,
link_with : liblastlog2,
install : true)
if get_option('compat-symlink')
install_symlink('lastlog',
pointing_to: 'lastlog2',
install_dir: 'bin')
endif
subdir('tmpfiles.d')
subdir('units')
# Unit tests
subdir('tests')
# Manual pages
subdir('man')