From 6e3c1a2fa29c066f7d1a25037a1f61cd295ac3af Mon Sep 17 00:00:00 2001
From: Paul Gevers <elbrus@debian.org>
Date: Tue, 2 Jan 2018 19:58:18 +0100
Subject: [PATCH] Improve internal linking

Building packages in Debian uses a tool to link libraries together at the
package level. It emits warnings when unknonw symbols are found. E.g:

dpkg-shlibdeps: warning: symbol us_tokentowords used by debian/libflite1/usr/lib/x86_64-linux-gnu/libflite_cmu_indic_lang.so.2.0.0 found in none of the libraries
---
 config/common_make_rules |  2 +-
 main/Makefile            | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/config/common_make_rules b/config/common_make_rules
index 7a03785..34434fd 100644
--- a/config/common_make_rules
+++ b/config/common_make_rules
@@ -123,7 +123,7 @@ $(LIBDIR)/%.so: $(LIBDIR)/%.shared.a
 	@ rm -rf shared_os && mkdir shared_os
 	@ rm -f $@ $@.${PROJECT_VERSION} $@.${PROJECT_SHLIB_VERSION} 
 	@ (cd shared_os && ar x ../$<)
-	@ (cd shared_os && $(CC) -shared -Wl,-soname,`basename $@`.${PROJECT_SHLIB_VERSION} -o ../$@.${PROJECT_VERSION} *.os)
+	@ (cd shared_os && $(CC) -shared -Wl,-soname,`basename $@`.${PROJECT_SHLIB_VERSION} -o ../$@.${PROJECT_VERSION} *.os $(LDFLAGS))
 	@ (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_VERSION}` `basename $@.${PROJECT_SHLIB_VERSION}` )
 	@ (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_SHLIB_VERSION}` `basename $@` )
 	@ rm -rf shared_os
diff --git a/main/Makefile b/main/Makefile
index ff422e0..47b6344 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -54,7 +54,8 @@ ALL = shared_libs \
 VOICES=$(VOXES)
 VOICELIBS=$(VOICES:%=flite_%)
 
-flite_LIBS = $(VOICELIBS) $(LANGS:%=flite_%) $(LEXES:%=flite_%) flite
+flite_MODS = $(VOICELIBS) $(LANGS:%=flite_%) $(LEXES:%=flite_%) 
+flite_LIBS = flite $(flite_MODS)
 
 flite_LIBS_flags = -L$(LIBDIR) $(flite_LIBS:%=-l%)
 flite_LIBS_deps = $(flite_LIBS:%=$(LIBDIR)/lib%.a)
@@ -65,6 +66,10 @@ include $(TOP)/config/common_make_rules
 # so make clean can remove them
 SHAREDARLIBS= $(flite_LIBS:%=$(LIBDIR)/lib%.shared.a)
 SHAREDLIBS = $(SHAREDARLIBS:%.shared.a=%.so)
+SHAREDMODS = $(flite_MODS:%=$(LIBDIR)/lib%.so)
+SHAREDusenMODS = $(LIBDIR)/libflite_cmu_time_awb.so $(LIBDIR)/libflite_cmu_us_awb.so $(LIBDIR)/libflite_cmu_us_kal16.so $(LIBDIR)/libflite_cmu_us_kal.so $(LIBDIR)/libflite_cmu_us_rms.so $(LIBDIR)/libflite_cmu_us_slt.so $(LIBDIR)/libflite_cmu_indic_lang.so
+SHAREDcmulexMODS = $(LIBDIR)/libflite_cmu_time_awb.so $(LIBDIR)/libflite_cmu_us_awb.so $(LIBDIR)/libflite_cmu_us_kal16.so $(LIBDIR)/libflite_cmu_us_kal.so $(LIBDIR)/libflite_cmu_us_rms.so $(LIBDIR)/libflite_cmu_us_slt.so  $(LIBDIR)/libflite_cmu_indic_lex.so
+SHAREDindicMODS = $(LIBDIR)/libflite_cmu_indic_lex.so
 VERSIONSHAREDLIBS = $(SHAREDLIBS:%=%.${PROJECT_VERSION}) \
                     $(SHAREDLIBS:%=%.${PROJECT_SHLIB_VERSION})
 
@@ -79,7 +84,14 @@ LOCAL_CLEAN = $(BINDIR)/flite$(EXEEXT) $(BINDIR)/flite_time$(EXEEXT) \
               flite_voice_list.c
 
 ifdef SHFLAGS
-flite_LIBS_flags += -Wl,-rpath $(LIBDIR) 
+$(SHAREDMODS): $(LIBDIR)/libflite.so
+$(SHAREDMODS): LDFLAGS+=-L../$(LIBDIR) -lflite
+$(SHAREDusenMODS): $(LIBDIR)/libflite_usenglish.so
+$(SHAREDusenMODS): LDFLAGS+=-L../$(LIBDIR) -lflite_usenglish
+$(SHAREDcmulexMODS): $(LIBDIR)/libflite_cmulex.so
+$(SHAREDcmulexMODS): LDFLAGS+=-L../$(LIBDIR) -lflite_cmulex
+$(SHAREDindicMODS): $(LIBDIR)/libflite_cmu_indic_lang.so
+$(SHAREDindicMODS): LDFLAGS+=-L../$(LIBDIR) -lflite_cmu_indic_lang
 shared_libs: $(SHAREDLIBS)
 else
 shared_libs: nothing
-- 
2.24.1

From d673f65b2c4a8cd3da7447079309a6dc4bcf1a5e Mon Sep 17 00:00:00 2001
From: Alan W Black <awb@cs.cmu.edu>
Date: Sun, 4 Mar 2018 08:55:40 -0500
Subject: [PATCH] get libs in the right order

---
 main/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main/Makefile b/main/Makefile
index 47b6344..1da18a8 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -55,7 +55,7 @@ VOICES=$(VOXES)
 VOICELIBS=$(VOICES:%=flite_%)
 
 flite_MODS = $(VOICELIBS) $(LANGS:%=flite_%) $(LEXES:%=flite_%) 
-flite_LIBS = flite $(flite_MODS)
+flite_LIBS = $(flite_MODS) flite
 
 flite_LIBS_flags = -L$(LIBDIR) $(flite_LIBS:%=-l%)
 flite_LIBS_deps = $(flite_LIBS:%=$(LIBDIR)/lib%.a)
-- 
2.24.1
