forked from i3/i3lock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
137 lines (114 loc) · 3.73 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
# -*- mode: meson -*-
# Style objective: be consistent with what mesonbuild.com documents/uses, and/or
# the meson book: https://meson-manual.com/
project(
'i3lock',
'c',
version: '2.15',
default_options: [
'c_std=c11',
'warning_level=1', # enable all warnings (-Wall)
# TODO(https://github.com/i3/i3/issues/4087): switch to
# 'buildtype=debugoptimized',
],
# Ubuntu 18.04 (supported until 2023) has meson 0.45.
# We can revisit our minimum supported meson version
# if it turns out to be too hard to maintain.
meson_version: '>=0.45.0',
)
cc = meson.get_compiler('c')
add_project_arguments(cc.get_supported_arguments(['-Wunused-value']), language: 'c')
if meson.version().version_compare('>=0.48.0')
# https://github.com/mesonbuild/meson/issues/2166#issuecomment-629696911
meson.add_dist_script('meson/meson-dist-script')
else
message('meson <0.48.0 detected, dist tarballs will not be filtered')
endif
################################################################################
# Version handling
################################################################################
cdata = configuration_data()
version_array = meson.project_version().split('.')
cdata.set_quoted('I3LOCK_VERSION', '@VCS_TAG@')
cdata.set_quoted('SYSCONFDIR', join_paths(get_option('prefix'), get_option('sysconfdir')))
if get_option('b_sanitize').split(',').contains('address')
cdata.set('I3LOCK_ASAN_ENABLED', 1)
endif
cdata.set('HAVE_STRNDUP', cc.has_function('strndup'))
cdata.set('HAVE_MKDIRP', cc.has_function('mkdirp'))
# Instead of generating config.h directly, make vcs_tag generate it so that
# @VCS_TAG@ is replaced.
config_h_in = configure_file(
output: 'config.h.in',
configuration: cdata,
)
config_h = declare_dependency(
sources: vcs_tag(
input: config_h_in,
output: 'config.h',
fallback: meson.project_version() + '-non-git',
)
)
################################################################################
# manpages
################################################################################
install_man('i3lock.1')
# Required for e.g. struct ucred to be defined as per unix(7).
add_project_arguments('-D_GNU_SOURCE', language: 'c')
# https://mesonbuild.com/howtox.html#add-math-library-lm-portably
m_dep = cc.find_library('m', required: false)
rt_dep = cc.find_library('rt', required: false)
xcb_dep = dependency('xcb', method: 'pkg-config')
xcb_xkb_dep = dependency('xcb-xkb', method: 'pkg-config')
xcb_xinerama_dep = dependency('xcb-xinerama', method: 'pkg-config')
xcb_randr_dep = dependency('xcb-randr', method: 'pkg-config')
xcb_image_dep = dependency('xcb-image', method: 'pkg-config')
xcb_util_dep = dependency('xcb-util', method: 'pkg-config')
xcb_util_xrm_dep = dependency('xcb-xrm', method: 'pkg-config')
xkbcommon_dep = dependency('xkbcommon', method: 'pkg-config')
xkbcommon_x11_dep = dependency('xkbcommon-x11', method: 'pkg-config')
cairo_dep = dependency('cairo', version: '>=1.14.4', method: 'pkg-config')
i3lock_srcs = [
'dpi.c',
'i3lock.c',
'randr.c',
'unlock_indicator.c',
'xcb.c',
]
ev_dep = cc.find_library('ev')
thread_dep = dependency('threads')
i3lock_deps = [
thread_dep,
m_dep,
rt_dep,
ev_dep,
config_h,
cairo_dep,
xcb_dep,
xcb_xkb_dep,
xcb_xinerama_dep,
xcb_randr_dep,
xcb_image_dep,
xcb_util_dep,
xcb_util_xrm_dep,
xkbcommon_dep,
xkbcommon_x11_dep,
]
host_os = host_machine.system()
if host_os != 'openbsd'
pam_dep = cc.find_library('pam', required: true)
i3lock_deps += [pam_dep]
endif
inc = include_directories('include')
executable(
'i3lock',
i3lock_srcs,
install: true,
include_directories: inc,
dependencies: i3lock_deps,
)
install_subdir(
'pam',
strip_directory: true,
install_dir: join_paths(get_option('sysconfdir'), 'pam.d'),
)