From dca1d87683eaba2319b5fc2c9f73b7b3a1e4ea69 Mon Sep 17 00:00:00 2001
From: Orion Poplawski <orion@nwra.com>
Date: Sat, 18 Jul 2020 20:21:30 -0600
Subject: [PATCH] Fix many out-of-tree build issues

---
 src/go/Makefile.am                         |  8 +++----
 src/libs/zbxalgo/Makefile.am               |  2 ++
 src/libs/zbxcommon/Makefile.am             |  2 ++
 src/libs/zbxcomms/Makefile.am              |  2 ++
 src/libs/zbxcommshigh/Makefile.am          |  2 ++
 src/libs/zbxcompress/Makefile.am           |  2 ++
 src/libs/zbxconf/Makefile.am               |  2 ++
 src/libs/zbxcrypto/Makefile.am             |  2 ++
 src/libs/zbxdb/Makefile.am                 |  2 ++
 src/libs/zbxdbcache/Makefile.am            |  2 ++
 src/libs/zbxdbhigh/Makefile.am             |  2 ++
 src/libs/zbxdbupgrade/Makefile.am          |  2 ++
 src/libs/zbxembed/Makefile.am              |  2 ++
 src/libs/zbxexec/Makefile.am               |  2 ++
 src/libs/zbxhistory/Makefile.am            |  2 ++
 src/libs/zbxhttp/Makefile.am               |  2 ++
 src/libs/zbxicmpping/Makefile.am           |  2 ++
 src/libs/zbxipcservice/Makefile.am         |  2 ++
 src/libs/zbxjson/Makefile.am               |  2 ++
 src/libs/zbxlog/Makefile.am                |  2 ++
 src/libs/zbxmedia/Makefile.am              |  2 ++
 src/libs/zbxmemory/Makefile.am             |  2 ++
 src/libs/zbxmodules/Makefile.am            |  2 ++
 src/libs/zbxnix/Makefile.am                |  2 ++
 src/libs/zbxprometheus/Makefile.am         |  2 ++
 src/libs/zbxregexp/Makefile.am             |  2 ++
 src/libs/zbxself/Makefile.am               |  2 ++
 src/libs/zbxserver/Makefile.am             |  2 ++
 src/libs/zbxsys/Makefile.am                |  2 ++
 src/libs/zbxsysinfo/Makefile.am            |  2 ++
 src/libs/zbxsysinfo/agent/Makefile.am      |  2 ++
 src/libs/zbxsysinfo/aix/Makefile.am        |  2 ++
 src/libs/zbxsysinfo/common/Makefile.am     |  2 ++
 src/libs/zbxsysinfo/freebsd/Makefile.am    |  2 ++
 src/libs/zbxsysinfo/hpux/Makefile.am       |  2 ++
 src/libs/zbxsysinfo/linux/Makefile.am      |  2 ++
 src/libs/zbxsysinfo/netbsd/Makefile.am     |  2 ++
 src/libs/zbxsysinfo/openbsd/Makefile.am    |  2 ++
 src/libs/zbxsysinfo/osf/Makefile.am        |  2 ++
 src/libs/zbxsysinfo/osx/Makefile.am        |  2 ++
 src/libs/zbxsysinfo/simple/Makefile.am     |  2 ++
 src/libs/zbxsysinfo/solaris/Makefile.am    |  2 ++
 src/libs/zbxsysinfo/unknown/Makefile.am    |  2 ++
 src/libs/zbxtasks/Makefile.am              |  2 ++
 src/zabbix_agent/Makefile.am               |  4 +++-
 src/zabbix_agent/logfiles/Makefile.am      |  2 ++
 src/zabbix_get/Makefile.am                 |  2 ++
 src/zabbix_java/Makefile.am                | 10 ++++----
 src/zabbix_js/Makefile.am                  | 28 ++++++++++++----------
 src/zabbix_proxy/Makefile.am               |  4 +++-
 src/zabbix_proxy/datasender/Makefile.am    |  2 ++
 src/zabbix_proxy/heart/Makefile.am         |  2 ++
 src/zabbix_proxy/housekeeper/Makefile.am   |  2 ++
 src/zabbix_proxy/proxyconfig/Makefile.am   |  2 ++
 src/zabbix_proxy/taskmanager/Makefile.am   |  2 ++
 src/zabbix_sender/Makefile.am              |  2 ++
 src/zabbix_server/Makefile.am              |  4 +++-
 src/zabbix_server/alerter/Makefile.am      |  2 ++
 src/zabbix_server/dbconfig/Makefile.am     |  2 ++
 src/zabbix_server/dbsyncer/Makefile.am     |  2 ++
 src/zabbix_server/discoverer/Makefile.am   |  2 ++
 src/zabbix_server/escalator/Makefile.am    |  2 ++
 src/zabbix_server/housekeeper/Makefile.am  |  2 ++
 src/zabbix_server/httppoller/Makefile.am   |  2 ++
 src/zabbix_server/ipmi/Makefile.am         |  2 ++
 src/zabbix_server/lld/Makefile.am          |  2 ++
 src/zabbix_server/odbc/Makefile.am         |  2 ++
 src/zabbix_server/pinger/Makefile.am       |  2 ++
 src/zabbix_server/poller/Makefile.am       |  2 ++
 src/zabbix_server/preprocessor/Makefile.am |  2 ++
 src/zabbix_server/proxypoller/Makefile.am  |  2 ++
 src/zabbix_server/scripts/Makefile.am      |  2 ++
 src/zabbix_server/selfmon/Makefile.am      |  2 ++
 src/zabbix_server/snmptrapper/Makefile.am  |  2 ++
 src/zabbix_server/taskmanager/Makefile.am  |  2 ++
 src/zabbix_server/timer/Makefile.am        |  2 ++
 src/zabbix_server/trapper/Makefile.am      |  2 ++
 src/zabbix_server/vmware/Makefile.am       |  2 ++
 78 files changed, 177 insertions(+), 25 deletions(-)

