kumquat-buildroot/package/tcl/tcl.mk
Julien Olivain 7af8dee3a8 package/tcl: add mandatory dependency to zlib
Tcl changed its zlib handling in upstream commit [1]. Before this
commit, the HAVE_ZLIB macro was defined only if a zlib headers/library
was found. After that commit, the HAVE_ZLIB macro is unconditionally
defined. The only change is that: if a working zlib library is found
in the toolchain sysroot, it is used. Otherwise, the package will use
a shipped version in [2]. See also [3] and [4].

This tcl commit is included in Buildroot since commit 7fda943b43
"tcl: bump to version 8.6.1".

In Buildroot, we prefer to not use bundled libraries wherever possible,
so add an unconditional dependency to zlib.

Further notes:

This behavior leads to runtime failures, when the package is compiled
with toolchains including zlib in their sysroot. This is because at
configuration time, the package will detect zlib in the sysroot and
link against it, but the library files won't be installed on target.

This happen to be the case with Bootlin toolchains such as [5], as they
also contaions gdbserver, and since 3341ceb1e5 (package/gdb: zlib is
mandatory, not optional), we also build zlib even if only gdbserver is
built (gdbserver does not use zlib, so that's a bug in our gdb
packaging).

This toolchain also happen to be the one used in basic configurations
of the runtime test infrastructure (this issue was found while
attempting to write a runtime test for tcl).

In such cases, running "tclsh" command fails with error message:

    tclsh: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

libtcl library also miss its dependency.

    ldd /usr/lib/libtcl8.6.so
	    libz.so.1 => not found
	    libm.so.6 => /lib/libm.so.6 (0xb6dad000)
	    libc.so.6 => /lib/libc.so.6 (0xb6c65000)
	    /lib/ld-linux.so.3 (0xb6f6c000)

[1] 6f3dea45ce
[2] https://github.com/tcltk/tcl/tree/core-8-6-13/compat/zlib
[3] https://github.com/tcltk/tcl/blob/core-8-6-13/unix/configure.in#L172
[4] https://github.com/tcltk/tcl/blob/core-8-6-13/unix/Makefile.in#L240
[5] https://toolchains.bootlin.com/downloads/releases/toolchains/armv5-eabi/tarballs/armv5-eabi--glibc--stable-2023.08-1.tar.bz2

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-09-17 15:27:01 +02:00

83 lines
2.5 KiB
Makefile

################################################################################
#
# tcl
#
################################################################################
TCL_VERSION_MAJOR = 8.6
TCL_VERSION = $(TCL_VERSION_MAJOR).13
TCL_SOURCE = tcl$(TCL_VERSION)-src.tar.gz
TCL_SITE = http://downloads.sourceforge.net/project/tcl/Tcl/$(TCL_VERSION)
TCL_LICENSE = TCL
TCL_LICENSE_FILES = license.terms
TCL_CPE_ID_VENDOR = tcl
TCL_SUBDIR = unix
TCL_INSTALL_STAGING = YES
TCL_AUTORECONF = YES
TCL_CONF_OPTS = \
--disable-symbols \
--disable-langinfo \
--disable-framework
HOST_TCL_CONF_OPTS = \
--disable-symbols \
--disable-langinfo \
--disable-framework
# I haven't found a good way to force pkgs to not build
# or configure without just removing the entire pkg directory.
define HOST_TCL_REMOVE_PACKAGES
rm -fr $(@D)/pkgs/sqlite3* $(@D)/pkgs/tdbc*
endef
HOST_TCL_PRE_CONFIGURE_HOOKS += HOST_TCL_REMOVE_PACKAGES
# We remove the bundled sqlite as we prefer to not use bundled stuff at all.
define TCL_REMOVE_PACKAGES
rm -fr $(@D)/pkgs/sqlite3* \
$(if $(BR2_PACKAGE_MYSQL),,$(@D)/pkgs/tdbcmysql*) \
$(@D)/pkgs/tdbcodbc* \
$(if $(BR2_PACKAGE_POSTGRESQL),,$(@D)/pkgs/tdbcpostgres*) \
$(if $(BR2_PACKAGE_SQLITE),,$(@D)/pkgs/tdbcsqlite3*)
endef
TCL_PRE_CONFIGURE_HOOKS += TCL_REMOVE_PACKAGES
ifeq ($(BR2_PACKAGE_TCL_DEL_ENCODINGS),y)
define TCL_REMOVE_ENCODINGS
rm -rf $(TARGET_DIR)/usr/lib/tcl$(TCL_VERSION_MAJOR)/encoding/*
endef
TCL_POST_INSTALL_TARGET_HOOKS += TCL_REMOVE_ENCODINGS
endif
ifeq ($(BR2_PACKAGE_TCL_SHLIB_ONLY),y)
define TCL_REMOVE_TCLSH
rm -f $(TARGET_DIR)/usr/bin/tclsh$(TCL_VERSION_MAJOR)
endef
TCL_POST_INSTALL_TARGET_HOOKS += TCL_REMOVE_TCLSH
else
define TCL_SYMLINK_TCLSH
ln -sf tclsh$(TCL_VERSION_MAJOR) $(TARGET_DIR)/usr/bin/tclsh
endef
TCL_POST_INSTALL_TARGET_HOOKS += TCL_SYMLINK_TCLSH
endif
# Until someone needs it, we don't handle locale installation. tcl has
# a complicated method of translating LANG-style locale names into its internal
# .msg name which makes it difficult to save the correct locales per the
# configured whitelist.
define TCL_REMOVE_EXTRA
rm -fr $(TARGET_DIR)/usr/lib/tclConfig.sh \
$(TARGET_DIR)/usr/lib/tclooConfig.sh \
$(TARGET_DIR)/usr/lib/tcl$(TCL_VERSION_MAJOR)/tclAppInit.c \
$(TARGET_DIR)/usr/lib/tcl$(TCL_VERSION_MAJOR)/msgs
endef
TCL_POST_INSTALL_TARGET_HOOKS += TCL_REMOVE_EXTRA
TCL_DEPENDENCIES = $(if $(BR2_PACKAGE_SQLITE),sqlite) \
$(if $(BR2_PACKAGE_MYSQL),mysql) \
$(if $(BR2_PACKAGE_POSTGRESQL),postgresql) \
zlib
$(eval $(autotools-package))
$(eval $(host-autotools-package))