1# Set compiler warning flags 2compiler = meson.get_compiler('c') 3if 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 ]) 16else 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 ]) 36endif 37 38# Configuration 39 40compile_args = [compiler_args] 41 42# Dependency: Threads 43thread_dep = dependency('threads', required: true) 44 45# Dependencies list 46dependencies = [ 47 thread_dep, 48] 49 50# Global settings 51compile_args += [ 52 '-D__Userspace__', 53 '-DSCTP_SIMPLE_ALLOCATOR', 54 '-DSCTP_PROCESS_LEVEL_LOCKS', 55] 56 57# OS-specific settings 58system = host_machine.system() 59if system in ['linux', 'android'] 60 compile_args += [ 61 '-D_GNU_SOURCE', 62 ] 63elif system == 'freebsd' 64 compile_args += [compiler.get_supported_arguments([ 65 '-Wno-address-of-packed-member', 66 ])] 67elif 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 ])] 74elif 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 '-D_WIN32_WINNT=0x601', # Enables inet_ntop and friends 81 ])] 82 endif 83else 84 warning('Unknown system: @0@'.format(system)) 85 usrsctp_dep = dependency('', required: false) 86 subdir_done() 87endif 88 89# Feature: sys/queue 90if compiler.has_header('sys/queue.h') 91 compile_args += ['-DHAVE_SYS_QUEUE_H'] 92endif 93 94# Feature: sys/socket, linux/ifaddr, linux/rtnetlink 95if compiler.has_header('sys/socket.h') 96 if compiler.has_header('linux/if_addr.h') 97 compile_args += ['-DHAVE_LINUX_IF_ADDR_H'] 98 endif 99 100 if compiler.has_header('linux/rtnetlink.h') 101 compile_args += ['-DHAVE_LINUX_RTNETLINK_H'] 102 endif 103endif 104 105# Feature: ICMP 106have_sys_types = compiler.has_header('sys/types.h') 107have_netinet_in = compiler.has_header('netinet/in.h') 108have_netinet_ip = compiler.has_header('netinet/ip.h') 109have_netinet_ip_icmp = compiler.has_header('netinet/ip_icmp.h') 110if have_sys_types and have_netinet_in and have_netinet_ip and have_netinet_ip_icmp 111 compile_args += ['-DHAVE_NETINET_IP_ICMP_H'] 112endif 113 114# Feature: stdatomic 115if compiler.has_header('stdatomic.h') 116 compile_args += ['-DHAVE_STDATOMIC_H'] 117endif 118 119# Feature: sockaddr.sa_len 120prefix = ''' 121#include <sys/types.h> 122#include <sys/socket.h> 123''' 124have_sa_len = compiler.has_member('struct sockaddr', 'sa_len', prefix: prefix) 125if have_sa_len 126 compile_args += ['-DHAVE_SA_LEN'] 127endif 128 129# Feature: sockaddr_in.sin_len / sockaddr_in6.sin6_len / sockaddr_conn.sconn_len 130prefix = ''' 131#include <sys/types.h> 132#include <netinet/in.h> 133''' 134have_sin_len = compiler.has_member('struct sockaddr_in', 'sin_len', prefix: prefix) 135if have_sin_len 136 compile_args += ['-DHAVE_SIN_LEN'] 137endif 138have_sin6_len = compiler.has_member('struct sockaddr_in6', 'sin6_len', prefix: prefix) 139if have_sin6_len 140 compile_args += ['-DHAVE_SIN6_LEN'] 141endif 142have_sconn_len = compiler.has_member('struct sockaddr_conn', 'sconn_len', prefix: '#include "usrsctp.h"', include_directories: include_directories('usrsctplib')) 143if have_sconn_len 144 compile_args += ['-DHAVE_SCONN_LEN'] 145endif 146 147# Options 148if false 149 compile_args += ['-DINVARIANTS'] 150endif 151if not gst_debug_disabled 152 compile_args += ['-DSCTP_DEBUG'] 153endif 154# We do not need the socket API in GStreamer since we will wrap inside a 155# DTLS packet anyway, because we use SCTP for WebRTC data channels. 156if false 157 compile_args += ['-DINET'] 158endif 159if false 160 compile_args += ['-DINET6'] 161endif 162 163compile_args += ['-DSCTP_STDINT_INCLUDE=<stdint.h>'] 164 165# Library 166subdir('usrsctplib') 167 168# Build library 169usrsctp_static = static_library('usrsctp-static', sources, 170 c_args: compile_args, 171 dependencies: dependencies, 172 include_directories: include_dirs, 173 install: false) 174 175# Declare dependency 176usrsctp_dep = declare_dependency( 177 include_directories: include_dirs, 178 link_with: usrsctp_static) 179