Skip to content
Permalink
Browse files

espeak: Fix library install name and other fixes

Use the makefile portgroup so that MacPorts CFLAGS, CXXFLAGS, and
LDFLAGS are respected and a universal variant is created.

Adjust description and long description.

Compute and use a branch variable in master_sites instead of hardcoding
it.

Remove distfile name from checksums since there is only one distfile.

Specify C++98 mode because the build fails in C++11 mode on newer
compilers.

Fix test phase by specifying DYLD_LIBRARY_PATH and ESPEAK_DATA_PATH so
that we're testing the just-built software not the already-installed
software.

Fix livecheck by removing livecheck overrides; the defaults work.

Fix patchfile to use most Macisms conditionally.
Fix patchfile to use -dynamiclib on macOS instead of -shared.
Fix patchfile to set the full path for the library install name.
Fix patchfile to not override CXXFLAGS.
Fix patchfile to not hardcode -lstdc++.

See #7507
  • Loading branch information
ryandesign committed Jun 26, 2020
1 parent 94a38e2 commit d9b027b58574a9a9b6a5f204153144ef8a58aa9f
Showing with 68 additions and 42 deletions.
  1. +18 −20 audio/espeak/Portfile
  2. +50 −22 audio/espeak/files/patch-espeak-mac.diff
@@ -1,27 +1,28 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup makefile 1.0

name espeak
version 1.48.04
revision 0
revision 1
categories audio
platforms darwin
maintainers nomaintainer
license GPL-3+

description eSpeak is a compact open source software speech synthesizer
description compact open source software speech synthesizer

long_description eSpeak is a Text to Speech engine for English and many other\
languages. Compact size with clear but artificial pronunciation.\
Available as a command-line program with many options and a shared library
Available as a command-line program with many options and as a shared library.

homepage http://espeak.sourceforge.net/
master_sites sourceforge:project/espeak/espeak/espeak-1.48
set branch [join [lrange [split ${version} .] 0 1] .]
master_sites sourceforge:project/espeak/espeak/espeak-${branch}
distname ${name}-${version}-source
use_zip yes
checksums ${distname}${extract.suffix} \
rmd160 95f45d86c86756c3bd3b359aaba3c844f4a1c23c \
checksums rmd160 95f45d86c86756c3bd3b359aaba3c844f4a1c23c \
sha256 bf9a17673adffcc28ff7ea18764f06136547e97bbd9edf2ec612f09b207f0659 \
size 3019245

@@ -32,33 +33,30 @@ if {${os.platform} eq "darwin" && ${os.major} >= 10} {
configure.args-append --with-mictype=portaudio
}

use_configure no
compiler.cxx_standard 1998
configure.cxxflags-append -std=c++98

build.dir ${worksrcpath}/src
build.args PREFIX=${prefix} DATADIR=${prefix}/share/espeak-data \
CC=${configure.cc} \
CXX=${configure.cxx} \
CPP=${configure.cpp}

destroot.args PREFIX=${prefix} DATADIR=${prefix}/share/espeak-data
makefile.override PREFIX

build.args DATADIR=${prefix}/share/espeak-data
destroot.args {*}${build.args}

set docdir ${prefix}/share/doc/${name}

post-destroot {
move ${worksrcpath}/docs ${destroot}${docdir}
xinstall -m 644 -W ${worksrcpath} \
xinstall -m 0644 -W ${worksrcpath} \
ReadMe \
ChangeLog.txt \
License.txt \
${destroot}${docdir}
system -W ${destroot}${prefix} \
"install_name_tool -change libespeak.dylib ${prefix}/lib/libespeak.dylib ./bin/espeak"
}

test.run yes
test.cmd ${worksrcpath}/src/espeak
test.cmd DYLD_LIBRARY_PATH=${build.dir} \
ESPEAK_DATA_PATH=${worksrcpath} \
./espeak
test.target
test.args "Testing." -w out.wav

livecheck.type regex
livecheck.url http://sourceforge.net/projects/${name}/releases/rss
livecheck.regex <title>${name}.* - (\[0-9.a-z\-\]+)</title>
@@ -1,36 +1,65 @@
diff -ruEN orig/Makefile src/Makefile
--- orig/Makefile 2020-06-25 22:03:43.000000000 +0700
+++ src/Makefile 2020-06-25 22:02:50.000000000 +0700
@@ -10,13 +10,13 @@
--- src/Makefile.orig 2014-02-02 04:58:11.000000000 -0600
+++ src/Makefile 2020-06-26 14:18:27.000000000 -0500
@@ -10,13 +10,24 @@
RELEASE = 1.48
BIN_NAME = speak
BIN2_NAME = espeak
-LIB_NAME = libespeak.so
+UNAME_S := $(shell uname -s)
+ifeq ($(UNAME_S),Darwin)
+LIB_NAME = libespeak.dylib
+else
LIB_NAME = libespeak.so
+endif
STATIC_LIB_NAME = libespeak.a
LIB_VERSION = 1
LIBTAG = $(LIB_VERSION).$(RELEASE)

