@@ -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,20 +210,20 @@ 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
- config_h .set(' HAVE_PIDFD_OPEN' , cc.get_define(' SYS_pidfd_open' , prefix : ' #include <sys/syscall.h>' ) != '' )
219
+ config_data .set(' HAVE_PIDFD_OPEN' , cc.get_define(' SYS_pidfd_open' , prefix : ' #include <sys/syscall.h>' ) != '' )
224
220
225
221
# User for running polkitd
226
222
polkitd_user = get_option (' polkitd_user' )
227
- config_h .set_quoted(' POLKITD_USER' , polkitd_user)
223
+ config_data .set_quoted(' POLKITD_USER' , polkitd_user)
228
224
229
225
polkitd_uid = get_option (' polkitd_uid' )
230
- config_h .set(' POLKITD_UID' , polkitd_uid)
226
+ config_data .set(' POLKITD_UID' , polkitd_uid)
231
227
232
228
# Select which authentication framework to use
233
229
auth_deps = []
@@ -253,7 +249,7 @@ if enable_pam
253
249
# FIXME: Not necessary anymore?
254
250
if cc.compiles(pam_strerror_src.format(' pam_handle_t *pamh = 0; char *s = pam_strerror(pamh, PAM_SUCCESS);' ))
255
251
# FIXME: unused?
256
- config_h .set(' PAM_STRERROR_TWO_ARGS' , true )
252
+ config_data .set(' PAM_STRERROR_TWO_ARGS' , true )
257
253
else
258
254
message (' how to call pam_strerror: ' + cc.compiles(pam_strerror_src.format(' char *s = pam_strerror(PAM_SUCCESS);' )).to_string(' 1' , ' unknown' ))
259
255
endif
@@ -274,7 +270,7 @@ if enable_pam
274
270
elif auth_fw == ' shadow'
275
271
auth_deps += cc.find_library (' crypt' )
276
272
endif
277
- config_h .set(' POLKIT_AUTHFW_' + auth_fw.to_upper(), true )
273
+ config_data .set(' POLKIT_AUTHFW_' + auth_fw.to_upper(), true )
278
274
279
275
# FIXME: sigtimedwait is not used anywhere?
280
276
'''
@@ -355,6 +351,16 @@ if enable_introspection
355
351
dependency (' gobject-introspection-1.0' , version : ' >= 0.6.2' )
356
352
endif
357
353
354
+ config_h = configure_file (
355
+ output : ' config.h' ,
356
+ configuration : config_data,
357
+ )
358
+
359
+ compiler_common_flags += [' -include' , config_h.full_path()]
360
+
361
+ add_project_arguments (compiler_common_flags + compiler_c_flags, language : ' c' )
362
+ add_project_arguments (compiler_common_flags + compiler_cpp_flags, language : ' cpp' )
363
+
358
364
content_files = files (' COPYING' )
359
365
360
366
subdir (' actions' )
@@ -368,12 +374,6 @@ if enable_tests
368
374
subdir (' test' )
369
375
endif
370
376
371
- configure_file (
372
- output : ' config.h' ,
373
- configuration : config_h,
374
- )
375
-
376
-
377
377
if not libs_only
378
378
meson .add_install_script(
379
379
' meson_post_install.py' ,
0 commit comments