1# setenv.m4 serial 4 2dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. 3dnl This file is free software, distributed under the terms of the GNU 4dnl General Public License. As a special exception to the GNU General 5dnl Public License, this file may be distributed as part of a program 6dnl that contains a configuration script generated by Autoconf, under 7dnl the same distribution terms as the rest of that program. 8 9AC_DEFUN([gt_FUNC_SETENV], 10[ 11 AC_REPLACE_FUNCS(setenv unsetenv) 12 if test $ac_cv_func_setenv = no; then 13 gl_PREREQ_SETENV 14 fi 15 if test $ac_cv_func_unsetenv = no; then 16 gl_PREREQ_UNSETENV 17 fi 18]) 19 20# Check if a variable is properly declared. 21# gt_CHECK_VAR_DECL(includes,variable) 22AC_DEFUN([gt_CHECK_VAR_DECL], 23[ 24 define([gt_cv_var], [gt_cv_var_]$2[_declaration]) 25 AC_MSG_CHECKING([if $2 is properly declared]) 26 AC_CACHE_VAL(gt_cv_var, [ 27 AC_TRY_COMPILE([$1 28 extern struct { int foo; } $2;], 29 [$2.foo = 1;], 30 gt_cv_var=no, 31 gt_cv_var=yes)]) 32 AC_MSG_RESULT($gt_cv_var) 33 if test $gt_cv_var = yes; then 34 AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_DECL], 1, 35 [Define if you have the declaration of $2.]) 36 fi 37]) 38 39# Prerequisites of lib/setenv.c. 40AC_DEFUN([gl_PREREQ_SETENV], 41[ 42 AC_REQUIRE([gl_ALLOCSA]) 43 AC_CHECK_HEADERS_ONCE(stdlib.h string.h unistd.h) 44 AC_CHECK_HEADERS(search.h) 45 AC_CHECK_FUNCS(tsearch) 46 gt_CHECK_VAR_DECL([#include <errno.h>], errno) 47 gt_CHECK_VAR_DECL([#include <unistd.h>], environ) 48]) 49 50# Prerequisites of lib/unsetenv.c. 51AC_DEFUN([gl_PREREQ_UNSETENV], 52[ 53 AC_CHECK_HEADERS_ONCE(stdlib.h string.h unistd.h) 54 gt_CHECK_VAR_DECL([#include <errno.h>], errno) 55 gt_CHECK_VAR_DECL([#include <unistd.h>], environ) 56]) 57