# Use SONAME_OPT=-Wl,h, on Solaris
-SONAME_OPT=-Wl,-soname,
+SONAME_OPT=-Wl,-install_name,
+ifeq ($(UNAME_S),Darwin)
+SHARED_OPT=-dynamiclib
+SONAME_OPT=-Wl,-install_name,$(LIBDIR)/
+else
+SHARED_OPT=-shared
SONAME_OPT=-Wl,-soname,
+endif

# Use EXTRA_LIBS=-lm on Solaris
EXTRA_LIBS =
@@ -114,11 +114,8 @@
@@ -83,17 +94,16 @@

SRCS1=$(speak_SOURCES)
OBJS1=$(patsubst %.cpp,%.o,$(SRCS1))
-LIBS1=-lstdc++ $(LIB_AUDIO) -lpthread $(EXTRA_LIBS)
+LIBS1=$(LIB_AUDIO) -lpthread $(EXTRA_LIBS)

SRCS2=$(libespeak_SOURCES)
OBJS2=$(patsubst %.cpp,x_%.o,$(SRCS2))
-LIBS2=-lstdc++ $(LIB_AUDIO) -lpthread
+LIBS2=$(LIB_AUDIO) -lpthread

SRCS3 = espeak.cpp
OBJS3=$(patsubst %.cpp,%.o,$(SRCS3))
-LIBS3=-lstdc++ -L . -lespeak
+LIBS3=-L . -lespeak

-CXXFLAGS=-O2


all: $(BIN_NAME) $(LIB_NAME) $(STATIC_LIB_NAME) $(BIN2_NAME)
@@ -114,11 +124,8 @@
-I. -D LIBRARY -c -fno-exceptions $< -o x_$*.o

$(LIB_NAME): $(OBJS2)
- $(CXX) $(LDFLAGS) -shared $(SONAME_OPT)$(LIB_NAME).$(LIB_VERSION) -o $@ \
+ $(CXX) $(LDFLAGS) -shared $(SONAME_OPT)$(LIB_NAME) -o $@ \
+ $(CXX) $(LDFLAGS) $(SHARED_OPT) $(SONAME_OPT)$(LIB_NAME) -o $@ \
$(OBJS2) $(LIBS2)
- mv $(LIB_NAME) $(LIB_NAME).$(LIBTAG)
- $(LN_SF) $(LIB_NAME).$(LIBTAG) $(LIB_NAME).$(LIB_VERSION)
- $(LN_SF) $(LIB_NAME).$(LIB_VERSION) $(LIB_NAME)

$(STATIC_LIB_NAME): $(OBJS2)
$(AR) cqs $(STATIC_LIB_NAME) $(OBJS2)
@@ -138,14 +135,14 @@
@@ -138,14 +145,14 @@
$(MKDIR) $(DESTDIR)$(LIBDIR)
$(MKDIR) $(DESTDIR)$(INCDIR)
$(MKDIR) $(DESTDIR)$(DATADIR)
@@ -48,9 +77,8 @@ diff -ruEN orig/Makefile src/Makefile
# Install development headers
$(INSTALL) -pm 644 speak_lib.h $(DESTDIR)$(INCDIR)
# Install data files
diff -ruEN orig/portaudio.h src/portaudio.h
--- orig/portaudio.h 2020-06-25 22:03:43.000000000 +0700
+++ src/portaudio.h 2020-06-25 22:25:46.000000000 +0700
--- src/portaudio.h.orig 2014-03-04 10:47:15.000000000 -0600
+++ src/portaudio.h 2020-06-26 14:07:39.000000000 -0500
@@ -1,21 +1,14 @@
-// NOTE: Copy this file to portaudio.h in order to compile with V18 portaudio
-
@@ -1463,21 +1491,21 @@ diff -ruEN orig/portaudio.h src/portaudio.h
#endif /* __cplusplus */
-#endif /* PORT_AUDIO_H */
+#endif /* PORTAUDIO_H */
diff -ruEN orig/speech.h src/speech.h
--- orig/speech.h 2020-06-25 22:03:43.000000000 +0700
+++ src/speech.h 2020-06-23 13:38:50.000000000 +0700
@@ -47,7 +47,7 @@
--- src/speech.h.orig 2014-03-04 10:47:15.000000000 -0600
+++ src/speech.h 2020-06-26 14:16:48.000000000 -0500
@@ -47,8 +47,10 @@
//#define ESPEAK_API extern "C"

#ifdef LIBRARY
-#define USE_ASYNC
+//#define USE_ASYNC
+#ifndef __APPLE__
#define USE_ASYNC
#endif
+#endif

#ifdef _ESPEAKEDIT
diff -ruEN orig/synthdata.cpp src/synthdata.cpp
--- orig/synthdata.cpp 2020-06-25 22:03:43.000000000 +0700
+++ src/synthdata.cpp 2020-06-23 13:38:50.000000000 +0700
#define USE_PORTAUDIO
--- src/synthdata.cpp.orig 2014-03-04 10:47:15.000000000 -0600
+++ src/synthdata.cpp 2020-06-26 14:07:39.000000000 -0500
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"

1 comment on commit d9b027b

@danielbair

This comment has been minimized.

Copy link
Contributor

@danielbair danielbair commented on d9b027b Jun 27, 2020

Wow. I've learned a lot here. Thanks!

Please sign in to comment.
You can’t perform that action at this time.