svn commit: r373754 - in head/audio/flite: . files

Mikhail Teterin mi at FreeBSD.org
Tue Dec 2 07:01:42 UTC 2014


Author: mi
Date: Tue Dec  2 07:01:40 2014
New Revision: 373754
URL: https://svnweb.freebsd.org/changeset/ports/373754
QAT: https://qat.redports.org/buildarchive/r373754/

Log:
  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.

Added:
  head/audio/flite/files/patch-parallel-build   (contents, props changed)
  head/audio/flite/files/patch-single-exe   (contents, props changed)
Modified:
  head/audio/flite/Makefile

Modified: head/audio/flite/Makefile
==============================================================================
--- head/audio/flite/Makefile	Tue Dec  2 06:52:58 2014	(r373753)
+++ head/audio/flite/Makefile	Tue Dec  2 07:01:40 2014	(r373754)
@@ -3,6 +3,7 @@
 
 PORTNAME=	flite
 PORTVERSION=	1.4
+PORTREVISION=	1
 CATEGORIES=	audio
 MASTER_SITES=	http://www.speech.cs.cmu.edu/flite/packed/${PORTNAME}-${PORTVERSION}/
 DISTNAME=	${PORTNAME}-${PORTVERSION}-release
@@ -17,13 +18,12 @@ GNU_CONFIGURE=	yes
 CONFIGURE_ARGS=	--enable-shared=yes
 USE_LDCONFIG=	yes
 
-MAKE_JOBS_UNSAFE=	yes
-
 post-patch:
