xref: /freebsd/contrib/ntp/sntp/m4/realpath.m4 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1#
2# SYNOPSIS
3#
4#   NTP_FUNC_REALPATH
5#
6# DESCRIPTION
7#
8#   This macro defines HAVE_FUNC_REALPATH if we have a realpath()
9#   function that accepts NULL as the 2nd argument.
10#
11# LICENSE
12#
13#   Copyright (c) 2020 Network Time Foundation
14#
15#   Author: Harlan Stenn <stenn@nwtime.org>
16#
17#   Copying and distribution of this file, with or without modification, are
18#   permitted in any medium without royalty provided the copyright notice
19#   and this notice are preserved. This file is offered as-is, without any
20#   warranty.
21
22#serial 1
23
24AC_DEFUN([NTP_FUNC_REALPATH], [
25	AC_MSG_CHECKING([for a POSIX-2008 compliant realpath()])
26	AC_REQUIRE([AC_PROG_CC_C99])
27
28	AC_LANG_PUSH([C])
29
30	AC_RUN_IFELSE(
31		[AC_LANG_SOURCE([[
32			#include <sys/param.h>
33			#include <stdlib.h>
34			int main() { return (NULL == realpath(".", NULL)); }
35			]])],
36		ans="yes",
37		ans="no",
38		ans="CROSS COMPILE!"
39		)
40	AC_MSG_RESULT([$ans])
41	case "$ans" in
42	 yes)
43	    AC_DEFINE([HAVE_FUNC_POSIX_REALPATH], [1],
44			[Define to 1 if we have realpath() that supports NULL as the 2nd argument])
45	    ;;
46	esac
47
48	AC_LANG_POP([C])
49	]);
50