forked from linux-pam/linux-pam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
629 lines (554 loc) · 17.1 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
project('Linux-PAM', 'c',
version: '1.6.1',
license: 'BSD-3-Clause OR GPL-2.0-or-later',
default_options: [
'b_pie=true',
'prefix=/usr',
'warning_level=2',
],
meson_version: '>= 0.62.0',
)
fs = import('fs')
pkgconfig = import('pkgconfig')
prefixdir = get_option('prefix')
if not fs.is_absolute(prefixdir)
error('Prefix is not absolute: "@0@"'.format(prefixdir))
endif
datadir = prefixdir / get_option('datadir')
includedir = prefixdir / get_option('includedir') / 'security'
libdir = prefixdir / get_option('libdir')
localedir = prefixdir / get_option('localedir')
localstatedir = '/' / get_option('localstatedir')
mandir = prefixdir / get_option('mandir')
sbindir = prefixdir / get_option('sbindir')
sysconfdir = prefixdir / get_option('sysconfdir')
securedir = get_option('securedir')
if securedir == ''
securedir = libdir / 'security'
endif
cc = meson.get_compiler('c')
cdata = configuration_data()
null_dep = dependency('', required: false)
cdata.set('_GNU_SOURCE', 1)
cdata.set_quoted('PACKAGE', meson.project_name())
cdata.set_quoted('PAM_VERSION', meson.project_version())
cdata.set('UNUSED', '__attribute__((__unused__))')
cdata.set('PAM_NO_HEADER_FUNCTIONS', 1, description: 'Disable function bodies in headers')
cdata.set_quoted('SYSCONFDIR', sysconfdir)
cdata.set_quoted('LTDIR', '')
# used in configure_file() only, so not quoted
cdata.set('sbindir', sbindir)
cdata.set('PAM_DEBUG', get_option('pam-debug') ? 1 : false)
cdata.set('PAM_LOCKING', get_option('pamlocking') ? 1 : false)
cdata.set('PAM_READ_BOTH_CONFS', get_option('read-both-confs') ? 1 : false)
cdata.set10('DEFAULT_USERGROUPS_SETTING', get_option('usergroups'))
cdata.set('PAM_USERTYPE_UIDMIN', get_option('uidmin'))
cdata.set('PAM_USERTYPE_OVERFLOW_UID', get_option('kernel-overflow-uid'))
cdata.set('PAM_MISC_CONV_BUFSIZE', get_option('misc-conv-bufsize'))
cdata.set_quoted('_PAM_ISA',
get_option('isadir') != '' ? get_option('isadir') : '../..' / fs.name(libdir) / 'security')
docdir = get_option('docdir')
if docdir == ''
docdir = datadir / 'doc' / meson.project_name()
endif
htmldir = get_option('htmldir')
if htmldir == ''
htmldir = docdir
endif
pdfdir = get_option('pdfdir')
if pdfdir == ''
pdfdir = docdir
endif
sconfigdir = get_option('sconfigdir')
if sconfigdir == ''
sconfigdir = sysconfdir / 'security'
endif
cdata.set_quoted('SCONFIG_DIR', sconfigdir)
# used in configure_file() only, so not quoted
cdata.set('SCONFIGDIR', sconfigdir)
vendordir = get_option('vendordir')
if get_option('vendordir') == ''
vendor_sconfigdir = sconfigdir
vendor_sysconfdir = sysconfdir
stringparam_vendordir = []
stringparam_profileconditions = 'without_vendordir'
else
vendor_sconfigdir = vendordir / 'security'
vendor_sysconfdir = vendordir
cdata.set_quoted('VENDORDIR', vendordir)
cdata.set_quoted('VENDOR_SCONFIG_DIR', vendor_sconfigdir)
stringparam_vendordir = ['--stringparam', 'vendordir', vendordir]
stringparam_profileconditions = 'with_vendordir'
endif
randomdev_option = get_option('randomdev')
if randomdev_option == '' or randomdev_option == 'yes'
cdata.set_quoted('PAM_PATH_RANDOMDEV', '/dev/urandom')
elif randomdev_option != 'no'
cdata.set_quoted('PAM_PATH_RANDOMDEV', randomdev_option)
endif
xauth_option = get_option('xauth')
if xauth_option != '' and xauth_option != '/usr/X11R6/bin/xauth'
cdata.set_quoted('PAM_PATH_XAUTH', xauth_option)
endif
# meson defines -D_STRIP_FILE_OFFSET_BITS=64 even for 64-bit systems, this
# forces glibc to use function names with the same semantics but with "64"
# suffix, and that leads to discrepancies in the build artefacts produced
# by different build systems.
if cc.sizeof('long') >= 8
add_project_arguments(
'-U_FILE_OFFSET_BITS',
language: 'c')
endif
try_cc_flags = [
'-Wbad-function-cast',
'-Wcast-align',
'-Wcast-align=strict',
'-Wcast-qual',
'-Wdeprecated',
'-Wformat=2',
'-Winit-self',
'-Wmain',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-prototypes',
'-Wnull-dereference',
'-Wpointer-arith',
'-Wreturn-type',
'-Wshadow',
'-Wstrict-prototypes',
'-Wundef',
'-Wuninitialized',
'-Wunused',
'-Wwrite-strings',
]
add_project_arguments(
cc.get_supported_arguments(try_cc_flags),
language: 'c')
add_project_link_arguments(
# --as-needed and --no-undefined are enabled by default
cc.get_supported_link_arguments([
'-Wl,--fatal-warnings',
'-Wl,-O1',
]),
language: 'c')
exe_link_args = cc.get_supported_link_arguments([
'-Wl,-z,relro',
'-Wl,-z,now',
])
check_headers = [
'crypt.h',
'paths.h',
'sys/random.h',
]
foreach h: check_headers
if cc.has_header(h)
cdata.set('HAVE_' + h.underscorify().to_upper(), 1)
endif
endforeach
check_functions = [
['close_range', '#include <unistd.h>'],
['explicit_bzero', '#include <string.h>'],
['getdomainname', '#include <unistd.h>'],
['getgrgid_r', '#include <grp.h>'],
['getgrnam_r', '#include <grp.h>'],
['getgrouplist', '#include <grp.h>'],
['getmntent_r', '#include <mntent.h>'],
['getpwnam', '#include <pwd.h>'],
['getpwnam_r', '#include <pwd.h>'],
['getpwuid_r', '#include <pwd.h>'],
['getrandom', '#include <sys/random.h>'],
['getspnam_r', '#include <shadow.h>'],
['getutent_r', '#include <utmp.h>'],
['innetgr', '#include <netdb.h>'],
['memset_explicit', '#include <string.h>'],
['quotactl', '#include <sys/quota.h>'],
['ruserok', '#include <netdb.h>'],
['ruserok_af', '#include <netdb.h>'],
['unshare', '#include <sched.h>'],
]
foreach ident: check_functions
if cc.has_function(ident[0], prefix: ident[1], args: '-D_GNU_SOURCE')
cdata.set('HAVE_' + ident[0].to_upper(), 1)
endif
endforeach
enable_pam_keyinit = cc.sizeof('__NR_keyctl', prefix: '#include <sys/syscall.h>') > 0
if get_option('mailspool') != ''
cdata.set_quoted('PAM_PATH_MAILDIR', get_option('mailspool'))
else
have = cc.sizeof('_PATH_MAILDIR', prefix: '#include <paths.h>') > 0
cdata.set('PAM_PATH_MAILDIR', have ? '_PATH_MAILDIR' : '"/var/spool/mail"')
endif
libdl = dependency('dl')
if not get_option('i18n').disabled()
libintl = dependency('intl', required: get_option('i18n'))
if libintl.found()
cdata.set('ENABLE_NLS', 1)
cdata.set_quoted('LOCALEDIR', localedir)
foreach f: ['bindtextdomain',
'dngettext',
]
if cc.has_function(f, prefix: '#include <libintl.h>',
args: '-D_GNU_SOURCE',
dependencies: libintl)
cdata.set('HAVE_' + f.to_upper(), 1)
endif
endforeach
endif
endif
libaudit = dependency('audit', required: get_option('audit'))
if libaudit.found()
cdata.set('HAVE_LIBAUDIT', 1)
foreach ident: ['struct audit_tty_status']
if cc.sizeof(ident, prefix: '#include <libaudit.h>') > 0
cdata.set('HAVE_' + ident.underscorify().to_upper(), 1)
endif
endforeach
foreach ident: [['struct audit_tty_status', 'log_passwd']]
if cc.has_member(ident[0], ident[1],
prefix: '#include <libaudit.h>',
args: '-D_GNU_SOURCE')
cdata.set('HAVE_@0@_@1@'.format(ident[0], ident[1]).underscorify().to_upper(), 1)
endif
endforeach
endif
libcrypt = dependency('libcrypt', 'libxcrypt', required: false)
if not libcrypt.found()
libcrypt = cc.find_library('crypt')
endif
crypt_h = cdata.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
foreach f: ['crypt_r']
if cc.has_function(f, prefix: crypt_h,
args: '-D_GNU_SOURCE',
dependencies: libcrypt)
cdata.set('HAVE_' + f.to_upper(), 1)
endif
endforeach
libeconf = dependency('libeconf', version: '>= 0.5.0', required: get_option('econf'))
if libeconf.found()
cdata.set('USE_ECONF', 1)
have_econf_readconfig = true
if stringparam_vendordir != []
stringparam_profileconditions += ';with_vendordir_and_with_econf'
endif
foreach f: ['econf_newKeyFile_with_options',
'econf_readConfigWithCallback',
]
if cc.has_function(f, prefix: '#include <libeconf.h>',
args: '-D_GNU_SOURCE',
dependencies: libeconf)
cdata.set('HAVE_' + f.to_upper(), 1)
else
have_econf_readconfig = false
endif
if have_econf_readconfig
cdata.set('HAVE_ECONF_READCONFIG', 1)
endif
endforeach
else
if stringparam_vendordir != []
stringparam_profileconditions += ';with_vendordir_and_without_econf'
endif
endif
libselinux = dependency('libselinux', required: get_option('selinux'))
if libselinux.found()
cdata.set('WITH_SELINUX', 1)
foreach f: ['getseuser', 'setkeycreatecon']
if cc.has_function(f, prefix: '#include <selinux/selinux.h>',
dependencies: libselinux)
cdata.set('HAVE_' + f.to_upper(), 1)
endif
endforeach
endif
if get_option('openssl').disabled()
libcrypto = null_dep
else
libcrypto = dependency('libcrypto', required: false)
endif
if libcrypto.found() and cc.has_function('EVP_MAC_CTX_new',
prefix: '#include <openssl/hmac.h>',
dependencies: libcrypto)
cdata.set('WITH_OPENSSL', 1)
stringparam_profileconditions += ';openssl_hmac'
else
stringparam_profileconditions += ';no_openssl_hmac'
endif
libsystemd = dependency('libsystemd', version: '>= 254', required: get_option('logind'))
cdata.set('USE_LOGIND', libsystemd.found() ? 1 : false)
systemdunitdir = get_option('systemdunitdir')
if systemdunitdir == ''
systemdunitdir = prefixdir / 'lib' / 'systemd' / 'system'
systemd = dependency('systemd', required: false)
if systemd.found()
systemdunitdir = systemd.get_variable(
pkgconfig: 'systemdsystemunitdir',
default_value: systemdunitdir,
)
endif
endif
feature_pam_userdb = get_option('pam_userdb')
if feature_pam_userdb.disabled()
enable_pam_userdb = false
else
use_db = get_option('db')
have = false
if use_db == 'db' or use_db == 'auto'
db_uniquename = get_option('db-uniquename')
name = 'db' + db_uniquename
libdb = cc.find_library(name, required: false)
if libdb.found()
foreach f: ['dbm_open' + db_uniquename, 'dbm_open']
have = cc.links('''
#define _GNU_SOURCE
#define DB_DBM_HSEARCH 1
#define HAVE_DBM 1
#include <db.h>
int main(void) {return !@0@("", 0, 0);}
'''.format(f),
args: '-l' + name,
name: '@0@ in @1@'.format(f, 'lib' + name))
if have
break
endif
endforeach
if have
use_db = 'db'
cdata.set('HAVE_DB_H', 1)
endif
endif
endif
if use_db == 'gdbm' or use_db == 'auto'
libdb = cc.find_library('gdbm', required: false)
if libdb.found()
have = cc.has_function('gdbm_store', prefix: '#include <gdbm.h>',
args: '-D_GNU_SOURCE', dependencies: libdb)
if have
use_db = 'gdbm'
cdata.set('HAVE_GDBM_H', 1)
endif
endif
endif
if use_db == 'ndbm' or use_db == 'auto'
libdb = cc.find_library('ndbm', required: false)
if libdb.found()
have = cc.has_function('dbm_store', prefix: '#include <ndbm.h>',
args: '-D_GNU_SOURCE', dependencies: libdb)
if have
use_db = 'ndbm'
cdata.set('HAVE_NDBM_H', 1)
endif
endif
endif
if not have and feature_pam_userdb.enabled()
error('pam_userdb module is enabled but the db library is not available')
endif
enable_pam_userdb = have
endif
feature_pam_lastlog = get_option('pam_lastlog')
if feature_pam_lastlog.disabled()
enable_pam_lastlog = false
else
libutil = cc.find_library('util', required: false)
have = cc.has_function('logwtmp', prefix: '#include <utmp.h>',
dependencies: libutil)
if not have and feature_pam_lastlog.enabled()
error('pam_lastlog module is enabled but logwtmp() is not available')
endif
enable_pam_lastlog = have
endif
enable_pam_unix = not get_option('pam_unix').disabled()
if enable_pam_unix
if get_option('lckpwdf')
cdata.set('USE_LCKPWDF', 1)
foreach f: ['lckpwdf']
if cc.has_function(f, prefix: '#include <shadow.h>')
cdata.set('HAVE_' + f.to_upper(), 1)
endif
endforeach
endif
feature_nis = get_option('nis')
if feature_nis.disabled()
enable_nis = false
libtirpc = null_dep
libnsl = null_dep
else
# If libtirpc is available, prefer that over the system implementation.
libtirpc = dependency('libtirpc', required: false)
enable_nis = true
foreach f: ['getrpcport',
'rpcb_getaddr',
]
if cc.has_function(f, prefix: '#include <rpc/rpc.h>',
dependencies: libtirpc)
cdata.set('HAVE_' + f.to_upper(), 1)
cdata.set('HAVE_DECL_' + f.to_upper(), 1)
endif
endforeach
libnsl = dependency('libnsl', required: feature_nis)
enable_nis = libnsl.found()
if enable_nis
foreach f: ['yp_bind',
'yp_get_default_domain',
'yp_match',
'yp_unbind',
]
if not cc.has_function(f, prefix: '''#include <rpcsvc/ypclnt.h>
#include <rpcsvc/yp_prot.h>''',
dependencies: [libnsl, libtirpc])
enable_nis = false
libnsl = null_dep
break
endif
endforeach
endif
if enable_nis
cdata.set('HAVE_NIS', 1)
elif feature_nis.enabled()
error('NIS is enabled but required interfaces are not available')
endif
endif
endif
feature_docs = get_option('docs')
enable_docs = not feature_docs.disabled()
if enable_docs
prog_xsltproc = find_program(
'xsltproc',
required: feature_docs,
disabler: true,
)
prog_xmllint = find_program(
'xmllint',
required: feature_docs,
disabler: true,
)
prog_w3m = find_program(
'w3m',
required: false,
)
if prog_w3m.found()
browser = [prog_w3m, '-T', 'text/html', '-dump']
else
prog_elinks = find_program(
'elinks',
required: feature_docs,
disabler: true,
)
browser = [prog_elinks, '-no-numbering', '-no-references', '-dump']
endif
prog_fop = find_program(
'fop',
required: feature_docs,
disabler: true,
)
prog_xmlcatalog = find_program(
'xmlcatalog',
required: feature_docs,
disabler: true,
)
xml_catalog = get_option('xml-catalog')
if xml_catalog == ''
xml_catalog = '/etc/xml/catalog'
endif
have = prog_xmlcatalog.found() and run_command(
['test', '-f', xml_catalog],
check: feature_docs.enabled()
).returncode() == 0
if not have
xml_catalog = disabler()
endif
docbook_rng = get_option('docbook-rng')
have = run_command(
[prog_xmlcatalog, '--noout', xml_catalog, docbook_rng],
check: feature_docs.enabled()
).returncode() == 0
if not have
docbook_rng = disabler()
endif
html_stylesheet = get_option('html-stylesheet')
have = run_command(
[prog_xmlcatalog, '--noout', xml_catalog, html_stylesheet],
check: feature_docs.enabled()
).returncode() == 0
if not have
html_stylesheet = disabler()
endif
txt_stylesheet = get_option('txt-stylesheet')
have = run_command(
[prog_xmlcatalog, '--noout', xml_catalog, txt_stylesheet],
check: feature_docs.enabled()
).returncode() == 0
if not have
txt_stylesheet = disabler()
endif
man_stylesheet = get_option('man-stylesheet')
have = run_command(
[prog_xmlcatalog, '--noout', xml_catalog, man_stylesheet],
check: feature_docs.enabled()
).returncode() == 0
if not have
man_stylesheet = disabler()
endif
pdf_stylesheet = get_option('pdf-stylesheet')
have = run_command(
[prog_xmlcatalog, '--noout', xml_catalog, pdf_stylesheet],
check: feature_docs.enabled()
).returncode() == 0
if not have
pdf_stylesheet = disabler()
endif
stringparam_profileconditions = [
'--stringparam',
'profile.condition',
stringparam_profileconditions
]
else
prog_xsltproc = disabler()
prog_xmllint = disabler()
prog_fop = disabler()
browser = disabler()
custom_man_xsl = disabler()
docbook_rng = disabler()
html_stylesheet = disabler()
man_stylesheet = disabler()
txt_stylesheet = disabler()
endif
prog_flex = find_program(
'flex',
required: false,
disabler: true,
)
yacc_cmd = []
prog_yacc = find_program(
'bison',
required: false,
)
if prog_yacc.found()
yacc_cmd = [prog_yacc, '-o', '@OUTPUT0@', '--defines=@OUTPUT1@', '@INPUT@']
else
prog_yacc = find_program(
'byacc',
required: false,
disabler: true,
)
yacc_cmd = [prog_yacc, '-o', '@OUTPUT0@', '-H', '@OUTPUT1@', '@INPUT@']
endif
redir_exe = files('aux' / 'redir_exe.sh')
chdir_meson_build_subdir = files('aux' / 'chdir_meson_build_subdir.sh')
libpam_private_inc = include_directories('libpam')
libpam_inc = include_directories('libpam' / 'include')
subdir('po')
subdir('libpam_internal')
subdir('libpam')
subdir('libpamc')
subdir('libpam_misc')
if enable_docs
subdir('doc')
endif
subdir('tests')
subdir('modules')
subdir('conf' / 'pam_conv1')
if get_option('examples')
subdir('examples')
endif
if get_option('xtests')
subdir('xtests')
endif