Skip to content

Commit f3d16aa

Browse files
authored
Merge pull request #1226 from apprehensions/master
Add initial meson support
2 parents 49acb50 + ee5b45b commit f3d16aa

File tree

12 files changed

+338
-6
lines changed

12 files changed

+338
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ core
1010
vgcore.*
1111

1212
/docs/*.1
13+
/docs/dunst.1.pod
1314
/docs/*.5
1415
/docs/internal/coverage
1516
/docs/internal/html

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ doc: docs/dunst.1 docs/dunst.5 docs/dunstctl.1 docs/dunstify.1
138138

139139
# Can't dedup this as we need to explicitly provide the name and title text to
140140
# pod2man :(
141+
docs/dunst.1.pod: docs/dunst.1.pod.in
142+
${SED} "s|@sysconfdir@|${SYSCONFDIR}|" $< > $@
141143
docs/dunst.1: docs/dunst.1.pod
142-
${SED} "s|##SYSCONFDIR##|${SYSCONFDIR}|" $< | ${POD2MAN} --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} > $@
144+
${POD2MAN} --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@
143145
docs/dunst.5: docs/dunst.5.pod
144146
${POD2MAN} --name=dunst -c "Dunst Reference" --section=5 --release=${VERSION} $< > $@
145147
docs/dunstctl.1: docs/dunstctl.pod
@@ -153,11 +155,11 @@ doc-doxygen:
153155
.PHONY: service service-dbus service-systemd wayland-protocols
154156
service: service-dbus
155157
service-dbus:
156-
@${SED} "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service
158+
@${SED} "s|@bindir@|$(BINDIR)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service
157159
ifneq (0,${SYSTEMD})
158160
service: service-systemd
159161
service-systemd:
160-
@${SED} "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service
162+
@${SED} "s|@bindir@|$(BINDIR)|" dunst.systemd.service.in > dunst.systemd.service
161163
endif
162164

163165
ifneq (0,${WAYLAND})

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,25 @@ The names will be different depending on your [distribution](https://github.com/
102102

103103
### Building
104104

105+
#### Makefile
106+
105107
```
106108
git clone https://github.com/dunst-project/dunst.git
107109
cd dunst
108110
make
109111
sudo make install
110112
```
111113

114+
#### Meson
115+
116+
```
117+
meson setup build
118+
ninja -C build
119+
ninja -C build install
120+
```
121+
122+
Custom Meson build parameters can be found in [meson_options.txt](meson_options.txt).
123+
112124
### Make parameters
113125

114126
- `DESTDIR=<PATH>`: Set the destination directory of the installation. (Default: `/`)

docs/dunst.1.pod renamed to docs/dunst.1.pod.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Set notification timeout time.
9292

9393
=head1 CONFIGURATION
9494

95-
A default configuration file is included (usually ##SYSCONFDIR##/dunst/dunstrc)
95+
A default configuration file is included (usually @sysconfdir@/dunst/dunstrc)
9696
and serves as the least important configuration file. Note: this was previously
9797
/usr/share/dunst/dunstrc. You can edit this file to change the system-wide
9898
defaults or copy it to a more important location to override its settings. See
@@ -145,7 +145,7 @@ This is the most important directory. (C<$HOME/.config> if unset or empty)
145145

146146
This, like C<$PATH> for instance, is a :-separated list of base directories
147147
in I<descending order of importance>.
148-
(F<##SYSCONFDIR##> if unset or empty)
148+
(F<@sysconfdir@> if unset or empty)
149149

150150
=back
151151

docs/meson.build

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
man1 = get_option('mandir') / 'man1'
2+
man5 = get_option('mandir') / 'man5'
3+
pod2man_version_arg = '--release=@0@'.format(meson.project_version())
4+
5+
dunst1 = configure_file(
6+
input: 'dunst.1.pod.in',
7+
output: 'dunst.1.pod',
8+
configuration: conf_data,
9+
)
10+
11+
custom_target(
12+
'dunst1_pod2man',
13+
input: dunst1,
14+
output: 'dunst.1',
15+
command: [
16+
pod2man,
17+
'--name=dunst',
18+
'--center=Dunst Reference',
19+
'--section=1',
20+
pod2man_version_arg,
21+
'@INPUT@',
22+
'@OUTPUT@',
23+
],
24+
install: true,
25+
install_dir: man1,
26+
)
27+
28+
custom_target(
29+
'dunst5_pod2man',
30+
input: 'dunst.5.pod',
31+
output: 'dunst.5',
32+
command: [
33+
pod2man,
34+
'--name=dunst',
35+
'--center=Dunst Reference',
36+
'--section=5',
37+
pod2man_version_arg,
38+
'@INPUT@',
39+
'@OUTPUT@',
40+
],
41+
install: true,
42+
install_dir: man5,
43+
)
44+
45+
custom_target(
46+
'dunstctl_pod2man',
47+
input: 'dunstctl.pod',
48+
output: 'dunstctl.1',
49+
command: [
50+
pod2man,
51+
'--name=dunst',
52+
'--center=dunstctl Reference',
53+
'--section=1',
54+
pod2man_version_arg,
55+
'@INPUT@',
56+
'@OUTPUT@',
57+
],
58+
install: true,
59+
install_dir: man1,
60+
)

dunst.systemd.service.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ PartOf=graphical-session.target
77
Type=dbus
88
BusName=org.freedesktop.Notifications
99
ExecStart=##PREFIX##/bin/dunst
10+
ExecStart=@bindir@/dunst
1011
Slice=session.slice

meson.build

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
project(
2+
'dunst',
3+
'c',
4+
version: '1.9.2',
5+
license: 'MIT',
6+
meson_version: '>=0.60.0',
7+
default_options: [
8+
'c_std=gnu11',
9+
'warning_level=1',
10+
'b_ndebug=if-release',
11+
],
12+
)
13+
14+
cc = meson.get_compiler('c')
15+
16+
cairo = dependency('cairo')
17+
glib = dependency('glib-2.0')
18+
gio = dependency('gio-2.0')
19+
gdk_pixbuf = dependency('gdk-pixbuf-2.0')
20+
pangocairo = dependency('pangocairo')
21+
x11 = dependency('x11', required: get_option('x11'))
22+
xinerama = dependency('xinerama', required: get_option('x11'))
23+
xext = dependency('xext', required: get_option('x11'))
24+
xrandr = dependency('xrandr', required: get_option('x11'), version: '>=1.5')
25+
xscrnsaver = dependency('xscrnsaver', required: get_option('x11'))
26+
systemd = dependency('systemd', required: get_option('systemd'))
27+
libnotify = dependency('libnotify', required: get_option('dunstify'))
28+
realtime = cc.find_library('rt')
29+
math = cc.find_library('m')
30+
wayland_client = dependency('wayland-client', required: get_option('wayland'))
31+
wayland_protos = dependency('wayland-protocols', version: '>=1.12', required: get_option('wayland'))
32+
wayland_cursor = dependency('wayland-cursor', required: get_option('wayland'))
33+
34+
dunst_depends = [
35+
cairo,
36+
glib,
37+
gio,
38+
gdk_pixbuf,
39+
pangocairo,
40+
systemd,
41+
libnotify,
42+
realtime,
43+
math,
44+
]
45+
46+
x11_support = x11.found() and xinerama.found() and xext.found() and xrandr.found() and xscrnsaver.found()
47+
wayland_support = wayland_client.found() and wayland_cursor.found() and wayland_protos.found()
48+
49+
if not x11_support and not wayland_support
50+
error('either wayland or x11 support is required')
51+
endif
52+
53+
if wayland_support and not x11_support
54+
add_project_arguments('-DWAYLAND_ONLY', language: 'c')
55+
endif
56+
57+
if x11_support
58+
dunst_depends += [x11, xinerama, xext, xrandr, xscrnsaver]
59+
add_project_arguments('-DENABLE_X11', language: 'c')
60+
endif
61+
62+
if wayland_support
63+
dunst_depends += [wayland_client, wayland_cursor]
64+
add_project_arguments('-DENABLE_WAYLAND', language: 'c')
65+
endif
66+
67+
c_version_arg = '-DVERSION="@0@"'.format(meson.project_version())
68+
sysconfdir = get_option('sysconfdir') / 'xdg'
69+
70+
add_project_arguments(
71+
'-DSYSCONFDIR="@0@"'.format(get_option('prefix') / sysconfdir),
72+
language: 'c',
73+
)
74+
75+
subdir('src')
76+
77+
install_data('dunstctl', install_dir: get_option('bindir'))
78+
install_data('dunstrc', install_dir: sysconfdir / 'dunst')
79+
80+
conf_data = configuration_data()
81+
conf_data.set('bindir', get_option('bindir'))
82+
conf_data.set('sysconfdir', sysconfdir)
83+
84+
configure_file(
85+
input: 'org.knopwob.dunst.service.in',
86+
output: 'dunst.service',
87+
configuration: conf_data,
88+
install_dir: get_option('datadir') / 'dbus-1/services',
89+
)
90+
91+
if systemd.found()
92+
user_units_dir = systemd.get_variable(pkgconfig: 'systemduserunitdir')
93+
configure_file(
94+
configuration: conf_data,
95+
input: 'dunst.systemd.service.in',
96+
output: '@BASENAME@',
97+
install_dir: user_units_dir,
98+
)
99+
endif
100+
101+
if libnotify.found()
102+
executable(
103+
'dunstify',
104+
'dunstify.c',
105+
dependencies: [glib, libnotify, gdk_pixbuf],
106+
install: true,
107+
)
108+
endif
109+
110+
subdir('test')
111+
112+
pod2man = find_program('pod2man', native: true, required: get_option('docs'))
113+
if pod2man.found()
114+
subdir('docs')
115+
endif
116+
117+
summary(
118+
{
119+
'X11 support': x11_support,
120+
'Wayland support': wayland_support,
121+
'Man pages': pod2man.found(),
122+
'Dunstify': libnotify.found(),
123+
'Install systemd service units': systemd.found(),
124+
},
125+
bool_yn: true,
126+
)

meson_options.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
option('docs', type: 'feature', value: 'auto', description: 'Generate and install man pages')
2+
option('wayland', type: 'feature', value: 'auto', description: 'Enable wayland support')
3+
option('x11', type: 'feature', value: 'auto', description: 'Enable X11 support')
4+
option('dunstify', type: 'feature', value: 'auto', description: 'Install libnotify dunstify utility')
5+
option('systemd', type: 'feature', value: 'auto', description: 'Install systemd user service unit')

org.knopwob.dunst.service.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[D-BUS Service]
22
Name=org.freedesktop.Notifications
3-
Exec=##PREFIX##/bin/dunst
3+
Exec=@bindir@/dunst
44
SystemdService=dunst.service

src/meson.build

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
dunst_src_files = files(
2+
'dbus.c',
3+
'draw.c',
4+
'dunst.c',
5+
'icon-lookup.c',
6+
'icon.c',
7+
'ini.c',
8+
'input.c',
9+
'log.c',
10+
'markup.c',
11+
'menu.c',
12+
'notification.c',
13+
'option_parser.c',
14+
'output.c',
15+
'queues.c',
16+
'rules.c',
17+
'settings.c',
18+
'utils.c',
19+
)
20+
21+
if x11_support
22+
dunst_src_files += files(
23+
'x11/screen.c',
24+
'x11/x.c',
25+
)
26+
endif
27+
28+
if wayland_support
29+
subdir('wayland/protocols')
30+
31+
dunst_src_files += files(
32+
'wayland/foreign_toplevel.c',
33+
'wayland/libgwater-wayland.c',
34+
'wayland/pool-buffer.c',
35+
'wayland/wl.c',
36+
'wayland/wl_output.c',
37+
'wayland/wl_seat.c',
38+
)
39+
endif
40+
41+
executable(
42+
'dunst',
43+
'../main.c',
44+
dunst_src_files,
45+
dependencies: dunst_depends,
46+
c_args: c_version_arg,
47+
install: true,
48+
)

0 commit comments

Comments
 (0)