2 # Copyright (C) 2007, 2009-2020 Free Software Foundation, Inc.
3 # This file is free software; the Free Software Foundation
4 # gives unlimited permission to copy and/or distribute it,
5 # with or without modifications, as long as this notice is preserved.
7 # Written by Ben Pfaff.
9 # Check whether to use a replacement tmpfile() function.
11 # The native Windows tmpfile function always tries to put the temporary
12 # file in the root directory. (This behaviour is even documented in
13 # Microsoft's documentation!) This often fails for ordinary users who
14 # don't have the permissions to write in the root directory.
16 # We can't test for tmpfile even at runtime, since our test program
17 # might be running with privileges that allow it to write to the root
18 # directory, even though tmpfile wouldn't work in general. Instead,
19 # just test for a Windows platform (excluding Cygwin).
21 # On Android 4.3, tmpfile() always returns NULL, even if TMPDIR is set
22 # to a writable directory.
24 AC_DEFUN([gl_FUNC_TMPFILE], [
25 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
26 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
27 AC_CACHE_CHECK([whether tmpfile works],
28 [gl_cv_func_tmpfile_works],
29 [AC_EGREP_CPP([choke me], [
30 #if defined _WIN32 && !defined __CYGWIN__
34 [gl_cv_func_tmpfile_works=no],
42 return tmpfile () == NULL;
44 [gl_cv_func_tmpfile_works=yes],
45 [gl_cv_func_tmpfile_works=no],
47 # Guess no on Android.
48 linux*-android*) gl_cv_func_tmpfile_works="guessing no" ;;
49 # Guess yes otherwise.
50 *) gl_cv_func_tmpfile_works="guessing yes" ;;
55 case "$gl_cv_func_tmpfile_works" in
57 *) REPLACE_TMPFILE=1 ;;
61 # Prerequisites of lib/tmpfile.c.
62 AC_DEFUN([gl_PREREQ_TMPFILE], [:])