Solaris is slightly different, use configure to find out what we need.
authorFabian Groffen <grobian@gentoo.org>
Sat, 13 Oct 2007 14:29:13 +0000 (14:29 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 13 Oct 2007 14:29:13 +0000 (14:29 -0000)
We compile on Darwin, Solaris and FreeBSD now.  Probably Linux breaks.

svn path=/main/branches/prefix/; revision=8112

configure.in
src/chpathtool.c

index cb92f2514949dca93186b2cb310c246a969b58c1..c23cc011b9127f0153d0b849954615f0a8ac2f19 100644 (file)
@@ -49,13 +49,46 @@ GENTOO_PATH_GNUPROG(GREP, [grep])
 dnl Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([string.h strings.h errno.h unistd.h stdio.h stdlib.h])
-AC_CHECK_HEADERS([sys/stat.h sys/types.h dirent.h sys/time.h])
+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_CHECK_LIB([c], [strcpy])
 AC_CHECK_LIB([c], [strstr])
 AC_CHECK_LIB([c], [memcpy])
 
+AC_TRY_LINK([
+                        #include <sys/types.h>
+                        #include <sys/stat.h>
+                        #ifdef HAVE_FCNTL_H
+                        #include <fcntl.h>
+                        #endif
+                ], [
+                        struct stat s;
+                        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_TRY_LINK([
+                        #include <sys/types.h>
+                        #include <sys/stat.h>
+                        #ifdef HAVE_FCNTL_H
+                        #include <fcntl.h>
+                        #endif
+                ], [
+                        struct stat s;
+                        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_ARG_ENABLE(tbz2tool,
 AC_HELP_STRING([--enable-tbz2tool],[build tbz2tool, tool for creating binpkgs (default yes)]),
 [case "${enableval}" in
index 07c1d256ad7f291ff7959b8dc09ae4fde38e23b2..032032def9bee974f77ff83bc07ec52bfabee713 100644 (file)
@@ -25,6 +25,7 @@
 #include <alloca.h>
 #endif
 #include <sys/time.h>
+#include <fcntl.h>
 
 /* Don't allocate too much, or you'll be paying for waiting on IO,
  * size -1 to align in memory. */
@@ -255,10 +256,10 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
                                                trg, strerror(errno));
                                return(-1);
                        }
-                       times[0].tv_sec = s.st_atimespec.tv_sec;
-                       times[0].tv_usec = s.st_atimespec.tv_nsec;
-                       times[1].tv_sec = s.st_mtimespec.tv_sec;
-                       times[1].tv_usec = s.st_mtimespec.tv_nsec;
+                       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;
                        if (utimes(trg, times) != 0) {
                                fprintf(stderr, "failed to set utimes of %s: %s\n",
                                                trg, strerror(errno));
@@ -327,10 +328,10 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
                                trg, strerror(errno));
                return(-1);
        }
-       times[0].tv_sec = s.st_atimespec.tv_sec;
-       times[0].tv_usec = s.st_atimespec.tv_nsec;
-       times[1].tv_sec = s.st_mtimespec.tv_sec;
-       times[1].tv_usec = s.st_mtimespec.tv_nsec;
+       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;
        if (utimes(trg, times) != 0) {
                fprintf(stderr, "failed to set utimes of %s: %s\n",
                                trg, strerror(errno));