0869dd59fdb13d13edf7fd93b7cdd85a9d951a61
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / ext / sctp / usrsctp / meson.build
1 # Set compiler warning flags
2 compiler = meson.get_compiler('c')
3 if compiler.get_argument_syntax() == 'msvc'
4     compiler_args = compiler.get_supported_arguments([
5         '/wd4100', # 'identifier' : unreferenced formal parameter
6         '/wd4127', # conditional expression is constant
7         '/wd4200', # nonstandard extension used : zero-sized array in struct/union
8         '/wd4214', # bit field types other than int
9         '/wd4706', # assignment within conditional expression
10         '/wd4245', # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
11         '/wd4389', # 'operator' : signed/unsigned mismatch
12         '/wd4702', # unreachable code
13         '/wd4701', # Potentially uninitialized local variable 'name' used
14         '/wd4244', # 'conversion' conversion from 'type1' to 'type2', possible loss of data
15     ])
16 else
17     compiler_args = compiler.get_supported_arguments([
18         '-Wfloat-equal',
19         '-Wshadow',
20         '-Wpointer-arith',
21         '-Winit-self',
22         '-Wno-unused-function',
23         '-Wno-unused-parameter',
24         '-Wno-unreachable-code',
25         '-Wstrict-prototypes',
26         # fix GStreamer build with -Werror
27         '-Wno-missing-prototypes',
28         '-Wno-incompatible-pointer-types-discards-qualifiers',
29         '-Wno-address-of-packed-member',
30         '-Wno-discarded-qualifiers',
31         '-Wno-missing-declarations',
32         '-Wno-old-style-definition',
33         '-Wno-redundant-decls',
34         '-Wno-error',
35     ])
36 endif
37
38 # Configuration
39
40 compile_args = [compiler_args]
41
42 # Dependency: Threads
43 thread_dep = dependency('threads', required: true)
44
45 # Dependencies list
46 dependencies = [
47     thread_dep,
48 ]
49
50 # Global settings
51 compile_args += [
52     '-D__Userspace__',
53     '-DSCTP_SIMPLE_ALLOCATOR',
54     '-DSCTP_PROCESS_LEVEL_LOCKS',
55 ]
56
57 # OS-specific settings
58 system = host_machine.system()
59 if system in ['linux', 'android']
60     compile_args += [
61         '-D_GNU_SOURCE',
62     ]
63 elif system == 'freebsd'
64     compile_args += [compiler.get_supported_arguments([
65             '-Wno-address-of-packed-member',
66         ])]
67 elif system in ['darwin', 'ios']
68     compile_args += [[
69             '-D__APPLE_USE_RFC_2292',
70         ] + compiler.get_supported_arguments([
71             '-Wno-address-of-packed-member',
72             '-Wno-deprecated-declarations',
73         ])]
74 elif system == 'windows'
75     dependencies += compiler.find_library('ws2_32', required: true)
76     dependencies += compiler.find_library('iphlpapi', required: true)
77     if compiler.get_id() == 'gcc'
78         compile_args += [compiler.get_supported_arguments([
79             '-Wno-format',
80         ])]
81     endif
82 else
83     warning('Unknown system: @0@'.format(system))
84     usrsctp_dep = dependency('', required: false)
85     subdir_done()
86 endif
87
88 # Feature: sys/queue
89 if compiler.has_header('sys/queue.h')
90     compile_args += ['-DHAVE_SYS_QUEUE_H']
91 endif
92
93 # Feature: sys/socket, linux/ifaddr, linux/rtnetlink
94 if compiler.has_header('sys/socket.h')
95     if compiler.has_header('linux/if_addr.h')
96         compile_args += ['-DHAVE_LINUX_IF_ADDR_H']
97     endif
98
99     if compiler.has_header('linux/rtnetlink.h')
100         compile_args += ['-DHAVE_LINUX_RTNETLINK_H']
101     endif
102 endif
103
104 # Feature: ICMP
105 have_sys_types = compiler.has_header('sys/types.h')
106 have_netinet_in = compiler.has_header('netinet/in.h')
107 have_netinet_ip = compiler.has_header('netinet/ip.h')
108 have_netinet_ip_icmp = compiler.has_header('netinet/ip_icmp.h')
109 if have_sys_types and have_netinet_in and have_netinet_ip and have_netinet_ip_icmp
110     compile_args += ['-DHAVE_NETINET_IP_ICMP_H']
111 endif
112
113 # Feature: stdatomic
114 if compiler.has_header('stdatomic.h')
115     compile_args += ['-DHAVE_STDATOMIC_H']
116 endif
117
118 # Feature: sockaddr.sa_len
119 prefix = '''
120 #include <sys/types.h>
121 #include <sys/socket.h>
122 '''
123 have_sa_len = compiler.has_member('struct sockaddr', 'sa_len', prefix: prefix)
124 if have_sa_len
125     compile_args += ['-DHAVE_SA_LEN']
126 endif
127
128 # Feature: sockaddr_in.sin_len / sockaddr_in6.sin6_len / sockaddr_conn.sconn_len
129 prefix = '''
130 #include <sys/types.h>
131 #include <netinet/in.h>
132 '''
133 have_sin_len = compiler.has_member('struct sockaddr_in', 'sin_len', prefix: prefix)
134 if have_sin_len
135     compile_args += ['-DHAVE_SIN_LEN']
136 endif
137 have_sin6_len = compiler.has_member('struct sockaddr_in6', 'sin6_len', prefix: prefix)
138 if have_sin6_len
139     compile_args += ['-DHAVE_SIN6_LEN']
140 endif
141 have_sconn_len = compiler.has_member('struct sockaddr_conn', 'sconn_len', prefix: '#include "usrsctp.h"', include_directories: include_directories('usrsctplib'))
142 if have_sconn_len
143     compile_args += ['-DHAVE_SCONN_LEN']
144 endif
145
146 # Options
147 if false
148     compile_args += ['-DINVARIANTS']
149 endif
150 if not gst_debug_disabled
151     compile_args += ['-DSCTP_DEBUG']
152 endif
153 # We do not need the socket API in GStreamer since we will wrap inside a
154 # DTLS packet anyway, because we use SCTP for WebRTC data channels.
155 if false
156     compile_args += ['-DINET']
157 endif
158 if false
159     compile_args += ['-DINET6']
160 endif
161
162 compile_args += ['-DSCTP_STDINT_INCLUDE=<stdint.h>']
163
164 # Library
165 subdir('usrsctplib')
166
167 # Build library
168 usrsctp_static = static_library('usrsctp-static', sources,
169     c_args: compile_args,
170     dependencies: dependencies,
171     include_directories: include_dirs,
172     install: false)
173
174 # Declare dependency
175 usrsctp_dep = declare_dependency(
176     include_directories: include_dirs,
177     link_with: usrsctp_static)