]> git.cworth.org Git - tar/blob - m4/setenv.m4
7af13d724163c4e5a6ba4071365a929b5a496762
[tar] / m4 / setenv.m4
1 # setenv.m4 serial 10
2 dnl Copyright (C) 2001-2004, 2006-2008 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.
6
7 AC_DEFUN([gl_FUNC_SETENV],
8 [
9   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10   AC_CHECK_FUNCS_ONCE([setenv])
11   if test $ac_cv_func_setenv = no; then
12     HAVE_SETENV=0
13     AC_LIBOBJ([setenv])
14     gl_PREREQ_SETENV
15   fi
16 ])
17
18 # Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
19 AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
20 [
21   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
22   AC_CHECK_FUNCS_ONCE([setenv])
23   if test $ac_cv_func_setenv = no; then
24     HAVE_SETENV=0
25   fi
26   gl_PREREQ_SETENV
27 ])
28
29 AC_DEFUN([gl_FUNC_UNSETENV],
30 [
31   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
32   AC_CHECK_FUNCS([unsetenv])
33   if test $ac_cv_func_unsetenv = no; then
34     HAVE_UNSETENV=0
35     AC_LIBOBJ([unsetenv])
36     gl_PREREQ_UNSETENV
37   else
38     AC_CACHE_CHECK([for unsetenv() return type], gt_cv_func_unsetenv_ret,
39       [AC_TRY_COMPILE([#include <stdlib.h>
40 extern
41 #ifdef __cplusplus
42 "C"
43 #endif
44 #if defined(__STDC__) || defined(__cplusplus)
45 int unsetenv (const char *name);
46 #else
47 int unsetenv();
48 #endif
49 ], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')])
50     if test $gt_cv_func_unsetenv_ret = 'void'; then
51       VOID_UNSETENV=1
52     fi
53   fi
54 ])
55
56 # Prerequisites of lib/setenv.c.
57 AC_DEFUN([gl_PREREQ_SETENV],
58 [
59   AC_REQUIRE([AC_FUNC_ALLOCA])
60   AC_REQUIRE([gl_ENVIRON])
61   AC_CHECK_HEADERS_ONCE(unistd.h)
62   AC_CHECK_HEADERS(search.h)
63   AC_CHECK_FUNCS(tsearch)
64 ])
65
66 # Prerequisites of lib/unsetenv.c.
67 AC_DEFUN([gl_PREREQ_UNSETENV],
68 [
69   AC_REQUIRE([gl_ENVIRON])
70   AC_CHECK_HEADERS_ONCE(unistd.h)
71 ])