espeak: add support for static builds
PATCH 1/1 espeak: add support for static builds
Currently espeak fails to build statically because its Makefile builds a shared binary and a shared library (among other things) by default. This is the error message:
---------------------------------------------------
/br/output/host/usr/bin/mipsel-linux-g++ -static -shared
-Wl,-soname,libespeak.so.1 -o libespeak.so \
x_speak_lib.o x_compiledict.o x_dictionary.o x_intonation.o
x_readclause.o x_setlengths.o x_numbers.o x_synth_mbrola.o x_synthdata.o
x_synthesize.o x_translate.o x_mbrowrap.o x_tr_languages.o x_voices.o
x_wavegen.o x_phonemelist.o x_espeak_command.o x_event.o x_fifo.o
x_wave.o x_debug.o x_klatt.o x_sonic.o -lstdc++ -lpthread /br/output/host/opt/ext-toolchain/bin/../lib/gcc/mipsel-buildroot-linux-uclibc/4.8.3/../../../../mipsel-buildroot-linux-uclibc/bin/ld:
/br/output/host/opt/ext-toolchain/bin/../lib/gcc/mipsel-buildroot-linux-uclibc/4.8.3/crtbeginT.o:
relocation R_MIPS_HI16 against `a local symbol' can not be used when
making a shared object; recompile with -fPIC /br/output/host/opt/ext-toolchain/bin/../lib/gcc/mipsel-buildroot-linux-uclibc/4.8.3/crtbeginT.o:
could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[1]: *** [libespeak.so] Error 1
---------------------------------------------------
espeak builds four things: a static binary (speak), a static library (libespeak.a), a shared binary (espeak) and a shared library (libespeak.so.1.1.48). The static binary is the same as the shared binary plus the shared library, so we can rewrite the logic of espeak.mk and install the static binary when BR2_STATIC_LIBS is set, and the shared binary and shared library otherwise, which is the default behavior of the Makefile.
Related:
http://sourceforge.net/p/espeak/mailman/message/33512484/
Fixes:
http://autobuild.buildroot.net/results/15b/15b33c97ce7268db96d2e04b8fffd64c19c41d66/
--- package/espeak/espeak.mk | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-)
package/espeak/espeak.mk +21 -2
@@ -33,11 +33,30 @@ endef define ESPEAK_BUILD_CMDS $(MAKE) -C $(@D)/src $(TARGET_CONFIGURE_OPTS) \ - AUDIO="$(ESPEAK_AUDIO_BACKEND)" all + AUDIO="$(ESPEAK_AUDIO_BACKEND)" \ + $(if $(BR2_STATIC_LIBS),speak,all) endef +ifeq ($(BR2_STATIC_LIBS),y) define ESPEAK_INSTALL_TARGET_CMDS - $(MAKE) -C $(@D)/src DESTDIR="$(TARGET_DIR)" install + # Install speak executable + $(INSTALL) -D -m 755 $(@D)/src/speak $(TARGET_DIR)/usr/bin + # Install data files + mkdir -p $(TARGET_DIR)/usr/share/espeak-data + cp -prf $(@D)/espeak-data/* $(TARGET_DIR)/usr/share/espeak-data endef +else +define ESPEAK_INSTALL_TARGET_CMDS + # Install espeak executable + $(INSTALL) -D -m 755 $(@D)/src/espeak $(TARGET_DIR)/usr/bin + # Install shared library + $(INSTALL) -D -m 755 $(@D)/src/libespeak.so.1.$(ESPEAK_VERSION_MAJOR) $(TARGET_DIR)/usr/lib + ln -sf libespeak.so.1.$(ESPEAK_VERSION_MAJOR) $(TARGET_DIR)/usr/lib/libespeak.so.1 + ln -sf libespeak.so.1 $(TARGET_DIR)/usr/lib/libespeak.so + # Install data files + mkdir -p $(TARGET_DIR)/usr/share/espeak-data + cp -prf $(@D)/espeak-data/* $(TARGET_DIR)/usr/share/espeak-data +endef +endif $(eval $(generic-package))
Signature · 1 line
1.7.1
PATCH 1/1 espeak: add support for static builds
Dear Vicente Olivert Riera,
package/espeak/espeak.mk endef · line 37
Quoted 5 lines · Vicente Olivert Riera
define
ESPEAK_BUILD_CMDSpackage/espeak/espeak.mk +2
-1$(MAKE) -C $(@D)/src $(TARGET_CONFIGURE_OPTS) \ - AUDIO="$(ESPEAK_AUDIO_BACKEND)" all + AUDIO="$(ESPEAK_AUDIO_BACKEND)" \ + $(if $(BR2_STATIC_LIBS),speak,all)
This does not work quite well: in shared scenarios, espeak is building four things:
* the espeak binary
* the speak binary
* the libespeak.a static library
* the libespeak.so shared library
Now, with your change, in static scenarios, you're only building the "speak" binary. The "espeak" binary is no longer built, and neither is the libespeak.a static library.
In such cases, if someone is really interested in being able to support static-only build, that someone should work with upstream a proper patch to make that possible, and then add support in Buildroot. I don't think espeak is a very likely candidate for use in static-only environments, so it's not worse the additional mess in Buildroot.
I've committed a patch that disables espeak when BR2_STATIC_LIBS is enabled, and marked your patch as Rejected in patchwork.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com