From 463f8e09f568ac5aa283f26bae5be26980f82fa0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Wed, 6 Jan 2010 08:53:13 +0000 Subject: [PATCH] Support systems without lstat and detect which libiconv to link --- CMakeLists.txt | 10 ++++++---- include/config.h.in | 1 + util.c | 8 +++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edc56fb..9cafb7d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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} " diff --git a/include/config.h.in b/include/config.h.in index 1fe586b..f794a3b 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -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 af5b976..bb33938 100644 --- 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); } -- 2.39.2