Build and install a shared libHTSEngine.so.1 next to the static archive.

Upstream builds only the static library, with plain automake (no libtool).
Link the same sources, compiled once more with -fPIC -DPIC, into a shared
object, point the libHTSEngine.so development link at it, and link the
hts_engine program with that instead of the archive.

--- lib/Makefile.am
+++ lib/Makefile.am
@@ -9,6 +9,31 @@
                          HTS_pstream.c  HTS_sstream.c  HTS_model.c  HTS_vocoder.c \
                          HTS_gstream.c HTS_label.c
 
+# The same sources once more, compiled position-independent, as a shared
+# library.  Automake cannot build those without libtool, but a "program"
+# linked with -shared is one; the per-target flags give it its own objects.
+shlibdir = $(libdir)
+shlib_PROGRAMS = libHTSEngine.so.1
+
+libHTSEngine_so_1_SOURCES = $(libHTSEngine_a_SOURCES)
+libHTSEngine_so_1_CFLAGS = -fPIC -DPIC
+libHTSEngine_so_1_LDFLAGS = -shared -Wl,-soname,libHTSEngine.so.1
+
+install-exec-hook:
+	cd $(DESTDIR)$(shlibdir) && rm -f libHTSEngine.so && \
+	    ln -s libHTSEngine.so.1 libHTSEngine.so
+
+uninstall-hook:
+	rm -f $(DESTDIR)$(shlibdir)/libHTSEngine.so
+
+# The development link in the build tree too, for linking bin/hts_engine.
+all-local: libHTSEngine.so
+
+libHTSEngine.so: libHTSEngine.so.1
+	rm -f $@ && ln -s libHTSEngine.so.1 $@
+
+CLEANFILES = libHTSEngine.so
+
 DISTCLEANFILES = *.log *.out *~
 
 MAINTAINERCLEANFILES = Makefile.in
--- bin/Makefile.am
+++ bin/Makefile.am
@@ -7,7 +7,9 @@
 
 hts_engine_SOURCES = hts_engine.c 
 
-hts_engine_LDADD = ../lib/libHTSEngine.a
+hts_engine_LDFLAGS = -L../lib
+hts_engine_LDADD = -lHTSEngine
+hts_engine_DEPENDENCIES = ../lib/libHTSEngine.so
 
 DISTCLEANFILES = *.log *.out *~
 
