environ.m4 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # environ.m4 serial 2
  2. dnl Copyright (C) 2001-2004, 2006-2009 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([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. gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
  12. if test $gt_cv_var_environ_declaration != yes; then
  13. HAVE_DECL_ENVIRON=0
  14. fi
  15. ])
  16. # Check if a variable is properly declared.
  17. # gt_CHECK_VAR_DECL(includes,variable)
  18. AC_DEFUN([gt_CHECK_VAR_DECL],
  19. [
  20. define([gt_cv_var], [gt_cv_var_]$2[_declaration])
  21. AC_MSG_CHECKING([if $2 is properly declared])
  22. AC_CACHE_VAL([gt_cv_var], [
  23. AC_TRY_COMPILE([$1
  24. extern struct { int foo; } $2;],
  25. [$2.foo = 1;],
  26. gt_cv_var=no,
  27. gt_cv_var=yes)])
  28. AC_MSG_RESULT([$gt_cv_var])
  29. if test $gt_cv_var = yes; then
  30. AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_DECL], 1,
  31. [Define if you have the declaration of $2.])
  32. fi
  33. undefine([gt_cv_var])
  34. ])