-	@${REINPLACE_CMD} -e 's|-pd|-p|g' ${WRKSRC}/main/Makefile
+	@${REINPLACE_CMD} -e 's|-pd|-pR|g' ${WRKSRC}/main/Makefile
 
 post-install:
 	@${MKDIR} ${STAGEDIR}${DOCSDIR}
 	${INSTALL_DATA} ${WRKSRC}/README ${STAGEDIR}${DOCSDIR}
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/* ${STAGEDIR}${PREFIX}/lib/*.so
 
 .include <bsd.port.mk>

Added: head/audio/flite/files/patch-parallel-build
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/audio/flite/files/patch-parallel-build	Tue Dec  2 07:01:40 2014	(r373754)
@@ -0,0 +1,155 @@
+Allow parallel builds:
+
+	1. First, modify make_voice_list script to accept the
+	   output file (defaulting to flite_voice_list.c as before).
+	2. Use a per-library subdirectory to build shared objecs from
+	   the .shared.a-counterparts -- using the same shared_os/
+	   was causing conflicts, when multiple such libraries were
+	   built in parallel.
+	3. Use the new feature of make_voice_list (see 1.) to build
+	   separate voice-list files for each voice, thus avoiding
+	   the last sort of conflicts.
+
+This also removes linking unnecessary libraries into flite_VOICE
+executables -- only the library providing the particular voice is used
+now.
+
+	-mi
+
+--- tools/make_voice_list	2009-04-08 09:18:42.000000000 -0400
++++ tools/make_voice_list	2014-12-01 19:39:40.000000000 -0500
+@@ -36,26 +36,38 @@
+ ###########################################################################
+ 
+-rm -f flite_voice_list.c
++case "$1" in
++-o)
++	output=$2
++	shift 2
++	;;
++*)
++	output=flite_voice_list.c
++	;;
++esac
++
++rm -f $output
++exec > $output
++
++cat << EOT
++/* Generated automatically from make_voice_list */
++
++#include "flite.h"
++
++EOT
+ 
+-echo "/* Generated automatically from make_voice_list */" >flite_voice_list.c
+-echo >>flite_voice_list.c
+-echo '#include "flite.h"' >>flite_voice_list.c
+-echo >>flite_voice_list.c
+ for i in $*
+ do
+-   echo "cst_voice *register_"$i"(const char *voxdir);">>flite_voice_list.c
++   echo "cst_voice *register_"$i"(const char *voxdir);"
+ done
+ 
+-echo >>flite_voice_list.c
+-echo "cst_val *flite_set_voice_list(void)" >>flite_voice_list.c
+-echo "{" >>flite_voice_list.c
++echo
++echo "cst_val *flite_set_voice_list(void)"
++echo "{"
+ for i in $*
+ do
+-   echo "   flite_voice_list = cons_val(voice_val(register_"$i"(NULL)),flite_voice_list);" >>flite_voice_list.c
++   echo "   flite_voice_list = cons_val(voice_val(register_"$i"(NULL)),flite_voice_list);"
+ done
+-   echo "   flite_voice_list = val_reverse(flite_voice_list);" >>flite_voice_list.c
+-   echo "   return flite_voice_list;" >>flite_voice_list.c
+-
+-echo "}" >>flite_voice_list.c
+-echo >>flite_voice_list.c
++   echo "   flite_voice_list = val_reverse(flite_voice_list);"
++   echo "   return flite_voice_list;"
+ 
++echo "}"
+--- config/common_make_rules	2009-07-30 10:52:56.000000000 -0400
++++ config/common_make_rules	2014-12-01 19:43:50.000000000 -0500
+@@ -121,11 +121,11 @@
+ $(LIBDIR)/%.so: $(LIBDIR)/%.shared.a
+ 	@ echo making $@
+-	@ rm -rf shared_os && mkdir shared_os
++	@ 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.$* && ar x ../$<)
++	@ (cd shared_os.$* && $(CC) -shared -Wl,-soname,`basename $@`.${PROJECT_SHLIB_VERSION} -o ../$@.${PROJECT_VERSION} *.os)
+ 	@ (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_VERSION}` `basename $@.${PROJECT_SHLIB_VERSION}` )
+ 	@ (cd $(LIBDIR) && ln -s `basename $@.${PROJECT_SHLIB_VERSION}` `basename $@` )
+-	@ rm -rf shared_os
++	@ rm -rf shared_os.$*
+ 
+ $(OBJDIR)/.make_build_dirs:
+--- main/Makefile	2009-08-14 17:11:07.000000000 -0400
++++ main/Makefile	2014-12-01 21:07:35.000000000 -0500
+@@ -40,5 +40,5 @@
+ ALL_DIRS= 
+ SRCS = flite_main.c flite_time_main.c t2p_main.c compile_regexes.c
+-OBJS = $(SRCS:.c=.o) flite_voice_list.o
++OBJS = $(SRCS:.c=.o)
+ FILES = Makefile $(SRCS)
+ LOCAL_INCLUDES = 
+@@ -47,8 +47,9 @@
+       $(BINDIR)/flite$(EXEEXT) \
+       $(BINDIR)/t2p$(EXEEXT) $(BINDIR)/compile_regexes$(EXEEXT) \
+-      flite_voice_list.c each $(EXTRABINS)
++      $(EXTRABINS)
+ 
+ VOICES=$(VOXES)
+ VOICELIBS=$(VOICES:%=flite_%)
++VOICEEXES=$(VOICES:%=${BINDIR}/flite_%)
+ 
+ flite_LIBS = $(VOICELIBS) $(LANGS:%=flite_%) $(LEXES:%=flite_%) flite
+@@ -76,5 +77,4 @@
+ 
+ ifdef SHFLAGS
+-flite_LIBS_flags += -Wl,-rpath $(LIBDIR) 
+ shared_libs: $(SHAREDLIBS)
+ else
+@@ -82,9 +82,9 @@
+ endif
+ 
+-$(BINDIR)/flite$(EXEEXT): flite_main.o $(flite_LIBS_deps)
++flite_voice_list.c:
+ 	$(TOP)/tools/make_voice_list $(VOICES)
+-	rm -f flite_voice_list.o
+-	$(MAKE) flite_voice_list.o
+-	$(CC) $(CFLAGS) -o $@ flite_main.o flite_voice_list.o $(flite_LIBS_flags) $(LDFLAGS)
++
++$(BINDIR)/flite$(EXEEXT): flite_main.o flite_voice_list.c $(flite_LIBS_deps)
++	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ flite_main.o flite_voice_list.c $(flite_LIBS_flags) $(LDFLAGS)
+ 
+ $(BINDIR)/flite_time$(EXEEXT): flite_time_main.o $(flite_time_LIBS_deps)
+@@ -98,15 +98,12 @@
+ 	$(CC) $(CFLAGS) -o $@ compile_regexes.o $(FLITELIBFLAGS) $(LDFLAGS)
+ 
+-each:
+-	@ for i in $(VOICES) ; \
+-	do \
+-	   $(MAKE) VOICE=$$i $(BINDIR)/flite_$$i ; \
+-	done
++each:	${VOICEEXES}
++
++voice_list_%.c: $(TOP)/tools/make_voice_list
++	$(TOP)/tools/make_voice_list -o $@
+ 
+-$(BINDIR)/flite_${VOICE}: flite_main.o $(flite_LIBS_deps)
+-	$(TOP)/tools/make_voice_list $(VOICE)
+-	rm -f flite_voice_list.o
+-	$(MAKE) flite_voice_list.o
+-	$(CC) $(CFLAGS) -o $@ flite_main.o flite_voice_list.o $(flite_LIBS_flags) $(LDFLAGS)
++$(BINDIR)/flite_%: voice_list_%.c flite_main.o $(flite_LIBS_deps)
++	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ flite_main.o voice_list_$*.c \
++	    $(filter-out -lflite_cmu_%,${flite_LIBS_flags}) -lflite_$* $(LDFLAGS)
+ 
+ install:

Added: head/audio/flite/files/patch-single-exe
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/audio/flite/files/patch-single-exe	Tue Dec  2 07:01:40 2014	(r373754)
@@ -0,0 +1,66 @@
+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;


More information about the svn-ports-head mailing list