From: Josh Date: Wed, 30 Jul 2014 20:54:25 +0000 (-0400) Subject: updating build system to reflect autoconf X-Git-Tag: 3.0.0-233~1175^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34cab180b032bdccf66f17051bc4dd3b598f1269;p=thirdparty%2Fsnort3.git updating build system to reflect autoconf --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3713ac849..0d5b9f2d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,39 +1,49 @@ cmake_minimum_required(VERSION 2.8) -project(snort CXX C) +project (snort CXX C) -set(SNORT_VERSION_MAJOR 2) -set(SNORT_VERSION_MINOR 10) -set(SNORT_VERSION_BUILD 103) -set(VERSION "${SNORT_VERSION_MAJOR}.${SNORT_VERSION_MINOR}.${SNORT_VERSION_BUILD}") +set (SNORT_VERSION_MAJOR 2) +set (SNORT_VERSION_MINOR 10) +set (SNORT_VERSION_BUILD 107) +set (VERSION "${SNORT_VERSION_MAJOR}.${SNORT_VERSION_MINOR}.${SNORT_VERSION_BUILD}") # ensure cmake will look in the cmake directory for configuration files set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") +set (INCLUDE_INSTALL_PATH "include/${CMAKE_PROJECT_NAME}") -include (cmake/macros.cmake) -include (cmake/createCommandLineOptions.cmake) -include (cmake/setConfigureOptions.cmake) -include (cmake/includePredefinedPackages.cmake) +include (cmake/macros.cmake) +include (cmake/create_options.cmake) +include (cmake/include_libraries.cmake) include (cmake/platforms.cmake) -include (cmake/sanityChecks.cmake) -include (cmake/packaging_data.cmake) +include (cmake/configure_options.cmake) +include (cmake/CheckCXX11Features.cmake) +include (cmake/sanity_checks.cmake) + +include(GenerateExportHeader) +#add_compiler_export_flags () # hidden visiblity - TODO --> PLAY WITH THESE FLAGS!! +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}") # c++11 flag -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}") # include this directory for the config.h file. created in sanityChecks.cmake include_directories(${PROJECT_BINARY_DIR}) -add_subdirectory(etc) -add_subdirectory(src) -add_subdirectory(tools) -add_subdirectory(lua) -add_subdirectory(doc) +add_subdirectory (etc) +add_subdirectory (src) +add_subdirectory (tools) +add_subdirectory (lua) +add_subdirectory (doc) -# uninstall target +# Miscelaneous stuff. Does NOT directly effect snort's building environment + +include (cmake/packaging_data.cmake) +include (cmake/create_pkg_config.cmake) + + +# uninstall target configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" @@ -42,16 +52,3 @@ configure_file( add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) - -# setting and install the pkg-config information - -include(cmake/setPkgConfigInfo.cmake) - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/snort.pc.in" - "${CMAKE_CURRENT_BINARY_DIR}/snort.pc" - @ONLY) - -install (FILES ${CMAKE_CURRENT_BINARY_DIR}/snort.pc - DESTINATION "lib/pkgconfig/" -) diff --git a/cmake/FindDAQ.cmake b/cmake/FindDAQ.cmake index e516a79f7..535877584 100644 --- a/cmake/FindDAQ.cmake +++ b/cmake/FindDAQ.cmake @@ -62,6 +62,7 @@ find_library(DAQ_LIBRARY DOC "DAQ library directory" NO_DEFAULT_PATH ) + find_library(DAQ_LIBRARY NAMES ${DAQ_LIB} HINTS ENV DAQ_DIR @@ -69,7 +70,7 @@ find_library(DAQ_LIBRARY DOC "DAQ library directory" ) -set(DAQ_LIBRARIES ${DAQ_LIBRARY} ${DAQ_STATIC_LIBRARIES} CACHE STRING "Daq libraries") +set(DAQ_LIBRARIES ${DAQ_LIBRARY} ${DAQ_STATIC_LIBRARIES}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(DAQ diff --git a/cmake/configure_options.cmake b/cmake/configure_options.cmake new file mode 100644 index 000000000..d786c0a59 --- /dev/null +++ b/cmake/configure_options.cmake @@ -0,0 +1,108 @@ +# +# +# This file converts cmake cache variables and command line options +# into compiler flags +# + +# FIX THIS!! +# Setting visibility options. +#IF(UNIX) +# IF(CMAKE_COMPILER_IS_GNUCC) +# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") +# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") +# ENDIF(CMAKE_COMPILER_IS_GNUCC) +#ENDIF(UNIX) + + + + +# convert cmake options into compiler defines + +set_project_compiler_defines_if_true (ENABLE_PERFPROFILING "PERF_PROFILING") +set_project_compiler_defines_if_true (ENABLE_DEBUG_MSGS "DEBUG_MSGS") +set_project_compiler_defines_if_true (ENABLE_DEBUG "DEBUG") +set_project_compiler_defines_if_true (ENABLE_SOURCEFIRE "PERF_PROFILING") +set_project_compiler_defines_if_true (BUILD_HA "ENABLE_HA") +set_project_compiler_defines_if_false (ENABLE_NON_ETHER_DECODERS "NO_NON_ETHER_DECODER") +set_project_compiler_defines_if_true (ENABLE_LARGE_PCAP "_LARGEFILE_SOURCE") +set_project_compiler_defines_if_true (ENABLE_LARGE_PCAP "_LARGEFILE64_SOURCE") +set_project_compiler_defines_if_true (ENABLE_LARGE_PCAP "_FILE_OFFSET_BITS=64") + + + +# convert cmake options into config.h defines + +set_if_true (STATIC_INSPECTORS STATIC_INSPECTORS) +set_if_true (STATIC_SEARCH_ENGINES STATIC_SEARCH_ENGINES) +set_if_true (STATIC_LOGGERS STATIC_LOGGERS) +set_if_true (STATIC_IPS_OPTIONS STATIC_IPS_OPTIONS) +set_if_true (STATIC_CODECS STATIC_CODECS) +set_if_true (BUILD_SIDE_CHANNEL SIDE_CHANNEL) +set_if_true (ENABLE_VALGRIND VALGRIND_TESTING) +set_if_true (ENABLE_PPM PPM_MGR) +set_if_true (ENABLE_PPM_TEST PPM_TEST) +set_if_true (ENABLE_PERFPROFILING PERF_PROFILING) +set_if_true (BUILD_HA ENABLE_HA ) +set_if_true (ENABLE_LINUX_SMP_STATS LINUX_SMP) +set_if_true (ENABLE_DEBUG DEBUG) +set_if_false (ENABLE_DEBUG NDEBUG) +set_if_true (ENABLE_SOURCEFIRE SOURCEFIRE) +set_if_true (ENABLE_SOURCEFIRE PPM_MGR) +set_if_true (ENABLE_SOURCEFIRE PERF_PROFILING) +set_if_false (ENABLE_COREFILES NOCOREFILE) +set_if_false (ENABLE_NON_ETHER_DECODERS NO_NON_ETHER_DECODER) +set_if_true (HAVE_INTEL_SOFT_CPM INTEL_SOFT_CPM) +set_if_true (BUILD_UNIT_TESTS UNIT_TEST) +set_if_true (ENABLE_PROFILE PROFILE) + + +if(LINUX AND BUILD_CONTROL_SOCKET) + add_definitions("-DCONTROL_SOCKET") + message(WARNING "The control socket is only supported on Linux systems.") + message(STATUS "Building the control socket.") +endif(LINUX AND BUILD_CONTROL_SOCKET) + +# convert cmake options into CXX flags +if(ENABLE_DEBUG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +endif(ENABLE_DEBUG) + +if (ENABLE_GDB) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -ggdb") +endif () + +if(ENABLE_PROFILE AND CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") +endif() + +if (BUILD_UNIT_TESTS) + enable_testing() +endif() + +# If Asciidoc or DBLatex not found, automatically set the cache to false +if (NOT ASCIIDOC_FOUND) + get_property(MAKE_HTML_DOC_HELP_STRING CACHE "MAKE_HTML_DOC" PROPERTY HELPSTRING) + set(MAKE_HTML_DOC "OFF" CACHE BOOL ${MAKE_HTML_DOC_HELP_STRING} FORCE) +endif() + +if (NOT DBLATEX_FOUND) + get_property(MAKE_PDF_DOC_HELP_STRING CACHE "MAKE_PDF_DOC" PROPERTY HELPSTRING) + set(MAKE_PDF_DOC "OFF" CACHE BOOL ${MAKE_PDF_DOC_HELP_STRING} FORCE) +endif() + + + +# If the user switches DAQS, search for the new, correct version +if(DEFINED STATIC_DAQ_PRREVIOUSLY_ENABLED) + if(NOT (ENABLE_STATIC_DAQ STREQUAL STATIC_DAQ_PRREVIOUSLY_ENABLED)) + unset(DAQ_FOUND CACHE) + unset(DAQ_INCLUDE_DIR) + unset(DAQ_LIBRARY CACHE) + unset(DAQ_LIBRARIES CACHE) + set(STATIC_DAQ_PRREVIOUSLY_ENABLED "${ENABLE_STATIC_DAQ}" CACHE INTERNAL "save daq link type" FORCE) + find_package(DAQ REQUIRED) + endif() +else() + set(STATIC_DAQ_PRREVIOUSLY_ENABLED "${ENABLE_STATIC_DAQ}" CACHE INTERNAL "save daq link type" FORCE) +endif() + diff --git a/cmake/createCommandLineOptions.cmake b/cmake/create_options.cmake similarity index 95% rename from cmake/createCommandLineOptions.cmake rename to cmake/create_options.cmake index c74c030c4..ef466229e 100644 --- a/cmake/createCommandLineOptions.cmake +++ b/cmake/create_options.cmake @@ -32,8 +32,8 @@ option (HAVE_INTEL_SOFT_CPM "Enable Intel Soft CPM support" OFF) option (ENABLE_LARGE_PCAP "Enable support for pcaps larger than 2 GB" OFF) option (BUILD_SIDE_CHANNEL "Build the side channel library" OFF) option (BUILD_UNIT_TESTS "Build snort++ unit tests" OFF) -option (MAKE_HTML_DOC "Create the HTML documentation" OFF) -option (MAKE_PDF_DOC "Create the PDF documentation" OFF) +option (MAKE_HTML_DOC "Create the HTML documentation" ON) +option (MAKE_PDF_DOC "Create the PDF documentation" ON) set (SIGNAL_SNORT_RELOAD "" CACHE STRING "set the SIGNAL_SNORT_RELOAD value. THIS NUMBER MUST BE AN INTEGER!!") diff --git a/cmake/setPkgConfigInfo.cmake b/cmake/create_pkg_config.cmake similarity index 79% rename from cmake/setPkgConfigInfo.cmake rename to cmake/create_pkg_config.cmake index 6508a149c..c32cfbbf7 100644 --- a/cmake/setPkgConfigInfo.cmake +++ b/cmake/create_pkg_config.cmake @@ -23,3 +23,14 @@ set(includedir "\${prefix}/${INCLUDE_INSTALL_PATH}") set(libdir "\${prefix}/snort") + +# setting and install the pkg-config information + +configure_file( + "${CMAKE_SOURCE_DIR}/snort.pc.in" + "${CMAKE_BINARY_DIR}/snort.pc" + @ONLY) + +install (FILES ${CMAKE_BINARY_DIR}/snort.pc + DESTINATION "lib/pkgconfig/" +) diff --git a/cmake/includePredefinedPackages.cmake b/cmake/include_libraries.cmake similarity index 100% rename from cmake/includePredefinedPackages.cmake rename to cmake/include_libraries.cmake diff --git a/cmake/macros.cmake b/cmake/macros.cmake index f10afff8c..7f158d99c 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -112,8 +112,8 @@ macro (set_if_true value var) endmacro () macro (set_if_false value var) - if(value) - set(${var} "NO") + if(NOT ${value}) + set(${var} "YES") endif() endmacro () diff --git a/cmake/platforms.cmake b/cmake/platforms.cmake index d83ba51c0..aab68a314 100644 --- a/cmake/platforms.cmake +++ b/cmake/platforms.cmake @@ -4,51 +4,57 @@ # +# TODO: Either make a macro or a of platforms and loop over them. -if (${CMAKE_SYSTEM_NAME} MATCHES "openbsd") - set(OPENBSD "1") +if (${CMAKE_SYSTEM_NAME} MATCHES "aix") + set(AIX "1") endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "sgi-irix") - set(IRIX "1") +if (${CMAKE_SYSTEM_NAME} MATCHES "bsdi") + set(BSDI "1") endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "solaris") - set(SOLARIS "1") +if (${CMAKE_SYSTEM_NAME} MATCHES "freebsd") + set(FREEBSD "1") endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "sunos") - set(SUNOS "1") +if (${CMAKE_SYSTEM_NAME} MATCHES "hpux") + set(HPUX "1") endif () if (${CMAKE_SYSTEM_NAME} MATCHES "linux") set(LINUX "1") endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "hpux") - set(HPUX "1") +if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set(LINUX "YES") +endif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + +if (${CMAKE_SYSTEM_NAME} MATCHES "openbsd") + set(OPENBSD "1") endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "freebsd") - set(FREEBSD "1") +if (${CMAKE_SYSTEM_NAME} MATCHES "osf") + set(OSF1 "1") endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "bsdi") - set(BSDI "1") +if (${CMAKE_SYSTEM_NAME} MATCHES "sgi-irix") + set(IRIX "1") endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "aix") - set(AIX "1") +if (${CMAKE_SYSTEM_NAME} MATCHES "solaris") + set(SOLARIS "1") endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "osf") - set(OSF1 "1") +if (${CMAKE_SYSTEM_NAME} MATCHES "sunos") + set(SUNOS "1") endif () if (${CMAKE_SYSTEM_NAME} MATCHES "tru64") set(OSF1 "1") endif () + # APPLE is defined by Cmake if (APPLE) set(MACOS 1) @@ -56,9 +62,6 @@ endif() - - - # the Clang compiler on MacOS X may need the c++ library explicityly specified if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") diff --git a/cmake/sanityChecks.cmake b/cmake/sanityChecks.cmake deleted file mode 100644 index 046f8dad5..000000000 --- a/cmake/sanityChecks.cmake +++ /dev/null @@ -1,247 +0,0 @@ -include (CheckIncludeFileCXX) -include (CheckFunctionExists) -include (CheckSymbolExists) -include (CheckTypeSize) -include (CheckLibraryExists) - - -#check include files -check_include_file_cxx("dlfcn.h" HAVE_DLFCN_H) -check_include_file_cxx("math.h" HAVE_MATH_H) -check_include_file_cxx("memory.h" HAVE_MEMORY_H) -check_include_file_cxx("wchar.h" HAVE_WCHAR_H) -check_include_file_cxx("inttypes.h" HAVE_INTTYPES_H) -check_include_file_cxx("openssl/sha.h" HAVE_OPENSSL_SHA_H) -check_include_file_cxx("paths.h" HAVE_PATHS_H) -check_include_file_cxx("stdint.h" HAVE_STDINT_H) -check_include_file_cxx("stdlib.h" HAVE_STDLIB_H) -check_include_file_cxx("strings.h" HAVE_STRINGS_H) -check_include_file_cxx("string.h" HAVE_STRING_H) -check_include_file_cxx("pfring.h" HAVE_PFRING_H) -check_include_file_cxx("sys/sockio.h" HAVE_SYS_SOCKIO_H) -check_include_file_cxx("sys/stat.h" HAVE_SYS_STAT_H) -check_include_file_cxx("sys/types.h" HAVE_SYS_TYPES_H) -check_include_file_cxx("unistd.h" HAVE_UNISTD_H) -check_include_file_cxx("uuid/uuid.h" HAVE_UUID_UUID_H) -check_include_file_cxx("arpa/inet.h" HAVE_ARPA_INET_H) -check_include_file_cxx("libintl.h" HAVE_LIBINTL_H) -check_include_file_cxx("limits.h" HAVE_LIMITS_H) -check_include_file_cxx("netdb.h " HAVE_NETDB_H) -check_include_file_cxx("netinet/in.h" HAVE_NETINET_IN_H) -check_include_file_cxx("stddef.h" HAVE_STDDEF_H) -check_include_file_cxx("sys/socket.h" HAVE_SYS_SOCKET_H) -check_include_file_cxx("sys/time.h" HAVE_SYS_TIME_H) -check_include_file_cxx("syslog.h" HAVE_SYSLOG_H) -check_include_file_cxx("dnet.h" HAVE_DNET_H) -check_include_file_cxx("dumbnet.h" HAVE_DUMBNET_H) -check_include_file_cxx("pcre.h" HAVE_PCRE_H) -check_include_file_cxx("zlib.h" HAVE_ZLIB_H) - - - -# checking for specific functions -check_function_exists(sigaction HAVE_SIGACTION) -check_function_exists(strlcpy HAVE_STRLCPY) -check_function_exists(strlcat HAVE_STRLCAT) -check_function_exists(vswprintf HAVE_VSWPRINTF) -check_function_exists(wprintf HAVE_WPRINTF) -check_function_exists(memrchr HAVE_MEMRCHR) -check_function_exists(inet_ntop HAVE_INET_NTOP) -check_function_exists(snprintf HAVE_SNPRINTF) -check_function_exists(vsnprintf HAVE_VSNPRINTF) - - - - - -#-------------------------------------------------------------------------- -# Checks for typedefs, structures, and compiler characteristics. -#-------------------------------------------------------------------------- -SET (CMAKE_EXTRA_INCLUDE_FILES "stdint.h") - -check_type_size("char" SIZEOF_CHAR) -check_type_size(int8_t INT8_T) -check_type_size(int16_t INT16_T) -check_type_size(int32_t INT32_T) -check_type_size(int64_t INT64_T) -check_type_size(u_int8_t U_INT8_T) -check_type_size(u_int16_t U_INT16_T) -check_type_size(u_int32_t U_INT32_T) -check_type_size(u_int64_t U_INT64_T) -check_type_size(uint8_t UINT8_T) -check_type_size(uint16_t UINT16_T) -check_type_size(uint32_t UINT32_T) -check_type_size(uint64_t UINT64_T) -check_type_size("short" SIZEOF_SHORT) -check_type_size("int" SIZEOF_INT) -check_type_size("unsigned int" SIZEOF_UNSIGNED_INT) -check_type_size("long int" SIZEOF_LONG_INT) -check_type_size("unsigned long int" SIZEOF_UNSIGNED_LONG_INT) -check_type_size("long long int" SIZEOF_LONG_LONG_INT) -check_type_size("unsigned long long int" SIZEOF_UNSIGNED_LONG_LONG_INT) - - - -# set all of the library variables - - -# DAQ specific functions -CHECK_LIBRARY_EXISTS(daq daq_hup_apply ${DAQ_LIBRARIES} HAVE_DAQ_HUP_APPLY) -CHECK_LIBRARY_EXISTS(daq daq_acquire_with_meta ${DAQ_LIBRARIES} HAVE_DAQ_ACQUIRE_WITH_META) - - -if ( OPENSSL_CRYPTO_LIBRARY ) - set (HAVE_LIBCRYPTO 1) -else() - message(FATAL_ERROR "Could not find openssl -lcrypto") -endif() - - - -include (TestBigEndian) -TEST_BIG_ENDIAN ( WORDS_BIGENDIAN ) - - - -# Set all of the library variables since we already found them -set(HAVE_LIBPCRE "YES") -set(HAVE_LIBZ "YES") -set(HAVE_LIBPCAP 1) -CHECK_LIBRARY_EXISTS(pcap pcap_lib_version "${PCAP_LIBRARIES}" HAVE_PCAP_LIB_VERSION) -CHECK_LIBRARY_EXISTS(pcap pcap_lex_destroy "${PCAP_LIBRARIES}" HAVE_PCAP_LEX_DESTROY) - - -if (HAVE_DNET_H) - set (HAVE_LIBDNET "YES") -else (HAVE_DNET_H) - set(HAVE_LIBDUMBNET "YES") -endif (HAVE_DNET_H) - - -find_library(MATH_LIBRARY m) -if(MATH_LIBRARY) - SET (HAVE_LIBM 1) -endif(MATH_LIBRARY) - - -# Check and set CXX11 compiler options -include ( "${CMAKE_CURRENT_LIST_DIR}/CheckCXX11Features.cmake" ) -if (HAS_CXX11_FUNC) - SET(HAVE___FUNCTION__ 1) -endif(HAS_CXX11_FUNC) - - -############################################################################# -############################################################################# -################ Foo that still needs to be written ###################### -############################################################################# -############################################################################# - - -find_library(NSL nsl) -if (NSL) - set(HAVE_LIBNSL "YES") -endif(NSL) - - -#/* Define to 1 if you have the `rt' library (-lrt). */ -check_library_exists(rt nanosleep "" HAVE_LIBRT) -# cmakedefine HAVE_LIBRT - -#/* Define to 1 if you have the `socket' library (-lsocket). */ -# cmakedefine HAVE_LIBSOCKET - -#/* Define to 1 if you have the `uuid' library (-luuid). */ -# cmakedefine HAVE_LIBUUID - - - - - - - - - - - - - - - - -#/* Define if broken SIOCGIFMTU */ -#cmakedefine BROKEN_SIOCGIFMTU - - -#/* Define if errlist is predefined */ -#cmakedefine ERRLIST_PREDEFINED - -#/* DAQ version supports address space ID in header. */ -#cmakedefine HAVE_DAQ_ADDRESS_SPACE_ID - - - - - -#/* Define if the compiler supports visibility declarations. */ -#cmakedefine HAVE_VISIBILITY - - -#/* Define whether yylex_destroy is supported in flex version */ -#cmakedefine HAVE_YYLEX_DESTROY - - -#/* Define if HP-UX 10 or 11 */ -#cmakedefine HPUX - -#/* For INADDR_NONE definition */ -#cmakedefine INADDR_NONE - -#/* Define to the sub-directory in which libtool stores uninstalled libraries. -# */ -#undef LT_OBJDIR - -#/* Name of package */ -#undef PACKAGE - -#/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -#/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -#/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -#/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -#/* Define to the home page for this package. */ -#undef PACKAGE_URL - -#/* Define to the version of this package. */ -#undef PACKAGE_VERSION - - -#/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - - - - - - -############################################################################### -############################################################################### -# -# Finally, create the config.h file - - -configure_file ( - "${PROJECT_SOURCE_DIR}/config.cmake.h.in" - "${PROJECT_BINARY_DIR}/config.h" - ) - -add_definitions( -DHAVE_CONFIG_H ) -#set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_SOURCE_DIR}/config.h") - diff --git a/cmake/sanity_checks.cmake b/cmake/sanity_checks.cmake new file mode 100644 index 000000000..611b1a41b --- /dev/null +++ b/cmake/sanity_checks.cmake @@ -0,0 +1,238 @@ +include(CheckIncludeFileCXX) +include(CheckFunctionExists) +include(CheckSymbolExists) +include(CheckTypeSize) +include(CheckLibraryExists) +include(CheckCXXSourceCompiles) + + +#UNCONVERTED AUTOTOOL OPTION + +#AC_FUNC_ALLOCA + + +include (TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) + + +#check include files +check_include_file_cxx("arpa/inet.h" HAVE_ARPA_INET_H) +check_include_file_cxx("fcntl.h" HAVE_FCNTL_H) +check_include_file_cxx("inttypes.h" HAVE_INTTYPES_H) +check_include_file_cxx("libintl.h" HAVE_LIBINTL_H) +check_include_file_cxx("limits.h" HAVE_LIMITS_H) +check_include_file_cxx("malloc.h" HAVE_MALLOC_H) +check_include_file_cxx("netdb.h " HAVE_NETDB_H) +check_include_file_cxx("netinet/in.h" HAVE_NETINET_IN_H) +check_include_file_cxx("stddef.h" HAVE_STDDEF_H) +check_include_file_cxx("stdint.h" HAVE_STDINT_H) +check_include_file_cxx("stdlib.h" HAVE_STDLIB_H) +check_include_file_cxx("string.h" HAVE_STRING_H) +check_include_file_cxx("strings.h" HAVE_STRINGS_H) +check_include_file_cxx("sys/socket.h" HAVE_SYS_SOCKET_H) +check_include_file_cxx("sys/time.h" HAVE_SYS_TIME_H) +check_include_file_cxx("syslog.h" HAVE_SYSLOG_H) +check_include_file_cxx("unistd.h" HAVE_UNISTD_H) +check_include_file_cxx("wchar.h" HAVE_WCHAR_H) + + + + +# Checks for library functions. -- REVISITED + + +# UNCONVERTED AUTOTOOL OPTIONS + +#AC_FUNC_MALLOC +#AC_FUNC_REALLOC +#AC_FUNC_STRERROR_R +#AC_FUNC_STRTOD + + +set (CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} unistd.h") +check_function_exists(chown HAVE_CHOWN) +check_function_exists(fork HAVE_WORKING_FORK) +check_function_exists(vfork HAVE_WORKING_VFORK) +check_function_exists(malloc HAVE_FORK) + + +check_function_exists(endgrent HAVE_ENDGRENT) +check_function_exists(endpwent HAVE_ENDPWENT) +check_function_exists(ftruncate HAVE_FTRUNCATE) +check_function_exists(getcwd HAVE_GETCWD) +check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) +check_function_exists(inet_ntoa HAVE_INET_NTOA) +check_function_exists(isascii HAVE_ISASCII) +check_function_exists(localtime_r HAVE_LOCALTIME_R) +check_function_exists(memchr HAVE_MEMCHR) +check_function_exists(memmove HAVE_MEMMOVE) +check_function_exists(memset HAVE_MEMSET) +check_function_exists(mkdir HAVE_MKDIR) +check_function_exists(select HAVE_SELECT) +check_function_exists(socket HAVE_SOCKET) +check_function_exists(strcasecmp HAVE_STRCASECMP) +check_function_exists(strchr HAVE_STRCHR) +check_function_exists(strerror HAVE_STRERROR) +check_function_exists(strncasecmp HAVE_STRNCASECMP) +check_function_exists(strrchr HAVE_STRRCHR) +check_function_exists(strstr HAVE_STRSTR) +check_function_exists(strtol HAVE_STRTOL) +check_function_exists(strtoul HAVE_STRTOUL) + +set (CMAKE_REQUIRED_INCLUDES) + + + + +#-------------------------------------------------------------------------- +# Checks for typedefs, structures, and compiler characteristics. +#-------------------------------------------------------------------------- + +check_type_size(int8_t INT8_T) +check_type_size(int16_t INT16_T) +check_type_size(int32_t INT32_T) +check_type_size(int64_t INT64_T) +check_type_size(uint8_t UINT8_T) +check_type_size(uint16_t UINT16_T) +check_type_size(uint32_t UINT32_T) +check_type_size(uint64_t UINT64_T) +check_type_size("char" SIZEOF_CHAR) +check_type_size("short" SIZEOF_SHORT) +check_type_size("int" SIZEOF_INT) +check_type_size("unsigned int" SIZEOF_UNSIGNED_INT) +check_type_size("long int" SIZEOF_LONG_INT) +check_type_size("unsigned long int" SIZEOF_UNSIGNED_LONG_INT) +check_type_size("long long int" SIZEOF_LONG_LONG_INT) +check_type_size("unsigned long long int" SIZEOF_UNSIGNED_LONG_LONG_INT) + + +check_type_size("uid_t" UID_T) +check_type_size("pid_t" PID_T) +check_type_size("size_t" SIZE_T) +check_type_size("ssize_t" SSIZE_T) +check_type_size("mode_t" MODE_T) + +set_if_false(UID_T uid_t) +set_if_false(PID_T pid_t) +set_if_false(SIZE_T size_t) +set_if_false(SSIZE_T ssize_t) +set_if_false(MODE_T mode_t) + + +# vvvvvvvvv INLINE TEST vvvvvvvvv + +# Taken and edited from www.cmake.org/wiki/CMakeTestInline + +FOREACH(KEYWORD "inline" "__inline__" "__inline") + IF(NOT DEFINED INLINE) + check_cxx_source_compiles( + " + typedef int foo_t; + static inline foo_t static_foo(){return 0;} + foo_t foo(){return 0;} + int main(int argc, char *argv[]){return 0;} + " + INLINE + ) + IF(INLINE) + add_definitions("-Dinline=${KEYWORD}") + break() + ENDIF(INLINE) + ENDIF(NOT DEFINED INLINE) +ENDFOREACH(KEYWORD) +IF(NOT DEFINED INLINE) + add_definitions("-Dinline=") +ENDIF(NOT DEFINED INLINE) + +# ^^^^^^^^^ INLINE TEST ^^^^^^^^^ + + +# vvvvvvvvv RESTRICT TEST vvvvvvvvv + + +# Taken directly from http://www.cmake.org/pipermail/cmake/2013-January/053113.html + +# Check for restrict keyword +# Builds the macro A_C_RESTRICT form automake +foreach(ac_kw __restrict __restrict__ _Restrict restrict) + check_cxx_source_compiles( + " + typedef int * int_ptr; + int foo (int_ptr ${ac_kw} ip) { + return ip[0]; + } + int main(){ + int s[1]; + int * ${ac_kw} t = s; + t[0] = 0; + return foo(t); + } + " + RESTRICT + ) + if(RESTRICT) + set(ac_cv_c_restrict ${ac_kw}) + break() + endif() +endforeach() +if(RESTRICT) + add_definitions("-Drestrict=${ac_cv_c_restrict}") +else() + add_definitions("-Drestrict=") +endif() + +# ^^^^^^^^^ RESTRICT TEST ^^^^^^^^^ + + + + +# set library variables + + + +set_if_true (HAS_CXX11_FUNC HAVE___FUNCTION__) +set_if_false (OPENSSL_CRYPTO_LIBRARY HAVE_OPENSSL_SHA) +check_library_exists (pcap pcap_lib_version "${PCAP_LIBRARIES}" HAVE_PCAP_LIB_VERSION) +check_library_exists (pcap pcap_lex_destroy "${PCAP_LIBRARIES}" HAVE_PCAP_LEX_DESTROY) + + +set (CMAKE_REQUIRED_FLAGS ${CXX11_COMPILER_FLAGS}) +set (CMAKE_REQUIRED_INCLUDES ${DAQ_INCLUDE_DIR}) +set (CMAKE_REQUIRED_LIBRARIES ${DAQ_LIBRARIES}) + + +check_cxx_source_compiles( + " + #include + + int main() + { + DAQ_PktHdr_t hdr; + hdr.address_space_id = 0; + return 0; + } + " + HAVE_DAQ_ADDRESS_SPACE_ID +) + +set (CMAKE_REQUIRED_FLAGS) +set (CMAKE_REQUIRED_INCLUDES) +set (CMAKE_REQUIRED_LIBRARIES) + + + + +############################################################################### +############################################################################### +# +# Finally, create the config.h file + + +configure_file ( + "${PROJECT_SOURCE_DIR}/config.cmake.h.in" + "${PROJECT_BINARY_DIR}/config.h" + ) + +add_definitions( -DHAVE_CONFIG_H ) +#set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_SOURCE_DIR}/config.h") + diff --git a/cmake/setConfigureOptions.cmake b/cmake/setConfigureOptions.cmake deleted file mode 100644 index 7a0574866..000000000 --- a/cmake/setConfigureOptions.cmake +++ /dev/null @@ -1,125 +0,0 @@ -# -# -# This file converts cmake cache variables and command line options -# into compiler flags -# - -if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - set(LINUX "YES") -endif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - -# FIX THIS!! -# Setting visibility options. -IF(UNIX) - IF(CMAKE_COMPILER_IS_GNUCC) -# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") -# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") - ENDIF(CMAKE_COMPILER_IS_GNUCC) -ENDIF(UNIX) - -set(INCLUDE_INSTALL_PATH "include/${CMAKE_PROJECT_NAME}") - - - -# convert cmake options into compiler defines - -set_project_compiler_defines_if_true( ENABLE_PERFPROFILING "PERF_PROFILING") -set_project_compiler_defines_if_true( ENABLE_DEBUG_MSGS "DEBUG_MSGS") -set_project_compiler_defines_if_true( ENABLE_DEBUG "DEBUG") -set_project_compiler_defines_if_true( ENABLE_SOURCEFIRE "PERF_PROFILING") -set_project_compiler_defines_if_true( BUILD_HA "ENABLE_HA") -set_project_compiler_defines_if_false(ENABLE_NON_ETHER_DECODERS "NO_NON_ETHER_DECODER") -set_project_compiler_defines_if_true( ENABLE_LARGE_PCAP "_LARGEFILE_SOURCE") -set_project_compiler_defines_if_true( ENABLE_LARGE_PCAP "_LARGEFILE64_SOURCE") -set_project_compiler_defines_if_true( ENABLE_LARGE_PCAP "_FILE_OFFSET_BITS=64") - - - -# convert cmake options into config.h defines - -set_if_true( STATIC_INSPECTORS STATIC_INSPECTORS ) -set_if_true( STATIC_SEARCH_ENGINES STATIC_SEARCH_ENGINES ) -set_if_true( STATIC_LOGGERS STATIC_LOGGERS ) -set_if_true( STATIC_IPS_OPTIONS STATIC_IPS_OPTIONS ) -set_if_true( STATIC_CODECS STATIC_CODECS ) -set_if_true( BUILD_SIDE_CHANNEL SIDE_CHANNEL ) -set_if_true( ENABLE_VALGRIND VALGRIND_TESTING ) -set_if_true( ENABLE_PPM PPM_MGR ) -set_if_true( ENABLE_PPM_TEST PPM_TEST ) -set_if_true( ENABLE_PERFPROFILING PERF_PROFILING ) -set_if_true( BUILD_HA ENABLE_HA ) -set_if_true( ENABLE_LINUX_SMP_STATS LINUX_SMP ) -set_if_true( ENABLE_DEBUG DEBUG ) -set_if_false(ENABLE_DEBUG NDEBUG ) -set_if_true( ENABLE_SOURCEFIRE SOURCEFIRE ) -set_if_true( ENABLE_SOURCEFIRE PPM_MGR ) -set_if_true( ENABLE_SOURCEFIRE PERF_PROFILING ) -set_if_false(ENABLE_COREFILES NOCOREFILE ) -set_if_false(ENABLE_NON_ETHER_DECODERS NO_NON_ETHER_DECODER ) -set_if_true( HAVE_INTEL_SOFT_CPM INTEL_SOFT_CPM ) -set_if_true( BUILD_UNIT_TESTS UNIT_TEST ) -set_if_true( ENABLE_PROFILE PROFILE) - - -if(LINUX AND BUILD_CONTROL_SOCKET) - add_definitions("-DCONTROL_SOCKET") - message(WARNING "The control socket is only supported on Linux systems.") - message(STATUS "Building the control socket.") -endif(LINUX AND BUILD_CONTROL_SOCKET) - - - -# convert cmake options into CXX flags - -if(ENABLE_DEBUG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") -endif(ENABLE_DEBUG) - - -if (ENABLE_GDB) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -ggdb") -endif () - - -if(ENABLE_PROFILE AND CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") -endif() - - -if (BUILD_UNIT_TESTS) - enable_testing() -endif() - -# sanity checks to re-check and set all necesssary variables - -if (NOT ASCIIDOC_FOUND) - get_property(MAKE_HTML_DOC_HELP_STRING CACHE "MAKE_HTML_DOC" PROPERTY HELPSTRING) - set(MAKE_HTML_DOC "OFF" CACHE BOOL ${MAKE_HTML_DOC_HELP_STRING}) -endif() - -if (NOT DBLATEX_FOUND) - get_property(MAKE_PDF_DOC_HELP_STRING CACHE "MAKE_PDF_DOC" PROPERTY HELPSTRING) - set(MAKE_PDF_DOC "OFF" CACHE BOOL ${MAKE_PDF_DOC_HELP_STRING}) -endif() - -if ("${CMAKE_GENERATOR}" MATCHES "Xcode") - get_property(MAKE_HTML_DOC_HELP_STRING CACHE "MAKE_HTML_DOC" PROPERTY HELPSTRING) - set(MAKE_HTML_DOC "OFF" CACHE BOOL ${MAKE_HTML_DOC_HELP_STRING}) - get_property(MAKE_PDF_DOC_HELP_STRING CACHE "MAKE_PDF_DOC" PROPERTY HELPSTRING) - set(MAKE_PDF_DOC "OFF" CACHE BOOL ${MAKE_PDF_DOC_HELP_STRING}) - -endif() - - -# This code resets the DAQ libraries so cmake will now search for the static/shared DAQ library -if(DEFINED STATIC_DAQ_PRREVIOUSLY_ENABLED) - if(NOT (ENABLE-STATIC_DAQ STREQUAL STATIC_DAQ_PRREVIOUSLY_ENABLED)) - unset(DAQ_FOUND CACHE) - unset(DAQ_LIBRARY CACHE) - unset(DAQ_LIBRARIES CACHE) - set(STATIC_DAQ_PRREVIOUSLY_ENABLED "${ENABLE_STATIC_DAQ}" CACHE INTERNAL "save daq link type" FORCE) - endif() -else() - set(STATIC_DAQ_PRREVIOUSLY_ENABLED "${ENABLE_STATIC_DAQ}" CACHE INTERNAL "save daq link type" FORCE) -endif() - diff --git a/config.cmake.h.in b/config.cmake.h.in index d68ebfd0c..ca6eb811b 100644 --- a/config.cmake.h.in +++ b/config.cmake.h.in @@ -16,25 +16,7 @@ /* General Snort++ Information */ /* Name of package */ -#define PACKAGE @PACKAGE@ - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@ - -/* Define to the full name of this package. */ -#define PACKAGE_NAME @PACKAGE_NAME@ - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING @PACKAGE_STRING@ - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME @PACKAGE_TARNAME@ - -/* Define to the home page for this package. */ -#define PACKAGE_URL @PACKAGE_URL@ - -/* Define to the version of this package. */ -#define PACKAGE_VERSION @PACKAGE_VERSION@ +#define PACKAGE @PROJECT_NAME@ /* Version number of package */ #define VERSION "@VERSION@" @@ -125,105 +107,43 @@ #cmakedefine SIGNAL_SNORT_ROTATE_STATS @SIGNAL_SNORT_ROTATE_STATS@ -/* platform specific foo */ - - - -/* Header file definitions */ - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DNET_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DUMBNET_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MATH_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_OPENSSL_SHA_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_PATHS_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_PCRE_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_PFRING_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_SOCKIO_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H 1 +/* platforms */ -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UUID_UUID_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_WCHAR_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ZLIB_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ARPA_INET_H 1 +/* Define if OpenBSD */ +#cmakedefine OPENBSD 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_LIBINTL_H 1 +/* Define if Irix */ +#cmakedefine IRIX 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_LIMITS_H 1 +/* Define if Solaris */ +#cmakedefine SOLARIS 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETDB_H 1 +/* Define if SunOS */ +#cmakedefine SUNOS 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET_IN_H 1 +/* Define if Linux */ +#cmakedefine LINUX 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDDEF_H 1 +/* Define if HP-UX */ +#cmakedefine HPUX 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_SOCKET_H 1 +/* Define if FreeBSD */ +#cmakedefine FREEBSD 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TIME_H 1 +/* Define if BSDi */ +#cmakedefine BSDI 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYSLOG_H 1 +/* Define if AIX */ +#cmakedefine AIX 1 -/* Define to 1 if you have the ANSI C header files. */ -#cmakedefine STDC_HEADERS 1 +/* Define if Tru64 or OSF*/ +#cmakedefine OSF1 1 +/* Define if MacOS */ +#cmakedefine MACOS 1 @@ -290,114 +210,96 @@ /* The size of `unsigned long long int', as computed by sizeof. */ #cmakedefine SIZEOF_UNSIGNED_LONG_LONG_INT @SIZEOF_UNSIGNED_LONG_LONG_INT@ -/* Define if words are big endian */ -#cmakedefine WORDS_BIGENDIAN 1 - -/* Define if words must align */ -#cmakedefine WORDS_MUSTALIGN 1 - - - -/* Available compiler options */ - -/* Define if the compiler understands __FUNCTION__. */ -#cmakedefine HAVE___FUNCTION__ - -/* Define if the compiler understands __func__. */ -#cmakedefine HAVE___func__ +/* Define to `unsigned int' if uid_t is undefined in the system */ +#cmakedefine uid_t unsigned int -/* Define __FUNCTION__ as required. */ -#cmakedefine __FUNCTION__ +/* Define to `unsigned int' if pid_t is undefined in the system */ +#cmakedefine pid_t unsigned int -/* Define if the compiler supports visibility declarations. */ -#cmakedefine HAVE_VISIBILITY - -/* Define whether linuxthreads is being used */ -#cmakedefine HAVE_LINUXTHREADS - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#cmakedefine inline -#endif +/* Define to `unsigned int' if size_t is undefined in the system */ +#cmakedefine size_t unsigned int +/* Define to `unsigned int' if ssize_t is undefined in the system */ +#cmakedefine ssize_t int +/* Define to `int' if mode_t is undefined in the system */ +#cmakedefine mode_t int -/* general functions */ +/* Define if words are big endian */ +#cmakedefine WORDS_BIGENDIAN 1 -/* Define to 1 if you have the `sigaction' function. */ -#cmakedefine HAVE_SIGACTION 1 +/* Define if words must align */ +#cmakedefine WORDS_MUSTALIGN 1 -/* snprintf function is available */ -#cmakedefine HAVE_SNPRINTF 1 -/* Define to 1 if you have the `strlcat' function. */ -#cmakedefine HAVE_STRLCAT 1 -/* Define to 1 if you have the `strlcpy' function. */ -#cmakedefine HAVE_STRLCPY 1 +/* Header file definitions */ -/* Define to 1 if you have the `vsnprintf' function. */ -#cmakedefine HAVE_VSNPRINTF 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ARPA_INET_H 1 -/* Define to 1 if you have the `vswprintf' function. */ -#cmakedefine HAVE_VSWPRINTF 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H 1 -/* Define to 1 if you have the `wprintf' function. */ -#cmakedefine HAVE_WPRINTF 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 -/* Define to 1 if you have the `memrchr' function. */ -#cmakedefine HAVE_MEMRCHR 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIBINTL_H 1 -/* Define to 1 if you have the `inet_ntop' function. */ -#cmakedefine HAVE_INET_NTOP 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIMITS_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MALLOC_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETDB_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_IN_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDDEF_H 1 -/* Available libraries */ +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 -/* Define to 1 if you have the `crypto' library (-lcrypto). */ -#cmakedefine HAVE_LIBCRYPTO 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 -/* Define to 1 if you have the `dnet' library (-ldnet). */ -#cmakedefine HAVE_LIBDNET 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 -/* Define to 1 if you have the `dumbnet' library (-ldumbnet). */ -#cmakedefine HAVE_LIBDUMBNET 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 -/* Define to 1 if you have the `m' library (-lm). */ -#cmakedefine HAVE_LIBM 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYSLOG_H 1 -/* Define to 1 if you have the `nsl' library (-lnsl). */ -#cmakedefine HAVE_LIBNSL 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKET_H 1 -/* Define to 1 if you have the `pcap' library (-lpcap). */ -#cmakedefine HAVE_LIBPCAP 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H 1 -/* Define to 1 if you have the `pcre' library (-lpcre). */ -#cmakedefine HAVE_LIBPCRE 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 -/* Define to 1 if you have the `pfring' library (-lpfring). */ -#cmakedefine HAVE_LIBPFRING 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_WCHAR_H 1 -/* Define to 1 if you have the `rt' library (-lrt). */ -#cmakedefine HAVE_LIBRT 1 -/* Define to 1 if you have the `socket' library (-lsocket). */ -#cmakedefine HAVE_LIBSOCKET 1 -/* Define to 1 if you have the `uuid' library (-luuid). */ -#cmakedefine HAVE_LIBUUID 1 -/* Define to 1 if you have the `z' library (-lz). */ -#cmakedefine HAVE_LIBZ 1 +/* Available libraries */ /* openssl SHA available */ #cmakedefine HAVE_OPENSSL_SHA 1 + + /* Library specific functions */ /* Can cleanup lex buffer stack created by pcap bpf filter */ @@ -406,76 +308,22 @@ /* Can output the library version. */ #cmakedefine HAVE_PCAP_LIB_VERSION 1 -/* Define to 1 if you have the `daq_acquire_with_meta' function. */ -#cmakedefine HAVE_DAQ_ACQUIRE_WITH_META 1 - /* DAQ version supports address space ID in header. */ #cmakedefine HAVE_DAQ_ADDRESS_SPACE_ID 1 -/* Define to 1 if you have the `daq_hup_apply' function. */ -#cmakedefine HAVE_DAQ_HUP_APPLY 1 - -/* Define whether yylex_destroy is supported in flex version */ -#cmakedefine HAVE_YYLEX_DESTROY 1 - - - -/* platforms */ - -/* Define if OpenBSD */ -#cmakedefine OPENBSD 1 - -/* Define if Irix */ -#cmakedefine IRIX 1 - -/* Define if Solaris */ -#cmakedefine SOLARIS 1 - -/* Define if SunOS */ -#cmakedefine SUNOS 1 - -/* Define if Linux */ -#cmakedefine LINUX 1 - -/* Define if HP-UX */ -#cmakedefine HPUX 1 - -/* Define if FreeBSD */ -#cmakedefine FREEBSD 1 - -/* Define if BSDi */ -#cmakedefine BSDI 1 - -/* Define if AIX */ -#cmakedefine AIX 1 - -/* Define if Tru64 or OSF*/ -#cmakedefine OSF1 1 - -/* Define if MacOS */ -#cmakedefine MACOS 1 - - - - -/* Random Foo */ +/* Available compiler options */ -/* Define if building universal (internal helper macro) */ -#cmakedefine AC_APPLE_UNIVERSAL_BUILD 1 +/* Define if the compiler supports visibility declarations. */ +#cmakedefine HAVE_VISIBILITY 1 -/* Define if errlist is predefined */ -#cmakedefine ERRLIST_PREDEFINED 1 +/* Define whether linuxthreads is being used */ +#cmakedefine HAVE_LINUXTHREADS 1 -/* For INADDR_NONE definition */ -#cmakedefine INADDR_NONE 1 -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#cmakedefine LT_OBJDIR +#endif -#endif diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index b7490aa99..76e6ab399 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -95,12 +95,13 @@ if (MAKE_PDF_DOC OR MAKE_HTML_DOC) # build modules.txt seperately set (output ${CMAKE_CURRENT_BINARY_DIR}/modules.txt) - set(SNORT_EXECUTABLE "${CMAKE_BINARY_DIR}/src/snort") add_custom_command( OUTPUT ${output} - COMMAND ${CMAKE_COMMAND} -E echo "" > ${output} - COMMAND for m in `${SNORT_EXECUTABLE} --list-modules`\; do ${SNORT_EXECUTABLE} --markup --help-module $$m >> ${output}\; done - DEPENDS snort + COMMAND ${CMAKE_COMMAND} + -DOUT_FILE=${output} + -DSNORT_EXECUTABLE=$ + -P ${CMAKE_CURRENT_LIST_DIR}/module_output.cmake + DEPENDS snort ${CMAKE_CURRENT_LIST_DIR}/module_output.cmake COMMENT "Documents: building modules.txt" ) list (APPEND ALL_SOURCES ${output}) @@ -122,7 +123,7 @@ if (MAKE_PDF_DOC OR MAKE_HTML_DOC) ) list (APPEND ALL_SOURCES ${output}) else() - list(APPEND UNBUILT_SOURCES conf_differences.txt) + list (APPEND UNBUILT_SOURCES conf_differences.txt) endif() # next, Copy all distributed files into the binary tree (necessary for asciidocs). diff --git a/doc/module_output.cmake b/doc/module_output.cmake new file mode 100644 index 000000000..a50c6eed0 --- /dev/null +++ b/doc/module_output.cmake @@ -0,0 +1,34 @@ + + +if (SNORT_EXECUTABLE AND OUT_FILE) + + # clear any previous data in the file + execute_process ( + COMMAND ${CMAKE_COMMAND} -E echo "" + OUTPUT_FILE ${OUT_FILE} + ) + + # get the list of modules from Snort + execute_process ( + COMMAND ${SNORT_EXECUTABLE} --list-modules + OUTPUT_FILE ${OUT_FILE}.list + ) + + file (STRINGS "${OUT_FILE}.list" MODULES) + file (REMOVE "${OUT_FILE}.list") + + + foreach (m ${MODULES}) + execute_process ( + COMMAND ${SNORT_EXECUTABLE} --markup --help-module ${m} + OUTPUT_VARIABLE CONTENTS + ) + + file (APPEND ${OUT_FILE} "${CONTENTS}") + endforeach(m ${MODULES}) + +else () + message (FATAL_ERROR "The options 'SNORT_EXECUTABLE' and 'OUT_FILE' must be provided to this script!!!") + +endif() + diff --git a/tools/snort2lua/config_states/config_deleted.cc b/tools/snort2lua/config_states/config_deleted.cc index f0b91d516..a328bd101 100644 --- a/tools/snort2lua/config_states/config_deleted.cc +++ b/tools/snort2lua/config_states/config_deleted.cc @@ -45,7 +45,7 @@ public: bool Deleted::convert(std::istringstream& data_stream) { - data_stream.setstate(std::ios::eofbit); // these deleted, not failures + data_stream.setstate(std::ios::eofbit); // deleted, not failures return true; } diff --git a/tools/snort2lua/config_states/config_memcaps.cc b/tools/snort2lua/config_states/config_memcaps.cc index 4b72bda3e..6da303118 100644 --- a/tools/snort2lua/config_states/config_memcaps.cc +++ b/tools/snort2lua/config_states/config_memcaps.cc @@ -43,9 +43,6 @@ public: virtual bool convert(std::istringstream& data_stream); }; -} // namespace - - template @@ -78,6 +75,9 @@ static ConversionState* ctor(Converter* cv, LuaData* ld) return new Memcap(cv, ld); } + +} // namespace + /************************** ******* A P I *********** **************************/ diff --git a/tools/snort2lua/config_states/config_no_option.cc b/tools/snort2lua/config_states/config_no_option.cc index 905d3c9ba..30d64468a 100644 --- a/tools/snort2lua/config_states/config_no_option.cc +++ b/tools/snort2lua/config_states/config_no_option.cc @@ -43,21 +43,21 @@ public: } }; -} // namespace - template + const std::string* lua_table, + const std::string* lua_option = nullptr> static ConversionState* config_true_no_opt_ctor(Converter* cv, LuaData* ld) { - ld->open_table(*lua_table_name); + ld->open_table(*lua_table); - if (lua_option_name == nullptr) - ld->add_option_to_table(*snort_option, true); + if (lua_option != nullptr && (*snort_option).compare(*lua_option)) + { + ld->add_diff_option_comment("config " + *snort_option + ":", *lua_option); + ld->add_option_to_table(*lua_option, true); + } else { - ld->add_diff_option_comment("config " + *snort_option + ":", *lua_option_name); - ld->add_option_to_table(*lua_option_name, true); + ld->add_option_to_table(*snort_option, true); } ld->close_table(); @@ -65,24 +65,28 @@ static ConversionState* config_true_no_opt_ctor(Converter* cv, LuaData* ld) } template + const std::string* lua_table, + const std::string* lua_option = nullptr> static ConversionState* config_false_no_opt_ctor(Converter* cv, LuaData* ld) { - ld->open_table(*lua_table_name); + ld->open_table(*lua_table); - if (lua_option_name == nullptr) - ld->add_option_to_table(*snort_option, false); + if (lua_option != nullptr && (*snort_option).compare(*lua_option)) + { + ld->add_diff_option_comment("config " + *snort_option + ":", *lua_option); + ld->add_option_to_table(*lua_option, false); + } else { - ld->add_diff_option_comment("config " + *snort_option + ":", *lua_option_name); - ld->add_option_to_table(*lua_option_name, false); + ld->add_option_to_table(*snort_option, false); } ld->close_table(); return new DeadCode(cv, ld); } +} // namespace + /************************************************* **************** STRUCT_NAMES ***************** *************************************************/ diff --git a/tools/snort2lua/config_states/config_one_int_option.cc b/tools/snort2lua/config_states/config_one_int_option.cc index a4cd367ae..ab6d2606a 100644 --- a/tools/snort2lua/config_states/config_one_int_option.cc +++ b/tools/snort2lua/config_states/config_one_int_option.cc @@ -26,9 +26,13 @@ #include "utils/converter.h" #include "utils/snort2lua_util.h" + namespace config { +namespace +{ + template @@ -43,26 +47,29 @@ public: virtual ~ConfigIntOption() {}; virtual bool convert(std::istringstream& stream) { - if (snort_option == nullptr || - lua_table == nullptr || - lua_option == nullptr) + if ((snort_option == nullptr) || + (lua_table == nullptr)) { return false; } ld->open_table(*lua_table); + bool retval; // if the two names are not equal ... - if((snort_option) && - (lua_option) && - (*snort_option).compare(*lua_option)) + if((lua_option != nullptr) && (*snort_option).compare(*lua_option)) { + retval = parse_int_option(*lua_option, stream); ld->add_diff_option_comment("config " + *snort_option + ":", *lua_option); } + else + { + retval = parse_int_option(*snort_option, stream); + } - bool retval = parse_int_option(*lua_option, stream); ld->close_table(); + stream.setstate(std::ios::eofbit); // not interested in any additional arguments return retval; } }; @@ -72,16 +79,12 @@ template static ConversionState* config_int_ctor(Converter* cv, LuaData* ld) { - if (lua_option) - return new ConfigIntOption(cv, ld); - else - return new ConfigIntOption(cv, ld); + return new ConfigIntOption(cv, ld); } +} // namespace /************************************************* **************** STRUCT_NAMES ***************** diff --git a/tools/snort2lua/config_states/config_one_string_option.cc b/tools/snort2lua/config_states/config_one_string_option.cc index 056e0ec2d..0a0ecf161 100644 --- a/tools/snort2lua/config_states/config_one_string_option.cc +++ b/tools/snort2lua/config_states/config_one_string_option.cc @@ -29,6 +29,9 @@ namespace config { +namespace +{ + template(cv, ld); } +} // namespace /************************************************* ***************** STRUCT_NAMES **************** diff --git a/tools/snort2lua/data/dt_data.cc b/tools/snort2lua/data/dt_data.cc index b1199ce33..5f9d04a1d 100644 --- a/tools/snort2lua/data/dt_data.cc +++ b/tools/snort2lua/data/dt_data.cc @@ -23,6 +23,7 @@ #include "utils/snort2lua_util.h" #include #include +#include LuaData::PrintMode LuaData::mode = LuaData::PrintMode::QUIET; @@ -162,8 +163,8 @@ std::string LuaData::expand_vars(std::string string) varcontents = NULL; - memset((char *) varname, 0, sizeof(varname)); - memset((char *) varaux, 0, sizeof(varaux)); + std::memset((char *) varname, 0, sizeof(varname)); + std::memset((char *) varaux, 0, sizeof(varaux)); varmodifier = ' '; p = strchr(rawvarname, ':'); @@ -180,7 +181,7 @@ std::string LuaData::expand_vars(std::string string) else std::strncpy(varname, rawvarname, sizeof(varname)); - memset((char *) varbuffer, 0, sizeof(varbuffer)); + std::memset((char *) varbuffer, 0, sizeof(varbuffer)); std::string tmp = translate_variable(varname); varcontents = tmp.c_str();