-
Notifications
You must be signed in to change notification settings - Fork 15
/
meson.build
112 lines (98 loc) · 2.66 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
project('libdesock', 'c', license: 'MIT', version: '1.1')
if get_option('interpreter') == ''
r = run_command('sh', '-c', 'readelf -l /bin/ls | grep "program interpreter" | cut -d: -f2 | sed -e "s/^.//" -e "s/.$//"', check: true)
interpreter = r.stdout().strip()
else
interpreter = get_option('interpreter')
endif
args = [
'-Ofast',
'-march=native',
'-fomit-frame-pointer',
'-fno-stack-protector',
'-Wall',
'-Wextra',
'-Wpedantic',
'-fvisibility=hidden',
'-D DESOCKARCH="@0@"'.format(get_option('arch')),
'-D FD_TABLE_SIZE=@0@'.format(get_option('fd_table_size')),
'-D INTERPRETER="@0@"'.format(interpreter)
]
link_args = [
'-Wl,-e,__libdesock_main',
'-flto'
]
if get_option('debug_desock')
args += '-D DEBUG'
endif
if get_option('desock_client')
args += '-D DESOCK_CONNECT'
endif
if get_option('desock_server')
args += '-D DESOCK_BIND'
endif
if get_option('allow_dup_stdin')
args += '-D DUP_STDIN'
endif
if get_option('multiple_requests')
args += '-D MULTI_REQUEST'
endif
args += '-D MAX_CONNS=@0@'.format(get_option('max_conns'))
if get_option('symbol_version') != ''
version_file = '@0@ {};'.format(get_option('symbol_version'))
file_path = '@0@/syms.map'.format(meson.build_root())
run_command('sh', '-c', 'echo "@0@" > @1@'.format(version_file, file_path), check: true)
args += '-D VERSION_NAME="@0@"'.format(get_option('symbol_version'))
link_args += '-Wl,--version-script=@0@'.format(file_path)
endif
args += '-D REQUEST_DELIMITER="@0@"'.format(get_option('request_delimiter'))
sources = [
'src/main.c',
'src/desock.c',
'src/stub_sockaddr.c',
'src/syscall.c',
'src/accept.c',
'src/bind.c',
'src/connect.c',
'src/socket.c',
'src/listen.c',
'src/close.c',
'src/test_helper.c',
'src/dup.c',
'src/getpeername.c',
'src/getsockname.c',
'src/epoll.c',
'src/hooks.c',
'src/multi.c',
'src/peekbuffer.c',
'src/poll.c',
'src/read.c',
'src/select.c',
'src/sendfile.c',
'src/shutdown.c',
'src/sockopt.c',
'src/write.c',
]
include_directories = [
include_directories('src/include'),
include_directories('src/include/arch/' + get_option('arch'))
]
shared_library('desock',
sources : sources,
include_directories : include_directories,
c_args : args + ['-D SHARED', '-flto'],
link_args : link_args,
install : false,
dependencies : [
dependency('threads')
]
)
static_library('desock',
sources : sources,
include_directories : include_directories,
c_args : args,
install : false,
dependencies : [
dependency('threads')
]
)