diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2018-05-22 00:46:18 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2018-05-22 06:11:12 +0000 |
commit | 5d69755c50da76733bd2aec29acdb78fe29b5aa2 (patch) | |
tree | 43eeae6ab8e9ba35ff124ff28fc80d7d222ac439 /doc/plugins.example | |
parent | 03aae2267fdc9beb8cdeb0a43294b2a5069780cd (diff) |
Convert doc/plugins.example to use CMake
Change-Id: Ic290249569ea9bb435638a9cabd4d87ac7ef9323
Reviewed-on: https://code.wireshark.org/review/27699
Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'doc/plugins.example')
-rw-r--r-- | doc/plugins.example/CMakeLists.txt | 52 | ||||
-rw-r--r-- | doc/plugins.example/Makefile.am | 34 | ||||
-rw-r--r-- | doc/plugins.example/README | 9 | ||||
-rw-r--r-- | doc/plugins.example/configure.ac | 38 |
4 files changed, 57 insertions, 76 deletions
diff --git a/doc/plugins.example/CMakeLists.txt b/doc/plugins.example/CMakeLists.txt new file mode 100644 index 0000000000..cd77217609 --- /dev/null +++ b/doc/plugins.example/CMakeLists.txt @@ -0,0 +1,52 @@ +# CMakeLists.txt +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@wireshark.org> +# Copyright 1998 Gerald Combs +# +# SPDX-License-Identifier: GPL-2.0-or-later +# + +cmake_minimum_required(VERSION 3.1) +cmake_policy(SET CMP0048 NEW) + +project(Hello VERSION 0.0.1 DESCRIPTION "Wireshark Hello Plugin" LANGUAGES C) + +option(SYSTEM_INSTALLATION "Install to system plugin directory" ON) + +find_package(PkgConfig REQUIRED) + +pkg_check_modules(WIRESHARK REQUIRED wireshark>=2.5) +pkg_get_variable(WIRESHARK_VERSION_RELEASE wireshark VERSION_RELEASE) +pkg_get_variable(WIRESHARK_PLUGIN_DIR wireshark plugindir) + +include(CMakePushCheckState) +include(CheckSymbolExists) + +cmake_push_check_state() +set(CMAKE_REQUIRED_INCLUDES ${WIRESHARK_INCLUDE_DIRS}) +set(CMAKE_REQUIRED_LIBRARIES ${WIRESHARK_LIBRARIES}) +set(CMAKE_REQUIRED_DEFINITIONS -DHAVE_PLUGINS) +check_symbol_exists("proto_register_plugin" "epan/proto.h" HAVE_PROTO_REGISTER_PLUGIN) +cmake_pop_check_state() +if(NOT HAVE_PROTO_REGISTER_PLUGIN) + message(FATAL_ERROR "Wireshark was compiled without support for plugins") +endif() + +add_definitions(-DHAVE_PLUGINS -DVERSION=\"${PROJECT_VERSION}\" -DVERSION_RELEASE=\"${WIRESHARK_VERSION_RELEASE}\") + +add_library(hello MODULE hello.c) +set_target_properties(hello PROPERTIES PREFIX "") +target_link_libraries(hello ${WIRESHARK_LIBRARIES}) +target_include_directories(hello PUBLIC ${WIRESHARK_INCLUDE_DIRS}) +target_compile_options(hello PUBLIC ${WIRESHARK_CFLAGS}) + +if(SYSTEM_INSTALLATION) + set(PLUGIN_INSTALL_LIBDIR "${WIRESHARK_PLUGIN_DIR}/epan") +else() + set(PLUGIN_INSTALL_LIBDIR "$ENV{HOME}/.local/lib/wireshark/plugins/${WIRESHARK_VERSION_RELEASE}/epan") +endif() + +install(TARGETS hello + LIBRARY DESTINATION ${PLUGIN_INSTALL_LIBDIR} NAMELINK_SKIP +) diff --git a/doc/plugins.example/Makefile.am b/doc/plugins.example/Makefile.am deleted file mode 100644 index 10abf565e8..0000000000 --- a/doc/plugins.example/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -# Makefile.am -# -# Wireshark - Network traffic analyzer -# By Gerald Combs <gerald@wireshark.org> -# Copyright 1998 Gerald Combs -# -# SPDX-License-Identifier: GPL-2.0-or-later -# - -WARNFLAGS = -Wall -Wextra - -plugindir := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --define-variable=libdir=$(libdir) --variable plugindir wireshark) - -epan_plugindir = $(plugindir)/epan - -VERSION_RELEASE := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --variable VERSION_RELEASE wireshark) - -epan_plugin_LTLIBRARIES = hello.la - -hello_la_SOURCES = hello.c - -hello_la_CPPFLAGS = -DVERSION_RELEASE=\"$(VERSION_RELEASE)\" - -hello_la_CFLAGS = $(WIRESHARK_CFLAGS) -fvisibility=hidden $(WARNFLAGS) - -hello_la_LDFLAGS = -module -avoid-version -shared - -hello_la_LIBADD = $(WIRESHARK_LIBS) - -homedir = $${HOME}/.local/lib/wireshark/plugins/$(VERSION_RELEASE)/epan - -install-home: - $(MKDIR_P) $(homedir) || exit 1; \ - $(INSTALL) $(builddir)/.libs/hello.so $(homedir) diff --git a/doc/plugins.example/README b/doc/plugins.example/README index 04bc5885eb..18f553be97 100644 --- a/doc/plugins.example/README +++ b/doc/plugins.example/README @@ -4,10 +4,11 @@ This is an example of how to build a Wireshark plugin out-of-tree. Tested on Linux using GCC 7. Note this builds against Wireshark's *installed* version. You should of course adapt to your own needs. -To build/install the plugin: +To build/install the plugin (assuming wireshark was installed in /usr/local): -$ autoreconf -v -i $ PREFIX=/usr/local -$ ./configure --prefix="$PREFIX" PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" +$ mkdir build +$ cd build +$ PKG_CONFIG_PATH="$PREFIX/lib64/pkgconfig" cmake -DCMAKE_PREFIX_PATH="$PREFIX" .. # Use -DSYSTEM_INSTALLATION=Off to install as single-user $ make -$ sudo make install # or single-user: make install-home +$ sudo make install diff --git a/doc/plugins.example/configure.ac b/doc/plugins.example/configure.ac deleted file mode 100644 index df66a02cc2..0000000000 --- a/doc/plugins.example/configure.ac +++ /dev/null @@ -1,38 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -dnl -dnl This file is free software; as a special exception the author gives -dnl unlimited permission to copy and/or distribute it, with or without -dnl modifications, as long as this notice is preserved. -dnl -dnl This program is distributed in the hope that it will be useful, but -dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -AC_INIT([Wireshark Hello Plugin], [0.0.1]) - -AM_INIT_AUTOMAKE([foreign]) - -AC_PREREQ([2.62]) - -LT_PREREQ([2.2.2]) -LT_INIT([disable-static dlopen]) - -AC_CONFIG_SRCDIR([hello.c]) - -dnl Requires Wireshark 2.5.0 or greater. -PKG_CHECK_MODULES([WIRESHARK], [wireshark >= 2.5]) - -saved_CFLAGS="$CFLAGS"; saved_LIBS="$LIBS"; -CFLAGS="$WIRESHARK_CFLAGS" -LIBS="$WIRESHARK_LIBS" -AC_CHECK_FUNCS([proto_register_plugin], - [AC_DEFINE([HAVE_PLUGINS], 1, [Define to 1 if Wireshark supports loading plugins])], - [AC_MSG_ERROR([Wireshark was compiled without support for plugins])] -) -CFLAGS="$saved_CFLAGS"; LIBS="$saved_LIBS" - -AC_CONFIG_HEADER([config.h]) - -AC_CONFIG_FILES([Makefile]) - -AC_OUTPUT |