Blame SOURCES/wireshark-autoconf.m4

ead5f6
dnl AM_PATH_WIRESHARK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
ead5f6
dnl Test for wireshark development files, and define WIRESHARK_CFLAGS,
ead5f6
dnl	WIRESHARK_LIBS and WIRESHARK_VERSION.
ead5f6
dnl
ead5f6
AC_DEFUN([AM_PATH_WIRESHARK],[ 
ead5f6
	AC_ARG_WITH(wireshark-prefix,
ead5f6
	    [  --with-wireshark-prefix=PFX  Prefix where wireshark libraries are installed (optional)],
ead5f6
	    wireshark_config_prefix="$withval", wireshark_config_prefix="")
ead5f6
ead5f6
	wireshark_found=no
ead5f6
	if test "$wireshark_config_prefix" != "" ; then
ead5f6
		AM_PATH_GLIB_2_0(,,,[gmodule])
ead5f6
		WIRESHARK_CFLAGS="-DWS_VAR_IMPORT=extern -DWS_MSVC_NORETURN= -I$wireshark_config_prefix/include/wireshark -I$wireshark_config_prefix/include/wireshark/epan -I/usr/include/wireshark -I/usr/include/wireshark/epan $GLIB_CFLAGS"
ead5f6
		WIRESHARK_LIBS="-L$wireshark_config_prefix/lib -lwireshark -lwiretap $GLIB_LIBS"
ead5f6
		wireshark_found=yes
ead5f6
	else
ead5f6
		PKG_PROG_PKG_CONFIG()
ead5f6
		PKG_CHECK_MODULES(WIRESHARK, wireshark, wireshark_found=yes)
ead5f6
	fi
ead5f6
ead5f6
	ac_save_CFLAGS="$CFLAGS"
ead5f6
	ac_save_CLIBS="$LIBS"
ead5f6
	CFLAGS="$CFLAGS $WIRESHARK_CFLAGS"
ead5f6
	LIBS="$WIRESHARK_LIBS $LIBS"
ead5f6
	min_wireshark_version=ifelse([$1], ,0.0.0,[$1])
ead5f6
	if test $wireshark_found = yes; then
ead5f6
		AC_MSG_CHECKING(for wireshark version >= $min_wireshark_version)
ead5f6
		wireshark_found=no
ead5f6
		AC_TRY_RUN([
ead5f6
#include <stdlib.h>
ead5f6
#include <stdio.h>
ead5f6
#include <string.h>
ead5f6
#include <gmodule.h>
ead5f6
#include <epan/packet.h>
ead5f6
#include <epan/prefs.h>
ead5f6
ead5f6
int 
ead5f6
main()
ead5f6
ead5f6
{
ead5f6
	int ws_major_version, ws_minor_version, ws_micro_version;
ead5f6
	int major, minor, micro;
ead5f6
	char **tmp_version;
ead5f6
ead5f6
	tmp_version = (char *) strdup("$min_wireshark_version");
ead5f6
	major = 0;
ead5f6
	minor = 0;
ead5f6
	micro = 0;
ead5f6
	sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ);
ead5f6
	free(tmp_version);
ead5f6
	tmp_version = (char *) epan_get_version();
ead5f6
	sscanf(tmp_version, "%d.%d.%d",
ead5f6
	    &ws_major_version, &ws_minor_version, &ws_micro_version);
ead5f6
ead5f6
	if (ws_major_version > major ||
ead5f6
	    (ws_major_version == major && ws_minor_version > minor) ||
ead5f6
	    (ws_major_version == major && ws_minor_version == minor &&
ead5f6
	    ws_micro_version >= micro))
ead5f6
		return 0;
ead5f6
ead5f6
	printf("\n*** An old version of wireshark (%d.%d.%d) was found.\n",
ead5f6
	    ws_major_version, ws_minor_version, ws_micro_version);
ead5f6
	printf("*** You need a version of wireshark not older than %d.%d.%d. ",
ead5f6
	    major, minor, micro);
ead5f6
	return 1;
ead5f6
}
ead5f6
		], wireshark_found=yes)
ead5f6
	fi
ead5f6
ead5f6
	if test "$wireshark_found" != no; then
ead5f6
		AC_LANG_PUSH(C)
ead5f6
		AC_LINK_IFELSE([AC_LANG_PROGRAM([
ead5f6
#include <stdlib.h>
ead5f6
#include <stdio.h>
ead5f6
#include <string.h>
ead5f6
#include <gmodule.h>
ead5f6
#include <epan/packet.h>
ead5f6
#include <epan/prefs.h>
ead5f6
], [puts(epan_get_version());])], [WIRESHARK_VERSION=`./conftest$ac_exeext`],
ead5f6
wireshark_found=no)
ead5f6
		
ead5f6
		AC_LANG_POP
ead5f6
	fi
ead5f6
ead5f6
	CFLAGS="$ac_save_CFLAGS"
ead5f6
	LIBS="$ac_save_LIBS"
ead5f6
ead5f6
	if test "$wireshark_found" != no; then
ead5f6
		AC_MSG_RESULT(yes)
ead5f6
		ifelse([$2],, :, [$2])     
ead5f6
	else
ead5f6
		AC_MSG_RESULT(no)
ead5f6
		WIRESHARK_CFLAGS=""
ead5f6
		WIRESHARK_LIBS=""
ead5f6
		WIRESHARK_VERSION=""
ead5f6
		ifelse([$3], , :, [$3])
ead5f6
	fi
ead5f6
	AC_SUBST(WIRESHARK_CFLAGS)
ead5f6
	AC_SUBST(WIRESHARK_LIBS)
ead5f6
	AC_SUBST(WIRESHARK_VERSION)
ead5f6
])