From c0ef3fe6b2a1fc2e1428b614d692b6a77a9100c8 Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <campbell@mumble.net>
Date: Sun, 21 Oct 2018 17:14:34 +0000
Subject: [PATCH] Fix automake library goo.

- Respect LDFLAGS in configure.
- Let automake figure out the .lo files.
- Specify -lX11 only if no pkg-config.
---
 src/x11/Makefile.am  | 9 +++------
 src/x11/configure.ac | 4 +++-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/x11/Makefile.am b/src/x11/Makefile.am
index 7b74e2e2c..cff56dd31 100644
--- a/src/x11/Makefile.am
+++ b/src/x11/Makefile.am
@@ -47,12 +47,9 @@ scmlib_sub_DATA += make.scm @MIT_SCHEME_PKD@
 AM_CPPFLAGS = -I@MIT_SCHEME_INCLUDEDIR@
 AM_CFLAGS = @MIT_CFLAGS@
 
-LIBS = @MIT_LIBS@
-LDFLAGS = @MIT_LIBS@
-
-x11_shim_la_LIBADD = x11base.lo x11color.lo x11graph.lo x11term.lo
-c_sources = x11-shim.h x11.h x11base.c x11color.c x11graph.c x11term.c
-x11_shim_la_LDFLAGS = -module -avoid-version -shared -lX11
+x11_shim_la_LIBADD = @MIT_LIBS@
+x11_shim_la_SOURCES = x11base.c x11color.c x11graph.c x11term.c x11-shim.c
+x11_shim_la_LDFLAGS = -module -avoid-version -shared
 
 noinst_PROGRAMS = x11-const
 x11_const_SOURCES = x11-const.c x11-shim.h
diff --git a/src/x11/configure.ac b/src/x11/configure.ac
index 6260f43ef..c53faaef3 100644
--- a/src/x11/configure.ac
+++ b/src/x11/configure.ac
@@ -91,9 +91,11 @@ if test "${no_x}" != yes; then
     fi
     if test "x${x_libraries}" != x; then
         FOO=-L`echo ${x_libraries} | sed -e "s/:/ -L/g"`
-        MIT_LIBS="${MIT_LIBS} ${FOO}"
+        MIT_LIBS="${MIT_LIBS} ${FOO} -lX11"
     elif pkg-config --exists x11 2>/dev/null; then
         MIT_LIBS="${MIT_LIBS} `pkg-config --libs x11`"
+    else
+        MIT_LIBS="${MIT_LIBS} -lX11"
     fi
 fi
 
-- 
2.25.1