Update some links.
[obnox/wireshark/wip.git] / CMakeLists.txt
index ee7a405d25aa5040d0719dfed1d4bb59bd074967..98c0bdae6641e92af5152b99d2842895d7ce8245 100644 (file)
@@ -92,42 +92,8 @@ if(NOT LIBRARY_OUTPUT_PATH)
                   "Single output directory for building all libraries.")
 endif()
 
-option(BUILD_wireshark   "Build the GUI version of Wireshark" ON)
-option(BUILD_tshark      "Build tshark" ON)
-option(BUILD_rawshark    "Build rawshark" ON)
-option(BUILD_dumpcap     "Build dumpcap" ON)
-option(BUILD_text2pcap   "Build text2pcap" ON)
-option(BUILD_mergecap    "Build mergecap" ON)
-option(BUILD_editcap     "Build editcap" ON)
-option(BUILD_capinfos    "Build capinfos" ON)
-option(BUILD_randpkt     "Build randpkt" ON)
-option(BUILD_dftest      "Build dftest" ON)
-option(AUTOGEN_dcerpc    "Autogenerate dcerpc dissectors" OFF)
-option(AUTOGEN_pidl      "Autogenerate pidl dissectors" OFF)
-
-option(DISABLE_WERROR   "Do not treat Warnings as errors" OFF)
-option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC (disables -Werror)" OFF)
-option(ENABLE_AIRPCAP   "Enable Airpcap support" ON)
-# todo
-option(ENABLE_STATIC     "Build a static version of Wireshark (not yet working)" OFF)
-option(ENABLE_PLUGINS    "Build with plugins" ON)
-# todo
-option(ENABLE_GUIDES     "Build Guides" ON)
-
-option(ENABLE_ADNS       "Build with adns support" ON)
-option(ENABLE_PCRE       "Build with pcre support" ON)
-option(ENABLE_PORTAUDIO  "Build with portaudio support" ON)
-option(ENABLE_Z          "Build with zlib compression support" ON)
-option(ENABLE_LUA       "Build with lua dissector support" ON)
-option(ENABLE_PYTHON    "Build with python dissector support" ON)
-option(ENABLE_SMI       "Build with smi snmp support" ON)
-option(ENABLE_GNUTLS    "Build with GNU TLS support" ON)
-option(ENABLE_GCRYPT    "Build with GNU crypto support" ON)
-option(ENABLE_GEOIP     "Build with GeoIP support" ON)
-option(ENABLE_CAP       "Build with posix capabilities support" ON)
-option(ENABLE_CARES      "Build with c_ares support" ON)
-# todo Mostly hardcoded
-option(ENABLE_KERBEROS  "Build with Kerberos support" ON)
+
+include(CMakeOptions.txt)
 
 
 set(WIRESHARK_C_FLAGS
@@ -142,6 +108,7 @@ set(WIRESHARK_C_FLAGS
        -Warray-bounds
        -Wcast-align
        -Wformat-security
+       -fexcess-precision=fast
 )
 
 set(WIRESHARK_EXTRA_C_FLAGS
@@ -213,12 +180,26 @@ else()
        add_definitions( -D_U_=\"\" )
 endif()
 
-# todo
-# Same for linker flags, but it looks like it's do-it-yourself here
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-flto])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhopr])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhole-program])
+set(WIRESHARK_LD_FLAGS
+       -Wl,--as-needed
+       # -flto
+       # -fwhopr
+       # -fwhole-program
+)
+
+include(CheckCLinkerFlag)
+set(C 0)
+# Sigh: Have to use THIS_FLAG instead of ${F} for some reason
+foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS})
+       set(F WS_LD_FLAG_${C})
+       set(${F} ${THIS_FLAG})
+       set(V WS_LD_FLAG_VALID${C})
+       check_c_linker_flag(${${F}} ${V})
+       if (${${V}})
+               set(WS_LINK_FLAGS ${WS_LINK_FLAGS} ${${F}})
+       endif()
+       math(EXPR C "${C} + 1")
+endforeach()
 
 if(ENABLE_STATIC)
   set(LINK_MODE_LIB STATIC)
