# 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.0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -ggdb")

set(CMAKE_LIBRARY_PATH /usr/lib/;/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 0)
#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 secure in order to avoid Arp Spoofing/Poisoning & co. This is possible using two kinds of anti Arp Poisoning  tecniques,  the first is based on SARPI or 'Static Arp Inspection', the second on DARPI or 'Dynamic Arp Inspection' approach. Keep in mind other common tools fighting ARP  poisoning  usually  limit their  activity  only  to point out the problem instead of blocking it, ArpON does it using SARPI and DARPI  policies.   Finally  you  can  use ArpON  to  pentest some switched/hubbed LAN with/without DHCP protocol, in fact you can disable the daemon in order to use the tools to  poison the ARP Cache. Remember it doesn't affect the communication efficiency of the ARP pro‐tocol!")

  set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ArpON is a portable handler daemon that make Arp secure in order to avoid Arp Spoofing/Poisoning & co.")
  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")
