5579c45
From: =?UTF-8?q?Radek=20Vok=C3=A1l?= <rvokal@fedoraproject.org>
5579c45
Date: Mon, 21 Dec 2009 11:19:39 +0000
1738882
Subject: [PATCH] adds autoconf macro file
5579c45
5579c45
updated autoconf macros and pkgconfig file in wireshark-devel to reflect current config.h Resolves: #746655
5579c45
5579c45
diff --git a/wireshark-autoconf.m4 b/wireshark-autoconf.m4
5579c45
new file mode 100644
5579c45
index 0000000..d8015d8
5579c45
--- /dev/null
5579c45
+++ b/wireshark-autoconf.m4
5579c45
@@ -0,0 +1,101 @@
5579c45
+dnl AM_PATH_WIRESHARK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
5579c45
+dnl Test for wireshark development files, and define WIRESHARK_CFLAGS,
5579c45
+dnl	WIRESHARK_LIBS and WIRESHARK_VERSION.
5579c45
+dnl
5579c45
+AC_DEFUN([AM_PATH_WIRESHARK],[ 
5579c45
+	AC_ARG_WITH(wireshark-prefix,
5579c45
+	    [  --with-wireshark-prefix=PFX  Prefix where wireshark libraries are installed (optional)],
5579c45
+	    wireshark_config_prefix="$withval", wireshark_config_prefix="")
5579c45
+
5579c45
+	wireshark_found=no
5579c45
+	if test "$wireshark_config_prefix" != "" ; then
5579c45
+		AM_PATH_GLIB_2_0(,,,[gmodule])
5579c45
+		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"
5579c45
+		WIRESHARK_LIBS="-L$wireshark_config_prefix/lib -lwireshark -lwiretap $GLIB_LIBS"
5579c45
+		wireshark_found=yes
5579c45
+	else
5579c45
+		PKG_PROG_PKG_CONFIG()
5579c45
+		PKG_CHECK_MODULES(WIRESHARK, wireshark, wireshark_found=yes)
5579c45
+	fi
5579c45
+
5579c45
+	ac_save_CFLAGS="$CFLAGS"
5579c45
+	ac_save_CLIBS="$LIBS"
5579c45
+	CFLAGS="$CFLAGS $WIRESHARK_CFLAGS"
5579c45
+	LIBS="$WIRESHARK_LIBS $LIBS"
5579c45
+	min_wireshark_version=ifelse([$1], ,0.0.0,[$1])
5579c45
+	if test $wireshark_found = yes; then
5579c45
+		AC_MSG_CHECKING(for wireshark version >= $min_wireshark_version)
5579c45
+		wireshark_found=no
5579c45
+		AC_TRY_RUN([
5579c45
+#include <stdlib.h>
5579c45
+#include <stdio.h>
5579c45
+#include <string.h>
5579c45
+#include <gmodule.h>
5579c45
+#include <epan/packet.h>
5579c45
+#include <epan/prefs.h>
5579c45
+
5579c45
+int 
5579c45
+main()
5579c45
+
5579c45
+{
5579c45
+	int ws_major_version, ws_minor_version, ws_micro_version;
5579c45
+	int major, minor, micro;
5579c45
+	char **tmp_version;
5579c45
+
5579c45
+	tmp_version = (char *) strdup("$min_wireshark_version");
5579c45
+	major = 0;
5579c45
+	minor = 0;
5579c45
+	micro = 0;
5579c45
+	sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ);
5579c45
+	free(tmp_version);
5579c45
+	tmp_version = (char *) epan_get_version();
5579c45
+	sscanf(tmp_version, "%d.%d.%d",
5579c45
+	    &ws_major_version, &ws_minor_version, &ws_micro_version);
5579c45
+
5579c45
+	if (ws_major_version > major ||
5579c45
+	    (ws_major_version == major && ws_minor_version > minor) ||
5579c45
+	    (ws_major_version == major && ws_minor_version == minor &&
5579c45
+	    ws_micro_version >= micro))
5579c45
+		return 0;
5579c45
+
5579c45
+	printf("\n*** An old version of wireshark (%d.%d.%d) was found.\n",
5579c45
+	    ws_major_version, ws_minor_version, ws_micro_version);
5579c45
+	printf("*** You need a version of wireshark not older than %d.%d.%d. ",
5579c45
+	    major, minor, micro);
5579c45
+	return 1;
5579c45
+}
5579c45
+		], wireshark_found=yes)
5579c45
+	fi
5579c45
+
5579c45
+	if test "$wireshark_found" != no; then
5579c45
+		AC_LANG_PUSH(C)
5579c45
+		AC_LINK_IFELSE([AC_LANG_PROGRAM([
5579c45
+#include <stdlib.h>
5579c45
+#include <stdio.h>
5579c45
+#include <string.h>
5579c45
+#include <gmodule.h>
5579c45
+#include <epan/packet.h>
5579c45
+#include <epan/prefs.h>
5579c45
+], [puts(epan_get_version());])], [WIRESHARK_VERSION=`./conftest$ac_exeext`],
5579c45
+wireshark_found=no)
5579c45
+		
5579c45
+		AC_LANG_POP
5579c45
+	fi
5579c45
+
5579c45
+	CFLAGS="$ac_save_CFLAGS"
5579c45
+	LIBS="$ac_save_LIBS"
5579c45
+
5579c45
+	if test "$wireshark_found" != no; then
5579c45
+		AC_MSG_RESULT(yes)
5579c45
+		ifelse([$2],, :, [$2])     
5579c45
+	else
5579c45
+		AC_MSG_RESULT(no)
5579c45
+		WIRESHARK_CFLAGS=""
5579c45
+		WIRESHARK_LIBS=""
5579c45
+		WIRESHARK_VERSION=""
5579c45
+		ifelse([$3], , :, [$3])
5579c45
+	fi
5579c45
+	AC_SUBST(WIRESHARK_CFLAGS)
5579c45
+	AC_SUBST(WIRESHARK_LIBS)
5579c45
+	AC_SUBST(WIRESHARK_VERSION)
5579c45
+])