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.
7 AC_DEFUN([gl_FUNC_SETENV],
9 AC_REQUIRE([gl_FUNC_SETENV_SEPARATE])
10 if test $HAVE_SETENV$REPLACE_SETENV != 10; then
15 # Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
16 AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
18 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
19 AC_CHECK_FUNCS_ONCE([setenv])
20 if test $ac_cv_func_setenv = no; then
23 AC_CACHE_CHECK([whether setenv validates arguments],
24 [gl_cv_func_setenv_works],
25 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
29 if (setenv (NULL, "", 0) != -1) return 1;
30 if (errno != EINVAL) return 2;
31 if (setenv ("a", "=", 1) != 0) return 3;
32 if (strcmp (getenv ("a"), "=") != 0) return 4;
34 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
35 [gl_cv_func_setenv_works="guessing no"])])
36 if test "$gl_cv_func_setenv_works" != yes; then
44 AC_DEFUN([gl_FUNC_UNSETENV],
46 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
47 AC_CHECK_FUNCS([unsetenv])
48 if test $ac_cv_func_unsetenv = no; then
53 AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret],
54 [AC_TRY_COMPILE([#include <stdlib.h>
59 #if defined(__STDC__) || defined(__cplusplus)
60 int unsetenv (const char *name);
64 ], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')])
65 if test $gt_cv_func_unsetenv_ret = 'void'; then
66 AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void
74 # Prerequisites of lib/setenv.c.
75 AC_DEFUN([gl_PREREQ_SETENV],
77 AC_REQUIRE([AC_FUNC_ALLOCA])
78 AC_REQUIRE([gl_ENVIRON])
79 AC_CHECK_HEADERS_ONCE([unistd.h])
80 AC_CHECK_HEADERS([search.h])
81 AC_CHECK_FUNCS([tsearch])
84 # Prerequisites of lib/unsetenv.c.
85 AC_DEFUN([gl_PREREQ_UNSETENV],
87 AC_REQUIRE([gl_ENVIRON])
88 AC_CHECK_HEADERS_ONCE([unistd.h])