Index: src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java
===================================================================
--- src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java	(revision 76923)
+++ src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java	(working copy)
@@ -23,7 +23,7 @@
 {
 	static final String APPLICATION_NAME = "Zabbix Java Gateway";
 	static final String REVISION_DATE = "8 January 2018";
-	static final String REVISION = "{ZABBIX_REVISION}";
+	static final String REVISION = Revision.ZABBIX_VERSION_REVISION;
 	static final String VERSION = "4.0.0alpha3";
 
 	static void printVersion()
Index: src/zabbix_java/src/com/zabbix/gateway
===================================================================
--- src/zabbix_java/src/com/zabbix/gateway	(revision 76923)
+++ src/zabbix_java/src/com/zabbix/gateway	(working copy)

Property changes on: src/zabbix_java/src/com/zabbix/gateway
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+Revision.java
Index: configure.ac
===================================================================
--- configure.ac	(revision 76923)
+++ configure.ac	(working copy)
@@ -1111,6 +1111,13 @@
 	have_ipv6="yes"
 fi
 
+dnl Checking pakage manager support for *BSD
+AC_CHECK_PROG(is_pkg_cfg,pkg-config,yes)
+AS_CASE([$ARCH],[*bsd],
+    AS_IF([test "xyes" != "x$is_pkg_cfg"],[
+	AC_MSG_ERROR([pkg-config not found])
+]))
+
 if test "x$server" = "xyes" || test "x$proxy" = "xyes"; then
 
 	have_multirow_insert="no"
@@ -1579,7 +1586,46 @@
 		;;
 esac
 
+dnl Check svn revision
+VER_H=include/version.h
+REV_CLASS=src/zabbix_java/src/com/zabbix/gateway/Revision.java
+ZBX_REV="no"
+ZBX_REV_VAL="{ZABBIX_REVISION}"
+AC_CHECK_PROG(svn_ver,svnversion,yes)
 
+AS_IF([test "xyes" = "x$svn_ver"],[
+	ZBX_REV_VAL="$(svn info .|sed -n -e '/Last Changed Rev:/s/.*: \([[0-9]]*\)/\1/p')/$(svnversion -n .)"
+	AS_IF([test "linux" = "${ARCH}"],[
+		ZBX_REV='$(shell svn info $(top_srcdir)|sed -n -e "/Last Changed Rev:/s/.*: \([[0-9]]*\)/\1/p")/$(shell svnversion -n $(top_srcdir))'
+	],[
+		ZBX_REV='$$(svn info $(top_srcdir)|sed -n -e "/Last Changed Rev:/s/.*: \([[0-9]]*\)/\1/p")/$$(svnversion -n $(top_srcdir))'
+	])
+])
+
+AS_IF([test "$(grep -q "{ZABBIX_REVISION}" $VER_H || echo 0)" = "0"],[
+	ZBX_REV=$(sed -n -e '/^[[#\t ]]*define[[\t ]]*ZABBIX_VERSION_REVISION/s/[[#\t a-zA-Z_]]*REVISION[[\t ]]*\([[0-9A-Z/:]]*\)/\1/p' $VER_H)
+	ZBX_REV_VAL=$ZBX_REV
+])
+
+AS_IF([test "xyes" = "x$java"],[
+	echo "/*" > $REV_CLASS
+	grep "\*\*" $(ls src/zabbix_java/src/com/zabbix/gateway/*.java|sort -n|head -1) >> $REV_CLASS
+	printf "\npackage com.zabbix.gateway;\n\npublic interface Revision {\n\tstatic final String ZABBIX_VERSION_REVISION = \"$ZBX_REV_VAL\";\n}" >> $REV_CLASS	
+])
+
+AS_IF([test "xno" != "x$ZBX_REV"],[
+	AC_SUBST(ZBX_REV)
+	AM_CPPFLAGS="${AM_CPPFLAGS} -D'ZABBIX_VERSION_REVISION='\"${ZBX_REV}\"''"
+	AC_SUBST(AM_CPPFLAGS)
+],[
+	AC_SUBST(ZBX_REV,$ZBX_REV_VAL)
+])
+
+dnl Support libs from pakages for netbsd
+AS_IF([test "netbsd" = "$ARCH"],[
+	AS_IF([test -d /usr/pkg/lib], [LDFLAGS="${LDFLAGS} -R/usr/pkg/lib"])
+])
+
 dnl *****************************************************************
 dnl *                                                               *
 dnl *                 Output configuration results                  *
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 76923)
+++ Makefile.am	(working copy)
@@ -19,14 +19,13 @@
 
 ## "dist-hook" run after the distribution directory is filled, but before the actual tar (or shar) file is created.
 dist-hook:
-	@zabbix_revision=`svn info|grep "Last Changed Rev"|awk '{print $$4;}'`; \
-	cat $(top_distdir)/include/version.h|sed "s/{ZABBIX_REVISION}/$$zabbix_revision/g" > $(top_distdir)/include/version.h.new; \
-	mv $(top_distdir)/include/version.h.new $(top_distdir)/include/version.h; \
-	cat $(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java|sed "s/{ZABBIX_REVISION}/$$zabbix_revision/g" > \
-		$(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java.new; \
-	mv $(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java.new \
-		$(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java
-
+	@if [ -f $(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/Revision.java ]; then \
+	  sed -e "s,\([\t ]*static final String ZABBIX_VERSION_REVISION =[\t ]*\).*,\1\"${ZBX_REV}\";," \
+	  $(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/Revision.java > $(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/Revision.java.new; \
+	  mv $(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/Revision.java.new $(top_distdir)/src/zabbix_java/src/com/zabbix/gateway/Revision.java; \
+	fi
+	sed -e "s,{ZABBIX_REVISION},${ZBX_REV},g" $(top_distdir)/include/version.h > $(top_distdir)/include/version.h.new; \
+ 	mv $(top_distdir)/include/version.h.new $(top_distdir)/include/version.h
 	rm -rf `find $(top_distdir) -name ".svn"`
 	rm -f $(top_distdir)/include/config.h
 	rm -f $(top_distdir)/frontends/php/conf/zabbix.conf.php
Index: include/version.h
===================================================================
--- include/version.h	(revision 76923)
+++ include/version.h	(working copy)
@@ -28,7 +28,9 @@
 #define ZABBIX_VERSION_MAJOR	4
 #define ZABBIX_VERSION_MINOR	0
 #define ZABBIX_VERSION_PATCH	0
-#define ZABBIX_VERSION_REVISION	{ZABBIX_REVISION}
+#ifndef ZABBIX_VERSION_REVISION
+#	define ZABBIX_VERSION_REVISION	{ZABBIX_REVISION}
+#endif
 #define ZABBIX_VERSION_RC	"alpha3"
 #define ZABBIX_VERSION		ZBX_STR(ZABBIX_VERSION_MAJOR) "." ZBX_STR(ZABBIX_VERSION_MINOR) "." \
 				ZBX_STR(ZABBIX_VERSION_PATCH) ZABBIX_VERSION_RC
Index: misc/snmptrap/zabbix_trap_receiver.pl
===================================================================
--- misc/snmptrap/zabbix_trap_receiver.pl	(revision 76923)
+++ misc/snmptrap/zabbix_trap_receiver.pl	(working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 # Zabbix
Index: misc/debug/sender.pl
===================================================================
--- misc/debug/sender.pl	(revision 76923)
+++ misc/debug/sender.pl	(working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
Index: tests/tests_run.pl
===================================================================
--- tests/tests_run.pl	(revision 76923)
+++ tests/tests_run.pl	(working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
Index: create/bin/gen_schema.pl
===================================================================
--- create/bin/gen_schema.pl	(revision 76923)
+++ create/bin/gen_schema.pl	(working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Zabbix
 # Copyright (C) 2001-2018 Zabbix SIA
Index: create/bin/gen_data.pl
===================================================================
--- create/bin/gen_data.pl	(revision 76923)
+++ create/bin/gen_data.pl	(working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Zabbix
 # Copyright (C) 2001-2018 Zabbix SIA
