@@ -64,7 +64,7 @@ top_inc = include_directories('.')
6464
6565cc = meson .get_compiler(' c' )
6666
67- config_h = configuration_data ()
67+ config_data = configuration_data ()
6868
6969# defines
7070set_defines = [
@@ -79,11 +79,11 @@ set_defines = [
7979]
8080
8181foreach define : set_defines
82- config_h .set_quoted(define[0 ], define[1 ])
82+ config_data .set_quoted(define[0 ], define[1 ])
8383endforeach
8484
8585# Globally define_GNU_SOURCE and therefore enable the GNU extensions
86- config_h .set(' _GNU_SOURCE' , true )
86+ config_data .set(' _GNU_SOURCE' , true )
8787
8888# functions
8989check_functions = [
@@ -93,19 +93,17 @@ check_functions = [
9393]
9494
9595foreach 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))
9797endforeach
9898
99- # compiler flags
100- common_c_flags = [
99+ compiler_common_flags = []
100+ compiler_c_flags = [
101101 # FIXME: this should go as 'c_std=c99' in project's default_options.
102102 # https://github.com/mesonbuild/meson/issues/1889
103103 # https://github.com/mesonbuild/meson/pull/6729
104104 ' -std=c99' ,
105- ' -DHAVE_CONFIG_H' ,
106105]
107- compiler_flags = []
108- compiler_c_flags = []
106+ compiler_cpp_flags = []
109107
110108if get_option (' buildtype' ).contains(' debug' )
111109 compiler_c_flags += cc.get_supported_arguments([
@@ -121,8 +119,6 @@ if get_option('buildtype').contains('debug')
121119 ])
122120endif
123121
124- add_project_arguments (common_c_flags + compiler_c_flags, language : ' c' )
125-
126122glib_req_version = ' >= 2.30.0'
127123
128124gio_dep = dependency (' gio-2.0' , version : glib_req_version)
@@ -151,13 +147,13 @@ if js_engine == 'duktape'
151147 libm_dep = cc.find_library (' m' )
152148 thread_dep = dependency (' threads' )
153149 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>' ))
155151elif js_engine == ' mozjs'
156152 js_dep = dependency (' mozjs-115' )
157153
158154 _system = host_machine .system().to_lower()
159155 if _system.contains(' freebsd' )
160- config_h .set(' __BSD_VISIBLE' , 1 )
156+ config_data .set(' __BSD_VISIBLE' , 1 )
161157 endif
162158endif
163159
@@ -172,12 +168,12 @@ endif
172168
173169# check OS
174170host_system = host_machine .system()
175- config_h .set(' HAVE_' + host_system.to_upper(), true )
171+ config_data .set(' HAVE_' + host_system.to_upper(), true )
176172
177173# 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' ))
179175
180- if config_h .get(' HAVE_SETNETGRENT' , false )
176+ if config_data .get(' HAVE_SETNETGRENT' , false )
181177 setnetgrent_return_src = '''
182178 #include <stddef.h>
183179 #ifdef HAVE_NETGROUP_H
@@ -190,7 +186,7 @@ if config_h.get('HAVE_SETNETGRENT', false)
190186 };
191187 '''
192188
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' ))
194190endif
195191
196192# Select wether to use logind, elogind or ConsoleKit for session tracking
@@ -214,11 +210,11 @@ if enable_logind
214210 endif
215211
216212 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))
218214 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))
220216endif
221- config_h .set(' HAVE_LIBSYSTEMD' , enable_logind)
217+ config_data .set(' HAVE_LIBSYSTEMD' , enable_logind)
222218
223219systemd_dep = dependency (' systemd' ).found()
224220if systemd_dep
@@ -232,14 +228,14 @@ if systemd_dep
232228 )
233229endif
234230
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>' ) != '' )
236232
237233# User for running polkitd
238234polkitd_user = get_option (' polkitd_user' )
239- config_h .set_quoted(' POLKITD_USER' , polkitd_user)
235+ config_data .set_quoted(' POLKITD_USER' , polkitd_user)
240236
241237polkitd_uid = get_option (' polkitd_uid' )
242- config_h .set(' POLKITD_UID' , polkitd_uid)
238+ config_data .set(' POLKITD_UID' , polkitd_uid)
243239
244240# Select which authentication framework to use
245241auth_deps = []
@@ -265,7 +261,7 @@ if enable_pam
265261 # FIXME: Not necessary anymore?
266262 if cc.compiles(pam_strerror_src.format(' pam_handle_t *pamh = 0; char *s = pam_strerror(pamh, PAM_SUCCESS);' ))
267263 # FIXME: unused?
268- config_h .set(' PAM_STRERROR_TWO_ARGS' , true )
264+ config_data .set(' PAM_STRERROR_TWO_ARGS' , true )
269265 else
270266 message (' how to call pam_strerror: ' + cc.compiles(pam_strerror_src.format(' char *s = pam_strerror(PAM_SUCCESS);' )).to_string(' 1' , ' unknown' ))
271267 endif
@@ -286,7 +282,7 @@ if enable_pam
286282elif auth_fw == ' shadow'
287283 auth_deps += cc.find_library (' crypt' )
288284endif
289- config_h .set(' POLKIT_AUTHFW_' + auth_fw.to_upper(), true )
285+ config_data .set(' POLKIT_AUTHFW_' + auth_fw.to_upper(), true )
290286
291287# FIXME: sigtimedwait is not used anywhere?
292288'''
@@ -367,6 +363,16 @@ if enable_introspection
367363 dependency (' gobject-introspection-1.0' , version : ' >= 0.6.2' )
368364endif
369365
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+
370376content_files = files (' COPYING' )
371377
372378subdir (' actions' )
@@ -380,12 +386,6 @@ if enable_tests
380386 subdir (' test' )
381387endif
382388
383- configure_file (
384- output : ' config.h' ,
385- configuration : config_h,
386- )
387-
388-
389389if not libs_only
390390 meson .add_install_script(
391391 ' meson_post_install.py' ,
0 commit comments