# CMakeLists.txt build arpon.c with cmake
#
# The following variables are set:
# CMAKE_C_FLAGS - flags to add to the C compiler for build arpon
# CMAKE_LIBS - set the library flags to add to the C compiler for build arpon
# CMAKE_INCLUDE - set the include flags  to add to the C compiler for build arpon
# CMAKE_INSTALL_PREFIX - set the install prefix for arpon. By default
#		arpon will be installed to /usr/loca/ path.
#
#
# Copyright 2010 <Giuseppe Marco Randazzo> zeld@freaknet.org
#
# Redistribution AND use is allowed according to the terms of the New
# BSD license.

cmake_minimum_required(VERSION 2.6)
project(ArpON)
set(AUTHOR "Andrea Di Pasquale" INTERNAL "Author")
set(VERSION "2.7")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g")

set(CMAKE_LIBRARY_PATH /usr/lib/;/usr/lib64/;/usr/local/lib/;
  /opt/local/lib/;/usr/local/lib/libnet11/;
  /usr/lib/libnet11/;/usr/lib/libnet113/;
  /usr/local/lib/libnet113/;/usr/lib/libnet-1.1/;
  /usr/local/lib/libnet-1.1/;/usr/pkg/lib/;
  /usr/pkg/lib/libnet11;${CMAKE_LIBRARY_PATH})

set(CMAKE_INCLUDE_PATH /usr/include/;/usr/local/include/;
  /opt/local/include/;/usr/local/include/libnet11/;
  /usr/include/libnet11/;/usr/include/libnet113/;
  /usr/local/include/libnet113/;/usr/include/libnet-1.1/;
  /usr/local/include/libnet-1.1/;/usr/pkg/include;
  /usr/pkg/include/libnet11;${CMAKE_INCLUDE_PATH})

set(CMAKE_INSTALL_PREFIX "/")

include_directories("/usr/include")
link_directories("/usr/lib")

set(INCLUDE_DIR "/usr/include")
set(LIB_DIR "/usr/lib")

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")
find_package(System)
find_package(Pthread)
find_package(DNET)
find_package(NET)
find_package(PCAP)

add_subdirectory(src)
add_subdirectory(man8)
add_subdirectory(etc)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" 
        "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P 
        "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")



set(MAJOR_VERSION 2)
set(MINOR_VERSION 7)
#set(PATCH_VERSION 0)
set(ARPON_NAME "arpon")

if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
  include(InstallRequiredSystemLibraries)

  set(CPACK_GENERATOR "DEB;RPM;TBZ2;TGZ;STGZ")

  set(CPACK_PACKAGE_DESCRIPTION "ArpON (ARP handler inspection) is a portable handler daemon that make ARP protocol secure in order to avoid the Man In The Middle (MITM) attack through ARP Spoofing, ARP Cache Poisoning, ARP Poison Routing (APR) attacks. It blocks also the derived attacks by it, which Sniffing, Hijacking, Injection, Filtering & co attacks for more complex derived attacks, as: DNS Spoofing, WEB Spoofing, Session Hijacking and SSL/TLS Hijacking & co attacks. This is possible using three kinds of anti ARP Spoofing tecniques: the first is based on SARPI or "Static ARP Inspection" in statically configured networks without DHCP; the second on DARPI or "Dynamic ARP Inspection" in dynamically configured networks having DHCP; the third on HARPI or "Hybrid ARP Inspection" in "hybrid" networks, that is in statically and dynamically (DHCP) configured networks together. ArpON is therefore a proactive point to point and multipoint based solution that requires a daemon in every host of the connection and that doesn't modify the classic ARP standard base protocol by IETF, but rather sets precise policies by using SARPI for static networks, DARPI for dynamic networks and HARPI for hybrid networks thus making today's standardized protocol working and secure from any foreign intrusion.") 

  set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ArpON (ARP handler inspection) is a portable handler daemon that make ARP protocol secure in order to avoid the Man In The Middle (MITM) attack through ARP Spoofing, ARP Cache Poisoning, ARP Poison Routing (APR) attacks attacks. It blocks also the derived attacks by it, which Sniffing, Hijacking, Injection, Filtering & co attacks for more complex derived attacks, as: DNS Spoofing, WEB Spoofing, Session Hijacking and SSL/TLS Hijacking & co attacks.")
  set(CPACK_PACKAGE_VENDOR  "zeld")
  set(CPACK_PACKAGE_CONTACT  "zeld <zeld@freaknet.org>")
  set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
  set(CPACK_PACKAGE_VERSION_MAJOR     "${MAJOR_VERSION}")
  set(CPACK_PACKAGE_VERSION_MINOR     "${MINOR_VERSION}")
  set(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
  #set(CPACK_PACKAGE_FILE_NAME     "${CMAKE_PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
  #set(CPACK_SOURCE_PACKAGE_FILE_NAME  "${CMAKE_PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
  set(CPACK_PACKAGE_FILE_NAME     "${CMAKE_PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}")
  set(CPACK_SOURCE_PACKAGE_FILE_NAME  "${CMAKE_PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}")


  set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.4), libdumbnet1, libnet1 (>= 1.1.2.1), libpcap0.8 (>= 0.9.3-1), lsb-base")
  set(CPACK_DEBIAN_PACKAGE_SECTION "universe/net")

  #set(CPACK_RPM_PACKAGE_LICENSE "BSD")
  #set(CPACK_RPM_PACKAGE_GROUP "Administration Tools")
  #set(CPACK_RPM_PACKAGE_REQUIRES "")

  set(CPACK_STRIP_FILES TRUE)
  set(CPACK_COMPONENTS_ALL Etcfile Man Application)

  include(CPack)
else(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
  message(FATAL_ERROR "${CMAKE_ROOT}/Modules/CPack.cmake not found! Unable to make package.")
endif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
