From aefc8007c6855ced471c8b5bcba83fccec1cc111 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 21 Dec 2016 23:49:11 +0530 Subject: [PATCH] meson: Add several missing features from configure.ac * -Wl,-Bsymbolic-functions * HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID * HAVE_POSIX_TIMERS * HAVE_MONOTONIC_CLOCK * HAVE_UINT128_T * HAVE_LONG_LONG * HAVE_PROCESS_H * HAVE_GMP * HAVE_GSL * HAVE_DLADDR Also, don't use prefix for checking functions, and only check msvc functions on Windows. --- gst/meson.build | 3 +- meson.build | 76 +++++++++++++++++++++++++++++++++++++++++++++---- tests/check/meson.build | 2 +- 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/gst/meson.build b/gst/meson.build index 2b8a224..42d6368 100644 --- a/gst/meson.build +++ b/gst/meson.build @@ -220,7 +220,8 @@ if libtype != 'static' include_directories('parse')], link_with : printf_lib, install : true, - dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib, unwind_dep, dw_dep] + platform_deps, + dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib, dl_dep, + unwind_dep, dw_dep] + platform_deps, vs_module_defs: vs_module_defs_dir + 'libgstreamer.def', ) libgst = libgst_shared diff --git a/meson.build b/meson.build index 9571caa..0a8846e 100644 --- a/meson.build +++ b/meson.build @@ -15,6 +15,8 @@ else gst_version_nano = 0 endif +host_system = host_machine.system() + apiversion = '1.0' soversion = 0 # maintaining compatibility with the previous libtool versioning @@ -40,6 +42,10 @@ if cc.get_id() == 'msvc' '/wd4244', # lossy type conversion (e.g. double -> int) '/wd4305', # truncating type conversion (e.g. double -> float) language : 'c') +elif cc.has_argument('-Wl,-Bsymbolic-functions') + # FIXME: Add an option for this if people ask for it + add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c') + # FIXME: Add FATAL_WARNINGS from configure.ac endif cdata = configuration_data() @@ -171,6 +177,51 @@ if cc.has_function('localtime_r', prefix : '#include') cdata.set('HAVE_DECL_LOCALTIME_R', 1) endif +if cc.links('''#include + int main() { + pthread_setname_np("example"); + }''', name : 'pthread_setname_np(const char*)') + cdata.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1) +endif + +# Check for posix timers and the monotonic clock +time_prefix = '#include \n' +if cdata.has('HAVE_UNISTD_H') + time_prefix += '#include ' +endif + +posix_timers_src = time_prefix + ''' +#if !defined(_POSIX_TIMERS) || _POSIX_TIMERS < 0 || !defined(CLOCK_REALTIME) +#error Either _POSIX_TIMERS or CLOCK_REALTIME not defined +#endif +''' +if cc.compiles(posix_timers_src, prefix : time_prefix, name : 'posix timers from time.h') + cdata.set('HAVE_POSIX_TIMERS', 1) +endif + +monotonic_clock_src = time_prefix + ''' +#if !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK < 0 || !defined(CLOCK_MONOTONIC) +#error Either _POSIX_MONOTONIC_CLOCK or CLOCK_MONOTONIC not defined +#endif +''' +if cc.compiles(monotonic_clock_src, prefix : time_prefix, name : 'monotonic clock from time.h') + cdata.set('HAVE_MONOTONIC_CLOCK', 1) +endif + +# Check for __uint128_t (gcc) by checking for 128-bit division +uint128_t_src = '''int main() { +static __uint128_t v1 = 100; +static __uint128_t v2 = 10; +static __uint128_t u; +u = v1 / v2; +}''' +if cc.compiles(uint128_t_src, name : '__uint128_t available') + cdata.set('HAVE_UINT128_T', 1) +endif + +# All supported platforms have long long now +cdata.set('HAVE_LONG_LONG', 1) + # We only want to use the __declspec(dllexport/import) dance in GST_EXPORT when # building with MSVC if cc.get_id() == 'msvc' @@ -182,14 +233,15 @@ endif # ------------------------------------------------------------------------------------- # config.h things needed by libcheck # ------------------------------------------------------------------------------------- -if cc.has_function('getpid', prefix : '#include \n#include ') +if cc.has_function('getpid') cdata.set('HAVE_GETPID', 1) -elif cc.has_function('_getpid', prefix : '#include ') - cdata.set('HAVE__GETPID', 1) # Windows (MSVC) +elif host_system == 'windows' and cc.has_function('_getpid') + cdata.set('HAVE_PROCESS_H', 1) # Used by gstreamer too + cdata.set('HAVE__GETPID', 1) endif -if cc.has_function('strdup', prefix : '#include ') +if cc.has_function('strdup') cdata.set('HAVE_DECL_STRDUP', 1) -elif cc.has_function('_strdup', prefix : '#include ') +elif host_system == 'windows' and cc.has_function('_strdup') cdata.set('HAVE__STRDUP', 1) # Windows (MSVC) endif if host_machine.system() != 'windows' @@ -198,7 +250,7 @@ else # libcheck requires HAVE_FORK to be 0 when fork() is not available cdata.set('HAVE_FORK', 0) endif -if cc.has_function('strsignal', prefix : '#include ') +if cc.has_function('strsignal') cdata.set('HAVE_DECL_STRSIGNAL', 1) endif # Check for availability of types @@ -258,6 +310,18 @@ if get_option('disable_gst_debug') add_project_arguments(['-Wno-unused'], language: 'c') endif +# Used by the gstutils test +gmp_dep = cc.find_library('gmp', required : false) +cdata.set('HAVE_GMP', gmp_dep.found()) +gsl_dep = cc.find_library('gsl', required : false) +gslcblas_dep = cc.find_library('gslcblas', required : false) +cdata.set('HAVE_GSL', gsl_dep.found() and gslcblas_dep.found()) +test_deps = [gmp_dep, gsl_dep, gslcblas_dep] + +# Used by gstinfo.c +dl_dep = cc.find_library('dl', required : false) +cdata.set('HAVE_DLADDR', cc.has_function('dladdr', dependencies : dl_dep)) + configure_file(input : 'config.h.meson', output : 'config.h', configuration : cdata) diff --git a/tests/check/meson.build b/tests/check/meson.build index 7d764eb..a6cbdbb8 100644 --- a/tests/check/meson.build +++ b/tests/check/meson.build @@ -133,7 +133,7 @@ foreach t : core_tests c_args : gst_c_args + test_defines, cpp_args : gst_c_args + test_defines, include_directories : [configinc], - dependencies : glib_deps + gst_deps, + dependencies : test_deps + glib_deps + gst_deps, ) env = environment() -- 2.7.4