CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
PROJECT(sarg C)
SET(sarg_VERSION 2)
-SET(sarg_REVISION "3.1-pre1")
+SET(sarg_REVISION "4-pre1")
SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Aug-25-2010")
+SET(sarg_BUILDDATE "Jul-19-2012")
INCLUDE(AddFileDependencies)
INCLUDE(CheckIncludeFile)
INCLUDE(CheckTypeSize)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckCCompilerFlag)
+INCLUDE(CheckStructHasMember)
DEFINE_PROPERTY(GLOBAL PROPERTY enable-htmldir BRIEF_DOCS "--enable-htmldir=htmldir"
FULL_DOCS "Select htmldir as the root of your WWW documents")
ENDMACRO(SET_ABS_SOURCE VAR DOC)
SET_ABS_SOURCE(SYSCONFDIR "The full path of the configuration directory to be compiled in the program")
-SET_ABS_SOURCE(LANGDIR "The full path of the language directory to be compiled in the program")
SET_ABS_SOURCE(FONTDIR "The full path of the fonts directory to be compiled in the program")
SET_ABS_SOURCE(IMAGEDIR "The full path of the images directory to be compiled in the program")
SET(SYSCONFDIR "etc/sarg" CACHE PATH "The configuration directory relative to the install directory")
SET(BINDIR "bin" CACHE PATH "The directory to install the exec relative to the install directory")
-SET(MANDIR "share/man" CACHE PATH "The directory to copy the man page relative to the install directory")
-SET(LANGDIR "share/sarg/languages" CACHE PATH "The directory to copy the languages files relative to the install directory")
+SET(MANDIR "share/man/man1" CACHE PATH "The directory to copy the man page relative to the install directory")
SET(FONTDIR "share/sarg/fonts" CACHE PATH "The directory to copy the fonts relative to the install directory")
SET(IMAGEDIR "share/sarg/images" CACHE PATH "The directory to copy the images files relative to the install directory")
SET(SARGPHPDIR "share/sarg/sarg-php" CACHE PATH "The directory to copy sarg-php relative to the install directory")
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}") #Make it find this config.h before the one in src/include
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
SET(SRC util.c log.c report.c topuser.c email.c sort.c html.c
- totger.c index.c getconf.c usage.c decomp.c ip2name.c
+ index.c getconf.c usage.c decomp.c ip2name.c ip2name_dns.c
useragent.c exclude.c convlog.c totday.c repday.c datafile.c
indexonly.c splitlog.c lastlog.c topsites.c siteuser.c css.c
- smartfilter.c denied.c authfail.c charset.c
- squidguard_log.c squidguard_report.c auth.c download.c grepday.c
+ smartfilter.c denied.c authfail.c charset.c dichotomic.c
+ redirector.c auth.c download.c grepday.c ip2name_exec.c
dansguardian_log.c dansguardian_report.c realtime.c btree_cache.c
- usertab.c userinfo.c longline.c)
+ usertab.c userinfo.c longline.c url.c readlog.c readlog_squid.c
+ readlog_sarg.c readlog_extlog.c readlog_common.c)
FOREACH(f ${SRC})
ADD_FILE_DEPENDENCIES(${f} ${CMAKE_BINARY_DIR}/config.h ${CMAKE_SOURCE_DIR}/include/conf.h ${CMAKE_SOURCE_DIR}/include/info.h ${CMAKE_SOURCE_DIR}/include/defs.h)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILE(sys/dirent.h HAVE_SYS_DIRENT_H)
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
+CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE(sys/socket.h HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILE(netdb.h HAVE_NETDB_H)
CHECK_INCLUDE_FILE(arpa/inet.h HAVE_ARPA_INET_H)
-CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE(netinet/in.h HAVE_NETINET_H)
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE(ctype.h HAVE_CTYPE_H)
CHECK_INCLUDE_FILE(libgen.h HAVE_LIBGEN_H)
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
CHECK_INCLUDE_FILE(getopt.h HAVE_GETOPT_H)
+CHECK_INCLUDE_FILE(fcntl.h HAVE_FCNTL_H)
IF(!HAVE_GETOPT_H)
MESSAGE(SEND_ERROR "getopt.h is required to compile sarg")
CHECK_FUNCTION_EXISTS(symlink HAVE_SYMLINK)
CHECK_FUNCTION_EXISTS(lstat HAVE_LSTAT)
CHECK_FUNCTION_EXISTS(getnameinfo HAVE_GETNAMEINFO)
+CHECK_FUNCTION_EXISTS(getaddrinfo HAVE_GETADDRINFO)
CHECK_FUNCTION_EXISTS(inet_aton HAVE_INET_ATON)
+CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" ss_len sys/socket.h HAVE_SOCKADDR_SA_LEN)
+
# Find gd
CHECK_INCLUDE_FILE(gd.h HAVE_GD_H)
IF(HAVE_GD_H)
ENDIF(LDAP_LIBRARY)
ENDIF(HAVE_LDAP_H)
+# Find pcre
+CHECK_INCLUDE_FILE(pcre.h HAVE_PCRE_H)
+IF(HAVE_PCRE_H)
+ FIND_LIBRARY(PCRE_LIBRARY NAMES pcre DOC "The pcre library")
+ IF(PCRE_LIBRARY)
+ TARGET_LINK_LIBRARIES(sarg ${PCRE_LIBRARY})
+ SET(HAVE_PCRE PCRE_LIBRARY CACHE PATH DOC "True if pcre was found")
+ SET(HAVE_PCRE CACHE BOOL DOC "True if must use pcre")
+ ENDIF(PCRE_LIBRARY)
+ENDIF(HAVE_PCRE_H)
+
# Support for large files
OPTION(ENABLE_LARGEFILE "Enable the usage of large files" ON)
IF(ENABLE_LARGEFILE)
IF(ENABLE_EXTRA_PROTECT)
GET_TARGET_PROPERTY(TMPCFLAGS sarg COMPILE_FLAGS)
SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAGS "${TMPCFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2 -Werror")
+
CHECK_C_COMPILER_FLAG("-Wformat -Werror=format-security" HAVE_WERROR_FORMAT_SECURITY)
IF(HAVE_WERROR_FORMAT_SECURITY)
GET_TARGET_PROPERTY(TMPCFLAGS sarg COMPILE_FLAGS)
SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAGS "${TMPCFLAGS} -Wformat -Werror=format-security")
ENDIF(HAVE_WERROR_FORMAT_SECURITY)
+
+ CHECK_C_COMPILER_FLAG("-Wempty-body" HAVE_EMPTY_BODY)
+ IF(HAVE_EMPTY_BODY)
+ GET_TARGET_PROPERTY(TMPCFLAGS sarg COMPILE_FLAGS)
+ SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAGS "${TMPCFLAGS} -Wempty-body")
+ ENDIF(HAVE_EMPTY_BODY)
ENDIF(ENABLE_EXTRA_PROTECT)
# Compile sarg for debugging
INSTALL(FILES sarg.conf DESTINATION "${SYSCONFDIR}" RENAME sarg.conf.exemple)
INSTALL(FILES exclude_codes user_limit_block css.tpl DESTINATION "${SYSCONFDIR}")
INSTALL(FILES sarg.1 DESTINATION "${MANDIR}")
-INSTALL(DIRECTORY languages/ DESTINATION "${LANGDIR}" PATTERN ".svn" EXCLUDE)
INSTALL(DIRECTORY images/ DESTINATION "${IMAGEDIR}" PATTERN ".svn" EXCLUDE)
INSTALL(DIRECTORY fonts/ DESTINATION "${FONTDIR}" FILES_MATCHING PATTERN "*.ttf" PATTERN ".svn" EXCLUDE)
INSTALL(DIRECTORY sarg-php/ DESTINATION "${SARGPHPDIR}" PATTERN ".svn" EXCLUDE)