summaryrefslogtreecommitdiff
path: root/ext/sctp/usrsctp/meson.build
blob: 8d474970bb1a44e73abf455f2ef27648cc1785e6 (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Set compiler warning flags
compiler = meson.get_compiler('c')
if compiler.get_argument_syntax() == 'msvc'
    compiler_args = compiler.get_supported_arguments([
        '/wd4100', # 'identifier' : unreferenced formal parameter
        '/wd4127', # conditional expression is constant
        '/wd4200', # nonstandard extension used : zero-sized array in struct/union
        '/wd4214', # bit field types other than int
        '/wd4706', # assignment within conditional expression
        '/wd4245', # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
        '/wd4389', # 'operator' : signed/unsigned mismatch
        '/wd4702', # unreachable code
        '/wd4701', # Potentially uninitialized local variable 'name' used
        '/wd4244', # 'conversion' conversion from 'type1' to 'type2', possible loss of data
    ])
else
    compiler_args = compiler.get_supported_arguments([
        '-Wfloat-equal',
        '-Wshadow',
        '-Wpointer-arith',
        '-Winit-self',
        '-Wno-unused-function',
        '-Wno-unused-parameter',
        '-Wno-unreachable-code',
        '-Wstrict-prototypes',
        # fix GStreamer build with -Werror
        '-Wno-missing-prototypes',
        '-Wno-incompatible-pointer-types-discards-qualifiers',
        '-Wno-address-of-packed-member',
        '-Wno-discarded-qualifiers',
        '-Wno-missing-declarations',
        '-Wno-old-style-definition',
        '-Wno-redundant-decls',
        '-Wno-error',
    ])
endif

# Configuration

compile_args = [compiler_args]

# Dependency: Threads
thread_dep = dependency('threads', required: true)

# Dependencies list
dependencies = [
    thread_dep,
]

# Global settings
compile_args += [
    '-D__Userspace__',
    '-DSCTP_SIMPLE_ALLOCATOR',
    '-DSCTP_PROCESS_LEVEL_LOCKS',
]

# OS-specific settings
system = host_machine.system()
if system in ['linux', 'android']
    compile_args += [
        '-D_GNU_SOURCE',
    ]
elif system == 'freebsd'
    compile_args += [compiler.get_supported_arguments([
            '-Wno-address-of-packed-member',
        ])]
elif system in ['darwin', 'ios']
    compile_args += [[
            '-D__APPLE_USE_RFC_2292',
        ] + compiler.get_supported_arguments([
            '-Wno-address-of-packed-member',
            '-Wno-deprecated-declarations',
        ])]
elif system == 'windows'
    dependencies += compiler.find_library('ws2_32', required: true)
    dependencies += compiler.find_library('iphlpapi', required: true)
    if compiler.get_id() == 'gcc'
        compile_args += [compiler.get_supported_arguments([
            '-Wno-format',
            '-D_WIN32_WINNT=0x601',  # Enables inet_ntop and friends
        ])]
    endif
else
    warning('Unknown system: @0@'.format(system))
    usrsctp_dep = dependency('', required: false)
    subdir_done()
endif

# Feature: sys/queue
if compiler.has_header('sys/queue.h')
    compile_args += ['-DHAVE_SYS_QUEUE_H']
endif

# Feature: sys/socket, linux/ifaddr, linux/rtnetlink
if compiler.has_header('sys/socket.h')
    if compiler.has_header('linux/if_addr.h')
        compile_args += ['-DHAVE_LINUX_IF_ADDR_H']
    endif

    if compiler.has_header('linux/rtnetlink.h')
        compile_args += ['-DHAVE_LINUX_RTNETLINK_H']
    endif
endif

# Feature: ICMP
have_sys_types = compiler.has_header('sys/types.h')
have_netinet_in = compiler.has_header('netinet/in.h')
have_netinet_ip = compiler.has_header('netinet/ip.h')
have_netinet_ip_icmp = compiler.has_header('netinet/ip_icmp.h')
if have_sys_types and have_netinet_in and have_netinet_ip and have_netinet_ip_icmp
    compile_args += ['-DHAVE_NETINET_IP_ICMP_H']
endif

# Feature: stdatomic
if compiler.has_header('stdatomic.h')
    compile_args += ['-DHAVE_STDATOMIC_H']
endif

# Feature: sockaddr.sa_len
prefix = '''
#include <sys/types.h>
#include <sys/socket.h>
'''
have_sa_len = compiler.has_member('struct sockaddr', 'sa_len', prefix: prefix)
if have_sa_len
    compile_args += ['-DHAVE_SA_LEN']
endif

# Feature: sockaddr_in.sin_len / sockaddr_in6.sin6_len / sockaddr_conn.sconn_len
prefix = '''
#include <sys/types.h>
#include <netinet/in.h>
'''
have_sin_len = compiler.has_member('struct sockaddr_in', 'sin_len', prefix: prefix)
if have_sin_len
    compile_args += ['-DHAVE_SIN_LEN']
endif
have_sin6_len = compiler.has_member('struct sockaddr_in6', 'sin6_len', prefix: prefix)
if have_sin6_len
    compile_args += ['-DHAVE_SIN6_LEN']
endif
have_sconn_len = compiler.has_member('struct sockaddr_conn', 'sconn_len', prefix: '#include "usrsctp.h"', include_directories: include_directories('usrsctplib'))
if have_sconn_len
    compile_args += ['-DHAVE_SCONN_LEN']
endif

# Options
if false
    compile_args += ['-DINVARIANTS']
endif
if not gst_debug_disabled
    compile_args += ['-DSCTP_DEBUG']
endif
# We do not need the socket API in GStreamer since we will wrap inside a
# DTLS packet anyway, because we use SCTP for WebRTC data channels.
if false
    compile_args += ['-DINET']
endif
if false
    compile_args += ['-DINET6']
endif

compile_args += ['-DSCTP_STDINT_INCLUDE=<stdint.h>']

# Library
subdir('usrsctplib')

# Build library
usrsctp_static = static_library('usrsctp-static', sources,
    c_args: compile_args,
    dependencies: dependencies,
    include_directories: include_dirs,
    install: false)

# Declare dependency
usrsctp_dep = declare_dependency(
    include_directories: include_dirs,
    link_with: usrsctp_static)