Debian Codegraph @

gnulib/m4/environ.m4

raw
1 # environ.m4
2 # serial 8
3 dnl Copyright (C) 2001-2004, 2006-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 AC_DEFUN_ONCE([gl_ENVIRON],
9 [
10 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
11 dnl Persuade glibc <unistd.h> to declare environ.
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13
14 AC_CHECK_HEADERS_ONCE([unistd.h])
15 gt_CHECK_VAR_DECL(
16 [#if HAVE_UNISTD_H
17 #include <unistd.h>
18 #endif
19 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
20 #include <stdlib.h>
21 ],
22 [environ])
23 if test $gt_cv_var_environ_declaration != yes; then
24 HAVE_DECL_ENVIRON=0
25 fi
26 ])
27
28 # Check if a variable is properly declared.
29 # gt_CHECK_VAR_DECL(includes,variable)
30 AC_DEFUN([gt_CHECK_VAR_DECL],
31 [
32 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
33 AC_CACHE_CHECK([if $2 is properly declared], [gt_cv_var],
34 [AC_COMPILE_IFELSE(
35 [AC_LANG_PROGRAM(
36 [[$1
37 typedef struct { int foo; } foo_t;
38 extern foo_t $2;]],
39 [[$2.foo = 1;]])],
40 [gt_cv_var=no],
41 [gt_cv_var=yes])])
42 if test $gt_cv_var = yes; then
43 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
44 [Define if you have the declaration of $2.])
45 fi
46 undefine([gt_cv_var])
47 ])