Debian Codegraph @

m4/tmpfile.m4

raw
1 # tmpfile.m4 serial 4
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.
6
7 # Written by Ben Pfaff.
8
9 # Check whether to use a replacement tmpfile() function.
10
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.
15 #
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).
20
21 # On Android 4.3, tmpfile() always returns NULL, even if TMPDIR is set
22 # to a writable directory.
23
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__
31 choke me
32 #endif
33 ],
34 [gl_cv_func_tmpfile_works=no],
35 [AC_RUN_IFELSE(
36 [AC_LANG_SOURCE([[
37 #include <stdio.h>
38 #include <stdlib.h>
39 int
40 main (void)
41 {
42 return tmpfile () == NULL;
43 }]])],
44 [gl_cv_func_tmpfile_works=yes],
45 [gl_cv_func_tmpfile_works=no],
46 [case "$host_os" in
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" ;;
51 esac
52 ])
53 ])
54 ])
55 case "$gl_cv_func_tmpfile_works" in
56 *yes) ;;
57 *) REPLACE_TMPFILE=1 ;;
58 esac
59 ])
60
61 # Prerequisites of lib/tmpfile.c.
62 AC_DEFUN([gl_PREREQ_TMPFILE], [:])