root / firmware / fx2 / config / mkstemp.m4 @ 70eae1d2
History | View | Annotate | Download (2.2 kB)
| 1 |
#serial 4 |
|---|---|
| 2 |
|
| 3 |
# On some hosts (e.g., HP-UX 10.20, SunOS 4.1.4, Solaris 2.5.1), mkstemp has a |
| 4 |
# silly limit that it can create no more than 26 files from a given template. |
| 5 |
# Other systems lack mkstemp altogether. |
| 6 |
# On OSF1/Tru64 V4.0F, the system-provided mkstemp function can create |
| 7 |
# only 32 files per process. |
| 8 |
# On systems like the above, arrange to use the replacement function. |
| 9 |
AC_DEFUN([UTILS_FUNC_MKSTEMP], |
| 10 |
[dnl |
| 11 |
AC_REPLACE_FUNCS(mkstemp) |
| 12 |
if test $ac_cv_func_mkstemp = no; then |
| 13 |
utils_cv_func_mkstemp_limitations=yes |
| 14 |
else |
| 15 |
AC_CACHE_CHECK([for mkstemp limitations], |
| 16 |
utils_cv_func_mkstemp_limitations, |
| 17 |
[ |
| 18 |
AC_TRY_RUN([ |
| 19 |
# include <stdlib.h> |
| 20 |
int main () |
| 21 |
{
|
| 22 |
int i; |
| 23 |
for (i = 0; i < 70; i++) |
| 24 |
{
|
| 25 |
char template[] = "conftestXXXXXX"; |
| 26 |
int fd = mkstemp (template); |
| 27 |
if (fd == -1) |
| 28 |
exit (1); |
| 29 |
close (fd); |
| 30 |
} |
| 31 |
exit (0); |
| 32 |
} |
| 33 |
], |
| 34 |
utils_cv_func_mkstemp_limitations=no, |
| 35 |
utils_cv_func_mkstemp_limitations=yes, |
| 36 |
utils_cv_func_mkstemp_limitations=yes |
| 37 |
) |
| 38 |
] |
| 39 |
) |
| 40 |
fi |
| 41 |
|
| 42 |
if test $utils_cv_func_mkstemp_limitations = yes; then |
| 43 |
AC_LIBOBJ(mkstemp) |
| 44 |
AC_LIBOBJ(tempname) |
| 45 |
AC_DEFINE(mkstemp, rpl_mkstemp, |
| 46 |
[Define to rpl_mkstemp if the replacement function should be used.]) |
| 47 |
gl_PREREQ_MKSTEMP |
| 48 |
jm_PREREQ_TEMPNAME |
| 49 |
fi |
| 50 |
]) |
| 51 |
|
| 52 |
# Prerequisites of lib/mkstemp.c. |
| 53 |
AC_DEFUN([gl_PREREQ_MKSTEMP], |
| 54 |
[ |
| 55 |
AH_BOTTOM( |
| 56 |
[ |
| 57 |
#ifndef HAVE_MKSTEMP |
| 58 |
#ifdef __cplusplus |
| 59 |
extern "C" {
|
| 60 |
#endif |
| 61 |
int rpl_mkstemp (char *templ); |
| 62 |
#ifdef __cplusplus |
| 63 |
} |
| 64 |
#endif |
| 65 |
#endif |
| 66 |
]) |
| 67 |
]) |
| 68 |
|
| 69 |
# Prerequisites of lib/tempname.c. |
| 70 |
AC_DEFUN([jm_PREREQ_TEMPNAME], |
| 71 |
[ |
| 72 |
AC_REQUIRE([AC_HEADER_STAT]) |
| 73 |
AC_CHECK_HEADERS_ONCE(fcntl.h sys/time.h unistd.h) |
| 74 |
AC_CHECK_HEADERS(stdint.h) |
| 75 |
AC_CHECK_FUNCS(__secure_getenv gettimeofday lstat) |
| 76 |
AC_CHECK_DECLS_ONCE(getenv) |
| 77 |
# AC_REQUIRE([jm_AC_TYPE_UINTMAX_T]) |
| 78 |
|
| 79 |
dnl Under Win32, mkdir prototype in io.h has only one arg |
| 80 |
AC_MSG_CHECKING(whether mkdir accepts only one arg) |
| 81 |
AC_TRY_COMPILE([#include <sys/types.h> |
| 82 |
#include <sys/stat.h> |
| 83 |
#include <fcntl.h>], [ |
| 84 |
mkdir("")
|
| 85 |
], [ AC_MSG_RESULT(yes) |
| 86 |
AC_DEFINE(MKDIR_TAKES_ONE_ARG,[],[Define if mkdir accepts only one arg]) ], |
| 87 |
[ AC_MSG_RESULT(no) |
| 88 |
]) |
| 89 |
]) |