summaryrefslogtreecommitdiffstats
path: root/gl/m4/environ.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/environ.m4')
-rw-r--r--gl/m4/environ.m427
1 files changed, 19 insertions, 8 deletions
diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4
index 4c6849a3..593a33ed 100644
--- a/gl/m4/environ.m4
+++ b/gl/m4/environ.m4
@@ -1,5 +1,5 @@
1# environ.m4 serial 4 1# environ.m4 serial 6
2dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,7 +9,16 @@ AC_DEFUN_ONCE([gl_ENVIRON],
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 dnl Persuade glibc <unistd.h> to declare environ. 10 dnl Persuade glibc <unistd.h> to declare environ.
11 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 11 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12 gt_CHECK_VAR_DECL([#include <unistd.h>], environ) 12
13 AC_CHECK_HEADERS_ONCE([unistd.h])
14 gt_CHECK_VAR_DECL(
15 [#if HAVE_UNISTD_H
16 #include <unistd.h>
17 #endif
18 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
19 #include <stdlib.h>
20 ],
21 [environ])
13 if test $gt_cv_var_environ_declaration != yes; then 22 if test $gt_cv_var_environ_declaration != yes; then
14 HAVE_DECL_ENVIRON=0 23 HAVE_DECL_ENVIRON=0
15 fi 24 fi
@@ -22,11 +31,13 @@ AC_DEFUN([gt_CHECK_VAR_DECL],
22 define([gt_cv_var], [gt_cv_var_]$2[_declaration]) 31 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
23 AC_MSG_CHECKING([if $2 is properly declared]) 32 AC_MSG_CHECKING([if $2 is properly declared])
24 AC_CACHE_VAL([gt_cv_var], [ 33 AC_CACHE_VAL([gt_cv_var], [
25 AC_TRY_COMPILE([$1 34 AC_COMPILE_IFELSE(
26 extern struct { int foo; } $2;], 35 [AC_LANG_PROGRAM(
27 [$2.foo = 1;], 36 [[$1
28 gt_cv_var=no, 37 extern struct { int foo; } $2;]],
29 gt_cv_var=yes)]) 38 [[$2.foo = 1;]])],
39 [gt_cv_var=no],
40 [gt_cv_var=yes])])
30 AC_MSG_RESULT([$gt_cv_var]) 41 AC_MSG_RESULT([$gt_cv_var])
31 if test $gt_cv_var = yes; then 42 if test $gt_cv_var = yes; then
32 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1, 43 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,