Skip to content

Commit

Permalink
Merge branch 'release/0.2'
Browse files Browse the repository at this point in the history
* release/0.2: (1069 commits)
  Add GITTAG build option
  Remove sha for source package
  Remove useless references in tutorial
  Fix tracking issue in html pages
  Fix marshal issue when no debug info available
  Fix doc duplicated title
  Fix workshop doc
  Improve package file name
  Fix luajit install path
  Exclude unneeded sphinx files
  Bump version to 0.2
  Add sha1sum for source package
  Fix indent in Makefile
  Fix class name in cross ref
  Fix crossrefs in workshop
  Remove unused files in workshop
  Fix sticky navbar issue
  Fix C API rendering
  Improve css for doc
  Fix navbar next, up, prev
  ...

Conflicts:
	.gitmodules
  • Loading branch information
Pierre-Sylvain Desse committed Aug 12, 2014
2 parents 7b867a4 + b65b43b commit 2c4217e
Show file tree
Hide file tree
Showing 857 changed files with 59,474 additions and 11,313 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/make
/workspace
/buildtag.cmake
/doc/genimages
/doc/theme/haka/track.html
/sample/mymodule/Makefile
*.swp
.project
.externalToolBuilders
27 changes: 15 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[submodule "external/luajit"]
path = external/luajit
url = git://repo.or.cz/luajit-2.0.git
[submodule "external/sphinx-lua"]
path = external/sphinx-lua
url = git://github.com/redjack/sphinx-lua
[submodule "external/iniparser"]
path = external/iniparser
url = git://github.com/ndevilla/iniparser.git
[submodule "external/lua"]
path = external/lua
url = git://github.com/haka-security/lua.git
[submodule "external/iniparser/src"]
path = external/iniparser/src
url = https://github.com/haka-security/iniparser.git
[submodule "external/lua/src"]
path = external/lua/src
url = https://github.com/haka-security/lua.git
[submodule "external/luajit/src"]
path = external/luajit/src
url = http://luajit.org/git/luajit-2.0.git
[submodule "external/luaunit/src"]
path = external/luaunit/src
url = https://github.com/haka-security/luaunit.git
[submodule "external/breathe"]
path = external/breathe
url = https://github.com/haka-security/breathe.git
146 changes: 95 additions & 51 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,71 @@ set(CTEST_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CTEST_MODULE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/build)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build ${CTEST_MODULE_BINARY_DIR} ${CMAKE_MODULE_PATH})

# System
message(STATUS "Build system: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}")

# Version
include(version.cmake)
set(HAKA_VERSION_BUILD "")

