AC_CHECK_HEADERS([sys/stat.h sys/types.h dirent.h sys/time.h alloca.h])
AC_CHECK_HEADERS([fcntl.h])
-AC_CHECK_LIB([c], [readdir])
+AC_SEARCH_LIBS([readdir], [c])
+AC_SEARCH_LIBS([strcpy], [c])
+AC_SEARCH_LIBS([strstr], [c])
+AC_SEARCH_LIBS([memcpy], [c])
AC_MSG_CHECKING([for the *time fields in struct stat])
AC_TRY_LINK([
s.st_atimespec.tv_sec = 0;
s.st_mtimespec.tv_sec = 0;
], [
- AC_DEFINE(ATIMESPEC, st_atimespec, [atime for this platform])
- AC_DEFINE(MTIMESPEC, st_mtimespec, [mtime for this platform])
+ AC_DEFINE(ATIME_SEC, st_atimespec.tv_sec, [atime seconds for this platform])
+ AC_DEFINE(ATIME_NSEC, st_atimespec.tv_nsec, [atime nanoseconds for this platform])
+ AC_DEFINE(MTIME_SEC, st_mtimespec.tv_sec, [mtime seconds for this platform])
+ AC_DEFINE(MTIME_NSEC, st_mtimespec.tv_nsec, [mtime nanoseconds for this platform])
AC_MSG_RESULT([st_*timespec])
], [
AC_TRY_LINK([
s.st_atim.tv_sec = 0;
s.st_mtim.tv_sec = 0;
], [
- AC_DEFINE(ATIMESPEC, st_atim, [atime for this platform])
- AC_DEFINE(MTIMESPEC, st_mtim, [mtime for this platform])
+ AC_DEFINE(ATIME_SEC, st_atim, [atime seconds for this platform])
+ AC_DEFINE(ATIME_NSEC, st_atim.tv_nsec, [atime nanoseconds for this platform])
+ AC_DEFINE(MTIME_SEC, st_mtim, [mtime seconds for this platform])
+ AC_DEFINE(MTIME_NSEC, st_mtim.tv_nsec, [mtime nanoseconds for this platform])
AC_MSG_RESULT([st_*tim])
- ]
-)
+ ], [
+AC_TRY_LINK([
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #ifdef HAVE_FCNTL_H
+ #include <fcntl.h>
+ #endif
+ ], [
+ struct stat s;
+ s.st_atime = 0;
+ s.st_mtime = 0;
+ ], [
+ AC_DEFINE(ATIME_SEC, st_atime, [atime seconds for this platform])
+ AC_DEFINE(MTIME_SEC, st_mtime, [mtime seconds for this platform])
+ AC_MSG_RESULT([st_*time])
], [
AC_MSG_ERROR([cannot determine])
]
)
+ ]
+)
+ ]
+)
AC_MSG_CHECKING([if S_ISWHT can be used])
AC_TRY_LINK([
trg, strerror(errno));
return(-1);
}
- times[0].tv_sec = s.ATIMESPEC.tv_sec;
- times[0].tv_usec = s.ATIMESPEC.tv_nsec;
- times[1].tv_sec = s.MTIMESPEC.tv_sec;
- times[1].tv_usec = s.MTIMESPEC.tv_nsec;
+ times[0].tv_sec = s.ATIME_SEC;
+#ifdef ATIME_NSEC
+ times[0].tv_usec = (s.ATIME_NSEC) / 1000;
+#else
+ times[0].tv_usec = 0;
+#endif
+ times[1].tv_sec = s.MTIME_SEC;
+#ifdef MTIME_NSEC
+ times[1].tv_usec = (s.MTIME_NSEC) / 1000;
+#else
+ times[1].tv_usec = 0;
+#endif
if (utimes(trg, times) != 0) {
fprintf(stderr, "failed to set utimes of %s: %s\n",
trg, strerror(errno));
trg, strerror(errno));
return(-1);
}
- times[0].tv_sec = s.ATIMESPEC.tv_sec;
- times[0].tv_usec = s.ATIMESPEC.tv_nsec;
- times[1].tv_sec = s.MTIMESPEC.tv_sec;
- times[1].tv_usec = s.MTIMESPEC.tv_nsec;
+ times[0].tv_sec = s.ATIME_SEC;
+#ifdef ATIME_NSEC
+ times[0].tv_usec = (s.ATIME_NSEC) / 1000;
+#else
+ times[0].tv_usec = 0;
+#endif
+ times[1].tv_sec = s.MTIME_SEC;
+#ifdef MTIME_NSEC
+ times[1].tv_usec = (s.MTIME_NSEC) / 1000;
+#else
+ times[1].tv_usec = 0;
+#endif
if (utimes(trg, times) != 0) {
fprintf(stderr, "failed to set utimes of %s: %s\n",
trg, strerror(errno));