forked from intel/metee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
117 lines (106 loc) · 2.78 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
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2020-2022 Intel Corporation
project('metee', 'c',
version : run_command('get-version.py').stdout().strip(),
license : 'Apache 2.0',
meson_version : '>=0.51.0',
default_options : ['warning_level=2',
'default_library=static',
'c_std=gnu99',
'optimization=2'],
)
metee_sources_linux = [
'src/linux/metee_linux.c',
'src/linux/mei.c'
]
metee_sources_windows = [
'src/Windows/metee_win.c',
'src/Windows/metee_winhelpers.c'
]
warning_flags = [
'-Wno-unused-command-line-argument',
'-Wsign-compare',
'-Wformat-security',
'-Wstack-protector',
'-Winit-self',
'/WX',
'/W4'
]
# secure compile flags
security_flags = [
'-fstack-protector-strong',
'-Wformat',
'-Wformat-security',
'-fno-strict-overflow',
'-fno-delete-null-pointer-checks',
'-fwrapv',
'/GS',
'/sdl'
]
if get_option('optimization').to_int() >= 2
security_flags += [
'-D_FORTIFY_SOURCE=2'
]
endif
debug_flags = []
if get_option('buildtype') == 'debug'
debug_flags += [
'-O0',
'-g3',
'-ggdb'
]
endif
cc = meson.get_compiler('c')
if cc.get_id() == 'msvc'
add_project_arguments('-DUNICODE', '-D_UNICODE',
language : 'c')
if get_option('mvsc_runtime_static')
if get_option('buildtype') == 'debug'
add_project_arguments('/MT', language : 'c')
else
add_project_arguments('/MTd', language : 'c')
endif
endif
endif
add_project_arguments(cc.get_supported_arguments(warning_flags),
language : 'c')
add_project_arguments(cc.get_supported_arguments(security_flags),
language : 'c')
add_project_arguments(cc.get_supported_arguments(debug_flags),
language : 'c')
add_project_arguments('-D_XOPEN_SOURCE=700', language : 'c')
global_link_args = []
test_link_args = [
'-Wl,-z,relro',
'-Wl,-z,now',
'-Wl,-z,noexecstack',
]
foreach link_arg: test_link_args
if cc.has_link_argument(link_arg)
global_link_args += link_arg
endif
endforeach
add_project_link_arguments(
global_link_args,
language: 'c'
)
if target_machine.system() == 'linux'
local_inc = ['include', 'src/linux']
if not cc.has_header_symbol('linux/mei.h', 'IOCTL_MEI_CONNECT_CLIENT_VTAG')
local_inc = ['src/linux/include'] + local_inc
endif
metee_lib_static = static_library('metee',
sources : metee_sources_linux,
include_directories : local_inc
)
elif target_machine.system() == 'windows'
metee_lib_static = static_library('metee',
sources : metee_sources_windows,
include_directories : ['include', 'src/Windows'],
link_args : ['CfgMgr32.lib']
)
endif
metee_dep_static = declare_dependency(
link_with : metee_lib_static,
include_directories : include_directories('include'),
)