diff options
Diffstat (limited to 'build/moz.configure/libraries.configure')
-rw-r--r-- | build/moz.configure/libraries.configure | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/build/moz.configure/libraries.configure b/build/moz.configure/libraries.configure new file mode 100644 index 0000000000..cac37e0ae5 --- /dev/null +++ b/build/moz.configure/libraries.configure @@ -0,0 +1,55 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + +@template +def check_clock_monotonic_support(lib=None, when=None): + check_msg = "for clock_gettime(CLOCK_MONOTONIC)" + flags = [] + + if lib is not None: + check_msg += f" in {lib}" + flags.append(f"-l{lib}") + + check_when = building_with_gnu_cc + if when is not None: + check_when &= when + + return try_link( + includes=["time.h"], + body="struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);", + check_msg=check_msg, + flags=flags, + when=check_when, + ) + + +have_raw_clock_monotonic_support = check_clock_monotonic_support() +have_rt_clock_monotonic_support = check_clock_monotonic_support( + lib="rt", when=~have_raw_clock_monotonic_support +) + +set_define( + "HAVE_CLOCK_MONOTONIC", + have_raw_clock_monotonic_support | have_rt_clock_monotonic_support, +) +set_config( + "HAVE_CLOCK_MONOTONIC", + have_raw_clock_monotonic_support | have_rt_clock_monotonic_support, +) + +set_config("REALTIME_LIBS", ["-lrt"], when=have_rt_clock_monotonic_support) + + +have_res_ninit = try_link( + includes=["sys/types.h", "netinet/in.h", "arpa/nameser.h", "resolv.h"], + body="int foo = res_ninit(&_res);", + check_msg="for res_ninit()", + flags=depends(when=building_linux)(["-D_BSD_SOURCE=1"]), + when=building_with_gnu_cc & ~target_is_netbsd & ~target_is_openbsd, +) + +set_define("HAVE_RES_NINIT", have_res_ninit) |