2018-12-06 15:16:13 +01:00
|
|
|
project('libpsl', 'c',
|
2022-01-06 00:08:32 +01:00
|
|
|
version : files('version.txt'),
|
|
|
|
meson_version : '>=0.57.0')
|
2020-02-28 08:50:23 +01:00
|
|
|
|
2018-12-06 15:16:13 +01:00
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
|
|
|
enable_runtime = get_option('runtime')
|
|
|
|
enable_builtin = get_option('builtin')
|
|
|
|
|
2020-10-25 11:55:17 +01:00
|
|
|
# We need to know the build type to determine what .lib files we need on Visual Studio
|
|
|
|
# for dependencies that don't normally come with pkg-config files for Visual Studio builds
|
|
|
|
buildtype = get_option('buildtype')
|
2019-01-21 12:20:53 +01:00
|
|
|
|
2018-12-06 15:16:13 +01:00
|
|
|
notfound = dependency('', required : false)
|
|
|
|
libidn2_dep = notfound
|
|
|
|
libicu_dep = notfound
|
|
|
|
libidn_dep = notfound
|
|
|
|
libunistring = notfound
|
2018-12-11 02:26:13 +01:00
|
|
|
networking_deps = notfound
|
2022-01-04 13:49:58 +01:00
|
|
|
libiconv_dep = notfound
|
2018-12-06 15:16:13 +01:00
|
|
|
|
2022-01-06 22:58:02 +01:00
|
|
|
link_language = 'c'
|
|
|
|
|
2018-12-08 20:13:51 +01:00
|
|
|
# FIXME: Cleanup this when Meson gets 'feature-combo':
|
2018-12-06 15:16:13 +01:00
|
|
|
# https://github.com/mesonbuild/meson/issues/4566
|
2018-12-08 20:13:51 +01:00
|
|
|
# Dependency fallbacks would help too:
|
|
|
|
# https://github.com/mesonbuild/meson/pull/4595
|
2018-12-06 15:16:13 +01:00
|
|
|
if ['libidn2', 'auto'].contains(enable_runtime) or ['libidn2', 'auto'].contains(enable_builtin)
|
|
|
|
libidn2_dep = dependency('libidn2', required : false)
|
2018-12-08 20:13:51 +01:00
|
|
|
if not libidn2_dep.found() and cc.has_header('idn2.h')
|
|
|
|
libidn2_dep = cc.find_library('idn2', required : false)
|
|
|
|
endif
|
2018-12-06 15:16:13 +01:00
|
|
|
if libidn2_dep.found()
|
|
|
|
if enable_runtime == 'auto'
|
|
|
|
enable_runtime = 'libidn2'
|
|
|
|
endif
|
|
|
|
if enable_builtin == 'auto'
|
|
|
|
enable_builtin = 'libidn2'
|
|
|
|
endif
|
2018-12-08 20:13:51 +01:00
|
|
|
elif [enable_runtime, enable_builtin].contains('libidn2')
|
|
|
|
error('You requested libidn2 but it is not installed.')
|
2018-12-06 15:16:13 +01:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if ['libicu', 'auto'].contains(enable_runtime) or ['libicu', 'auto'].contains(enable_builtin)
|
|
|
|
libicu_dep = dependency('icu-uc', required : false)
|
2018-12-08 20:13:51 +01:00
|
|
|
if not libicu_dep.found() and cc.has_header('unicode/ustring.h')
|
2019-01-21 12:20:53 +01:00
|
|
|
# MSVC: the debug configuration of ICU generated the libraries with d suffix
|
|
|
|
# we must handle this and search for the right library depending on the
|
|
|
|
# build type. Note debugoptimized is just a release build with .pdb files enabled
|
2020-10-25 11:55:17 +01:00
|
|
|
if cc.get_id() == 'msvc' and buildtype == 'debug'
|
2019-01-21 12:20:53 +01:00
|
|
|
libicu_dep = cc.find_library('icuucd', required : false)
|
|
|
|
else
|
|
|
|
libicu_dep = cc.find_library('icuuc', required : false)
|
|
|
|
endif
|
2018-12-08 20:13:51 +01:00
|
|
|
endif
|
2018-12-08 13:50:36 +01:00
|
|
|
if libicu_dep.found()
|
2018-12-06 15:16:13 +01:00
|
|
|
if enable_runtime == 'auto'
|
|
|
|
enable_runtime = 'libicu'
|
|
|
|
endif
|
|
|
|
if enable_builtin == 'auto'
|
|
|
|
enable_builtin = 'libicu'
|
|
|
|
endif
|
2022-01-06 22:58:02 +01:00
|
|
|
if add_languages('cpp', native : false)
|
|
|
|
link_language = 'cpp'
|
|
|
|
else
|
|
|
|
error('C++ compiler is not available')
|
|
|
|
endif
|
2018-12-08 20:13:51 +01:00
|
|
|
elif [enable_runtime, enable_builtin].contains('libicu')
|
|
|
|
error('You requested libicu but it is not installed.')
|
2018-12-06 15:16:13 +01:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if ['libidn', 'auto'].contains(enable_runtime) or ['libidn', 'auto'].contains(enable_builtin)
|
|
|
|
libidn_dep = dependency('libidn', required : false)
|
2018-12-08 20:13:51 +01:00
|
|
|
if not libidn_dep.found() and cc.has_header('idna.h')
|
|
|
|
libidn_dep = cc.find_library('idn', required : false)
|
|
|
|
endif
|
2018-12-08 13:50:36 +01:00
|
|
|
if libidn_dep.found()
|
2018-12-06 15:16:13 +01:00
|
|
|
if enable_runtime == 'auto'
|
|
|
|
enable_runtime = 'libidn'
|
|
|
|
endif
|
|
|
|
if enable_builtin == 'auto'
|
|
|
|
enable_builtin = 'libidn'
|
|
|
|
endif
|
2018-12-08 20:13:51 +01:00
|
|
|
elif [enable_runtime, enable_builtin].contains('libidn')
|
|
|
|
error('You requested libidn but it is not installed.')
|
2018-12-06 15:16:13 +01:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if libidn2_dep.found() or libidn_dep.found()
|
|
|
|
# Check for libunistring, we need it for psl_str_to_utf8lower()
|
|
|
|
libunistring = cc.find_library('unistring')
|
2022-01-04 13:49:58 +01:00
|
|
|
found_iconv = false
|
|
|
|
if cc.has_function('iconv_open')
|
|
|
|
libiconv_dep = []
|
|
|
|
found_iconv = true
|
|
|
|
endif
|
|
|
|
if not found_iconv and cc.has_header_symbol('iconv.h', 'iconv_open')
|
|
|
|
libiconv_dep = [cc.find_library('iconv')]
|
|
|
|
found_iconv = true
|
|
|
|
endif
|
|
|
|
|
|
|
|
if not found_iconv
|
|
|
|
error('iconv implementation not found')
|
|
|
|
endif
|
2018-12-06 15:16:13 +01:00
|
|
|
endif
|
|
|
|
|
2018-12-11 02:26:13 +01:00
|
|
|
if host_machine.system() == 'windows'
|
|
|
|
networking_deps = cc.find_library('ws2_32')
|
|
|
|
endif
|
|
|
|
|
2018-12-06 15:16:13 +01:00
|
|
|
if enable_runtime == 'auto'
|
|
|
|
enable_runtime = 'no'
|
|
|
|
endif
|
|
|
|
if enable_builtin == 'auto'
|
|
|
|
enable_builtin = 'no'
|
|
|
|
endif
|
|
|
|
|
|
|
|
config = configuration_data()
|
|
|
|
config.set_quoted('PACKAGE_VERSION', meson.project_version())
|
|
|
|
config.set('WITH_LIBIDN2', enable_runtime == 'libidn2')
|
|
|
|
config.set('WITH_LIBICU', enable_runtime == 'libicu')
|
|
|
|
config.set('WITH_LIBIDN', enable_runtime == 'libidn')
|
|
|
|
config.set('BUILTIN_GENERATOR_LIBIDN2', enable_builtin == 'libidn2')
|
|
|
|
config.set('BUILTIN_GENERATOR_LIBICU', enable_builtin == 'libicu')
|
|
|
|
config.set('BUILTIN_GENERATOR_LIBIDN', enable_builtin == 'libidn')
|
|
|
|
config.set('HAVE_UNISTD_H', cc.check_header('unistd.h'))
|
|
|
|
config.set('HAVE_STDINT_H', cc.check_header('stdint.h'))
|
|
|
|
config.set('HAVE_ALLOCA_H', cc.check_header('alloca.h'))
|
2019-06-04 21:31:43 +02:00
|
|
|
config.set('HAVE_DIRENT_H', cc.check_header('dirent.h'))
|
2018-12-06 15:16:13 +01:00
|
|
|
config.set('HAVE_ALLOCA', cc.has_function('alloca'))
|
|
|
|
config.set('HAVE_STRNDUP', cc.has_function('strndup'))
|
|
|
|
config.set('HAVE_CLOCK_GETTIME', cc.has_function('clock_gettime'))
|
|
|
|
config.set('HAVE_FMEMOPEN', cc.has_function('fmemopen'))
|
|
|
|
config.set('HAVE_NL_LANGINFO', cc.has_function('nl_langinfo'))
|
|
|
|
configure_file(output : 'config.h', configuration : config)
|
|
|
|
|
|
|
|
configinc = include_directories('.')
|
|
|
|
includedir = include_directories('include')
|
|
|
|
|
|
|
|
psl_distfile = get_option('psl_distfile')
|
|
|
|
psl_file = get_option('psl_file')
|
|
|
|
if psl_file == ''
|
|
|
|
psl_file = join_paths(meson.current_source_dir(), 'list', 'public_suffix_list.dat')
|
|
|
|
endif
|
|
|
|
psl_test_file = get_option('psl_testfile')
|
|
|
|
if psl_test_file == ''
|
|
|
|
psl_test_file = join_paths(meson.current_source_dir(), 'list', 'tests', 'tests.txt')
|
|
|
|
endif
|
|
|
|
|
|
|
|
python = import('python').find_installation()
|
|
|
|
pkgconfig = import('pkgconfig')
|
|
|
|
|
2018-12-11 02:26:13 +01:00
|
|
|
if cc.get_id() == 'msvc'
|
|
|
|
if not cc.has_header_symbol('stdio.h', 'snprintf')
|
|
|
|
if cc.has_header_symbol('stdio.h', '_snprintf')
|
|
|
|
add_project_arguments('-Dsnprintf=_snprintf', language: 'c')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
if cc.has_header_symbol('malloc.h', '_alloca')
|
|
|
|
add_project_arguments('-Dalloca=_alloca', language: 'c')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-12-06 15:16:13 +01:00
|
|
|
subdir('include')
|
|
|
|
subdir('src')
|
|
|
|
subdir('tools')
|
|
|
|
subdir('tests')
|
2018-12-08 14:07:57 +01:00
|
|
|
subdir('fuzz')
|
2021-01-15 02:02:53 +01:00
|
|
|
subdir(join_paths('docs', 'libpsl'))
|