diff --git a/misc/m4/qt.m4 b/misc/m4/qt.m4
index 224cd58..694b80a 100644
--- a/misc/m4/qt.m4
+++ b/misc/m4/qt.m4
@@ -16,10 +16,10 @@ m4_include([misc/m4/qt5.m4])
 
 AC_DEFUN([LC_WITH_QT],[
 #QT has the install dir hard coded in library so we need to fix it manually for relocatable environment
-QT5_AVAILABLE="no"
+QT5_AVAILABLE="yes"
 SAVE_LIBS="$LIBS"
 LIBS=""
-#     AX_HAVE_QT
+     AX_HAVE_QT
 LIBS="$SAVE_LIBS"
 if test x"$have_qt" = xyes; then 
   AC_MSG_RESULT([Qt5 found])
@@ -27,6 +27,7 @@ if test x"$have_qt" = xyes; then
   QMAKE="qmake"
   MOC="moc"
   QT5_AVAILABLE="yes"
+  AX_HAVE_QT
 else
 # AC_MSG_RESULT([Qt5 seems not present, trying Qt4...])
   typeset xtralibs
diff --git a/misc/m4/qt5.m4 b/misc/m4/qt5.m4
index 44cbcae..68c914e 100644
--- a/misc/m4/qt5.m4
+++ b/misc/m4/qt5.m4
@@ -53,7 +53,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 12
+#serial 14 + additions added by Karl Hegbloom trying to fix it. :-)
 
 AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT])
 AC_DEFUN([AX_HAVE_QT],
@@ -65,49 +65,52 @@ AC_DEFUN([AX_HAVE_QT],
   AC_MSG_CHECKING(for Qt)
   # If we have Qt5 or later in the path, we're golden
   ver=`qmake --version | grep -o "Qt version ."`
+  echo $ver
   if test "$ver" ">" "Qt version 4"; then
     have_qt=yes
     # This pro file dumps qmake's variables, but it only works on Qt 5 or later
     am_have_qt_pro=`mktemp`
     am_have_qt_makefile=`mktemp`
     # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt
+    # the below list is not complete because I do not have every module installed on my laptop ~karlheg
     cat > $am_have_qt_pro << EOF
-qtHaveModule(axcontainer):       QT += axcontainer
-qtHaveModule(axserver):          QT += axserver
-qtHaveModule(concurrent):        QT += concurrent
+dnl qtHaveModule(axcontainer):       QT += axcontainer
+dnl qtHaveModule(axserver):          QT += axserver
+dnl qtHaveModule(concurrent):        QT += concurrent
 qtHaveModule(core):              QT += core
 qtHaveModule(dbus):              QT += dbus
-qtHaveModule(declarative):       QT += declarative
-qtHaveModule(designer):          QT += designer
+dnl qtHaveModule(declarative):       QT += declarative
+dnl qtHaveModule(designer):          QT += designer
 qtHaveModule(gui):               QT += gui
 qtHaveModule(help):              QT += help
-qtHaveModule(multimedia):        QT += multimedia
-qtHaveModule(multimediawidgets): QT += multimediawidgets
+dnl qtHaveModule(multimedia):        QT += multimedia
+dnl qtHaveModule(multimediawidgets): QT += multimediawidgets
 qtHaveModule(network):           QT += network
-qtHaveModule(opengl):            QT += opengl
+dnl qtHaveModule(opengl):            QT += opengl
+qtHaveModule(platformheaders):   QT += platformheaders
 qtHaveModule(printsupport):      QT += printsupport
-qtHaveModule(qml):               QT += qml
-qtHaveModule(qmltest):           QT += qmltest
+dnl qtHaveModule(qml):               QT += qml
+dnl qtHaveModule(qmltest):           QT += qmltest
 qtHaveModule(x11extras):         QT += x11extras
-qtHaveModule(script):            QT += script
-qtHaveModule(scripttools):       QT += scripttools
-qtHaveModule(sensors):           QT += sensors
-qtHaveModule(serialport):        QT += serialport
-qtHaveModule(sql):               QT += sql
+dnl qtHaveModule(script):            QT += script
+dnl qtHaveModule(scripttools):       QT += scripttools
+dnl qtHaveModule(sensors):           QT += sensors
+dnl qtHaveModule(serialport):        QT += serialport
+dnl qtHaveModule(sql):               QT += sql
 qtHaveModule(svg):               QT += svg
-qtHaveModule(testlib):           QT += testlib
-qtHaveModule(uitools):           QT += uitools
+dnl qtHaveModule(testlib):           QT += testlib
+dnl qtHaveModule(uitools):           QT += uitools
 qtHaveModule(webkit):            QT += webkit
-qtHaveModule(webkitwidgets):     QT += webkitwidgets
-qtHaveModule(xml):               QT += xml
-qtHaveModule(xmlpatterns):       QT += xmlpatterns
+dnl qtHaveModule(webkitwidgets):     QT += webkitwidgets
+dnl qtHaveModule(xml):               QT += xml
+dnl qtHaveModule(xmlpatterns):       QT += xmlpatterns
 percent.target = %
 percent.commands = @echo -n "\$(\$(@))\ "
 QMAKE_EXTRA_TARGETS += percent
 EOF
     qmake $am_have_qt_pro -o $am_have_qt_makefile
-    QT_CXXFLAGS=`cd $(dirname  $am_have_qt_makefile ); make -f $am_have_qt_makefile CXXFLAGS INCPATH`
-    QT_LIBS=`cd $(dirname  $am_have_qt_makefile ); make -f $am_have_qt_makefile LIBS`
+    QT_CXXFLAGS=`make -s -f $am_have_qt_makefile CXXFLAGS INCPATH`
+    QT_LIBS=`make -s -f $am_have_qt_makefile LIBS`
     rm $am_have_qt_pro $am_have_qt_makefile
 
     # Look for specific tools in $PATH
diff --git a/misc/m4/tm_gui.m4 b/misc/m4/tm_gui.m4
index c2dcea3..7f60e12 100644
--- a/misc/m4/tm_gui.m4
+++ b/misc/m4/tm_gui.m4
@@ -12,6 +12,9 @@
 #--------------------------------------------------------------------
 
 AC_DEFUN([TM_GUI],[
+  LC_X_HEADERS
+  AC_PATH_X
+  AC_PATH_XTRA
 
   CONFIG_X11=""
   CONFIG_COCOA=""
@@ -39,9 +42,9 @@ AC_DEFUN([TM_GUI],[
       no)
          CONFIG_QTPIPES="no"
          AC_MSG_RESULT([enabling X11 port])
-         LC_X_HEADERS
-         AC_PATH_X
-         AC_PATH_XTRA
+         #LC_X_HEADERS
+         #AC_PATH_X
+         #AC_PATH_XTRA
          ;;
       *)
          CONFIG_QTPIPES="no"
@@ -51,10 +54,25 @@ AC_DEFUN([TM_GUI],[
 
   # Qt Plugins list
   if test "$QT5_AVAILABLE" = yes; then
-    QT_PLUGINS_LIST="imageformats"
+    QT_PLUGINS_LIST="generic,imageformats,printsupport" #,accessiblebridge,inputmethods"
   else
     QT_PLUGINS_LIST="accessible,imageformats"
   fi
+  QT_PLUGINS_LIST="$PLUGINS_LIST"
+  AC_ARG_ENABLE(QtPlugins,
+	 AS_HELP_STRING([--enable-QtPlugins@<:@=list@:>@],
+		  [default qt4 plugins: imageformats,accessible,accessiblebridge,inputmethods
+default qt5 plugins: generic,imageformats,platforminputcontexts,platforms,printsupport,xcbglintegrations]),
+    [QT_PLUGINS_LIST=$enableval],[QT_PLUGINS_LIST="$PLUGINS_LIST"])
+  case $QT_PLUGINS_LIST in
+  yes) QT_PLUGINS_LIST="$PLUGINS_LIST";;
+  no) unset QT_PLUGINS_LIST
+  esac
+
+  [[[ $enable_qt == no ]]] &&  unset QT_PLUGINS_LIST
+  for p in ${QT_PLUGINS_LIST//,/ }
+  do [ echo $p ] && ([[ -d $QT_PLUGINS_PATH/$p ]] || AC_MSG_ERROR(QT plugins not found!))
+  done
 
   # Qt Pipes
   AC_ARG_ENABLE(qtpipes,
diff --git a/misc/m4/tm_platform.m4 b/misc/m4/tm_platform.m4
index 5a81624..3c4d13e 100644
--- a/misc/m4/tm_platform.m4
+++ b/misc/m4/tm_platform.m4
@@ -69,6 +69,7 @@ AC_DEFUN([TM_PLATFORM],[
       AC_SUBST([CONFIG_PACKAGE],[GENERIC_PACKAGE])
       CONFIG_OS="GNU_LINUX"
       CONFIG_OS_SUFFIX="i386-pc-linux-gnu"
+      CONFIG_CXXFLAGS="-fPIC"
       CONFIG_CXXOPTIMIZE="-O3 -fexpensive-optimizations"
       CONFIG_QTPIPES="yes"
       AC_DEFINE([STACK_SIZE], 0x1000000, [If not set during link])
