Mercurial > gnulib
annotate m4/mkstemp.m4 @ 40196:e63f5d3edab5
relocatable-prog: Update documentation.
* doc/relocatable-maint.texi (Supporting Relocation): Update to match
the recent changes.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 24 Feb 2019 01:49:15 +0100 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
19479
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
1 #serial 25 |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5570
diff
changeset
|
2 |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
3 # Copyright (C) 2001, 2003-2007, 2009-2019 Free Software Foundation, Inc. |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5570
diff
changeset
|
4 # This file is free software; the Free Software Foundation |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5570
diff
changeset
|
5 # gives unlimited permission to copy and/or distribute it, |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5570
diff
changeset
|
6 # with or without modifications, as long as this notice is preserved. |
3613
4dd9d0ce43ce
(UTILS_FUNC_MKSTEMP): New file and macro.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
7 |
4474
f1650b772bb6
Correct SunOS and Solaris version number notation to match Sun's usage.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4108
diff
changeset
|
8 # On some hosts (e.g., HP-UX 10.20, SunOS 4.1.4, Solaris 2.5.1), mkstemp has a |
3641
9c9890fb6aca
update comment to reflect that SunOS4, solaris2.5.1 lose, too.
Jim Meyering <jim@meyering.net>
parents:
3632
diff
changeset
|
9 # silly limit that it can create no more than 26 files from a given template. |
4609
6446dccc56f6
Require that the system mkstemp be able to create
Jim Meyering <jim@meyering.net>
parents:
4476
diff
changeset
|
10 # Other systems lack mkstemp altogether. |
6446dccc56f6
Require that the system mkstemp be able to create
Jim Meyering <jim@meyering.net>
parents:
4476
diff
changeset
|
11 # On OSF1/Tru64 V4.0F, the system-provided mkstemp function can create |
6446dccc56f6
Require that the system mkstemp be able to create
Jim Meyering <jim@meyering.net>
parents:
4476
diff
changeset
|
12 # only 32 files per process. |
14627
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
13 # On some hosts, mkstemp creates files with mode 0666, which is a security |
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
14 # problem and a violation of POSIX 2008. |
4609
6446dccc56f6
Require that the system mkstemp be able to create
Jim Meyering <jim@meyering.net>
parents:
4476
diff
changeset
|
15 # On systems like the above, arrange to use the replacement function. |
5037
87454c3545b5
Change UTILS_ to gl_ in AC_DEFINE'd names.
Jim Meyering <jim@meyering.net>
parents:
5016
diff
changeset
|
16 AC_DEFUN([gl_FUNC_MKSTEMP], |
7338 | 17 [ |
8193
acdb54cba552
mkstemp.h is replaced with <stdlib.h>.
Bruno Haible <bruno@clisp.org>
parents:
7594
diff
changeset
|
18 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
19 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
3613
4dd9d0ce43ce
(UTILS_FUNC_MKSTEMP): New file and macro.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
20 |
13120
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
21 AC_CHECK_FUNCS_ONCE([mkstemp]) |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
22 if test $ac_cv_func_mkstemp = yes; then |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
23 AC_CACHE_CHECK([for working mkstemp], |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
24 [gl_cv_func_working_mkstemp], |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
25 [ |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
26 mkdir conftest.mkstemp |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
27 AC_RUN_IFELSE( |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
28 [AC_LANG_PROGRAM( |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
29 [AC_INCLUDES_DEFAULT], |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
30 [[int result = 0; |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
31 int i; |
13120
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
32 off_t large = (off_t) 4294967295u; |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
33 if (large < 0) |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
34 large = 2147483647; |
14627
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
35 umask (0); |
13120
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
36 for (i = 0; i < 70; i++) |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 { |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
38 char templ[] = "conftest.mkstemp/coXXXXXX"; |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
39 int (*mkstemp_function) (char *) = mkstemp; |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
40 int fd = mkstemp_function (templ); |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
41 if (fd < 0) |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
42 result |= 1; |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
43 else |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
44 { |
14627
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
45 struct stat st; |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
46 if (lseek (fd, large, SEEK_SET) != large) |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
47 result |= 2; |
14627
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
48 if (fstat (fd, &st) < 0) |
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
49 result |= 4; |
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
50 else if (st.st_mode & 0077) |
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
51 result |= 8; |
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
52 if (close (fd)) |
780006cfcb42
mkstemp: replace if system version uses wrong permissions
Reuben Thomas <rrt@sc3d.org>
parents:
14079
diff
changeset
|
53 result |= 16; |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
54 } |
13120
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
55 } |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13120
diff
changeset
|
56 return result;]])], |
13120
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
57 [gl_cv_func_working_mkstemp=yes], |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
58 [gl_cv_func_working_mkstemp=no], |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
59 [case "$host_os" in |
19479
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
60 # Guess yes on glibc systems. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
61 *-gnu* | gnu*) gl_cv_func_working_mkstemp="guessing yes" ;; |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
62 # Guess no on native Windows. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
63 mingw*) gl_cv_func_working_mkstemp="guessing no" ;; |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
64 # If we don't know, assume the worst. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
65 *) gl_cv_func_working_mkstemp="guessing no" ;; |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
66 esac |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
67 ]) |
13120
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
68 rm -rf conftest.mkstemp |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
69 ]) |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
70 case "$gl_cv_func_working_mkstemp" in |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
71 *yes) ;; |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
72 *) |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
73 REPLACE_MKSTEMP=1 |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
74 ;; |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
75 esac |
13120
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
76 else |
0f4b3b66e73c
mkstemp: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
77 HAVE_MKSTEMP=0 |
3613
4dd9d0ce43ce
(UTILS_FUNC_MKSTEMP): New file and macro.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
78 fi |
4dd9d0ce43ce
(UTILS_FUNC_MKSTEMP): New file and macro.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
79 ]) |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3641
diff
changeset
|
80 |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3641
diff
changeset
|
81 # Prerequisites of lib/mkstemp.c. |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3641
diff
changeset
|
82 AC_DEFUN([gl_PREREQ_MKSTEMP], |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3641
diff
changeset
|
83 [ |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3641
diff
changeset
|
84 ]) |