Description: Dynamically link to liblwgeom
 Instead of statically pulling liblwgeom into the postgis.so, dynamically
 link to it.
Author: Stephen Frost <sfrost@snowman.net>, Markus Wanner <markus@bluegap.ch>
Forwarded: https://trac.osgeo.org/postgis/ticket/3290

--- a/postgis/Makefile.in
+++ b/postgis/Makefile.in
@@ -112,15 +112,9 @@ PG_OBJS= \
 OBJS=$(PG_OBJS)
 
 # Libraries to link into the module (proj, geos)
-#
-# Note: we specify liblwgeom.a directly in SHLIB_LINK rather than using
-# -L... -l options to prevent issues with some platforms trying to link
-# to an existing liblwgeom.so in the PostgreSQL $libdir supplied by an
-# older version of PostGIS, rather than with the static liblwgeom.a
-# supplied with newer versions of PostGIS
 override CFLAGS := -I../liblwgeom @CFLAGS@
 PG_CPPFLAGS += -I../libpgcommon @CPPFLAGS@ -fPIC
-SHLIB_LINK_F = ../libpgcommon/libpgcommon.a ../liblwgeom/.libs/liblwgeom.a @SHLIB_LINK@
+SHLIB_LINK_F = -L../liblwgeom/.libs -llwgeom ../libpgcommon/libpgcommon.a @SHLIB_LINK@
 
 # Add SFCGAL Flags if defined
 ifeq (@SFCGAL@,sfcgal)
--- a/raster/rt_pg/Makefile.in
+++ b/raster/rt_pg/Makefile.in
@@ -50,14 +50,7 @@ OBJS = \
 	rtpg_statistics.o
 
 # Libraries to link into the module (proj, geos)
-#
-# Note: we specify liblwgeom.a directly in SHLIB_LINK rather than using
-# -L... -l options to prevent issues with some platforms trying to link
-# to an existing liblwgeom.so in the PostgreSQL $libdir supplied by an
-# older version of PostGIS, rather than with the static liblwgeom.a
-# supplied with newer versions of PostGIS
-#
-LIBLWGEOM_LDFLAGS=../../liblwgeom/.libs/liblwgeom.a
+LIBLWGEOM_LDFLAGS=-L../../liblwgeom/.libs -llwgeom
 LIBLWGEOM_CFLAGS="-I../../liblwgeom"
 LIBPGCOMMON_CFLAGS="-I../../libpgcommon"
 LIBPGCOMMON_LDFLAGS=../../libpgcommon/libpgcommon.a
--- a/raster/loader/Makefile.in
+++ b/raster/loader/Makefile.in
@@ -36,7 +36,7 @@ PGSQL_BINDIR=@PGSQL_BINDIR@
 
 RT_CORE=../rt_core
 
-LIBLWGEOM_LDFLAGS=../../liblwgeom/liblwgeom.la
+LIBLWGEOM_LDFLAGS=-L../../liblwgeom/.libs -llwgeom
 LIBLWGEOM_CFLAGS=-I../../liblwgeom
 LIBGDAL_CFLAGS=@LIBGDAL_CFLAGS@
 LIBGDAL_LDFLAGS=@LIBGDAL_LDFLAGS@