diff --git a/src/go/Makefile.am b/src/go/Makefile.am
index 9d14894757..f43ba98d1c 100644
--- a/src/go/Makefile.am
+++ b/src/go/Makefile.am
@@ -19,17 +19,17 @@ GOLDFLAGS += -X main.confDefault=${AGENT2_CONFIG_FILE}
 all: build
 
 build:
-	CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go build -ldflags="${GOLDFLAGS}" -o bin ./...
+	CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go build -ldflags="${GOLDFLAGS}" -o bin $(srcdir)/...
 
 clean:
-	go clean ./...
+	go clean $(srcdir)/...
 	rm -f bin/zabbix_agent2 bin/mock_server
 
 install:
 	CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" GOBIN=${GOBIN} \
 		go install -ldflags="${GOLDFLAGS}" zabbix.com/cmd/zabbix_agent2
-	test -f "$(DESTDIR)@AGENT2_CONFIG_FILE@" || cp "conf/zabbix_agent2.conf" "$(DESTDIR)@AGENT2_CONFIG_FILE@"
+	test -f "$(DESTDIR)@AGENT2_CONFIG_FILE@" || cp "$(top_srcdir)/conf/zabbix_agent2.conf" "$(DESTDIR)@AGENT2_CONFIG_FILE@"
 
 check:
-	CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go test ./...
+	CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go test $(srcdir)/...
 
diff --git a/src/libs/zbxalgo/Makefile.am b/src/libs/zbxalgo/Makefile.am
index 17c668e3f8..691e75b387 100644
--- a/src/libs/zbxalgo/Makefile.am
+++ b/src/libs/zbxalgo/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxalgo.a
 
 if SERVER
diff --git a/src/libs/zbxcommon/Makefile.am b/src/libs/zbxcommon/Makefile.am
index dda144eff4..04b9c5e5e4 100644
--- a/src/libs/zbxcommon/Makefile.am
+++ b/src/libs/zbxcommon/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxcommon.a
 
 libzbxcommon_a_SOURCES = \
diff --git a/src/libs/zbxcomms/Makefile.am b/src/libs/zbxcomms/Makefile.am
index 7d5c725c6b..91071d79c5 100644
--- a/src/libs/zbxcomms/Makefile.am
+++ b/src/libs/zbxcomms/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxcomms.a
 
 libzbxcomms_a_SOURCES = \
diff --git a/src/libs/zbxcommshigh/Makefile.am b/src/libs/zbxcommshigh/Makefile.am
index 2439782ee0..e1e518ec2e 100644
--- a/src/libs/zbxcommshigh/Makefile.am
+++ b/src/libs/zbxcommshigh/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxcommshigh.a
 
 libzbxcommshigh_a_SOURCES = \
diff --git a/src/libs/zbxcompress/Makefile.am b/src/libs/zbxcompress/Makefile.am
index 2ae49d738a..94cb7fc52e 100644
--- a/src/libs/zbxcompress/Makefile.am
+++ b/src/libs/zbxcompress/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxcompress.a
 
 libzbxcompress_a_SOURCES = \
diff --git a/src/libs/zbxconf/Makefile.am b/src/libs/zbxconf/Makefile.am
index eb3b3d4bbf..b05cc34f06 100644
--- a/src/libs/zbxconf/Makefile.am
+++ b/src/libs/zbxconf/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxconf.a
 
 libzbxconf_a_SOURCES = \
diff --git a/src/libs/zbxcrypto/Makefile.am b/src/libs/zbxcrypto/Makefile.am
index 6d39a1f722..5257f61909 100644
--- a/src/libs/zbxcrypto/Makefile.am
+++ b/src/libs/zbxcrypto/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxcrypto.a
 
 libzbxcrypto_a_SOURCES = \
diff --git a/src/libs/zbxdb/Makefile.am b/src/libs/zbxdb/Makefile.am
index 815d64c8b2..bc41fdf599 100644
--- a/src/libs/zbxdb/Makefile.am
+++ b/src/libs/zbxdb/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxdb.a
 
 libzbxdb_a_SOURCES = \
