diff -r 000000000000 -r c9bf2537109a ait/os/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ait/os/CMakeLists.txt Tue Nov 12 11:31:34 2013 +0100 @@ -0,0 +1,285 @@ +# ------------------------------------------------------------ +# CMakeLists.txt the AIT OpenSecurity ShadowFUSE +# +# Autor: Oliver Maurhart, +# +# Copyright (C) 2013 AIT Austrian Institute of Technology +# AIT Austrian Institute of Technology GmbH +# Donau-City-Strasse 1 | 1220 Vienna | Austria +# http://www.ait.ac.at +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# ------------------------------------------------------------ + +# project data +project(os-server C CXX) +cmake_minimum_required(VERSION 2.6) + +# load necessary basic cmake modules +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckLibraryExists) +include(FindPkgConfig) +include(FindPythonInterp) + +# enable tests +ENABLE_TESTING() + + +# ------------------------------------------------------------ +# set global compiler flags + +set(VERSION "0.1") +add_definitions(-DVERSION=\"${VERSION}\") + +# we relay on a GNU/BSD SOURCE +add_definitions(-D_GNU_SOURCE) +add_definitions(-D_BSD_SOURCE) + +# set compile flags +if (CMAKE_COMPILER_IS_GNUCC) + + # tweak capabilities of gcc versions prior to 4.8 + if (${CMAKE_C_COMPILER_VERSION} LESS 4.8) + + message(STATUS "gcc compiler < 4.8 detected - tweaking flags") + + # make this clear: we use std::thread + # so enforce pthread bindings + # this may not be needed for gcc >= 4.8 + add_definitions(-pthread) + + # this is needed to have + # std::_this_thread::sleep(...) + # at hand - at least for gcc 4.6.3 and glibc 2.15 + add_definitions(-D_GLIBCXX_USE_NANOSLEEP) + + # this is needed to have + # std::_this_thread::yield() + # at hand - at least for gcc 4.6.3 and glibc 2.15 + add_definitions(-D_GLIBCXX_USE_SCHED_YIELD) + + endif (${CMAKE_C_COMPILER_VERSION} LESS 4.8) + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Werror -Wall -Wextra -pedantic -g -ggdb3 -rdynamic") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x -Werror -Wall -Wextra -pedantic -g -ggdb3 -rdynamic") + + # TODO: make speed tests with -fno-builtin especially to + # get a better memcpy performance + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin") + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin") + +endif (CMAKE_COMPILER_IS_GNUCC) + +# additional debug and profiling options +option(DEBUG_MODE_ENABLED "enable debug mode" off) +if (CMAKE_COMPILER_IS_GNUCC) + if (DEBUG_MODE_ENABLED) + message(STATUS "debug and profiling mode enabled") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -pg --coverage") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -pg --coverage") + else(DEBUG_MODE_ENABLED) + message(STATUS "debug and profiling mode disabled: go for optimizations") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") + endif(DEBUG_MODE_ENABLED) +endif (CMAKE_COMPILER_IS_GNUCC) + + +# ------------------------------------------------------------ +# check for an existing python module (maybe extra) + +macro(CHECK_PYTHON_MODULE VARIABLE MODULE) + + message(STATUS "Looking for python module ${MODULE}") + + if (PYTHONINTERP_FOUND) + + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "import ${MODULE}" + RESULT_VARIABLE _result + OUTPUT_QUIET + ERROR_QUIET + ) + + if ("${_result}" EQUAL "0") + set (${VARIABLE}_FOUND TRUE) + endif ("${_result}" EQUAL "0") + + endif (PYTHONINTERP_FOUND) + + if (${VARIABLE}_FOUND) + message(STATUS "Looking for python module ${MODULE} - found") + else (${VARIABLE}_FOUND) + message(STATUS "Looking for python module ${MODULE} - not found") + endif (${VARIABLE}_FOUND) + +endmacro(CHECK_PYTHON_MODULE MODULE) + + +# ------------------------------------------------------------ +# check libs and packages (headers + lib) + +# standard C files +check_include_file(stdio.h HAVE_STDIO_H) +check_include_file(stddef.h HAVE_STDDEF_H) +check_include_file(stdlib.h HAVE_STDLIB_H) +check_include_file(inttypes.h HAVE_INTTYPES_H) +check_include_file(memory.h HAVE_MEMORY_H) +check_include_file(string.h HAVE_STRING_H) +check_include_file(unistd.h HAVE_UNISTD_H) + +# time +check_include_file(sys/time.h HAVE_SYS_TIME_H) +check_include_file(time.h HAVE_TIME_H) + +# file system stuff +check_include_file(fcntl.h HAVE_FCNTL_H) +check_include_file(sys/stat.h HAVE_SYS_STAT_H) + +# math +check_include_file(math.h HAVE_MATH_H) + +# stdbool +check_include_file(stdbool.h HAVE_STDBOOL_H) + +# endian +check_include_file(endian.h HAVE_ENDIAN_H) + +# math.h +check_include_file(math.h HAVE_MATH_H) + +# networking +check_include_file(netdb.h HAVE_NETDB_H) +check_include_file(ifaddrs.h HAVE_IFADDRS_H) +check_include_file(netinet/in.h HAVE_NETINET_IN_H) +check_include_file(arpa/inet.h HAVE_ARPA_INET_H) +check_include_file(sys/socket.h HAVE_SYS_SOCKET_H) +check_include_file(sys/un.h HAVE_SYS_UN_H) + +# assert +check_include_file(assert.h HAVE_ASSERT_H) + +# signal +check_include_file(signal.h HAVE_SIGNAL_H) + +# sys/uio +check_include_file(sys/uio.h HAVE_SYS_UIO_H) + +# syslog +check_include_file(syslog.h HAVE_SYSLOG_H) + +# errno +check_include_file(errno.h HAVE_ERRNO_H) + +# limits +check_include_file(limits.h HAVE_LIMITS_H) + +# sys/mman.h +check_include_file(sys/mman.h HAVE_SYS_MMAN_H) + +# dirent.h +check_include_file(dirent.h HAVE_DIRENT_H) + +# fuse.h +pkg_check_modules(FUSE REQUIRED fuse) +if (FUSE_FOUND) + set(HAVE_FUSE_H 1) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FUSE_CFLAGS_OTHER}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FUSE_CFLAGS_OTHER}") + set(CMAKE_REQUIRED_LIBRARIES "${FUSE_LIBRARIES};${CMAKE_REQUIRED_LIBRARIES}") +endif (FUSE_FOUND) + +# check python module dbus +check_python_module(PYTHON_DBUS dbus) +if (NOT PYTHON_DBUS_FOUND) + message(FATAL_ERROR "python module 'dbus' missing.") +endif (NOT PYTHON_DBUS_FOUND) + +# check python module fuse +check_python_module(PYTHON_FUSE fuse) +if (NOT PYTHON_FUSE_FOUND) + message(FATAL_ERROR "python module 'fuse' missing. please install 'fuse-python'.") +endif (NOT PYTHON_FUSE_FOUND) + +# check python module web +check_python_module(PYTHON_WEB web) +if (NOT PYTHON_WEB_FOUND) + message(FATAL_ERROR "python module 'web' missing. please install 'web.py'.") +endif (NOT PYTHON_WEB_FOUND) + + +# ------------------------------------------------------------ +# dump the config file + +# create the config.h and baseinc.h +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + + +# ------------------------------------------------------------ +# go through the subs + +add_subdirectory(bin) + + +# ------------------------------------------------------------ +# additional stuff for installation + +install(DIRECTORY etc/dbus-1 DESTINATION /etc) + + +# ------------------------------------------------------------ +# packaging + +set(CPACK_PACKAGE_NAME "opensecurity") + +set(CPACK_PACKAGE_DESCRIPTION "OpenSecurity System") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is the OpenSecurity System suite to be insalled into a Security VM") +set(CPACK_PACKAGE_CONTACT "Oliver Maurhart ") +set(CPACK_PACKAGE_VENDOR "AIT") +set(CPACK_PACKAGE_VERSION_MAJOR "0") +set(CPACK_PACKAGE_VERSION_MINOR "1") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PROJECT_VERSION_STRING "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" ) + +set(CPACK_GENERATOR "DEB;RPM;") +set(CPACK_SOURCE_GENERATOR "TGZ") + +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CMAKE_SYSTEM_PROCESSOR}") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") +set(CPACK_SOURCE_IGNORE_FILES "/build/*;/.git/") + +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.13), libgcc1 (>= 1:4.4), python (>= 2.7)") +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpack/deb/control/postinst;${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpack/deb/control/postrm;${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpack/deb/control/prerm;") + +# debianization +string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE) +find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") +if (DPKG_PROGRAM) + # use dpkg to fix the package file name + execute_process( + COMMAND ${DPKG_PROGRAM} --print-architecture + OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${CPACK_PROJECT_VERSION_STRING}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") +else (DPKG_PROGRAM) + set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${CPACK_PROJECT_VERSION_STRING}_${CMAKE_SYSTEM_NAME}") +endif (DPKG_PROGRAM) + +# package it +include(CPack) +