Skip to content

Commit d920c22

Browse files
authored
Refactor config.h (#454)
* Include config.h globally via compiler options * Clean up trailing whitespace
1 parent 00be0af commit d920c22

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,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))
220216
endif
221-
config_h.set('HAVE_LIBSYSTEMD', enable_logind)
217+
config_data.set('HAVE_LIBSYSTEMD', enable_logind)
222218

223219
systemd_dep = dependency('systemd').found()
224220
if systemd_dep
@@ -232,14 +228,14 @@ if systemd_dep
232228
)
233229
endif
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
238234
polkitd_user = get_option('polkitd_user')
239-
config_h.set_quoted('POLKITD_USER', polkitd_user)
235+
config_data.set_quoted('POLKITD_USER', polkitd_user)
240236

241237
polkitd_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
245241
auth_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
286282
elif auth_fw == 'shadow'
287283
auth_deps += cc.find_library('crypt')
288284
endif
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')
368364
endif
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+
370376
content_files = files('COPYING')
371377

372378
subdir('actions')
@@ -380,12 +386,6 @@ if enable_tests
380386
subdir('test')
381387
endif
382388

383-
configure_file(
384-
output: 'config.h',
385-
configuration: config_h,
386-
)
387-
388-
389389
if not libs_only
390390
meson.add_install_script(
391391
'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"

0 commit comments

Comments
 (0)