kumquat-buildroot/package/erlang/erlang.mk

114 lines
3.5 KiB
Makefile
Raw Normal View History

################################################################################
#
# erlang
#
################################################################################
ERLANG_VERSION = 26.0.2
package/erlang: do not hard-code the Erlang Interface Version (EI_VSN) The note above the erlang version instructs to refer to another note further down the file. However, even if it is not too difficult to find, it is still located a bit too far away, and the reference is not very explicit what note we should look at. When we introduced that variable in 6c1d128844c5 (package/erlang: export EI_VSN so other packages can use it), the rationale for hard-coding it was "to avoid spawning a shell every time the variable is dereferenced". However, that can get a bit confusing and hard to follow. Also, that in fact spawns a shell only once for each rebar-packages, so the overhead is far from being too high. The EI_VSN is only used by rebar-package packages, is derefrenced from the rebar-infra and not the packages themselves, and is not needed by erlang itself (it knows its own EI_VSN), so we can de-hard-code it, and rely on build-time detection, by looking in the appropriate file. We have two files where we could look: - lib/erl_interface/vsn.mk in the erlang source tree, but it is not installed, - .../lib/erlang/releases/$(ERLANG_RELASE)/installed_application_versions as installed by erlang. We use the second one, as it is cleaner, for a package, to look into installed files, rather than to look in the source tree of another package. Although both the host and target erlang are the same, we still look into the corresponding file to extract the version. This is so that it would be easier if in the future we ever manage to rely on a system-installed erlang that could have a EI_VSN different from the target one. We can't re-use the variable ERLANG_EI_VSN, because it now needs to be $(call)-ed with a parameter. Hopefully, external packages that use it directly rather than through the rebar infra, are not legion... Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Will Newton <will.newton@gmail.com> Cc: Johan Oudinet <johan.oudinet@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-02-10 22:55:48 +01:00
ERLANG_RELEASE = $(firstword $(subst ., ,$(ERLANG_VERSION)))
ERLANG_SITE = \
https://github.com/erlang/otp/releases/download/OTP-$(ERLANG_VERSION)
ERLANG_SOURCE = otp_src_$(ERLANG_VERSION).tar.gz
ERLANG_DEPENDENCIES = host-erlang
ERLANG_LICENSE = Apache-2.0
ERLANG_LICENSE_FILES = LICENSE.txt
ERLANG_CPE_ID_VENDOR = erlang
ERLANG_CPE_ID_PRODUCT = erlang\/otp
ERLANG_INSTALL_STAGING = YES
define ERLANG_FIX_AUTOCONF_VERSION
$(SED) "s/USE_AUTOCONF_VERSION=.*/USE_AUTOCONF_VERSION=$(AUTOCONF_VERSION)/" $(@D)/otp_build
endef
# Patched erts/aclocal.m4
define ERLANG_RUN_AUTOCONF
cd $(@D) && PATH=$(BR_PATH) ./otp_build update_configure --no-commit
endef
ERLANG_DEPENDENCIES += host-autoconf
ERLANG_PRE_CONFIGURE_HOOKS += \
ERLANG_FIX_AUTOCONF_VERSION \
ERLANG_RUN_AUTOCONF
HOST_ERLANG_DEPENDENCIES += host-autoconf
HOST_ERLANG_PRE_CONFIGURE_HOOKS += \
ERLANG_FIX_AUTOCONF_VERSION \
ERLANG_RUN_AUTOCONF
package/erlang: fix detection of libatomic_ops For some platforms, hardware-assisted compare-and-swap may not be available, so libatomic_ops will not provide it. However, libatomic_ops can provide a purely software CAS emulation, but must be instructed to do so. erlang just forgot to tell libatomic_ops that it does require CAS. Fix that by defining AO_REQUIRE_CAS before including atmoic_ops.h, like is done in libunwind, as pointed out by Thomas. Also, erlang has a convoluted, mind-alterating set on aclocal.m4 macros, that just forgets to link against -latomic_ops when checking CAS is available, so that even if CAS is available, configure chokes. Since I would like to keep the little sanity I still have, just force linking with -latomic_ops. This is useless when the check is natrally sucessful (i.e. on platforms where CAS is available in HW), but we would eventually link with -latomic_ops there, too; it's just redundant. Overall, just consider that erlang requires libatomic_ops, so forcibly depend on it, it is easier than trying to disable it. We can revisit that whenever someone wants to run erlang on a platform for which there is no libatomic_ops support. Fixes a slew of autobuild ARM failures: http://autobuild.buildroot.org/results/e7b/e7bfc4893dea6b133f0794ef44d50ad89bcb6662/ http://autobuild.buildroot.org/results/3e9/3e9c307f1ec6536482641019dcaa94677f7267a3/ http://autobuild.buildroot.org/results/a85/a85ca414e5b67af46510abd7b610eb5ae8661de4/ [...] [Thomas: fix minor typos in commit log, add dependency on BR2_PACKAGE_LIBATOMIC_ARCH_SUPPORTS to the Erlang comment about thread and shared library dependency.] Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Frank Hunleth <fhunleth@troodon-software.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-01-04 15:17:14 +01:00
package/erlang: do not hard-code the Erlang Interface Version (EI_VSN) The note above the erlang version instructs to refer to another note further down the file. However, even if it is not too difficult to find, it is still located a bit too far away, and the reference is not very explicit what note we should look at. When we introduced that variable in 6c1d128844c5 (package/erlang: export EI_VSN so other packages can use it), the rationale for hard-coding it was "to avoid spawning a shell every time the variable is dereferenced". However, that can get a bit confusing and hard to follow. Also, that in fact spawns a shell only once for each rebar-packages, so the overhead is far from being too high. The EI_VSN is only used by rebar-package packages, is derefrenced from the rebar-infra and not the packages themselves, and is not needed by erlang itself (it knows its own EI_VSN), so we can de-hard-code it, and rely on build-time detection, by looking in the appropriate file. We have two files where we could look: - lib/erl_interface/vsn.mk in the erlang source tree, but it is not installed, - .../lib/erlang/releases/$(ERLANG_RELASE)/installed_application_versions as installed by erlang. We use the second one, as it is cleaner, for a package, to look into installed files, rather than to look in the source tree of another package. Although both the host and target erlang are the same, we still look into the corresponding file to extract the version. This is so that it would be easier if in the future we ever manage to rely on a system-installed erlang that could have a EI_VSN different from the target one. We can't re-use the variable ERLANG_EI_VSN, because it now needs to be $(call)-ed with a parameter. Hopefully, external packages that use it directly rather than through the rebar infra, are not legion... Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Will Newton <will.newton@gmail.com> Cc: Johan Oudinet <johan.oudinet@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-02-10 22:55:48 +01:00
# Return the EIV (Erlang Interface Version, EI_VSN)
# $(1): base directory, i.e. either $(HOST_DIR) or $(STAGING_DIR)/usr
erlang_ei_vsn = `sed -r -e '/^erl_interface-(.+)/!d; s//\1/' $(1)/lib/erlang/releases/$(ERLANG_RELEASE)/installed_application_versions`
# The configure checks for these functions fail incorrectly
ERLANG_CONF_ENV = ac_cv_func_isnan=yes ac_cv_func_isinf=yes
# Set erl_xcomp variables. See xcomp/erl-xcomp.conf.template
# for documentation.
ERLANG_CONF_ENV += erl_xcomp_sysroot=$(STAGING_DIR)
ERLANG_CONF_OPTS = --without-javac
# Force ERL_TOP to the downloaded source directory. This prevents
# Erlang's configure script from inadvertantly using files from
# a version of Erlang installed on the host.
ERLANG_CONF_ENV += ERL_TOP=$(@D)
HOST_ERLANG_CONF_ENV += ERL_TOP=$(@D)
# erlang uses openssl for all things crypto. Since the host tools (such as
# rebar) uses crypto, we need to build host-erlang with support for openssl.
HOST_ERLANG_DEPENDENCIES += host-openssl
HOST_ERLANG_CONF_OPTS = --without-javac --with-ssl=$(HOST_DIR)
HOST_ERLANG_CONF_OPTS += --without-termcap
ifeq ($(BR2_PACKAGE_NCURSES),y)
ERLANG_CONF_OPTS += --with-termcap
ERLANG_DEPENDENCIES += ncurses
else
ERLANG_CONF_OPTS += --without-termcap
endif
ifeq ($(BR2_PACKAGE_OPENSSL),y)
ERLANG_CONF_OPTS += --with-ssl
ERLANG_DEPENDENCIES += openssl
else
ERLANG_CONF_OPTS += --without-ssl
endif
ifeq ($(BR2_PACKAGE_UNIXODBC),y)
ERLANG_DEPENDENCIES += unixodbc
ERLANG_CONF_OPTS += --with-odbc
else
ERLANG_CONF_OPTS += --without-odbc
endif
# Always use Buildroot's zlib
ERLANG_CONF_OPTS += --disable-builtin-zlib
ERLANG_DEPENDENCIES += zlib
# Remove source, example, gs and wx files from staging and target.
ERLANG_REMOVE_PACKAGES = gs wx
ifneq ($(BR2_PACKAGE_ERLANG_MEGACO),y)
ERLANG_REMOVE_PACKAGES += megaco
endif
define ERLANG_REMOVE_STAGING_UNUSED
for package in $(ERLANG_REMOVE_PACKAGES); do \
rm -rf $(STAGING_DIR)/usr/lib/erlang/lib/$${package}-*; \
done
endef
define ERLANG_REMOVE_TARGET_UNUSED
find $(TARGET_DIR)/usr/lib/erlang -type d -name src -prune -exec rm -rf {} \;
find $(TARGET_DIR)/usr/lib/erlang -type d -name examples -prune -exec rm -rf {} \;
for package in $(ERLANG_REMOVE_PACKAGES); do \
rm -rf $(TARGET_DIR)/usr/lib/erlang/lib/$${package}-*; \
done
endef
ERLANG_POST_INSTALL_STAGING_HOOKS += ERLANG_REMOVE_STAGING_UNUSED
ERLANG_POST_INSTALL_TARGET_HOOKS += ERLANG_REMOVE_TARGET_UNUSED
$(eval $(autotools-package))
$(eval $(host-autotools-package))