diff --git a/makefile b/makefile
index 5eae279e8699ce350cfcbab32516708cd73e2c70..161caf7b5ef9c401f4bbf5388f01c217f5157305 100644
--- a/makefile
+++ b/makefile
@@ -32,6 +32,12 @@ SUBDIRS_BINS = aecho2 \
 		atrim2 \
 		tniceprint \
 
+define NEW_LINE
+
+
+endef
+
+export NEW_LINE
 
 ifneq (3.81, $(firstword $(sort $(MAKE_VERSION) 3.81)))
 $(error version $(MAKE_VERSION) is not supported. You need at least 3.82 is needed for make to work)
@@ -42,29 +48,16 @@ ifneq (0, $(TCLAP_EXISTS))
 $(error You need tclap installed)
 endif
 
-CPPUNIT_EXISTS = $(shell $(CXX) -c -o /dev/null -xc++ - <<< \\\#include\ \<cppunit/Test.h\> 2>/dev/null; echo $$?)
+CPPUNIT_EXISTS = $(shell $(CXX) -o /dev/null -lcppunit -xc++ - <<< $$'\#include <cppunit/Test.h>\nint main() {\nreturn 0;\n}' 2>/dev/null; echo $$?)
 ifneq (0, $(CPPUNIT_EXISTS))
 $(error You need cppunit installed)
 endif
 
-CPPUNIT_SO_TMP = $(shell ld --verbose | grep SEARCH | tr \  \\\n | sed s/SEARCH_DIR//g | sed s/\(\\\"//g | sed s/\\\"\)\\\;//g | sed s/^=//g | sort -u | sed \s/$$/\\/libcppunit.so*/g\)
-CPPUNIT_SO_EXISTS = $(shell ls $(CPPUNIT_SO_TMP) 2>/dev/null | wc -l)
-ifeq (0, $(CPPUNIT_SO_EXISTS))
-$(error You need cppunit installed)
-endif
-
-LIBXML2_EXISTS = $(shell $(CXX) -c -o /dev/null -xc++ - <<< \\\#include\ \<libxml/xmlreader.h\> 2>/dev/null; echo $$?)
+LIBXML2_EXISTS = $(shell $(CXX) -o /dev/null -lxml2 -xc++ - <<< $$'\#include <libxml/xmlreader.h>\nint main() {\nreturn 0;\n}' 2>/dev/null; echo $$?)
 ifneq (0, $(LIBXML2_EXISTS))
 $(error You need libxml2 installed)
 endif
 
-LIBXML2_SO_TMP = $(shell ld --verbose | grep SEARCH | tr \  \\\n | sed s/SEARCH_DIR//g | sed s/\(\\\"//g | sed s/\\\"\)\\\;//g | sed s/^=//g | sort -u | sed \s/$$/\\/libxml2.so*/g\)
-$(info $(LIBXML2_SO_TMP))
-LIBXML2_SO_EXISTS = $(shell ls $(LIBXML2_SO_TMP) 2>/dev/null | wc -l)
-ifeq (0, $(LIBXML2_SO_EXISTS))
-$(error You need libxml2 installed)
-endif
-
 
 SUBDIRS_WITH_MAKE = $(dir $(wildcard */makefile))