Skip to content

Commit f7668d9

Browse files
authored
Merge pull request #148 from francma/etc-prefix
Respect prefix when searching for global (sysconfdir) wob.ini
2 parents 6d4fd4b + cb02c40 commit f7668d9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

meson.build

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ add_project_arguments(
2525
)
2626

2727
cc = meson.get_compiler('c')
28+
fs = import('fs')
2829

2930
prefix = get_option('prefix')
3031

@@ -38,8 +39,16 @@ libm = cc.find_library('m')
3839
seccomp = dependency('libseccomp', required: get_option('seccomp'))
3940
inih = dependency('inih')
4041

41-
wob_version = '"@0@"'.format(meson.project_version())
42-
add_project_arguments('-DWOB_VERSION=@0@'.format(wob_version), language: 'c')
42+
sysconfdir = get_option('sysconfdir')
43+
if not fs.is_absolute(sysconfdir)
44+
sysconfdir = prefix / sysconfdir
45+
endif
46+
47+
global_configuration_h = configuration_data({
48+
'WOB_VERSION': '"@0@"'.format(meson.project_version()),
49+
'WOB_ETC_CONFIG_FOLDER_PATH': '"@0@"'.format(sysconfdir),
50+
})
51+
configure_file(output: 'global_configuration.h', configuration: global_configuration_h)
4352

4453
wayland_scanner_code = generator(
4554
wayland_scanner,

src/config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <wordexp.h>
1212

1313
#include "config.h"
14+
15+
#include "global_configuration.h"
1416
#include "log.h"
1517

1618
bool
@@ -466,7 +468,7 @@ wob_config_default_path()
466468
static const char *config_paths[] = {
467469
"$XDG_CONFIG_HOME/wob/wob.ini",
468470
"$HOME/.config/wob/wob.ini",
469-
"/etc/wob/wob.ini",
471+
WOB_ETC_CONFIG_FOLDER_PATH "/wob.ini",
470472
};
471473

472474
for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) {

src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <unistd.h>
99

1010
#include "config.h"
11+
#include "global_configuration.h"
1112
#include "log.h"
1213
#include "wob.h"
1314

0 commit comments

Comments
 (0)