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