@@ -228,6 +209,13 @@ else()
   set(LINK_MODE_MODULE MODULE)
 endif()
 
+# The packagelist is doing some magic:  If we add XXX to the packagelist, we
+# - may optionally set XXX_OPTIONS to pass to the find_package command
+# - will call FindXXX.cmake
+# - return found libraries in XXX_LIBRARIES
+# - return found include in XXX_INCLUDE_DIRS
+# - set HAVE_XXX
+
 #The minimum package list
 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
 
@@ -277,8 +265,8 @@ elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
 endif()
 
 # Zlib compression
-if(ENABLE_Z)
-       set(PACKAGELIST Z ${PACKAGELIST})
+if(ENABLE_ZLIB)
+       set(PACKAGELIST ZLIB ${PACKAGELIST})
 endif()
 
 # Lua 5.1 dissectors
@@ -349,6 +337,10 @@ endif()
 if(ENABLE_AIRPCAP)
        set(HAVE_AIRPCAP 1)
 endif()
+# That's the name autofoo uses
+if(HAVE_LIBZLIB)
+       set(HAVE_LIBZ 1)
+endif()
 
 include(ConfigureChecks.cmake)
 
@@ -402,8 +394,7 @@ add_subdirectory( wiretap )
 add_subdirectory( wsutil )
 
 if(ENABLE_GUIDES)
-#      FIXME: Disabling the build via option currently doesn't work
-#      add_subdirectory( docbook )
+       add_subdirectory( docbook )
 endif()
 
 find_package(POD)