diff --git a/src/libs/zbxdbcache/Makefile.am b/src/libs/zbxdbcache/Makefile.am
index d3345a8ca7..6c8324bf9b 100644
--- a/src/libs/zbxdbcache/Makefile.am
+++ b/src/libs/zbxdbcache/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxdbcache.a
 
 libzbxdbcache_a_SOURCES = \
diff --git a/src/libs/zbxdbhigh/Makefile.am b/src/libs/zbxdbhigh/Makefile.am
index 5310c3cf55..f2cf0b22e2 100644
--- a/src/libs/zbxdbhigh/Makefile.am
+++ b/src/libs/zbxdbhigh/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 if DBSCHEMA
 dbschema.c: $(top_srcdir)/create/src/schema.tmpl
 	$(top_srcdir)/create/bin/gen_schema.pl c > dbschema.c
diff --git a/src/libs/zbxdbupgrade/Makefile.am b/src/libs/zbxdbupgrade/Makefile.am
index 78940671b0..2068d88854 100644
--- a/src/libs/zbxdbupgrade/Makefile.am
+++ b/src/libs/zbxdbupgrade/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxdbupgrade.a
 
 libzbxdbupgrade_a_SOURCES = \
diff --git a/src/libs/zbxembed/Makefile.am b/src/libs/zbxembed/Makefile.am
index 089f49b734..2fabe4ed27 100644
--- a/src/libs/zbxembed/Makefile.am
+++ b/src/libs/zbxembed/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxembed.a
 
 libzbxembed_a_SOURCES = \
diff --git a/src/libs/zbxexec/Makefile.am b/src/libs/zbxexec/Makefile.am
index 42880a8d0a..9fed446cc5 100644
--- a/src/libs/zbxexec/Makefile.am
+++ b/src/libs/zbxexec/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxexec.a
 
 libzbxexec_a_SOURCES = \
diff --git a/src/libs/zbxhistory/Makefile.am b/src/libs/zbxhistory/Makefile.am
index 90922617be..79feba8e5b 100644
--- a/src/libs/zbxhistory/Makefile.am
+++ b/src/libs/zbxhistory/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxhistory.a
 
 libzbxhistory_a_SOURCES = \
diff --git a/src/libs/zbxhttp/Makefile.am b/src/libs/zbxhttp/Makefile.am
index 3f369bb21c..e5cc927d2b 100644
--- a/src/libs/zbxhttp/Makefile.am
+++ b/src/libs/zbxhttp/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxhttp.a
 
 libzbxhttp_a_SOURCES = \
diff --git a/src/libs/zbxicmpping/Makefile.am b/src/libs/zbxicmpping/Makefile.am
index 303c6d29d4..d3f1965adf 100644
--- a/src/libs/zbxicmpping/Makefile.am
+++ b/src/libs/zbxicmpping/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxicmpping.a
 
 libzbxicmpping_a_SOURCES = \
diff --git a/src/libs/zbxipcservice/Makefile.am b/src/libs/zbxipcservice/Makefile.am
index 5f91378d63..62bc36223f 100644
--- a/src/libs/zbxipcservice/Makefile.am
+++ b/src/libs/zbxipcservice/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxipcservice.a
 
 libzbxipcservice_a_SOURCES = \
diff --git a/src/libs/zbxjson/Makefile.am b/src/libs/zbxjson/Makefile.am
index ad27f80c98..0b2c099d60 100644
--- a/src/libs/zbxjson/Makefile.am
+++ b/src/libs/zbxjson/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxjson.a
 
 libzbxjson_a_SOURCES = \
diff --git a/src/libs/zbxlog/Makefile.am b/src/libs/zbxlog/Makefile.am
index 78278a2343..de9f7c4c3c 100644
--- a/src/libs/zbxlog/Makefile.am
+++ b/src/libs/zbxlog/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxlog.a
 
 libzbxlog_a_SOURCES = \
diff --git a/src/libs/zbxmedia/Makefile.am b/src/libs/zbxmedia/Makefile.am
index cf9a052d10..ebc451b863 100644
--- a/src/libs/zbxmedia/Makefile.am
+++ b/src/libs/zbxmedia/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxmedia.a
 
 libzbxmedia_a_SOURCES = \
diff --git a/src/libs/zbxmemory/Makefile.am b/src/libs/zbxmemory/Makefile.am
index 7dcd4dbfbb..15707dce55 100644
--- a/src/libs/zbxmemory/Makefile.am
+++ b/src/libs/zbxmemory/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxmemory.a
 
 libzbxmemory_a_SOURCES = \
diff --git a/src/libs/zbxmodules/Makefile.am b/src/libs/zbxmodules/Makefile.am
index 87b93dfadb..ffb216a2a3 100644
--- a/src/libs/zbxmodules/Makefile.am
+++ b/src/libs/zbxmodules/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxmodules.a
 
 libzbxmodules_a_SOURCES = \
diff --git a/src/libs/zbxnix/Makefile.am b/src/libs/zbxnix/Makefile.am
index 88ccea05cb..3eb59b8ddf 100644
--- a/src/libs/zbxnix/Makefile.am
+++ b/src/libs/zbxnix/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxnix.a
 
 libzbxnix_a_SOURCES = \
