putenv.m4 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # putenv.m4 serial 20
  2. dnl Copyright (C) 2002-2014 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. dnl From Jim Meyering.
  7. dnl
  8. dnl Check whether putenv ("FOO") removes FOO from the environment.
  9. dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
  10. AC_DEFUN([gl_FUNC_PUTENV],
  11. [
  12. AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
  13. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  14. AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
  15. [gl_cv_func_svid_putenv],
  16. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[
  17. /* Put it in env. */
  18. if (putenv ("CONFTEST_putenv=val"))
  19. return 1;
  20. /* Try to remove it. */
  21. if (putenv ("CONFTEST_putenv"))
  22. return 2;
  23. /* Make sure it was deleted. */
  24. if (getenv ("CONFTEST_putenv") != 0)
  25. return 3;
  26. return 0;
  27. ]])],
  28. gl_cv_func_svid_putenv=yes,
  29. gl_cv_func_svid_putenv=no,
  30. dnl When crosscompiling, assume putenv is broken.
  31. [case "$host_os" in
  32. # Guess yes on glibc systems.
  33. *-gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
  34. # If we don't know, assume the worst.
  35. *) gl_cv_func_svid_putenv="guessing no" ;;
  36. esac
  37. ])
  38. ])
  39. case "$gl_cv_func_svid_putenv" in
  40. *yes) ;;
  41. *)
  42. REPLACE_PUTENV=1
  43. ;;
  44. esac
  45. ])
  46. # Prerequisites of lib/putenv.c.
  47. AC_DEFUN([gl_PREREQ_PUTENV],
  48. [
  49. AC_CHECK_DECLS([_putenv])
  50. ])