CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
PROJECT(sarg C)
SET(sarg_VERSION 2)
-SET(sarg_REVISION "3.3-pre1")
+SET(sarg_REVISION "4.0-pre2")
SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Jan-06-2012")
+SET(sarg_BUILDDATE "Mar-19-2015")
INCLUDE(AddFileDependencies)
INCLUDE(CheckIncludeFile)
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/man1" 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(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")
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
- redirector.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 url.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)
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)
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)
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)
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)
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)