2020-07-24 18:23:19 +00:00
|
|
|
# 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',
|
2020-07-25 16:56:43 +00:00
|
|
|
# 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',
|
2020-07-24 18:23:19 +00:00
|
|
|
])
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Configuration
|
2020-07-25 16:56:43 +00:00
|
|
|
|
|
|
|
compile_args = [compiler_args]
|
2020-07-24 18:23:19 +00:00
|
|
|
|
|
|
|
# Dependency: Threads
|
|
|
|
thread_dep = dependency('threads', required: true)
|
|
|
|
|
|
|
|
# Dependencies list
|
|
|
|
dependencies = [
|
|
|
|
thread_dep,
|
|
|
|
]
|
|
|
|
|
|
|
|
# Global settings
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += [
|
2020-07-24 18:23:19 +00:00
|
|
|
'-D__Userspace__',
|
|
|
|
'-DSCTP_SIMPLE_ALLOCATOR',
|
|
|
|
'-DSCTP_PROCESS_LEVEL_LOCKS',
|
2020-07-25 16:56:43 +00:00
|
|
|
]
|
2020-07-24 18:23:19 +00:00
|
|
|
|
|
|
|
# OS-specific settings
|
|
|
|
system = host_machine.system()
|
|
|
|
if system in ['linux', 'android']
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += [
|
2020-07-24 18:23:19 +00:00
|
|
|
'-D_GNU_SOURCE',
|
2020-07-25 16:56:43 +00:00
|
|
|
]
|
2020-07-24 18:23:19 +00:00
|
|
|
elif system == 'freebsd'
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += [compiler.get_supported_arguments([
|
2020-07-24 18:23:19 +00:00
|
|
|
'-Wno-address-of-packed-member',
|
2020-07-25 16:56:43 +00:00
|
|
|
])]
|
2020-07-24 18:23:19 +00:00
|
|
|
elif system in ['darwin', 'ios']
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += [[
|
2020-07-24 18:23:19 +00:00
|
|
|
'-D__APPLE_USE_RFC_2292',
|
|
|
|
] + compiler.get_supported_arguments([
|
|
|
|
'-Wno-address-of-packed-member',
|
|
|
|
'-Wno-deprecated-declarations',
|
2020-07-25 16:56:43 +00:00
|
|
|
])]
|
2020-07-24 18:23:19 +00:00
|
|
|
elif system == 'windows'
|
|
|
|
dependencies += compiler.find_library('ws2_32', required: true)
|
|
|
|
dependencies += compiler.find_library('iphlpapi', required: true)
|
|
|
|
if compiler.get_id() == 'gcc'
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += [compiler.get_supported_arguments([
|
2020-07-24 18:23:19 +00:00
|
|
|
'-Wno-format',
|
|
|
|
'-D_WIN32_WINNT=0x601', # Enables inet_ntop and friends
|
2020-07-25 16:56:43 +00:00
|
|
|
])]
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
|
|
|
else
|
2020-07-25 16:56:43 +00:00
|
|
|
warning('Unknown system: @0@'.format(system))
|
|
|
|
usrsctp_dep = dependency('', required: false)
|
|
|
|
subdir_done()
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Feature: sys/queue
|
|
|
|
if compiler.has_header('sys/queue.h')
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_SYS_QUEUE_H']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Feature: sys/socket, linux/ifaddr, linux/rtnetlink
|
|
|
|
if compiler.has_header('sys/socket.h')
|
|
|
|
if compiler.has_header('linux/if_addr.h')
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_LINUX_IF_ADDR_H']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
if compiler.has_header('linux/rtnetlink.h')
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_LINUX_RTNETLINK_H']
|
2020-07-24 18:23:19 +00:00
|
|
|
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
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_NETINET_IP_ICMP_H']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Feature: stdatomic
|
|
|
|
if compiler.has_header('stdatomic.h')
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_STDATOMIC_H']
|
2020-07-24 18:23:19 +00:00
|
|
|
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
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_SA_LEN']
|
2020-07-24 18:23:19 +00:00
|
|
|
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
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_SIN_LEN']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
|
|
|
have_sin6_len = compiler.has_member('struct sockaddr_in6', 'sin6_len', prefix: prefix)
|
|
|
|
if have_sin6_len
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_SIN6_LEN']
|
2020-07-24 18:23:19 +00:00
|
|
|
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
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DHAVE_SCONN_LEN']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Options
|
2020-07-25 16:56:43 +00:00
|
|
|
if false
|
|
|
|
compile_args += ['-DINVARIANTS']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
2020-07-25 16:56:43 +00:00
|
|
|
if not gst_debug_disabled
|
|
|
|
compile_args += ['-DSCTP_DEBUG']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
2020-07-25 16:56:43 +00:00
|
|
|
# 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']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
2020-07-25 16:56:43 +00:00
|
|
|
if false
|
|
|
|
compile_args += ['-DINET6']
|
2020-07-24 18:23:19 +00:00
|
|
|
endif
|
|
|
|
|
2020-07-25 16:56:43 +00:00
|
|
|
compile_args += ['-DSCTP_STDINT_INCLUDE=<stdint.h>']
|
|
|
|
|
2020-07-24 18:23:19 +00:00
|
|
|
# Library
|
|
|
|
subdir('usrsctplib')
|
|
|
|
|
|
|
|
# Build library
|
2020-07-25 16:56:43 +00:00
|
|
|
usrsctp_static = static_library('usrsctp-static', sources,
|
|
|
|
c_args: compile_args,
|
|
|
|
dependencies: dependencies,
|
|
|
|
include_directories: include_dirs,
|
|
|
|
install: false)
|
2020-07-24 18:23:19 +00:00
|
|
|
|
|
|
|
# Declare dependency
|
|
|
|
usrsctp_dep = declare_dependency(
|
|
|
|
include_directories: include_dirs,
|
2020-07-25 16:56:43 +00:00
|
|
|
link_with: usrsctp_static)
|