@@ -64,7 +64,7 @@ top_inc = include_directories('.')
64
64
65
65
cc = meson .get_compiler(' c' )
66
66
67
- config_h = configuration_data ()
67
+ config_data = configuration_data ()
68
68
69
69
# defines
70
70
set_defines = [
@@ -79,11 +79,11 @@ set_defines = [
79
79
]
80
80
81
81
foreach define : set_defines
82
- config_h .set_quoted(define[0 ], define[1 ])
82
+ config_data .set_quoted(define[0 ], define[1 ])
83
83
endforeach
84
84
85
85
# Globally define_GNU_SOURCE and therefore enable the GNU extensions
86
- config_h .set(' _GNU_SOURCE' , true )
86
+ config_data .set(' _GNU_SOURCE' , true )
87
87
88
88
# functions
89
89
check_functions = [
@@ -93,19 +93,17 @@ check_functions = [
93
93
]
94
94
95
95
foreach func : check_functions
96
- config_h .set(' HAVE_' + func.to_upper(), cc.has_function(func))
96
+ config_data .set(' HAVE_' + func.to_upper(), cc.has_function(func))
97
97
endforeach
98
98
99
- # compiler flags
100
- common_c_flags = [
99
+ compiler_common_flags = []
100
+ compiler_c_flags = [
101
101
# FIXME: this should go as 'c_std=c99' in project's default_options.
102
102
# https://github.com/mesonbuild/meson/issues/1889
103
103
# https://github.com/mesonbuild/meson/pull/6729
104
104
' -std=c99' ,
105
- ' -DHAVE_CONFIG_H' ,
106
105
]
107
- compiler_flags = []
108
- compiler_c_flags = []
106
+ compiler_cpp_flags = []
109
107
110
108
if get_option (' buildtype' ).contains(' debug' )
111
109
compiler_c_flags += cc.get_supported_arguments([
@@ -121,8 +119,6 @@ if get_option('buildtype').contains('debug')
121
119
])
122
120
endif
123
121
124
- add_project_arguments (common_c_flags + compiler_c_flags, language : ' c' )
125
-
126
122
glib_req_version = ' >= 2.30.0'
127
123
128
124
gio_dep = dependency (' gio-2.0' , version : glib_req_version)
@@ -151,13 +147,13 @@ if js_engine == 'duktape'
151
147
libm_dep = cc.find_library (' m' )
152
148
thread_dep = dependency (' threads' )
153
149
func = ' pthread_condattr_setclock'
154
- config_h .set(' HAVE_' + func.to_upper(), cc.has_function(func, prefix : ' #include <pthread.h>' ))
150
+ config_data .set(' HAVE_' + func.to_upper(), cc.has_function(func, prefix : ' #include <pthread.h>' ))
155
151
elif js_engine == ' mozjs'
156
152
js_dep = dependency (' mozjs-115' )
157
153
158
154
_system = host_machine .system().to_lower()
159
155
if _system.contains(' freebsd' )
160
- config_h .set(' __BSD_VISIBLE' , 1 )
156
+ config_data .set(' __BSD_VISIBLE' , 1 )
161
157
endif
162
158
endif
163
159
@@ -172,12 +168,12 @@ endif
172
168
173
169
# check OS
174
170
host_system = host_machine .system()
175
- config_h .set(' HAVE_' + host_system.to_upper(), true )
171
+ config_data .set(' HAVE_' + host_system.to_upper(), true )
176
172
177
173
# Check whether setnetgrent has a return value
178
- config_h .set(' HAVE_NETGROUP_H' , cc.has_header(' netgroup.h' ))
174
+ config_data .set(' HAVE_NETGROUP_H' , cc.has_header(' netgroup.h' ))
179
175
180
- if config_h .get(' HAVE_SETNETGRENT' , false )
176
+ if config_data .get(' HAVE_SETNETGRENT' , false )
181
177
setnetgrent_return_src = '''
182
178
#include <stddef.h>
183
179
#ifdef HAVE_NETGROUP_H
@@ -190,7 +186,7 @@ if config_h.get('HAVE_SETNETGRENT', false)
190
186
};
191
187
'''
192
188
193
- config_h .set(' HAVE_SETNETGRENT_RETURN' , cc.compiles(setnetgrent_return_src, name : ' setnetgrent return support' ))
189
+ config_data .set(' HAVE_SETNETGRENT_RETURN' , cc.compiles(setnetgrent_return_src, name : ' setnetgrent return support' ))
194
190
endif
195
191
196
192
# Select wether to use logind, elogind or ConsoleKit for session tracking
@@ -214,11 +210,11 @@ if enable_logind
214
210
endif
215
211
216
212
func = ' sd_uid_get_display'
217
- config_h .set10(' HAVE_' + func.to_upper(), cc.has_function(func, dependencies : logind_dep))
213
+ config_data .set10(' HAVE_' + func.to_upper(), cc.has_function(func, dependencies : logind_dep))
218
214
func = ' sd_pidfd_get_session'
219
- config_h .set10(' HAVE_' + func.to_upper(), cc.has_function(func, dependencies : logind_dep))
215
+ config_data .set10(' HAVE_' + func.to_upper(), cc.has_function(func, dependencies : logind_dep))
220
216
endif
221
- config_h .set(' HAVE_LIBSYSTEMD' , enable_logind)
217
+ config_data .set(' HAVE_LIBSYSTEMD' , enable_logind)
222
218
223
219
systemd_dep = dependency (' systemd' ).found()
224
220
if systemd_dep
@@ -232,14 +228,14 @@ if systemd_dep
232
228
)
233
229
endif
234
230
235
- config_h .set(' HAVE_PIDFD_OPEN' , cc.get_define(' SYS_pidfd_open' , prefix : ' #include <sys/syscall.h>' ) != '' )
231
+ config_data .set(' HAVE_PIDFD_OPEN' , cc.get_define(' SYS_pidfd_open' , prefix : ' #include <sys/syscall.h>' ) != '' )
236
232
237
233
# User for running polkitd
238
234
polkitd_user = get_option (' polkitd_user' )
239
- config_h .set_quoted(' POLKITD_USER' , polkitd_user)
235
+ config_data .set_quoted(' POLKITD_USER' , polkitd_user)
240
236
241
237
polkitd_uid = get_option (' polkitd_uid' )
242
- config_h .set(' POLKITD_UID' , polkitd_uid)
238
+ config_data .set(' POLKITD_UID' , polkitd_uid)
243
239
244
240
# Select which authentication framework to use
245
241
auth_deps = []
@@ -265,7 +261,7 @@ if enable_pam
265
261
# FIXME: Not necessary anymore?
266
262
if cc.compiles(pam_strerror_src.format(' pam_handle_t *pamh = 0; char *s = pam_strerror(pamh, PAM_SUCCESS);' ))
267
263
# FIXME: unused?
268
- config_h .set(' PAM_STRERROR_TWO_ARGS' , true )
264
+ config_data .set(' PAM_STRERROR_TWO_ARGS' , true )
269
265
else
270
266
message (' how to call pam_strerror: ' + cc.compiles(pam_strerror_src.format(' char *s = pam_strerror(PAM_SUCCESS);' )).to_string(' 1' , ' unknown' ))
271
267
endif
@@ -286,7 +282,7 @@ if enable_pam
286
282
elif auth_fw == ' shadow'
287
283
auth_deps += cc.find_library (' crypt' )
288
284
endif
289
- config_h .set(' POLKIT_AUTHFW_' + auth_fw.to_upper(), true )
285
+ config_data .set(' POLKIT_AUTHFW_' + auth_fw.to_upper(), true )
290
286
291
287
# FIXME: sigtimedwait is not used anywhere?
292
288
'''
@@ -367,6 +363,16 @@ if enable_introspection
367
363
dependency (' gobject-introspection-1.0' , version : ' >= 0.6.2' )
368
364
endif
369
365
366
+ configure_file (
367
+ output : ' config.h' ,
368
+ configuration : config_data,
369
+ )
370
+
371
+ compiler_common_flags += [' -include' , ' config.h' ]
372
+
373
+ add_project_arguments (compiler_common_flags + compiler_c_flags, language : ' c' )
374
+ add_project_arguments (compiler_common_flags + compiler_cpp_flags, language : ' cpp' )
375
+
370
376
content_files = files (' COPYING' )
371
377
372
378
subdir (' actions' )
@@ -380,12 +386,6 @@ if enable_tests
380
386
subdir (' test' )
381
387
endif
382
388
383
- configure_file (
384
- output : ' config.h' ,
385
- configuration : config_h,
386
- )
387
-
388
-
389
389
if not libs_only
390
390
meson .add_install_script(
391
391
' meson_post_install.py' ,
0 commit comments