From: Thorsten Glaser <tg@mirbsd.org>
Subject: Build system fixes
 recurse into xorgxrdp/ as well (make into proper configure option?)
 also, actually install keymaps shipped
Forwarded: https://github.com/neutrinolabs/xrdp/pull/467
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,4 +65,5 @@ SUBDIRS = \
   genkeymap \
   xrdpapi \
   pkgconfig \
+  xorgxrdp \
   $(XRDPVRDIR)
--- a/configure.ac
+++ b/configure.ac
@@ -264,6 +264,14 @@ AC_CHECK_HEADER([X11/extensions/Xrandr.h
   [AC_MSG_ERROR([please install libxrandr-dev or libXrandr-devel])],
   [#include <X11/Xlib.h>])
 
+# checking if we need libdl
+save_LIBS=$LIBS
+AC_SEARCH_LIBS([dlopen], [dl dld], [], [
+  AC_MSG_ERROR([unable to find the dlopen() function])
+])
+AM_CONDITIONAL(NEED_LIBDL, [test x"$LIBS" != x"$save_LIBS"])
+LIBS=$save_LIBS
+
 CFLAGS="$save_CFLAGS"
 
 AC_SUBST([moduledir], '${libdir}/xrdp')
--- a/xrdp/Makefile.am
+++ b/xrdp/Makefile.am
@@ -24,7 +24,7 @@ endif
 if XRDP_RFXCODEC
 AM_CPPFLAGS += -DXRDP_RFXCODEC
 AM_CPPFLAGS += -I$(top_srcdir)/librfxcodec/include
-XRDP_EXTRA_LIBS += $(top_builddir)/librfxcodec/src/.libs/librfxencode.a
+XRDP_EXTRA_LIBS += $(top_builddir)/librfxcodec/src/.libs/librfxencode.la
 endif
 
 if XRDP_PIXMAN
--- a/xrdpapi/Makefile.am
+++ b/xrdpapi/Makefile.am
@@ -9,3 +9,9 @@ module_LTLIBRARIES = \
 libxrdpapi_la_SOURCES = \
   xrdpapi.c \
   xrdpapi.h
+
+AM_CPPFLAGS = \
+  -I$(top_srcdir)/common
+
+libxrdpapi_la_LIBADD = \
+  $(top_builddir)/common/libcommon.la