diff --git a/src/libs/zbxprometheus/Makefile.am b/src/libs/zbxprometheus/Makefile.am
index d998a3716e..a7963f4323 100644
--- a/src/libs/zbxprometheus/Makefile.am
+++ b/src/libs/zbxprometheus/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxprometheus.a
 
 libzbxprometheus_a_SOURCES = \
diff --git a/src/libs/zbxregexp/Makefile.am b/src/libs/zbxregexp/Makefile.am
index 0801299f7c..01f940fed9 100644
--- a/src/libs/zbxregexp/Makefile.am
+++ b/src/libs/zbxregexp/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxregexp.a
 
 libzbxregexp_a_SOURCES = \
diff --git a/src/libs/zbxself/Makefile.am b/src/libs/zbxself/Makefile.am
index 18920c70d2..63617b94e3 100644
--- a/src/libs/zbxself/Makefile.am
+++ b/src/libs/zbxself/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxself.a
 
 libzbxself_a_SOURCES = \
diff --git a/src/libs/zbxserver/Makefile.am b/src/libs/zbxserver/Makefile.am
index c96d0ef0a3..f4eeb57a0b 100644
--- a/src/libs/zbxserver/Makefile.am
+++ b/src/libs/zbxserver/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxserver.a libzbxserver_server.a libzbxserver_proxy.a
 
 libzbxserver_a_SOURCES = \
diff --git a/src/libs/zbxsys/Makefile.am b/src/libs/zbxsys/Makefile.am
index a4c3fa5699..9f297ec899 100644
--- a/src/libs/zbxsys/Makefile.am
+++ b/src/libs/zbxsys/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxsys.a
 
 libzbxsys_a_SOURCES = \
diff --git a/src/libs/zbxsysinfo/Makefile.am b/src/libs/zbxsysinfo/Makefile.am
index 7bfedfeedb..03f28ba214 100644
--- a/src/libs/zbxsysinfo/Makefile.am
+++ b/src/libs/zbxsysinfo/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 DIST_SUBDIRS = \
 	agent \
 	common \
diff --git a/src/libs/zbxsysinfo/agent/Makefile.am b/src/libs/zbxsysinfo/agent/Makefile.am
index fea20838f5..e4c5a89083 100644
--- a/src/libs/zbxsysinfo/agent/Makefile.am
+++ b/src/libs/zbxsysinfo/agent/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libagentsysinfo.a
 
 libagentsysinfo_a_SOURCES = \
diff --git a/src/libs/zbxsysinfo/aix/Makefile.am b/src/libs/zbxsysinfo/aix/Makefile.am
index d3eb37ecca..5c3fc193c8 100644
--- a/src/libs/zbxsysinfo/aix/Makefile.am
+++ b/src/libs/zbxsysinfo/aix/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/common/Makefile.am b/src/libs/zbxsysinfo/common/Makefile.am
index 6a3654f92b..423f789cdd 100644
--- a/src/libs/zbxsysinfo/common/Makefile.am
+++ b/src/libs/zbxsysinfo/common/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libcommonsysinfo.a
 
 libcommonsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent/
diff --git a/src/libs/zbxsysinfo/freebsd/Makefile.am b/src/libs/zbxsysinfo/freebsd/Makefile.am
index 7cb13e8a22..7f462b084b 100644
--- a/src/libs/zbxsysinfo/freebsd/Makefile.am
+++ b/src/libs/zbxsysinfo/freebsd/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/hpux/Makefile.am b/src/libs/zbxsysinfo/hpux/Makefile.am
index d25fb54e38..db6b01cc5d 100644
--- a/src/libs/zbxsysinfo/hpux/Makefile.am
+++ b/src/libs/zbxsysinfo/hpux/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/linux/Makefile.am b/src/libs/zbxsysinfo/linux/Makefile.am
index d4cad21218..e36462dfe7 100644
--- a/src/libs/zbxsysinfo/linux/Makefile.am
+++ b/src/libs/zbxsysinfo/linux/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/netbsd/Makefile.am b/src/libs/zbxsysinfo/netbsd/Makefile.am
index 770609d135..6e1ce561e3 100644
--- a/src/libs/zbxsysinfo/netbsd/Makefile.am
+++ b/src/libs/zbxsysinfo/netbsd/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/openbsd/Makefile.am b/src/libs/zbxsysinfo/openbsd/Makefile.am
index e9df770331..86dcfadb08 100644
--- a/src/libs/zbxsysinfo/openbsd/Makefile.am
+++ b/src/libs/zbxsysinfo/openbsd/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/osf/Makefile.am b/src/libs/zbxsysinfo/osf/Makefile.am
index 44d4c4c9e4..411ea1fd44 100644
--- a/src/libs/zbxsysinfo/osf/Makefile.am
+++ b/src/libs/zbxsysinfo/osf/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/osx/Makefile.am b/src/libs/zbxsysinfo/osx/Makefile.am
index d19a785a02..388db6fe89 100644
--- a/src/libs/zbxsysinfo/osx/Makefile.am
+++ b/src/libs/zbxsysinfo/osx/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/simple/Makefile.am b/src/libs/zbxsysinfo/simple/Makefile.am
index f0f167f801..20684f496f 100644
--- a/src/libs/zbxsysinfo/simple/Makefile.am
+++ b/src/libs/zbxsysinfo/simple/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libsimplesysinfo.a
 
 libsimplesysinfo_a_SOURCES = \