@@ -521,35 +512,36 @@ set(WIRESHARK_COMMON_SRC
 )
 
 set(TSHARK_TAP_SRC
-        tap-afpstat.c
-        tap-ansi_astat.c
-        tap-bootpstat.c
-        tap-camelcounter.c
-        tap-camelsrt.c
-        tap-comparestat.c
-        tap-dcerpcstat.c
-        tap-diameter-avp.c
-        tap-funnel.c
-        tap-gsm_astat.c
-        tap-h225counter.c
-        tap-h225rassrt.c
-        tap-httpstat.c
-        tap-iostat.c
-        tap-iousers.c
-        tap-mgcpstat.c
-        tap-megacostat.c
-        tap-protocolinfo.c
-        tap-protohierstat.c
-        tap-radiusstat.c
-        tap-rpcstat.c
-        tap-rpcprogs.c
-        tap-rtp.c
-        tap-sctpchunkstat.c
-        tap-sipstat.c
-        tap-smbsids.c
-        tap-smbstat.c
-        tap-stats_tree.c
-        tap-wspstat.c
+       tap-afpstat.c
+       tap-ansi_astat.c
+       tap-bootpstat.c
+       tap-camelcounter.c
+       tap-camelsrt.c
+       tap-comparestat.c
+       tap-dcerpcstat.c
+       tap-diameter-avp.c
+       tap-funnel.c
+       tap-gsm_astat.c
+       tap-h225counter.c
+       tap-h225rassrt.c
+       tap-httpstat.c
+       tap-iostat.c
+       tap-iousers.c
+       tap-mgcpstat.c
+       tap-megacostat.c
+       tap-protocolinfo.c
+       tap-protohierstat.c
+       tap-radiusstat.c
+       tap-rpcstat.c
+       tap-rpcprogs.c
+       tap-rtp.c
+       tap-sctpchunkstat.c
+       tap-sipstat.c
+       tap-smbsids.c
+       tap-smbstat.c
+       tap-stats_tree.c
+       tap-sv.c
+       tap-wspstat.c
 )
 
 set(INSTALL_DIRS
@@ -568,12 +560,14 @@ set(INSTALL_FILES
        cfilters
        colorfilters
        dfilters
+       ${CMAKE_BINARY_DIR}/dftest.html
        ${CMAKE_BINARY_DIR}/dumpcap.html
        ${CMAKE_BINARY_DIR}/editcap.html
        ${CMAKE_BINARY_DIR}/idl2wrs.html
        ipmap.html
        manuf
        ${CMAKE_BINARY_DIR}/mergecap.html
+       ${CMAKE_BINARY_DIR}/randpkt.html
        ${CMAKE_BINARY_DIR}/rawshark.html
        services
        smi_modules
@@ -585,16 +579,9 @@ set(INSTALL_FILES
 )
 
 set(LIBEPAN_LIBS
-#              @GETOPT_O@      # wsgetopt.c
-#              @INET_ATON_LO@  # epan/inet_aton.c
-#              @INET_NTOP_LO@  # inet_ntop.c
-#              @INET_PTON_LO@  # inet_pton.c
 #              @NSL_LIBS@      # -lnsl
 #              @SOCKET_LIBS@   # -lsocket
 #              @SSL_LIBS@      # -lcrypto
-#              @STRERROR_O@    # strerror.c
-#              @STRNCASECMP_O@ # strncasecmp.c
-#              @STRPTIME_O@    # strptime.c
                epan
 #              $(plugin_ldadd) # in case of static
                ${PCRE_LIBRARIES}
@@ -608,7 +595,7 @@ set(LIBEPAN_LIBS
                ${GCRYPT_LIBRARIES}
                ${GNUTLS_LIBRARIES}
                ${SMI_LIBRARIES}
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
                ${M_LIBRARIES}
 )
 
@@ -643,6 +630,7 @@ if(BUILD_wireshark)
        )
        add_executable(wireshark ${wireshark_FILES})
        add_dependencies(wireshark svnversion)
+       set_target_properties(wireshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(wireshark ${wireshark_LIBS})
        install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -664,6 +652,7 @@ if(BUILD_tshark)
        )
        add_executable(tshark ${tshark_FILES})
        add_dependencies(tshark svnversion)
+       set_target_properties(tshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(tshark ${tshark_LIBS})
        install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -679,6 +668,7 @@ if(BUILD_rawshark)
        )
        add_executable(rawshark ${rawshark_FILES})
        add_dependencies(rawshark svnversion)
+       set_target_properties(rawshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(rawshark ${rawshark_LIBS})
        install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -692,6 +682,7 @@ if(BUILD_dftest)
                util.c
        )
        add_executable(dftest ${dftest_FILES})
+       set_target_properties(dftest PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(dftest ${dftest_LIBS})
        install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -705,12 +696,13 @@ if(BUILD_randpkt)
 #              @NSL_LIBS@
                ${CARES_LIBRARIES}
                ${ADNS_LIBRARIES}
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
        )
        set(randpkt_FILES
                randpkt.c
        )
        add_executable(randpkt ${randpkt_FILES})
+       set_target_properties(randpkt PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(randpkt ${randpkt_LIBS})
        install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -719,16 +711,20 @@ if(BUILD_text2pcap)
        set(text2pcap_LIBS
                wiretap
                ${M_LIBRARIES}
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
        )
-       set(text2pcap_FILES
+       set(text2pcap_CLEAN_FILES
                text2pcap.c
        )
+       set(text2pcap_FILES
+               ${text2pcap_CLEAN_FILES}
+       )
        add_lex_files(text2pcap_FILES
                text2pcap-scanner.l
        )
        add_executable(text2pcap ${text2pcap_FILES})
        add_dependencies(text2pcap svnversion)
+       set_target_properties(text2pcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(text2pcap ${text2pcap_LIBS})
        install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -736,7 +732,7 @@ endif()
 if(BUILD_mergecap)
        set(mergecap_LIBS
                wiretap
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
        )
        set(mergecap_FILES
                mergecap.c
@@ -745,6 +741,7 @@ if(BUILD_mergecap)
        )
        add_executable(mergecap ${mergecap_FILES})
        add_dependencies(mergecap svnversion)
+       set_target_properties(mergecap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(mergecap ${mergecap_LIBS})
        install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -752,7 +749,7 @@ endif()
 if(BUILD_capinfos)
        set(capinfos_LIBS
                wiretap
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
                ${GCRYPT_LIBRARIES}
                ${APPLE_COCOA_LIBRARY}
        )
@@ -761,6 +758,8 @@ if(BUILD_capinfos)
                ${WTAP_PLUGIN_SOURCES}
        )
        add_executable(capinfos ${capinfos_FILES})
+       add_dependencies(capinfos svnversion)
+       set_target_properties(capinfos PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(capinfos ${capinfos_LIBS})
        install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -768,7 +767,7 @@ endif()
 if(BUILD_editcap)
        set(editcap_LIBS
                wiretap
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
        )
        set(editcap_FILES
                editcap.c
@@ -778,6 +777,7 @@ if(BUILD_editcap)
        )
        add_executable(editcap ${editcap_FILES})
        add_dependencies(editcap svnversion)
+       set_target_properties(editcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(editcap ${editcap_LIBS})
        install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -790,9 +790,7 @@ if(BUILD_dumpcap)
                ${CAP_LIBRARIES}
 #              @SOCKET_LIBS@
 #              @NSL_LIBS@
-               ${GCRYPT_LIBRARIES}
-               ${GNUTLS_LIBRARIES}
-               ${Z_LIBRARIES}
+               ${ZLIB_LIBRARIES}
                ${APPLE_COCOA_LIBRARY}
        )
        set(dumpcap_FILES
@@ -812,6 +810,7 @@ if(BUILD_dumpcap)
        )
        add_executable(dumpcap ${dumpcap_FILES})
        add_dependencies(dumpcap svnversion)
+       set_target_properties(dumpcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
        target_link_libraries(dumpcap ${dumpcap_LIBS})
        install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
@@ -848,40 +847,30 @@ ADD_CUSTOM_COMMAND(
                ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
 )
 
-ADD_CUSTOM_COMMAND(
-       OUTPUT  wireshark-filter.pod
-       COMMAND tshark
-               -G fields |
-               ${PERL}
-               ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
-               ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
-               > wireshark-filter.pod
-       DEPENDS
-               ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
-               ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
-               tshark
-)
-
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
+pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dftest 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
+pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/randpkt 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
 pod2manhtml( wireshark 1 )
-pod2manhtml( wireshark-filter 4 )
+pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
 
 add_custom_target(
        auxiliary ALL
        DEPENDS
                AUTHORS-SHORT
                capinfos.html
+               dftest.html
                dumpcap.html
                editcap.html
                idl2wrs.html
                mergecap.html
+               randpkt.html
                rawshark.html
                text2pcap.html
                tshark.html
@@ -891,10 +880,12 @@ add_custom_target(
 
 set(MAN1_FILES
        ${CMAKE_BINARY_DIR}/capinfos.1
+       ${CMAKE_BINARY_DIR}/dftest.1
        ${CMAKE_BINARY_DIR}/dumpcap.1
        ${CMAKE_BINARY_DIR}/editcap.1
        ${CMAKE_BINARY_DIR}/idl2wrs.1
        ${CMAKE_BINARY_DIR}/mergecap.1
+       ${CMAKE_BINARY_DIR}/randpkt.1
        ${CMAKE_BINARY_DIR}/rawshark.1
        ${CMAKE_BINARY_DIR}/text2pcap.1
        ${CMAKE_BINARY_DIR}/tshark.1
@@ -911,7 +902,7 @@ set(CLEAN_FILES
        ${rawshark_FILES}
        ${dftest_FILES}
        ${randpkt_FILES}
-       ${text2pcap_FILES}
+       ${text2pcap_CLEAN_FILES}
        ${mergecap_FILES}
        ${capinfos_FILES}
        ${editcap_FILES}