From 69710addd121a18ff662c5a6dcb1d8f329f39d69 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Wed, 7 Feb 2024 23:51:00 +0100 Subject: [PATCH] package/swipl: new package SWI-Prolog offers a comprehensive free Prolog environment. Since its start in 1987, SWI-Prolog development has been driven by the needs of real world applications. SWI-Prolog is widely used in research and education as well as commercial applications. Signed-off-by: Julien Olivain Signed-off-by: Thomas Petazzoni --- DEVELOPERS | 3 +++ package/Config.in | 1 + package/swipl/Config.in | 43 +++++++++++++++++++++++++++++++ package/swipl/swipl.hash | 4 +++ package/swipl/swipl.mk | 55 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+) create mode 100644 package/swipl/Config.in create mode 100644 package/swipl/swipl.hash create mode 100644 package/swipl/swipl.mk diff --git a/DEVELOPERS b/DEVELOPERS index 76f7fc5ed6..90c34e51f5 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1818,6 +1818,7 @@ F: package/python-pyalsa/ F: package/python-spake2/ F: package/rdma-core/ F: package/riscv-isa-sim/ +F: package/swipl/ F: package/tig/ F: package/tinycompress/ F: package/z3/ @@ -1962,6 +1963,8 @@ F: support/testing/tests/package/test_sox.py F: support/testing/tests/package/test_sqlite.py F: support/testing/tests/package/test_strace.py F: support/testing/tests/package/test_stress_ng.py +F: support/testing/tests/package/test_swipl.py +F: support/testing/tests/package/test_swipl/ F: support/testing/tests/package/test_tcl.py F: support/testing/tests/package/test_tcl/ F: support/testing/tests/package/test_tcpdump.py diff --git a/package/Config.in b/package/Config.in index 2ac351cce5..0d51c6af1e 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1476,6 +1476,7 @@ endmenu endif source "package/quickjs/Config.in" source "package/ruby/Config.in" + source "package/swipl/Config.in" source "package/tcl/Config.in" if BR2_PACKAGE_TCL menu "Tcl libraries/modules" diff --git a/package/swipl/Config.in b/package/swipl/Config.in new file mode 100644 index 0000000000..84b6ace47f --- /dev/null +++ b/package/swipl/Config.in @@ -0,0 +1,43 @@ +# swipl supports arch for which libc fenv.h provides all four macros: +# FE_DOWNWARD, FE_TONEAREST, FE_TOWARDZERO, FE_UPWARD +# See for example in glibc https://sourceware.org/git/glibc.git +# git grep -E '^[[:space:]]*#[[:space:]]*define[[:space:]]+FE_(TONEAREST|UPWARD|DOWNWARD|TOWARDZERO)' sysdeps/ +config BR2_PACKAGE_SWIPL_ARCH_SUPPORTS + bool + default y if BR2_aarch64 || BR2_aarch64_be + default y if BR2_arceb || BR2_arcle + default y if BR2_arm || BR2_armeb + default y if BR2_i386 + default y if BR2_m68k + # BR2_microblaze has only FE_TONEAREST + default y if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el + # BR2_nios2 has only FE_TONEAREST + default y if BR2_or1k + default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le + default y if BR2_riscv + default y if BR2_s390x + # BR2_sh has only FE_{TONEAREST,TOWARDZERO} + default y if BR2_sparc || BR2_sparc64 + default y if BR2_x86_64 + # BR2_xtensa supports only uclibc which does not have fenv.h + +config BR2_PACKAGE_SWIPL + bool "swipl" + depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 # __has_attribute() + depends on BR2_PACKAGE_SWIPL_ARCH_SUPPORTS + # swipl needs fenv.h which is not provided by uclibc + depends on !BR2_TOOLCHAIN_USES_UCLIBC + select BR2_PACKAGE_ZLIB + help + SWI-Prolog offers a comprehensive free Prolog + environment. Since its start in 1987, SWI-Prolog development + has been driven by the needs of real world + applications. SWI-Prolog is widely used in research and + education as well as commercial applications. + + https://www.swi-prolog.org + +comment "swipl needs a glibc or musl toolchain w/ gcc >= 5" + depends on BR2_PACKAGE_SWIPL_ARCH_SUPPORTS + depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5 || \ + BR2_TOOLCHAIN_USES_UCLIBC diff --git a/package/swipl/swipl.hash b/package/swipl/swipl.hash new file mode 100644 index 0000000000..9f980654ba --- /dev/null +++ b/package/swipl/swipl.hash @@ -0,0 +1,4 @@ +# From https://www.swi-prolog.org/download/stable +sha256 10d90b15734d14d0d7972dc11a3584defd300d65a9f0b1185821af8c3896da5e swipl-9.2.0.tar.gz +# Locally calculated +sha256 770594d0f4463b71f1485f00e4bc5cf4b6f667d62ef6bc9bde2fee236541992a LICENSE diff --git a/package/swipl/swipl.mk b/package/swipl/swipl.mk new file mode 100644 index 0000000000..d4263a6aa8 --- /dev/null +++ b/package/swipl/swipl.mk @@ -0,0 +1,55 @@ +################################################################################ +# +# swipl +# +################################################################################ + +SWIPL_VERSION = 9.2.0 +SWIPL_SITE = https://www.swi-prolog.org/download/stable/src +SWIPL_LICENSE = BSD-2-Clause +SWIPL_LICENSE_FILES = LICENSE + +SWIPL_DEPENDENCIES = host-swipl zlib + +# A host-swipl is needed to compile the target prolog boot +# boot.prl file. +HOST_SWIPL_CONF_OPTS = \ + -DBUILD_PDF_DOCUMENTATION=OFF \ + -DSWIPL_PACKAGES=OFF \ + -DUSE_GMP=OFF \ + -DUSE_TCMALLOC=OFF + +# swipl uses cmake macros try_run() and check_c_source_runs(), which +# are not suitable for cross compilation. We add results in cache to +# avoid running those tests. The SWIPL_NATIVE_FRIEND variable, is +# meant to point to build directory of a host native swipl, rather +# than the binary itself. The Cmake macro will append "src/swipl" to +# the path set to this variable. Therefore, we cannot use the host +# "swipl" binary installed in $(HOST_DIR)/usr/bin. +SWIPL_CONF_OPTS = \ + -DBUILD_PDF_DOCUMENTATION=OFF \ + -DHAVE_WEAK_ATTRIBUTE=1 \ + -DLLROUND_OK=1 \ + -DMODF_OK=1 \ + -DQSORT_R_GNU=1 \ + -DSWIPL_NATIVE_FRIEND=$(HOST_SWIPL_SRCDIR) \ + -DSWIPL_PACKAGES=OFF \ + -DUSE_TCMALLOC=OFF + +ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y) +SWIPL_CONF_OPTS += -DCMAKE_EXE_LINKER_FLAGS=-latomic +endif + +ifeq ($(BR2_PACKAGE_GMP),y) +SWIPL_CONF_OPTS += -DUSE_GMP=ON +SWIPL_DEPENDENCIES += gmp +else +SWIPL_CONF_OPTS += -DUSE_GMP=OFF +endif + +ifeq ($(BR2_PACKAGE_NCURSES),y) +SWIPL_DEPENDENCIES += ncurses +endif + +$(eval $(cmake-package)) +$(eval $(host-cmake-package))