setenv.m4 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # setenv.m4 serial 11
  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_FUNC_SETENV],
  7. [
  8. AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
  9. AC_CHECK_FUNCS_ONCE([setenv])
  10. if test $ac_cv_func_setenv = no; then
  11. HAVE_SETENV=0
  12. AC_LIBOBJ([setenv])
  13. gl_PREREQ_SETENV
  14. fi
  15. ])
  16. # Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
  17. AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
  18. [
  19. AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
  20. AC_CHECK_FUNCS_ONCE([setenv])
  21. if test $ac_cv_func_setenv = no; then
  22. HAVE_SETENV=0
  23. fi
  24. gl_PREREQ_SETENV
  25. ])
  26. AC_DEFUN([gl_FUNC_UNSETENV],
  27. [
  28. AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
  29. AC_CHECK_FUNCS([unsetenv])
  30. if test $ac_cv_func_unsetenv = no; then
  31. HAVE_UNSETENV=0
  32. AC_LIBOBJ([unsetenv])
  33. gl_PREREQ_UNSETENV
  34. else
  35. AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret],
  36. [AC_TRY_COMPILE([#include <stdlib.h>
  37. extern
  38. #ifdef __cplusplus
  39. "C"
  40. #endif
  41. #if defined(__STDC__) || defined(__cplusplus)
  42. int unsetenv (const char *name);
  43. #else
  44. int unsetenv();
  45. #endif
  46. ], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')])
  47. if test $gt_cv_func_unsetenv_ret = 'void'; then
  48. VOID_UNSETENV=1
  49. fi
  50. fi
  51. ])
  52. # Prerequisites of lib/setenv.c.
  53. AC_DEFUN([gl_PREREQ_SETENV],
  54. [
  55. AC_REQUIRE([AC_FUNC_ALLOCA])
  56. AC_REQUIRE([gl_ENVIRON])
  57. AC_CHECK_HEADERS_ONCE([unistd.h])
  58. AC_CHECK_HEADERS([search.h])
  59. AC_CHECK_FUNCS([tsearch])
  60. ])
  61. # Prerequisites of lib/unsetenv.c.
  62. AC_DEFUN([gl_PREREQ_UNSETENV],
  63. [
  64. AC_REQUIRE([gl_ENVIRON])
  65. AC_CHECK_HEADERS_ONCE([unistd.h])
  66. ])