diff --git a/src/libs/zbxsysinfo/solaris/Makefile.am b/src/libs/zbxsysinfo/solaris/Makefile.am
index a2f8e6fe46..3d11b58fa5 100644
--- a/src/libs/zbxsysinfo/solaris/Makefile.am
+++ b/src/libs/zbxsysinfo/solaris/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxsysinfo/unknown/Makefile.am b/src/libs/zbxsysinfo/unknown/Makefile.am
index 5f9b871eaa..8613113554 100644
--- a/src/libs/zbxsysinfo/unknown/Makefile.am
+++ b/src/libs/zbxsysinfo/unknown/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libspecsysinfo.a libspechostnamesysinfo.a
 
 libspecsysinfo_a_CFLAGS = -I$(top_srcdir)/src/zabbix_agent
diff --git a/src/libs/zbxtasks/Makefile.am b/src/libs/zbxtasks/Makefile.am
index e7b0be1cd3..bc0773a1e0 100644
--- a/src/libs/zbxtasks/Makefile.am
+++ b/src/libs/zbxtasks/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxtasks.a
 
 libzbxtasks_a_SOURCES = \
diff --git a/src/zabbix_agent/Makefile.am b/src/zabbix_agent/Makefile.am
index 55aa04c00d..36a12f6c45 100644
--- a/src/zabbix_agent/Makefile.am
+++ b/src/zabbix_agent/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 SUBDIRS = \
 	logfiles
 	
@@ -74,4 +76,4 @@ zabbix_agentd_CFLAGS = \
 install-data-hook:
 	$(MKDIR_P) "$(DESTDIR)$(AGENT_CONFIG_FILE).d"
 	$(MKDIR_P) "$(DESTDIR)$(LOAD_MODULE_PATH)"
-	test -f "$(DESTDIR)$(AGENT_CONFIG_FILE)" || cp "../../conf/zabbix_agentd.conf" "$(DESTDIR)$(AGENT_CONFIG_FILE)"
+	test -f "$(DESTDIR)$(AGENT_CONFIG_FILE)" || cp "$(top_srcdir)/conf/zabbix_agentd.conf" "$(DESTDIR)$(AGENT_CONFIG_FILE)"
diff --git a/src/zabbix_agent/logfiles/Makefile.am b/src/zabbix_agent/logfiles/Makefile.am
index 795bee6ae8..f831050111 100644
--- a/src/zabbix_agent/logfiles/Makefile.am
+++ b/src/zabbix_agent/logfiles/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxlogfiles.a
 
 libzbxlogfiles_a_SOURCES = \
diff --git a/src/zabbix_get/Makefile.am b/src/zabbix_get/Makefile.am
index 8ced0057cc..80f19c0ea0 100644
--- a/src/zabbix_get/Makefile.am
+++ b/src/zabbix_get/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 bin_PROGRAMS = zabbix_get
 
 zabbix_get_SOURCES = \
diff --git a/src/zabbix_java/Makefile.am b/src/zabbix_java/Makefile.am
index 373df12cf4..52242bc419 100644
--- a/src/zabbix_java/Makefile.am
+++ b/src/zabbix_java/Makefile.am
@@ -9,19 +9,19 @@ EXTRA_DIST = \
 	startup.sh
 
 ZJG = bin/zabbix-java-gateway-$(VERSION).jar
-LIB = lib/android-json-4.3_r3.1.jar:lib/logback-core-0.9.27.jar:lib/logback-classic-0.9.27.jar:lib/slf4j-api-1.6.1.jar
-JUNIT = tests/junit-4.8.2.jar
+LIB = $(srcdir)/lib/android-json-4.3_r3.1.jar:$(srcdir)/lib/logback-core-0.9.27.jar:$(srcdir)/lib/logback-classic-0.9.27.jar:$(srcdir)/lib/slf4j-api-1.6.1.jar
+JUNIT = $(srcdir)/tests/junit-4.8.2.jar
 
 ZJG_DEST = $(DESTDIR)$(sbindir)/zabbix_java
 
 all: $(ZJG)
 
