Commit | Line | Data |
---|---|---|
5e69ceb7 MW |
1 | # putenv.m4 serial 20 |
2 | dnl Copyright (C) 2002-2014 Free Software Foundation, Inc. | |
f240aacb LC |
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 | dnl From Jim Meyering. | |
8 | dnl | |
9 | dnl Check whether putenv ("FOO") removes FOO from the environment. | |
10 | dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that. | |
11 | ||
12 | AC_DEFUN([gl_FUNC_PUTENV], | |
13 | [ | |
14 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) | |
005de2e8 | 15 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
f240aacb LC |
16 | AC_CACHE_CHECK([for putenv compatible with GNU and SVID], |
17 | [gl_cv_func_svid_putenv], | |
18 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[ | |
19 | /* Put it in env. */ | |
20 | if (putenv ("CONFTEST_putenv=val")) | |
21 | return 1; | |
22 | ||
23 | /* Try to remove it. */ | |
24 | if (putenv ("CONFTEST_putenv")) | |
0f00f2c3 | 25 | return 2; |
f240aacb LC |
26 | |
27 | /* Make sure it was deleted. */ | |
28 | if (getenv ("CONFTEST_putenv") != 0) | |
0f00f2c3 | 29 | return 3; |
f240aacb LC |
30 | |
31 | return 0; | |
1cd4fffc LC |
32 | ]])], |
33 | gl_cv_func_svid_putenv=yes, | |
34 | gl_cv_func_svid_putenv=no, | |
35 | dnl When crosscompiling, assume putenv is broken. | |
005de2e8 LC |
36 | [case "$host_os" in |
37 | # Guess yes on glibc systems. | |
38 | *-gnu*) gl_cv_func_svid_putenv="guessing yes" ;; | |
39 | # If we don't know, assume the worst. | |
40 | *) gl_cv_func_svid_putenv="guessing no" ;; | |
41 | esac | |
42 | ]) | |
f240aacb | 43 | ]) |
005de2e8 LC |
44 | case "$gl_cv_func_svid_putenv" in |
45 | *yes) ;; | |
46 | *) | |
47 | REPLACE_PUTENV=1 | |
48 | ;; | |
49 | esac | |
f240aacb | 50 | ]) |
af07e104 AW |
51 | |
52 | # Prerequisites of lib/putenv.c. | |
53 | AC_DEFUN([gl_PREREQ_PUTENV], | |
54 | [ | |
5e69ceb7 | 55 | AC_CHECK_DECLS([_putenv]) |
af07e104 | 56 | ]) |