]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Support systems without lstat and detect which libiconv to link
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 6 Jan 2010 08:53:13 +0000 (08:53 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 6 Jan 2010 08:53:13 +0000 (08:53 +0000)
CMakeLists.txt
include/config.h.in
util.c

index edc56fb15f6b3fde9fc3d6911165dc457ccb32e3..9cafb7dab323b532af09f3c1d911a6d3b6c2d7d9 100755 (executable)
@@ -105,6 +105,7 @@ CHECK_INCLUDE_FILE(execinfo.h HAVE_EXECINFO_H)
 CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
 CHECK_FUNCTION_EXISTS(backtrace HAVE_BACKTRACE)
 CHECK_FUNCTION_EXISTS(symlink HAVE_SYMLINK)
+CHECK_FUNCTION_EXISTS(lstat HAVE_LSTAT)
 
 # Find gd
 CHECK_INCLUDE_FILE(gd.h HAVE_GD_H)
@@ -128,11 +129,12 @@ OPTION(ENABLE_ICONV "Enable the usage of iconv" ON)
 IF(ENABLE_ICONV)
    CHECK_INCLUDE_FILE(iconv.h HAVE_ICONV_H)
    IF(HAVE_ICONV_H)
+      FIND_PATH(ICONV_INCLUDE_PATH NAMES iconv.h)
+      FIND_LIBRARY(ICONV_LIBRARY NAMES iconv DOC "The ICONV library")
+      IF(ICONV_LIBRARY)
+         TARGET_LINK_LIBRARIES(sarg ${ICONV_LIBRARY})
+      ENDIF(ICONV_LIBRARY)
       CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV)
-      IF(!HAVE_ICONV)
-         FIND_PATH(ICONV_INCLUDE_PATH NAMES iconv.h)
-         FIND_LIBRARY(ICONV_LIBRARY NAMES iconv DOC "The ICONV library")
-      ENDIF(!HAVE_ICONV)
 
       SET(ICONV_CONST_FILE ${CMAKE_BINARY_DIR}/consticonv.c)
       FILE(WRITE ${ICONV_CONST_FILE} "
index 1fe586b99f37cc888b823c10cc40577fcfe755ba..f794a3bfdf33e3ee25ca93389fc5bbf98dcf0bc7 100644 (file)
@@ -50,6 +50,7 @@
 #cmakedefine HAVE_FOPEN64
 #cmakedefine HAVE_BACKTRACE
 #cmakedefine HAVE_SYMLINK
+#cmakedefine HAVE_LSTAT
 
 #define RLIM_STRING "@RLIM_STRING@"
 #define ICONV_CONST @ICONV_CONST@
diff --git a/util.c b/util.c
index af5b9765502a5032aefaec825b145e4a65268ba5..bb33938181eb33aef2a6cc838f40764a04ca0c4c 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1632,6 +1632,7 @@ void unlinkdir(const char *dir,int contentonly)
    DIR *dirp;
    struct dirent *direntp;
    char dname[MAXLEN];
+   int err;
 
    dirp=opendir(dir);
    if (!dirp) return;
@@ -1643,7 +1644,12 @@ void unlinkdir(const char *dir,int contentonly)
          fprintf(stderr,"SARG: directory name to delete too long: %s/%s\n",dir,direntp->d_name);
          exit(1);
       }
-      if (lstat(dname,&st)) {
+#ifdef HAVE_LSTAT
+      err=lstat(dname,&st);
+#else
+      err=stat(dname,&st);
+#endif
+      if (err) {
          fprintf(stderr,"SARG: cannot stat %s\n",dname);
          exit(1);
       }