stack-trace: Use libasan as an alternative to libbacktrace.
[gnulib.git] / m4 / putenv.m4
blob5616fdf558a3a2f61df8ba305a4ba839c83bf366
1 # putenv.m4
2 # serial 28
3 dnl Copyright (C) 2002-2024 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.
8 dnl From Jim Meyering.
9 dnl
10 dnl Check whether putenv ("FOO") removes FOO from the environment.
11 dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
13 AC_DEFUN([gl_FUNC_PUTENV],
15   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
16   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
17   AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
18     [gl_cv_func_svid_putenv],
19     [AC_RUN_IFELSE(
20        [AC_LANG_PROGRAM(
21           [AC_INCLUDES_DEFAULT
22            GL_MDA_DEFINES],
23           [[
24             /* Put it in env.  */
25             if (putenv ("CONFTEST_putenv=val"))
26               return 1;
28             /* Try to remove it.  */
29             if (putenv ("CONFTEST_putenv"))
30               return 2;
32             /* Make sure it was deleted.  */
33             if (getenv ("CONFTEST_putenv") != 0)
34               return 3;
36             return 0;
37           ]])],
38        [gl_cv_func_svid_putenv=yes],
39        [gl_cv_func_svid_putenv=no],
40        [dnl When crosscompiling, assume putenv is broken.
41         case "$host_os" in
42                               # Guess yes on glibc systems.
43           *-gnu* | gnu*)      gl_cv_func_svid_putenv="guessing yes" ;;
44                               # Guess yes on musl systems.
45           *-musl* | midipix*) gl_cv_func_svid_putenv="guessing yes" ;;
46                               # Guess no on native Windows.
47           mingw* | windows*)  gl_cv_func_svid_putenv="guessing no" ;;
48                               # If we don't know, obey --enable-cross-guesses.
49           *)                  gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;;
50         esac
51        ])
52     ])
53   case "$gl_cv_func_svid_putenv" in
54     *yes) ;;
55     *)
56       REPLACE_PUTENV=1
57       ;;
58   esac
61 # Prerequisites of lib/putenv.c.
62 AC_DEFUN([gl_PREREQ_PUTENV],
64   AC_CHECK_DECLS_ONCE([_putenv])