Debian Codegraph @

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 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN_ONCE([gl_ENVIRON],
10 [
11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
12 dnl Persuade glibc <unistd.h> to declare environ.
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14
15 AC_CHECK_HEADERS_ONCE([unistd.h])
16 gt_CHECK_VAR_DECL(
17 [#if HAVE_UNISTD_H
18 #include <unistd.h>
19 #endif
20 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
21 #include <stdlib.h>
22 ],
23 [environ])
24 if test $gt_cv_var_environ_declaration != yes; then
25 HAVE_DECL_ENVIRON=0
26 fi
27 ])
28
29 # Check if a variable is properly declared.
30 # gt_CHECK_VAR_DECL(includes,variable)
31 AC_DEFUN([gt_CHECK_VAR_DECL],
32 [
33 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
34 AC_CACHE_CHECK([if $2 is properly declared], [gt_cv_var],
35 [AC_COMPILE_IFELSE(
36 [AC_LANG_PROGRAM(
37 [[$1
38 typedef struct { int foo; } foo_t;
39 extern foo_t $2;]],
40 [[$2.foo = 1;]])],
41 [gt_cv_var=no],
42 [gt_cv_var=yes])])
43 if test $gt_cv_var = yes; then
44 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
45 [Define if you have the declaration of $2.])
46 fi
47 undefine([gt_cv_var])
48 ])