]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - CMakeLists.txt
Update the man page
[thirdparty/sarg.git] / CMakeLists.txt
index dd5a1b3d66fae4dc1371494a2461c1c0a8c2ba70..d2d99606395e1a2049f7f79f5a25a41ce2a336c0 100755 (executable)
@@ -1,9 +1,9 @@
 CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
 PROJECT(sarg C)
 SET(sarg_VERSION 2)
-SET(sarg_REVISION "3.2-pre1")
+SET(sarg_REVISION "4.0-pre2")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Dec-26-2010")
+SET(sarg_BUILDDATE "Mar-19-2015")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
@@ -12,6 +12,7 @@ INCLUDE(CheckFunctionExists)
 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")
@@ -31,14 +32,12 @@ MACRO(SET_ABS_SOURCE VAR DOC)
 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")
@@ -47,13 +46,16 @@ SET(SARGPHPDIR "share/sarg/sarg-php" CACHE PATH "The directory to copy sarg-php
 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 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 fnmatch.c stringbuffer.c
+       filelist.c readlog.c alias.c
+          readlog_squid.c readlog_sarg.c readlog_extlog.c readlog_common.c
+          include/conf.h include/info.h include/defs.h include/stringbuffer.h)
 
 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)
@@ -95,10 +97,10 @@ CHECK_INCLUDE_FILE(time.h HAVE_TIME_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)
@@ -115,16 +117,24 @@ CHECK_INCLUDE_FILE(libintl.h HAVE_LIBINTL_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)
+CHECK_INCLUDE_FILE(fnmatch.h HAVE_FNMATCH_H)
+CHECK_INCLUDE_FILE(glob.h HAVE_GLOB_H)
 
 IF(!HAVE_GETOPT_H)
    MESSAGE(SEND_ERROR "getopt.h is required to compile sarg")
 ENDIF(!HAVE_GETOPT_H)
 
+# Required libraries
+TARGET_LINK_LIBRARIES(sarg m)
+
 # Windows need lib wsock32 and ws2_32
 IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+   CHECK_INCLUDE_FILE(winsock2.h HAVE_WINSOCK2_H)
    CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
    CHECK_INCLUDE_FILE(winsock.h HAVE_WINSOCK_H)
    CHECK_INCLUDE_FILE(ws2tcpip.h HAVE_WS2TCPIP_H)
+   CHECK_INCLUDE_FILE(direct.h HAVE_DIRECT_H)
 
    FIND_LIBRARY(WSOCK_LIB NAMES wsock32 DOC "The winsock library")
    IF(WSOCK_LIB)
@@ -141,12 +151,15 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
    ADD_DEFINITIONS(-DWINDOWS)
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
 
-CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
 CHECK_FUNCTION_EXISTS(backtrace HAVE_BACKTRACE)
 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_FUNCTION_EXISTS(fnmatch HAVE_FNMATCH)
+
+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)
@@ -226,6 +239,17 @@ IF(HAVE_LDAP_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)
@@ -327,12 +351,20 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "solaris")
 OPTION(ENABLE_EXTRA_PROTECT "Enable compile and runtime extra protections" OFF)
 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")
+   # _FORTIFY_SOURCE may have been defined by the system. It must be undefined before it is changed to the value we want.
+   SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAGS "${TMPCFLAGS} -fstack-protector -U _FORTIFY_SOURCE -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
@@ -353,7 +385,6 @@ INSTALL(TARGETS sarg DESTINATION "${BINDIR}")
 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)
@@ -365,5 +396,5 @@ SET(CPACK_PACKAGE_VERSION_MINOR "${sarg_REVISION}")
 SET(CPACK_PACKAGE_VERSION_PATCH "${sarg_BUILD}")
 SET(CPACK_GENERATOR TGZ)
 SET(CPACK_SOURCE_GENERATOR TGZ)
-SET(CPACK_SOURCE_IGNORE_FILES "/.svn/" "/debian/" "/html/" "Makefile$" "config\\\\.log$" "config\\\\.status$" ".*~$" "\\\\.o$")
+SET(CPACK_SOURCE_IGNORE_FILES "/.git/" "/debian/" "/html/" "Makefile$" "config\\\\.log$" "config\\\\.status$" ".*~$" "\\\\.o$")
 INCLUDE(CPack)