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_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 AC_CHECK_FUNCS_ONCE([setenv])
11 if test $ac_cv_func_setenv = no; then
18 # Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
19 AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
21 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
22 AC_CHECK_FUNCS_ONCE([setenv])
23 if test $ac_cv_func_setenv = no; then
29 AC_DEFUN([gl_FUNC_UNSETENV],
31 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
32 AC_CHECK_FUNCS([unsetenv])
33 if test $ac_cv_func_unsetenv = no; then
38 AC_CACHE_CHECK([for unsetenv() return type], gt_cv_func_unsetenv_ret,
39 [AC_TRY_COMPILE([#include <stdlib.h>
44 #if defined(__STDC__) || defined(__cplusplus)
45 int unsetenv (const char *name);
49 ], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')])
50 if test $gt_cv_func_unsetenv_ret = 'void'; then
56 # Check if a variable is properly declared.
57 # gt_CHECK_VAR_DECL(includes,variable)
58 AC_DEFUN([gt_CHECK_VAR_DECL],
60 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
61 AC_MSG_CHECKING([if $2 is properly declared])
62 AC_CACHE_VAL(gt_cv_var, [
64 extern struct { int foo; } $2;],
68 AC_MSG_RESULT($gt_cv_var)
69 if test $gt_cv_var = yes; then
70 AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_DECL], 1,
71 [Define if you have the declaration of $2.])
75 # Prerequisites of lib/setenv.c.
76 AC_DEFUN([gl_PREREQ_SETENV],
78 AC_REQUIRE([AC_FUNC_ALLOCA])
79 AC_CHECK_HEADERS_ONCE(unistd.h)
80 AC_CHECK_HEADERS(search.h)
81 AC_CHECK_FUNCS(tsearch)
82 gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
85 # Prerequisites of lib/unsetenv.c.
86 AC_DEFUN([gl_PREREQ_UNSETENV],
88 AC_CHECK_HEADERS_ONCE(unistd.h)
89 gt_CHECK_VAR_DECL([#include <unistd.h>], environ)