2 dnl Copyright (C) 2001-2004, 2006-2007 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_CHECK_FUNCS_ONCE([setenv])
10 if test $ac_cv_func_setenv = no; then
16 AC_DEFUN([gl_FUNC_UNSETENV],
18 AC_CHECK_FUNCS([unsetenv])
19 if test $ac_cv_func_unsetenv = no; then
23 AC_CACHE_CHECK([for unsetenv() return type], gt_cv_func_unsetenv_ret,
24 [AC_TRY_COMPILE([#include <stdlib.h>
29 #if defined(__STDC__) || defined(__cplusplus)
30 int unsetenv (const char *name);
34 ], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')])
35 if test $gt_cv_func_unsetenv_ret = 'void'; then
36 AC_DEFINE(VOID_UNSETENV, 1, [Define if unsetenv() returns void, not int.])
41 # Check if a variable is properly declared.
42 # gt_CHECK_VAR_DECL(includes,variable)
43 AC_DEFUN([gt_CHECK_VAR_DECL],
45 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
46 AC_MSG_CHECKING([if $2 is properly declared])
47 AC_CACHE_VAL(gt_cv_var, [
49 extern struct { int foo; } $2;],
53 AC_MSG_RESULT($gt_cv_var)
54 if test $gt_cv_var = yes; then
55 AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_DECL], 1,
56 [Define if you have the declaration of $2.])
60 # Prerequisites of lib/setenv.c.
61 AC_DEFUN([gl_PREREQ_SETENV],
63 AC_REQUIRE([AC_FUNC_ALLOCA])
64 AC_CHECK_HEADERS_ONCE(unistd.h)
65 AC_CHECK_HEADERS(search.h)
66 AC_CHECK_FUNCS(tsearch)
67 gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
70 # Prerequisites of lib/unsetenv.c.
71 AC_DEFUN([gl_PREREQ_UNSETENV],
73 AC_CHECK_HEADERS_ONCE(unistd.h)
74 gt_CHECK_VAR_DECL([#include <unistd.h>], environ)