environ.m4 1.4 KB

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