ports/audio/flite/files/patch-single-exe
Mikhail Teterin f4e0b7d13d Fix the ancient problem, where we replaced Linux' "cp -pd" with
simple "cp -p". This caused symbolic links (like libFOO.so ->
libFOO.so.X.Y) to be dereferenced installing three copies of each
library instead of one.

Strip the executables and the shared libraries after staging.

Fix the authors' makefiles to allow parallel building.

Add a patch which allows us to replace the multitude of
flite_VOICE-executables (one for each voice) with sym-links to the
single flite itself.

The size of the package shrunk from 100Mb to 50Mb here (amd64) as the
result of the above measures.

Bump PORTREVISION.

Note: the new patches are deliberately organized by feature rather than
by the patched files -- to make it easier to refer the upstream
maintainers to them.
2014-12-02 07:01:40 +00:00

66 lines
1.8 KiB
Text

This patch completely dispenses with building flite_VOICE executables
for each voice, replacing them all with symlinks to flite itself.
The flite itself will now determine the desired voice -- if not
explicitly given on command-line -- based on the name of the invoked
program (argv[0]).
-mi
--- main/Makefile 2009-08-14 17:11:07.000000000 -0400
+++ main/Makefile 2014-12-02 01:11:35.000000000 -0500
@@ -116,3 +113,3 @@
do \
- $(INSTALL) $(BINDIR)/flite_$$i $(INSTALLBINDIR); \
+ ln -s flite $(INSTALLBINDIR)/flite_$$i; \
done
+++ main/flite_main.c 2014-12-02 01:05:49.000000000 -0500
@@ -51,4 +51,18 @@
void cst_alloc_debug_summary();
+/* Return 1 if the big string ends with the small one, 0 otherwise */
+static int
+endsWith(const char *big, const char *small)
+{
+ size_t biglen, smallen;
+
+ biglen = strlen(big);
+ smallen = strlen(small);
+
+ if (smallen > biglen)
+ return 0;
+ return strcmp(big + (biglen - smallen), small) == 0;
+}
+
static void flite_version()
{
@@ -299,6 +313,27 @@
if (filename == NULL) filename = "-"; /* stdin */
- if (desired_voice == 0)
- desired_voice = flite_voice_select(NULL);
+ if (desired_voice == NULL) {
+ cst_voice *voice;
+ const cst_val *val;
+ const cst_lexicon *lex;
+
+ /* Try to find the voice based on the executable filename */
+ for (val = flite_voice_list; val; val = val_cdr(val)) {
+ voice = val_voice(val_car(val));
+ /* First check the name of the voice itself: */
+ if (endsWith(argv[0], voice->name)) {
+ desired_voice = voice;
+ break;
+ }
+ /* Ok, check the name of the voice's lexicon: */
+ lex = val_lexicon(feat_val(voice->features, "lexicon"));
+ if (endsWith(argv[0], lex->name)) {
+ desired_voice = voice;
+ break;
+ }
+ }
+ if (desired_voice == NULL)
+ desired_voice = flite_voice_select(NULL);
+ }
v = desired_voice;