summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build130
1 files changed, 130 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c3b4dc8
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,130 @@
1# -*- mode: meson -*-
2
3# Style objective: be consistent with what mesonbuild.com documents/uses, and/or
4# the meson book: https://meson-manual.com/
5
6project(
7 'i3lock-extended',
8 'c',
9 version: '2.2.14',
10 default_options: [
11 'c_std=c11',
12 'warning_level=1', # enable all warnings (-Wall)
13 ],
14 # Ubuntu 18.04 (supported until 2023) has meson 0.45.
15 # We can revisit our minimum supported meson version
16 # if it turns out to be too hard to maintain.
17 meson_version: '>=0.45.0',
18)
19
20cc = meson.get_compiler('c')
21add_project_arguments(cc.get_supported_arguments(['-Wunused-value']), language: 'c')
22
23if meson.version().version_compare('>=0.48.0')
24 # https://github.com/mesonbuild/meson/issues/2166#issuecomment-629696911
25 meson.add_dist_script('meson/meson-dist-script')
26else
27 message('meson <0.48.0 detected, dist tarballs will not be filtered')
28endif
29
30################################################################################
31# Version handling
32################################################################################
33
34cdata = configuration_data()
35
36version_array = meson.project_version().split('.')
37cdata.set_quoted('I3LOCK_VERSION', meson.project_version())
38cdata.set_quoted('SYSCONFDIR', join_paths(get_option('prefix'), get_option('sysconfdir')))
39
40if get_option('b_sanitize').split(',').contains('address')
41 cdata.set('I3LOCK_ASAN_ENABLED', 1)
42endif
43
44cdata.set('HAVE_STRNDUP', cc.has_function('strndup'))
45cdata.set('HAVE_MKDIRP', cc.has_function('mkdirp'))
46
47config_h = configure_file(
48 output: 'config.h',
49 configuration: cdata,
50)
51
52config_h = declare_dependency(sources: config_h)
53
54################################################################################
55# manpages
56################################################################################
57
58install_man('i3lock-extended.1')
59
60# Required for e.g. struct ucred to be defined as per unix(7).
61add_project_arguments('-D_GNU_SOURCE', language: 'c')
62add_project_arguments('-DEXTRAS', language: 'c')
63
64# https://mesonbuild.com/howtox.html#add-math-library-lm-portably
65m_dep = cc.find_library('m', required: false)
66rt_dep = cc.find_library('rt', required: false)
67
68xcb_dep = dependency('xcb', method: 'pkg-config')
69xcb_xkb_dep = dependency('xcb-xkb', method: 'pkg-config')
70xcb_xinerama_dep = dependency('xcb-xinerama', method: 'pkg-config')
71xcb_randr_dep = dependency('xcb-randr', method: 'pkg-config')
72xcb_image_dep = dependency('xcb-image', method: 'pkg-config')
73xcb_util_dep = dependency('xcb-util', method: 'pkg-config')
74xcb_util_xrm_dep = dependency('xcb-xrm', method: 'pkg-config')
75xkbcommon_dep = dependency('xkbcommon', method: 'pkg-config')
76xkbcommon_x11_dep = dependency('xkbcommon-x11', method: 'pkg-config')
77cairo_dep = dependency('cairo', version: '>=1.14.4', method: 'pkg-config')
78
79i3lock_srcs = [
80 'dpi.c',
81 'extras.c',
82 'i3lock.c',
83 'randr.c',
84 'unlock_indicator.c',
85 'xcb.c',
86]
87
88ev_dep = cc.find_library('ev')
89
90thread_dep = dependency('threads')
91
92i3lock_deps = [
93 thread_dep,
94 m_dep,
95 rt_dep,
96 ev_dep,
97 config_h,
98 cairo_dep,
99 xcb_dep,
100 xcb_xkb_dep,
101 xcb_xinerama_dep,
102 xcb_randr_dep,
103 xcb_image_dep,
104 xcb_util_dep,
105 xcb_util_xrm_dep,
106 xkbcommon_dep,
107 xkbcommon_x11_dep,
108]
109
110host_os = host_machine.system()
111if host_os != 'openbsd'
112 pam_dep = cc.find_library('pam', required: true)
113 i3lock_deps += [pam_dep]
114endif
115
116inc = include_directories('include')
117
118executable(
119 'i3lock-extended',
120 i3lock_srcs,
121 install: true,
122 include_directories: inc,
123 dependencies: i3lock_deps,
124)
125
126install_subdir(
127 'pam',
128 strip_directory: true,
129 install_dir: join_paths(get_option('sysconfdir'), 'pam.d'),
130)