Debian Codegraph @

m4/putenv.m4

raw
1 # putenv.m4
2 # serial 28
3 dnl Copyright (C) 2002-2025 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 dnl From Jim Meyering.
10 dnl
11 dnl Check whether putenv ("FOO") removes FOO from the environment.
12 dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
13
14 AC_DEFUN([gl_FUNC_PUTENV],
15 [
16 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
17 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
18 AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
19 [gl_cv_func_svid_putenv],
20 [AC_RUN_IFELSE(
21 [AC_LANG_PROGRAM(
22 [AC_INCLUDES_DEFAULT
23 GL_MDA_DEFINES],
24 [[
25 /* Put it in env. */
26 if (putenv ("CONFTEST_putenv=val"))
27 return 1;
28
29 /* Try to remove it. */
30 if (putenv ("CONFTEST_putenv"))
31 return 2;
32
33 /* Make sure it was deleted. */
34 if (getenv ("CONFTEST_putenv") != 0)
35 return 3;
36
37 return 0;
38 ]])],
39 [gl_cv_func_svid_putenv=yes],
40 [gl_cv_func_svid_putenv=no],
41 [dnl When crosscompiling, assume putenv is broken.
42 case "$host_os" in
43 # Guess yes on glibc systems.
44 *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
45 # Guess yes on musl systems.
46 *-musl* | midipix*) gl_cv_func_svid_putenv="guessing yes" ;;
47 # Guess no on native Windows.
48 mingw* | windows*) gl_cv_func_svid_putenv="guessing no" ;;
49 # If we don't know, obey --enable-cross-guesses.
50 *) gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;;
51 esac
52 ])
53 ])
54 case "$gl_cv_func_svid_putenv" in
55 *yes) ;;
56 *)
57 REPLACE_PUTENV=1
58 ;;
59 esac
60 ])
61
62 # Prerequisites of lib/putenv.c.
63 AC_DEFUN([gl_PREREQ_PUTENV],
64 [
65 AC_CHECK_DECLS_ONCE([_putenv])
66 ])