-
Notifications
You must be signed in to change notification settings - Fork 21
/
meson.build
150 lines (135 loc) · 3.71 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
project('libgusb', 'c',
version : '0.4.9',
license : 'LGPL-2.1-or-later',
meson_version : '>=0.56.0',
default_options : ['c_std=c99']
)
gusb_version = meson.project_version()
varr = gusb_version.split('.')
gusb_major_version = varr[0]
gusb_minor_version = varr[1]
gusb_micro_version = varr[2]
conf = configuration_data()
conf.set_quoted('VERSION', gusb_version)
# libtool versioning - this applies to libgusb
lt_current = 2
lt_revision = 10
lt_age = 0
lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)
# get supported warning flags
test_args = [
'-Waggregate-return',
'-Wunused',
'-Warray-bounds',
'-Wcast-align',
'-Wclobbered',
'-Wdeclaration-after-statement',
'-Wempty-body',
'-Wextra',
'-Wformat=2',
'-Wformat-nonliteral',
'-Wformat-security',
'-Wformat-signedness',
'-Wignored-qualifiers',
'-Wimplicit-function-declaration',
'-Winit-self',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wmissing-parameter-type',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wno-discarded-qualifiers',
'-Wno-missing-field-initializers',
'-Wno-strict-aliasing',
'-Wno-suggest-attribute=format',
'-Wno-unused-parameter',
'-Wno-gnu-variable-sized-type-not-at-end',
'-Wold-style-definition',
'-Woverride-init',
'-Wpointer-arith',
'-Wreturn-type',
'-Wshadow',
'-Wsign-compare',
'-Wstrict-aliasing',
'-Wstrict-prototypes',
'-Wswitch-default',
'-Wswitch-enum',
'-Wtype-limits',
'-Wundef',
'-Wuninitialized',
'-Wunused-but-set-variable',
'-Wwrite-strings'
]
cc = meson.get_compiler('c')
foreach arg: test_args
if cc.has_argument(arg)
add_project_arguments(arg, language : 'c')
endif
endforeach
if not meson.is_cross_build()
add_project_arguments('-fstack-protector-strong', language : 'c')
endif
# enable full RELRO where possible
# FIXME: until https://github.com/mesonbuild/meson/issues/1140 is fixed
global_link_args = []
test_link_args = [
'-Wl,-z,relro',
'-Wl,-z,now',
]
foreach arg: test_link_args
if cc.has_link_argument(arg)
global_link_args += arg
endif
endforeach
add_project_link_arguments(
global_link_args,
language: 'c'
)
if get_option('tests')
umockdev = dependency('umockdev-1.0', version: '>= 0.17.7', disabler: true, required: get_option('umockdev'))
else
umockdev = disabler()
endif
libgio = dependency('gio-2.0', version : '>= 2.44.0')
libusb = dependency('libusb-1.0', version : '>= 1.0.9')
if cc.has_header_symbol('libusb.h', 'LIBUSB_CAP_HAS_HOTPLUG', dependencies: libusb)
conf.set('HAVE_LIBUSB_CAP_HAS_HOTPLUG', '1')
endif
if cc.has_header_symbol('libusb.h', 'libusb_has_capability', dependencies: libusb)
conf.set('HAVE_LIBUSB_HAS_CAPABILITY', '1')
endif
if cc.has_header_symbol('libusb.h', 'libusb_set_option', dependencies: libusb)
conf.set('HAVE_LIBUSB_SET_OPTION', '1')
endif
if cc.has_header_symbol('libusb.h', 'libusb_get_parent', dependencies: libusb)
conf.set('HAVE_LIBUSB_GET_PARENT', '1')
endif
if cc.has_header_symbol('libusb.h', 'libusb_get_port_number', dependencies: libusb)
conf.set('HAVE_LIBUSB_GET_PORT_NUMBER', '1')
endif
libjsonglib = dependency('json-glib-1.0', version: '>= 1.1.1')
gusb_deps = [
libgio,
libusb,
libjsonglib,
]
if not get_option('introspection') and get_option('vapi')
error('-Dvapi=true requires -Dintrospection=true')
endif
gnome = import('gnome')
add_project_arguments('-DGUSB_COMPILATION', language: 'c')
prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))
datadir = join_paths(prefix, get_option('datadir'))
configure_file(
output : 'config.h',
configuration : conf
)
root_incdir = include_directories('.')
subdir('gusb')
subdir('tools')
if get_option('docs')
subdir('docs')
endif