# Add a build tag from the Git information
execute_process(COMMAND git symbolic-ref -q --short HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE BUILD_BRANCH RESULT_VARIABLE HAD_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(COMMAND git describe --dirty --always WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE BUILDTAG RESULT_VARIABLE HAD_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(HAD_ERROR EQUAL 0)
if((BUILD_BRANCH MATCHES "^master$" OR BUILD_BRANCH MATCHES "^release/.*$") AND
(NOT BUILDTAG MATCHES "-dirty"))
# Release build not dirty, no extra buildtag
execute_process(COMMAND rm -f "${CMAKE_SOURCE_DIR}/buildtag.cmake")
else()
set(GITTAG "yes" CACHE STRING "Append git tag to build number")
if(GITTAG STREQUAL "yes")
# Add a build tag from the Git information
execute_process(COMMAND git symbolic-ref -q --short HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE BUILD_BRANCH RESULT_VARIABLE HAD_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(COMMAND git describe --dirty --always WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE BUILDTAG RESULT_VARIABLE HAD_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(HAD_ERROR EQUAL 0)
set(HAKA_VERSION_BUILD "+${BUILDTAG}")
execute_process(COMMAND echo "set(HAKA_VERSION_BUILD \"${HAKA_VERSION_BUILD}\")" OUTPUT_FILE ${CMAKE_SOURCE_DIR}/buildtag.cmake)
execute_process(COMMAND echo "set(HAKA_VERSION_BUILD \"${HAKA_VERSION_BUILD}\")"
OUTPUT_FILE ${CMAKE_SOURCE_DIR}/buildtag.cmake)
else()
include(buildtag.cmake OPTIONAL)
endif()
else()
include(buildtag.cmake OPTIONAL)
endif()

message(STATUS "Build version: ${HAKA_VERSION_MAJOR}.${HAKA_VERSION_MINOR}.${HAKA_VERSION_PATCH}${HAKA_VERSION_BUILD}")

# Distribution
find_package(Distrib REQUIRED)
set(HAKA_VERSION "${HAKA_VERSION_MAJOR}.${HAKA_VERSION_MINOR}.${HAKA_VERSION_PATCH}${HAKA_VERSION_BUILD}")
message(STATUS "Build version: ${HAKA_VERSION}")

# Build type
set(BUILD "Release" CACHE STRING "Selected build type")
set(CMAKE_BUILD_TYPE ${BUILD})
message(STATUS "Building configuration (BUILD): ${CMAKE_BUILD_TYPE}")

if(NOT ("$ENV{BUILD}" STREQUAL ""))
set(CMAKE_BUILD_TYPE $ENV{BUILD})
else()
set(CMAKE_BUILD_TYPE ${BUILD})
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")

if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-gnu-designator")
endif()

set(CMAKE_C_FLAGS_MEMCHECK ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_CXX_FLAGS_MEMCHECK ${CMAKE_CXX_FLAGS_DEBUG})

set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_DEBUG} --coverage")
set(CMAKE_LINK_FLAGS_COVERAGE "${CMAKE_LINK_FLAGS_COVERAGE} --coverage")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} --coverage")

set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2 -fstack-protector --param ssp-buffer-size=4")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2 -fstack-protector --param ssp-buffer-size=4")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Wl,-z,relro -Wl,-z,now")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,-z,relro -Wl,-z,now")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,-z,relro -Wl,-z,now")

# The RelWithDebInfo options should be the same as Release
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELEASE}")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(HAKA_DEBUG 1)
elseif(CMAKE_BUILD_TYPE STREQUAL "Coverage")
set(HAKA_DEBUG 1)
elseif(CMAKE_BUILD_TYPE STREQUAL "Memcheck")
set(HAKA_DEBUG 1)
set(HAKA_MEMCHECK 1)
Expand All @@ -71,10 +99,35 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(HAKA_NDEBUG 1)
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
set(HAKA_NDEBUG 1)
else()
message(FATAL_ERROR "Build configuration (BUILD): Unsupported build ${CMAKE_BUILD_TYPE}")
endif()

message(STATUS "Build configuration (BUILD): ${CMAKE_BUILD_TYPE}")

# Coverage
find_package(LCov)
if(LCOV_FOUND)
add_custom_target(coverage_clean
COMMAND lcov -z --directory ${CMAKE_CURRENT_BINARY_DIR}
COMMAND rm -f coverage/coverage.info
COMMENT "Clean coverage data" VERBATIM
)

add_custom_target(coverage
COMMAND mkdir -p coverage
COMMAND lcov --capture --directory ${CMAKE_CURRENT_BINARY_DIR} --output-file coverage/coverage_full.info
COMMAND lcov -r coverage/coverage_full.info "*test*.c" -o coverage/coverage.info
COMMAND lcov -r coverage/coverage.info "*LUA_wrap.c" -o coverage/coverage.info
COMMAND lcov -r coverage/coverage.info "*external*" -o coverage/coverage.info
COMMAND genhtml --legend coverage/coverage.info --output-directory coverage
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Build coverage data" VERBATIM
)
endif(LCOV_FOUND)

# Force the RUNPATH to be set to the RPATH to improve library search order
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-new-dtags")

# Default SWIG behavior to not create global module
find_package(SWIG 2 REQUIRED)
Expand All @@ -83,46 +136,36 @@ include(UseSWIG)
set(CMAKE_SWIG_FLAGS "-nomoduleglobal")

