Skip to content

Commit 245355d

Browse files
committed
Include config.h globally via compiler options
1 parent d89c360 commit 245355d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+37
-151
lines changed

meson.build

+31-31
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ top_inc = include_directories('.')
6464

6565
cc = meson.get_compiler('c')
6666

67-
config_h = configuration_data()
67+
config_data = configuration_data()
6868

6969
# defines
7070
set_defines = [
@@ -79,11 +79,11 @@ set_defines = [
7979
]
8080

8181
foreach define: set_defines
82-
config_h.set_quoted(define[0], define[1])
82+
config_data.set_quoted(define[0], define[1])
8383
endforeach
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
8989
check_functions = [
@@ -93,19 +93,17 @@ check_functions = [
9393
]
9494

9595
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))
9797
endforeach
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

110108
if get_option('buildtype').contains('debug')
111109
compiler_c_flags += cc.get_supported_arguments([
@@ -121,8 +119,6 @@ if get_option('buildtype').contains('debug')
121119
])
122120
endif
123121

124-
add_project_arguments(common_c_flags + compiler_c_flags, language: 'c')
125-
126122
glib_req_version = '>= 2.30.0'
127123

128124
gio_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>'))
155151
elif 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
162158
endif
163159

@@ -172,12 +168,12 @@ endif
172168

173169
# check OS
174170
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)
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'))
194190
endif
195191

196192
# Select wether to use logind, elogind or ConsoleKit for session tracking
@@ -214,20 +210,20 @@ 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))
220216
endif
221-
config_h.set('HAVE_LIBSYSTEMD', enable_logind)
217+
config_data.set('HAVE_LIBSYSTEMD', enable_logind)
222218

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>') != '')
224220

225221
# User for running polkitd
226222
polkitd_user = get_option('polkitd_user')
227-
config_h.set_quoted('POLKITD_USER', polkitd_user)
223+
config_data.set_quoted('POLKITD_USER', polkitd_user)
228224

229225
polkitd_uid = get_option('polkitd_uid')
230-
config_h.set('POLKITD_UID', polkitd_uid)
226+
config_data.set('POLKITD_UID', polkitd_uid)
231227

232228
# Select which authentication framework to use
233229
auth_deps = []
@@ -253,7 +249,7 @@ if enable_pam
253249
# FIXME: Not necessary anymore?
254250
if cc.compiles(pam_strerror_src.format('pam_handle_t *pamh = 0; char *s = pam_strerror(pamh, PAM_SUCCESS);'))
255251
# FIXME: unused?
256-
config_h.set('PAM_STRERROR_TWO_ARGS', true)
252+
config_data.set('PAM_STRERROR_TWO_ARGS', true)
257253
else
258254
message('how to call pam_strerror: ' + cc.compiles(pam_strerror_src.format('char *s = pam_strerror(PAM_SUCCESS);')).to_string('1', 'unknown'))
259255
endif
@@ -274,7 +270,7 @@ if enable_pam
274270
elif auth_fw == 'shadow'
275271
auth_deps += cc.find_library('crypt')
276272
endif
277-
config_h.set('POLKIT_AUTHFW_' + auth_fw.to_upper(), true)
273+
config_data.set('POLKIT_AUTHFW_' + auth_fw.to_upper(), true)
278274

279275
# FIXME: sigtimedwait is not used anywhere?
280276
'''
@@ -355,6 +351,16 @@ if enable_introspection
355351
dependency('gobject-introspection-1.0', version: '>= 0.6.2')
356352
endif
357353

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+
358364
content_files = files('COPYING')
359365

360366
subdir('actions')
@@ -368,12 +374,6 @@ if enable_tests
368374
subdir('test')
369375
endif
370376

371-
configure_file(
372-
output: 'config.h',
373-
configuration: config_h,
374-
)
375-
376-
377377
if not libs_only
378378
meson.add_install_script(
379379
'meson_post_install.py',

src/examples/cancel.c

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* authentication dialog is removed.
3333
*/
3434

35-
#include "config.h"
3635
#include <polkit/polkit.h>
3736

3837
static gboolean

src/examples/frobnicate.c

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#include "config.h"
23-
2422
#include <glib.h>
2523
#include <unistd.h>
2624
#include <stdlib.h>

src/polkit/polkitactiondescription.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723
#include "polkitimplicitauthorization.h"
2824
#include "polkitactiondescription.h"

src/polkit/polkitauthority.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include "polkitauthorizationresult.h"
2723
#include "polkitcheckauthorizationflags.h"
2824
#include "polkitauthority.h"

src/polkit/polkitauthorityfeatures.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include "polkitcheckauthorizationflags.h"
2723
#include "polkitprivate.h"
2824

src/polkit/polkitauthorizationresult.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include "polkitauthorizationresult.h"
2723
#include "polkitdetails.h"
2824
#include "polkitprivate.h"

src/polkit/polkitcheckauthorizationflags.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include "polkitcheckauthorizationflags.h"
2723
#include "polkitprivate.h"
2824

src/polkit/polkitdetails.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723
#include "polkitimplicitauthorization.h"
2824
#include "polkitdetails.h"

src/polkit/polkiterror.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include "polkiterror.h"
2723
#include "polkitprivate.h"
2824

src/polkit/polkitidentity.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723

2824
#include "polkitidentity.h"

src/polkit/polkitimplicitauthorization.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723

2824
#include "polkitimplicitauthorization.h"

src/polkit/polkitpermission.c

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
* David Zeuthen <[email protected]>
2121
*/
2222

23-
#ifdef HAVE_CONFIG_H
24-
# include "config.h"
25-
#endif
26-
2723
#ifdef HAVE_LIBSYSTEMD
2824
# include <systemd/sd-login.h>
2925
#endif

src/polkit/polkitsubject.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723
#include <stdio.h>
2824

src/polkit/polkitsystembusname.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723
#include <gio/gunixfdlist.h>
2824
#include "polkitsystembusname.h"

src/polkit/polkittemporaryauthorization.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723
#include "polkitimplicitauthorization.h"
2824
#include "polkittemporaryauthorization.h"

src/polkit/polkitunixgroup.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723
#include <grp.h>
2824
#include <errno.h>

src/polkit/polkitunixnetgroup.c

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
* Author: Nikki VonHollen <[email protected]>
2121
*/
2222

23-
#ifdef HAVE_CONFIG_H
24-
# include "config.h"
25-
#endif
26-
2723
#include <string.h>
2824
#include <errno.h>
2925
#include "polkitunixnetgroup.h"

src/polkit/polkitunixprocess.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <sys/types.h>
2723
#ifdef HAVE_FREEBSD
2824
#include <sys/param.h>

src/polkit/polkitunixsession-systemd.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: Matthias Clasen
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <stdlib.h>
2723
#include <string.h>
2824
#include "polkitunixsession.h"

src/polkit/polkitunixsession.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723
#include "polkitunixsession.h"
2824
#include "polkitsubject.h"

src/polkit/polkitunixuser.c

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* Author: David Zeuthen <[email protected]>
2020
*/
2121

22-
#ifdef HAVE_CONFIG_H
23-
# include "config.h"
24-
#endif
25-
2622
#include <string.h>
2723
#include <pwd.h>
2824
#include <errno.h>

0 commit comments

Comments
 (0)