Blame m4/putenv.m4

Packit Service 4684c1
# putenv.m4 serial 24
Packit Service 4684c1
dnl Copyright (C) 2002-2020 Free Software Foundation, Inc.
Packit Service 4684c1
dnl This file is free software; the Free Software Foundation
Packit Service 4684c1
dnl gives unlimited permission to copy and/or distribute it,
Packit Service 4684c1
dnl with or without modifications, as long as this notice is preserved.
Packit Service 4684c1
Packit Service 4684c1
dnl From Jim Meyering.
Packit Service 4684c1
dnl
Packit Service 4684c1
dnl Check whether putenv ("FOO") removes FOO from the environment.
Packit Service 4684c1
dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gl_FUNC_PUTENV],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
Packit Service 4684c1
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit Service 4684c1
  AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
Packit Service 4684c1
   [gl_cv_func_svid_putenv],
Packit Service 4684c1
   [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[
Packit Service 4684c1
    /* Put it in env.  */
Packit Service 4684c1
    if (putenv ("CONFTEST_putenv=val"))
Packit Service 4684c1
      return 1;
Packit Service 4684c1
Packit Service 4684c1
    /* Try to remove it.  */
Packit Service 4684c1
    if (putenv ("CONFTEST_putenv"))
Packit Service 4684c1
      return 2;
Packit Service 4684c1
Packit Service 4684c1
    /* Make sure it was deleted.  */
Packit Service 4684c1
    if (getenv ("CONFTEST_putenv") != 0)
Packit Service 4684c1
      return 3;
Packit Service 4684c1
Packit Service 4684c1
    return 0;
Packit Service 4684c1
              ]])],
Packit Service 4684c1
             gl_cv_func_svid_putenv=yes,
Packit Service 4684c1
             gl_cv_func_svid_putenv=no,
Packit Service 4684c1
             dnl When crosscompiling, assume putenv is broken.
Packit Service 4684c1
             [case "$host_os" in
Packit Service 4684c1
                               # Guess yes on glibc systems.
Packit Service 4684c1
                *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
Packit Service 4684c1
                               # Guess yes on musl systems.
Packit Service 4684c1
                *-musl*)       gl_cv_func_svid_putenv="guessing yes" ;;
Packit Service 4684c1
                               # Guess no on native Windows.
Packit Service 4684c1
                mingw*)        gl_cv_func_svid_putenv="guessing no" ;;
Packit Service 4684c1
                               # If we don't know, obey --enable-cross-guesses.
Packit Service 4684c1
                *)             gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;;
Packit Service 4684c1
              esac
Packit Service 4684c1
             ])
Packit Service 4684c1
   ])
Packit Service 4684c1
  case "$gl_cv_func_svid_putenv" in
Packit Service 4684c1
    *yes) ;;
Packit Service 4684c1
    *)
Packit Service 4684c1
      REPLACE_PUTENV=1
Packit Service 4684c1
      ;;
Packit Service 4684c1
  esac
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# Prerequisites of lib/putenv.c.
Packit Service 4684c1
AC_DEFUN([gl_PREREQ_PUTENV],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_CHECK_DECLS([_putenv])
Packit Service 4684c1
])