# Install prefix
set(PREFIX "/" CACHE STRING "Installation prefix")
message(STATUS "Installation prefix (PREFIX): ${PREFIX}")
message(STATUS "Installation prefix (CMAKE_INSTALL_PREFIX): ${CMAKE_INSTALL_PREFIX}")

if(NOT IS_ABSOLUTE ${PREFIX})
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${PREFIX})
else()
set(CMAKE_INSTALL_PREFIX ${PREFIX})
endif()

set(HAKA_INSTALL_PREFIX "opt/haka")

if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/")
set(CMAKE_INSTALL_PREFIX "")
set(CMAKE_HAKA_INSTALL_PREFIX "/${HAKA_INSTALL_PREFIX}")
else()
set(CMAKE_HAKA_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${HAKA_INSTALL_PREFIX}")
endif()
set(ENV_SH ${CMAKE_CURRENT_BINARY_DIR}/out/env.sh)

add_custom_target(localinstall
COMMAND $(MAKE) install DESTDIR=${CMAKE_BINARY_DIR}/out
COMMAND echo "export LD_LIBRARY_PATH=\"${CMAKE_CURRENT_BINARY_DIR}/out/opt/haka/lib\"; export HAKA_PATH=\"${CMAKE_CURRENT_BINARY_DIR}/out/opt/haka\"; export PATH=\"${CMAKE_CURRENT_BINARY_DIR}/out/opt/haka/bin\":\"${CMAKE_CURRENT_BINARY_DIR}/out/opt/haka/sbin\":$PATH" > ${CMAKE_CURRENT_BINARY_DIR}/out/env.sh
COMMAND echo "export LD_LIBRARY_PATH=\"${CMAKE_CURRENT_BINARY_DIR}/out${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_CURRENT_BINARY_DIR}/out${CMAKE_INSTALL_PREFIX}/lib/haka/modules/protocol\"" > ${ENV_SH}
COMMAND echo "export HAKA_PATH=\"${CMAKE_CURRENT_BINARY_DIR}/out${CMAKE_INSTALL_PREFIX}\"" >> ${ENV_SH}
COMMAND echo "export PATH=\"${CMAKE_CURRENT_BINARY_DIR}/out${CMAKE_INSTALL_PREFIX}/bin\":\"${CMAKE_CURRENT_BINARY_DIR}/out${CMAKE_INSTALL_PREFIX}/sbin\":$PATH" >> ${ENV_SH}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Install locally..." VERBATIM
VERBATIM
)

# Lua
set(LUA "luajit" CACHE STRING "Lua version")
message(STATUS "Lua version (LUA): ${LUA}")
include(UseLua)

# Configure
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
if(NOT ("$ENV{LUA}" STREQUAL ""))
set(CMAKE_LUA $ENV{LUA})
else()
set(CMAKE_LUA ${LUA})
endif()

message(STATUS "Lua version (LUA): ${CMAKE_LUA}")
include(UseLua)

find_package(Threads REQUIRED)

set(HAKA_MODULE_PREFIX "" CACHE STRING "Haka module prefix")
set(HAKA_MODULE_SUFFIX ".ho" CACHE STRING "Haka module suffix")
set(HAKA_MODULE_SUFFIX ".so" CACHE STRING "Haka module suffix")

TEST_BIG_ENDIAN(BIGENDIAN)
set(HAKA_BIGENDIAN ${BIGENDIAN})
Expand Down Expand Up @@ -178,45 +221,46 @@ include_directories(include)
enable_testing()
set(TEST_RUNDIR ${CMAKE_BINARY_DIR}/test/${CMAKE_INSTALL_PREFIX})

add_custom_target(pre-tests-build
add_custom_target(pretests-build
COMMAND $(MAKE) all
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
VERBATIM
)

add_custom_target(pre-tests
add_custom_target(pretests
COMMAND rm -rf ${CMAKE_BINARY_DIR}/test
COMMAND $(MAKE) install/fast DESTDIR=${CMAKE_BINARY_DIR}/test > /dev/null
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Preparing tests environment..." VERBATIM
VERBATIM
DEPENDS pre-tests-build
DEPENDS pretests-build
)

add_custom_target(tests
COMMAND ctest -j${CPU_COUNT} $(CTEST_ARGS)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Run all tests" VERBATIM
DEPENDS pre-tests
DEPENDS pretests
)

# Add sub directories)
add_subdirectory(external)

include_directories(${UTHASH_INCLUDE})

add_subdirectory(include)
add_subdirectory(doc)
add_subdirectory(lib)
add_subdirectory(src)
add_subdirectory(modules)
add_subdirectory(lib)
add_subdirectory(sample)
add_subdirectory(include)

# add a target to run cppcheck on the sources
find_package(Cppcheck)
if(CPPCHECK_FOUND)
add_custom_target(cppcheck
${CPPCHECK_EXECUTABLE} --enable=all -imake -iexternal -Iincludes -Imake/includes .
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Run cppcheck static analyzer on the sources" VERBATIM
)
endif(CPPCHECK_FOUND)
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ Dependencies
* Toolchain (GCC, Make, ...)
* cmake (>= 2.8)
* swig
* sphinx (>= 2)
* tshark
* check
* rsync
* libpcap
* gawk
* libedit
* libeditline
* libpcre

### Optional

* Git
* Cppcheck
* Netfilter Queue
* Valgrind
* Sphinx (>= 2)
* Doxygen
* Inkscape
* python-blockdiag
* python-seqdiag

Submodules
----------
Expand Down Expand Up @@ -63,7 +68,8 @@ clean (`make clean`).
### Documentation

Run `make doc` to generate documentation in `html`. The documentation is then available
in `doc` inside your build folder.
in `doc` inside your build folder. In order to build it, you need to have Sphinx and
Doxygen installed.

The documentation contains more information about building and using Haka.

Expand Down
1 change: 0 additions & 1 deletion autobuild/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ _build() {
_runeach _build

exit 0

2 changes: 1 addition & 1 deletion autobuild/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _configure() {
_run mkdir -p "$MAKEDIR/$1-$2"
cd "$MAKEDIR/$1-$2"

_run cmake -DBUILD=$1 -DLUA=$2 "$ROOT"
_run cmake -DBUILD=$1 -DLUA=$2 -DCMAKE_INSTALL_PREFIX=/usr "$ROOT"
}

_runeach _configure
Expand Down
24 changes: 24 additions & 0 deletions autobuild/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /bin/bash

source autobuild/vars.sh
source autobuild/includes.sh

_coverage() {
_run mkdir -p "$MAKEDIR/Coverage-$1"
cd "$MAKEDIR/Coverage-$1"

_run cmake -DBUILD=Coverage -DLUA=$1 "$ROOT"
_run make all
_run make coverage_clean
VALGRIND=0 make tests
_run make coverage

if [ -n "$DROPDIR" ]; then
_run mkdir -p "$DROPDIR/coverage-$1"
_run cp -r coverage "$DROPDIR/coverage-$1"
fi
}

_runeachoptions _coverage

exit 0
20 changes: 20 additions & 0 deletions autobuild/doc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/bash

source autobuild/vars.sh
source autobuild/includes.sh

_doc() {
cd "$MAKEDIR/$1-$2"
_run make doc

if [ -n "$DROPDIR" ]; then
### Copy to destination
_run mkdir -p "$DROPDIR/"
_run cp -r doc/doc "$DROPDIR/"
_run cd doc/doc && tar -cz -f "$DROPDIR/haka-doc.tgz" *
fi
}

_runeach _doc

exit 0
5 changes: 5 additions & 0 deletions autobuild/includes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ _runeach() {
done
}

_runeachoptions() {
for lua in $(echo "$HAKA_LUA" | sed s/,/\\n/g); do
$* $lua
done
}
1 change: 0 additions & 1 deletion autobuild/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ _package() {
_runeach _package

exit 0

Loading

0 comments on commit 2c4217e

Please sign in to comment.