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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
# This file is part of libmicrodns.
#
# Copyright © 2019 VideoLabs SAS
#
# Author: Mathieu Duponchelle <mathieu@centricular.com>
#
#########################################################################
# libmicrodns is released under LGPLv2.1 (or later) and is also available
# under a commercial license.
#########################################################################
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
project('microdns', ['c'],
version : '0.2.0',
meson_version : '>= 0.50.0',
default_options : ['warning_level=2',
'buildtype=release',
'b_ndebug=if-release'])
mdns_version = meson.project_version()
mdns_soname_version = '1.0.0'
ver_arr = mdns_soname_version.split('.')
mdns_major_version = ver_arr[0]
mdns_minor_version = ver_arr[1]
mdns_micro_version = ver_arr[2]
cc = meson.get_compiler('c')
warning_flags = []
warning_flags += [
'-Wsign-compare',
'-Wstrict-aliasing',
'-Wstrict-overflow',
'-Wformat=2',
'-Wno-unused-parameter',
'-Wcast-align',
'-Wpointer-arith',
'-Wmissing-prototypes',
'-Wwrite-strings',
'-Wlogical-op',
]
add_project_arguments(cc.get_supported_arguments(warning_flags), language: 'c')
cdata = configuration_data()
deps = []
host_system = host_machine.system()
if host_system == 'windows'
deps += [cc.find_library('ws2_32')]
deps += [cc.find_library('iphlpapi')]
endif
inet_ntop_src = '''
#ifdef _WIN32
#include <ws2tcpip.h>
#include <windows.h>
# if _WIN32_WINNT < 0x600
# error Needs vista+
# endif
#else
#include <sys/socket.h>
#include <arpa/inet.h>
#endif
int main() {
inet_ntop(AF_INET, NULL, NULL, 0);
}
'''
if cc.links(inet_ntop_src, dependencies: deps)
cdata.set('HAVE_INET_NTOP', 1)
endif
poll_src = '''
#include <stddef.h>
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
# if _WIN32_WINNT < 0x600
# error Needs vista+
# endif
# if defined(_MSC_VER)
# error
# endif
#else
#include <poll.h>
#endif
int main() {
poll(NULL, 0, 0);
}
'''
if cc.links(poll_src, dependencies: deps)
cdata.set('HAVE_POLL', 1)
endif
pollfd_check_prefix = '#include <sys/types.h>\n'
if cdata.get('HAVE_POLL', 0) == 1
pollfd_check_prefix += '#include <poll.h>\n'
elif host_system == 'windows'
pollfd_check_prefix += '#include <winsock2.h>'
endif
if cc.has_type('struct pollfd', prefix: pollfd_check_prefix)
cdata.set('HAVE_STRUCT_POLLFD', 1)
endif
if cc.has_function('getifaddrs')
cdata.set('HAVE_GETIFADDRS', 1)
endif
if cc.has_header('ifaddrs.h')
cdata.set('HAVE_IFADDRS_H', 1)
endif
if cc.has_header('unistd.h')
cdata.set('HAVE_UNISTD_H', 1)
endif
configure_file(output : 'config.h', configuration : cdata)
c_args = ['-DHAVE_CONFIG_H']
if host_system == 'windows'
c_args += [
'-D_UNICODE=1',
'-DUNICODE=1',
'-D_POSIX_C_SOURCE=200809L',
'-D_BSD_SOURCE=1'
]
endif
if cc.get_id() == 'msvc'
c_args += [
'-D_CRT_NONSTDC_NO_DEPRECATE',
'-D_CRT_SECURE_NO_WARNINGS',
'-D_CRT_SECURE_NO_DEPRECATE',
]
endif
link_flags=[]
if get_option('fuzzing')
if cc.has_argument('-fsanitize=fuzzer')
fuzz_flags = ['-fsanitize=fuzzer-no-link,address,undefined']
c_args += fuzz_flags
c_args += ['-fprofile-instr-generate', '-fcoverage-mapping']
link_flags += fuzz_flags
link_flags += ['-fprofile-instr-generate', '-fcoverage-mapping']
else
error('Unsupported required option: -fsanitize=fuzzer')
endif
endif
incdirs = include_directories('.', 'include', 'compat')
subdir('compat')
subdir('include')
subdir('src')
pkg_cdata = configuration_data()
pkg_cdata.set('prefix', join_paths(get_option('prefix')))
pkg_cdata.set('exec_prefix', '${prefix}')
pkg_cdata.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
pkg_cdata.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
pkg_cdata.set('VERSION', mdns_version)
pkg_cdata.set('LIBSOCKET', host_system == 'windows' ? '-lws2_32 -liphlpapi': '')
pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir'))
configure_file(
input: 'src/microdns.pc.in',
output: 'microdns.pc',
configuration: pkg_cdata,
install_dir: pkg_install_dir,
install: true,
)
mdns_dep = declare_dependency(link_with : libmicrodns,
include_directories : incdirs,
dependencies: deps,
)
doc_cdata = configuration_data()
doc_cdata.set('PACKAGE_NAME', meson.project_name())
doc_cdata.set('VERSION', mdns_version)
doc_cdata.set('abs_top_srcdir', meson.current_source_dir())
configure_file(
input: 'doc/Doxyfile.in',
output: 'Doxyfile',
configuration: doc_cdata
)
subdir('examples')
subdir('tests')
|