-$(ZJG): class src/com/zabbix/gateway/*.java
-	$(JAVAC) -d class/src -classpath $(LIB) src/com/zabbix/gateway/*.java
+$(ZJG): class $(srcdir)/src/com/zabbix/gateway/*.java
+	$(JAVAC) -d class/src -classpath $(LIB) $(srcdir)/src/com/zabbix/gateway/*.java
 	$(JAR) cf $(ZJG) -C class/src .
 
 test: class
-	$(JAVAC) -d class/tests -classpath class/src:$(JUNIT) tests/com/zabbix/gateway/*.java
+	$(JAVAC) -d class/tests -classpath class/src:$(JUNIT) $(srcdir)/tests/com/zabbix/gateway/*.java
 	java -classpath class/tests:$(LIB):$(ZJG):$(JUNIT) com.zabbix.gateway.AllTestRunner
 
 class:
diff --git a/src/zabbix_js/Makefile.am b/src/zabbix_js/Makefile.am
index d4f48562ce..c2c5d53af6 100644
--- a/src/zabbix_js/Makefile.am
+++ b/src/zabbix_js/Makefile.am
@@ -1,23 +1,25 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 bin_PROGRAMS = zabbix_js
 
 zabbix_js_SOURCES = zabbix_js.c
 
 zabbix_js_LDADD = \
-	$(top_srcdir)/src/libs/zbxlog/libzbxlog.a \
-	$(top_srcdir)/src/libs/zbxembed/libzbxembed.a \
-	$(top_srcdir)/src/libs/zbxjson/libzbxjson.a \
-	$(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \
-	$(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \
-	$(top_srcdir)/src/libs/zbxsys/libzbxsys.a \
-	$(top_srcdir)/src/libs/zbxnix/libzbxnix.a \
-	$(top_srcdir)/src/libs/zbxcommon/libzbxcommon.a \
-	$(top_srcdir)/src/libs/zbxcomms/libzbxcomms.a \
-	$(top_srcdir)/src/libs/zbxconf/libzbxconf.a \
-	$(top_srcdir)/src/libs/zbxcommon/libzbxcommon.a \
-	$(top_srcdir)/src/libs/zbxcrypto/libzbxcrypto.a \
-	$(top_srcdir)/src/libs/zbxcompress/libzbxcompress.a
+	$(top_builddir)/src/libs/zbxlog/libzbxlog.a \
+	$(top_builddir)/src/libs/zbxembed/libzbxembed.a \
+	$(top_builddir)/src/libs/zbxjson/libzbxjson.a \
+	$(top_builddir)/src/libs/zbxregexp/libzbxregexp.a \
+	$(top_builddir)/src/libs/zbxalgo/libzbxalgo.a \
+	$(top_builddir)/src/libs/zbxsys/libzbxsys.a \
+	$(top_builddir)/src/libs/zbxnix/libzbxnix.a \
+	$(top_builddir)/src/libs/zbxcommon/libzbxcommon.a \
+	$(top_builddir)/src/libs/zbxcomms/libzbxcomms.a \
+	$(top_builddir)/src/libs/zbxconf/libzbxconf.a \
+	$(top_builddir)/src/libs/zbxcommon/libzbxcommon.a \
+	$(top_builddir)/src/libs/zbxcrypto/libzbxcrypto.a \
+	$(top_builddir)/src/libs/zbxcompress/libzbxcompress.a
 	
 zabbix_js_LDADD += @ZBXJS_LIBS@
 
diff --git a/src/zabbix_proxy/Makefile.am b/src/zabbix_proxy/Makefile.am
index adb892d825..aac5564754 100644
--- a/src/zabbix_proxy/Makefile.am
+++ b/src/zabbix_proxy/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 SUBDIRS = \
 	heart \
 	housekeeper \
@@ -97,4 +99,4 @@ install-data-hook:
 	$(MKDIR_P) "$(DESTDIR)$(PROXY_CONFIG_FILE).d"
 	$(MKDIR_P) "$(DESTDIR)$(EXTERNAL_SCRIPTS_PATH)"
 	$(MKDIR_P) "$(DESTDIR)$(LOAD_MODULE_PATH)"
-	test -f "$(DESTDIR)$(PROXY_CONFIG_FILE)" || cp "../../conf/zabbix_proxy.conf" "$(DESTDIR)$(PROXY_CONFIG_FILE)"
+	test -f "$(DESTDIR)$(PROXY_CONFIG_FILE)" || cp "$(top_srcdir)/conf/zabbix_proxy.conf" "$(DESTDIR)$(PROXY_CONFIG_FILE)"
diff --git a/src/zabbix_proxy/datasender/Makefile.am b/src/zabbix_proxy/datasender/Makefile.am
index 8f098b8c8a..3e24381ef8 100644
--- a/src/zabbix_proxy/datasender/Makefile.am
+++ b/src/zabbix_proxy/datasender/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxdatasender.a
 
 libzbxdatasender_a_SOURCES = \
diff --git a/src/zabbix_proxy/heart/Makefile.am b/src/zabbix_proxy/heart/Makefile.am
index a96da81e93..82ca6e7992 100644
--- a/src/zabbix_proxy/heart/Makefile.am
+++ b/src/zabbix_proxy/heart/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxheart.a
 
 libzbxheart_a_SOURCES = \
diff --git a/src/zabbix_proxy/housekeeper/Makefile.am b/src/zabbix_proxy/housekeeper/Makefile.am
index 2f93cf8e5f..225565ee47 100644
--- a/src/zabbix_proxy/housekeeper/Makefile.am
+++ b/src/zabbix_proxy/housekeeper/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxhousekeeper.a
 
 libzbxhousekeeper_a_SOURCES = \
diff --git a/src/zabbix_proxy/proxyconfig/Makefile.am b/src/zabbix_proxy/proxyconfig/Makefile.am
index a6497c5b97..63704ee397 100644
--- a/src/zabbix_proxy/proxyconfig/Makefile.am
+++ b/src/zabbix_proxy/proxyconfig/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxproxyconfig.a
 
 libzbxproxyconfig_a_SOURCES = \
diff --git a/src/zabbix_proxy/taskmanager/Makefile.am b/src/zabbix_proxy/taskmanager/Makefile.am
index 112cc99fd6..e6a5043fd9 100644
--- a/src/zabbix_proxy/taskmanager/Makefile.am
+++ b/src/zabbix_proxy/taskmanager/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxtaskmanager.a
 
 libzbxtaskmanager_a_SOURCES = \
diff --git a/src/zabbix_sender/Makefile.am b/src/zabbix_sender/Makefile.am
index 461cde0003..9b72dc43c8 100644
--- a/src/zabbix_sender/Makefile.am
+++ b/src/zabbix_sender/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 bin_PROGRAMS = zabbix_sender
 
 zabbix_sender_SOURCES = \
diff --git a/src/zabbix_server/Makefile.am b/src/zabbix_server/Makefile.am
index 3d0018e9c4..5144ac5555 100644
--- a/src/zabbix_server/Makefile.am
+++ b/src/zabbix_server/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 SUBDIRS = \
 	alerter \
 	dbsyncer \
@@ -121,4 +123,4 @@ install-data-hook:
 	$(MKDIR_P) "$(DESTDIR)$(EXTERNAL_SCRIPTS_PATH)"
 	$(MKDIR_P) "$(DESTDIR)$(ALERT_SCRIPTS_PATH)"
 	$(MKDIR_P) "$(DESTDIR)$(LOAD_MODULE_PATH)"
-	test -f "$(DESTDIR)$(SERVER_CONFIG_FILE)" || cp "../../conf/zabbix_server.conf" "$(DESTDIR)$(SERVER_CONFIG_FILE)"
+	test -f "$(DESTDIR)$(SERVER_CONFIG_FILE)" || cp "$(top_srcdir)/conf/zabbix_server.conf" "$(DESTDIR)$(SERVER_CONFIG_FILE)"
diff --git a/src/zabbix_server/alerter/Makefile.am b/src/zabbix_server/alerter/Makefile.am
index 8654a9fa90..115524da0d 100644
--- a/src/zabbix_server/alerter/Makefile.am
+++ b/src/zabbix_server/alerter/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxalerter.a
 
 libzbxalerter_a_SOURCES = \
diff --git a/src/zabbix_server/dbconfig/Makefile.am b/src/zabbix_server/dbconfig/Makefile.am
index e7cf0ff930..e304ab5af6 100644
--- a/src/zabbix_server/dbconfig/Makefile.am
+++ b/src/zabbix_server/dbconfig/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxdbconfig.a
 
 libzbxdbconfig_a_SOURCES = \
diff --git a/src/zabbix_server/dbsyncer/Makefile.am b/src/zabbix_server/dbsyncer/Makefile.am
index 5636572209..79f40f90f7 100644
--- a/src/zabbix_server/dbsyncer/Makefile.am
+++ b/src/zabbix_server/dbsyncer/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxdbsyncer.a
 
 libzbxdbsyncer_a_SOURCES = \
diff --git a/src/zabbix_server/discoverer/Makefile.am b/src/zabbix_server/discoverer/Makefile.am
index 70cc9e96cc..eb599ba327 100644
--- a/src/zabbix_server/discoverer/Makefile.am
+++ b/src/zabbix_server/discoverer/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxdiscoverer.a
 
 libzbxdiscoverer_a_SOURCES = \
diff --git a/src/zabbix_server/escalator/Makefile.am b/src/zabbix_server/escalator/Makefile.am
index 371f47782d..0e0c2a67bf 100644
--- a/src/zabbix_server/escalator/Makefile.am
+++ b/src/zabbix_server/escalator/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxescalator.a
 
 libzbxescalator_a_SOURCES = \
diff --git a/src/zabbix_server/housekeeper/Makefile.am b/src/zabbix_server/housekeeper/Makefile.am
index 29d6a28a9a..6467ceea4a 100644
--- a/src/zabbix_server/housekeeper/Makefile.am
+++ b/src/zabbix_server/housekeeper/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxhousekeeper.a
 
 libzbxhousekeeper_a_SOURCES = \
diff --git a/src/zabbix_server/httppoller/Makefile.am b/src/zabbix_server/httppoller/Makefile.am
index 60050e3f1e..633d56f03f 100644
--- a/src/zabbix_server/httppoller/Makefile.am
+++ b/src/zabbix_server/httppoller/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxhttppoller.a
 
 libzbxhttppoller_a_SOURCES = \
diff --git a/src/zabbix_server/ipmi/Makefile.am b/src/zabbix_server/ipmi/Makefile.am
index 0b64ea61cd..b7592c956d 100644
--- a/src/zabbix_server/ipmi/Makefile.am
+++ b/src/zabbix_server/ipmi/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libipmi.a
 
 libipmi_a_SOURCES = \
diff --git a/src/zabbix_server/lld/Makefile.am b/src/zabbix_server/lld/Makefile.am
index 4c73a79974..d9e016367f 100644
--- a/src/zabbix_server/lld/Makefile.am
+++ b/src/zabbix_server/lld/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxlld.a
 
 libzbxlld_a_SOURCES = \
diff --git a/src/zabbix_server/odbc/Makefile.am b/src/zabbix_server/odbc/Makefile.am
index 6214cb617c..75c98db488 100644
--- a/src/zabbix_server/odbc/Makefile.am
+++ b/src/zabbix_server/odbc/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxodbc.a
 
 libzbxodbc_a_SOURCES = \
diff --git a/src/zabbix_server/pinger/Makefile.am b/src/zabbix_server/pinger/Makefile.am
index 7ec738b686..3f247daea2 100644
--- a/src/zabbix_server/pinger/Makefile.am
+++ b/src/zabbix_server/pinger/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxpinger.a
 
 libzbxpinger_a_SOURCES = \
diff --git a/src/zabbix_server/poller/Makefile.am b/src/zabbix_server/poller/Makefile.am
index 03b1745eb6..1ad4c66f00 100644
--- a/src/zabbix_server/poller/Makefile.am
+++ b/src/zabbix_server/poller/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxpoller.a libzbxpoller_server.a libzbxpoller_proxy.a
 
 libzbxpoller_a_SOURCES = \
diff --git a/src/zabbix_server/preprocessor/Makefile.am b/src/zabbix_server/preprocessor/Makefile.am
index c01aca9c9d..05dcd81abf 100644
--- a/src/zabbix_server/preprocessor/Makefile.am
+++ b/src/zabbix_server/preprocessor/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libpreprocessor.a
 
 libpreprocessor_a_SOURCES = \
diff --git a/src/zabbix_server/proxypoller/Makefile.am b/src/zabbix_server/proxypoller/Makefile.am
index c988506594..9b70bf0fb4 100644
--- a/src/zabbix_server/proxypoller/Makefile.am
+++ b/src/zabbix_server/proxypoller/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxproxypoller.a
 
 libzbxproxypoller_a_SOURCES = \
diff --git a/src/zabbix_server/scripts/Makefile.am b/src/zabbix_server/scripts/Makefile.am
index 817b0cdb38..0ade637266 100644
--- a/src/zabbix_server/scripts/Makefile.am
+++ b/src/zabbix_server/scripts/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxscripts.a
 
 libzbxscripts_a_SOURCES = \
diff --git a/src/zabbix_server/selfmon/Makefile.am b/src/zabbix_server/selfmon/Makefile.am
index f9cb126957..dd57dd40d4 100644
--- a/src/zabbix_server/selfmon/Makefile.am
+++ b/src/zabbix_server/selfmon/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxselfmon.a
 
 libzbxselfmon_a_SOURCES = \
diff --git a/src/zabbix_server/snmptrapper/Makefile.am b/src/zabbix_server/snmptrapper/Makefile.am
index 1d36a8808c..963451c793 100644
--- a/src/zabbix_server/snmptrapper/Makefile.am
+++ b/src/zabbix_server/snmptrapper/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxsnmptrapper.a
 
 libzbxsnmptrapper_a_SOURCES = \
diff --git a/src/zabbix_server/taskmanager/Makefile.am b/src/zabbix_server/taskmanager/Makefile.am
index dec8fddd20..140135d220 100644
--- a/src/zabbix_server/taskmanager/Makefile.am
+++ b/src/zabbix_server/taskmanager/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxtaskmanager.a
 
 libzbxtaskmanager_a_SOURCES = \
diff --git a/src/zabbix_server/timer/Makefile.am b/src/zabbix_server/timer/Makefile.am
index 0f19ffb740..3a870f48b2 100644
--- a/src/zabbix_server/timer/Makefile.am
+++ b/src/zabbix_server/timer/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxtimer.a
 
 libzbxtimer_a_SOURCES = \
diff --git a/src/zabbix_server/trapper/Makefile.am b/src/zabbix_server/trapper/Makefile.am
index 3caa66fcc3..57c2c7f7e0 100644
--- a/src/zabbix_server/trapper/Makefile.am
+++ b/src/zabbix_server/trapper/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxtrapper.a
 
 libzbxtrapper_a_SOURCES = \
diff --git a/src/zabbix_server/vmware/Makefile.am b/src/zabbix_server/vmware/Makefile.am
index 88842dcb25..5f678b1e54 100644
--- a/src/zabbix_server/vmware/Makefile.am
+++ b/src/zabbix_server/vmware/Makefile.am
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
 noinst_LIBRARIES = libzbxvmware.a
 
 libzbxvmware_a_SOURCES = \
-- 
2.27.0

