|
| 1 | +# -*- mode: sh-script; mode: ebuild; -*- |
| 2 | +# Copyright 1999-2024 Gentoo Authors |
| 3 | +# Distributed under the terms of the GNU General Public License v2 or later. |
| 4 | + |
| 5 | +EAPI=8 |
| 6 | + |
| 7 | +CHECKREQS_MEMORY="2G" |
| 8 | +LLVM_COMPAT=( {15..18} ) |
| 9 | + |
| 10 | +inherit check-reqs edo flag-o-matic llvm-r1 multiprocessing ninja-utils toolchain-funcs |
| 11 | + |
| 12 | +# Dependencies are in two groups: (1) a minimal set which are spec'd in |
| 13 | +# this ebuild and must be pre-installed, and (2) an additional set which |
| 14 | +# are obtained by the build scripts. |
| 15 | +# |
| 16 | +# Version N.N.N is a normal release. All necessary sources are wrapped |
| 17 | +# up in a tarball, including the additional dependencies but not the |
| 18 | +# minimal ebuild set. |
| 19 | +# |
| 20 | +# Version 9999 is the standard Gentoo "live ebuild" (git HEAD). The |
| 21 | +# minimal set of dependencies must already be installed, the Clasp |
| 22 | +# sources will be pulled down via git in this ebuild, and then the build |
| 23 | +# scripts will pull down the additional set of dependencies, also via |
| 24 | +# git. |
| 25 | + |
| 26 | +if [ ${PV} = "9999" ]; then |
| 27 | + EGIT_REPO_URI="https://github.com/clasp-developers/clasp" |
| 28 | + EGIT_BRANCH="main" |
| 29 | + # The app build script will git the dependencies not in BDEPEND. |
| 30 | + EGIT_MIN_CLONE_TYPE="shallow" |
| 31 | + inherit git-r3 |
| 32 | + SLOT="0" |
| 33 | +else |
| 34 | + SRC_URI="https://github.com/clasp-developers/clasp/releases/download/${PV}/${P}.tar.gz" |
| 35 | + KEYWORDS="~amd64" |
| 36 | + SLOT="0/${PV}" |
| 37 | +fi |
| 38 | + |
| 39 | +DESCRIPTION="Common Lisp implementation based on LLVM." |
| 40 | +HOMEPAGE="https://github.com/clasp-developers/clasp" |
| 41 | +# Primary Clasp and core ECL (src/lisp/kernel/lsp) are LGPL-2+, |
| 42 | +# Parts of Clasp are MIT. |
| 43 | +# MPS is Sleepycat, |
| 44 | +# src/lisp/kernel/clos is LGPL-2+, |
| 45 | +# src/lisp/kernel/lsp/loop2.lisp is MIT, |
| 46 | +# src/lisp/kernel/lsp/{pprint,format}.lisp are Public Domain by CMU, |
| 47 | +# src/lisp/kernel/clos is LGPL-2+ |
| 48 | +LICENSE="LGPL-2+ Sleepycat MIT public-domain" |
| 49 | + |
| 50 | +IUSE="+bcfaso" |
| 51 | + |
| 52 | +# Clasp needs llvm's libunwind, but runs OK without the Portage |
| 53 | +# sys-devel/llvm-libunwind being installed. (Or even an "unwind" |
| 54 | +# lib anywhere in installed llvm tree.) Don't question it, |
| 55 | +# it's magic. |
| 56 | + |
| 57 | +RDEPEND="sys-devel/binutils:= |
| 58 | + $(llvm_gen_dep ' |
| 59 | + sys-devel/clang:${LLVM_SLOT}= |
| 60 | + sys-devel/llvm:${LLVM_SLOT}= |
| 61 | + sys-devel/lld:${LLVM_SLOT}= |
| 62 | + ') |
| 63 | + dev-libs/boost:= |
| 64 | + >=dev-libs/libfmt-7.1.0 |
| 65 | + >=dev-libs/gmp-6.0.0[cxx] |
| 66 | + virtual/pkgconfig |
| 67 | + virtual/libelf:=" |
| 68 | +DEPEND="${RDEPEND}" |
| 69 | +BDEPEND="app-alternatives/ninja |
| 70 | + dev-lisp/sbcl" |
| 71 | +[ "${PV}" = "2.6.0" ] && BDEPEND+=" dev-util/ctags" |
| 72 | +IDEPEND="app-alternatives/ninja |
| 73 | + dev-lisp/sbcl" |
| 74 | + |
| 75 | +RESTRICT="strip" |
| 76 | + |
| 77 | +DOCS=( |
| 78 | + CONTRIBUTING.md |
| 79 | + README.md |
| 80 | + RELEASE_NOTES.md |
| 81 | + SECURITY.md |
| 82 | +) |
| 83 | +MANDOCS=( docs/clasp.1 ) |
| 84 | + |
| 85 | +pkg_pretend() { |
| 86 | + if [ "${PV}" = "9999" ]; then |
| 87 | + ewarn "This live ebuild is incompatible with make.conf FEATURE 'network-sandbox'." |
| 88 | + ewarn "The koga/ninja build script downloads additional C++ and Common Lisp" |
| 89 | + ewarn "dependencies by internally calling git, without going through ebuild" |
| 90 | + ewarn "helpers. network-sandbox intentionally prevents all such access." |
| 91 | + ewarn "See https://wiki.gentoo.org/wiki/Sandbox_(Portage)" |
| 92 | + ewarn " https://bugs.gentoo.org/691472" |
| 93 | + fi |
| 94 | +} |
| 95 | + |
| 96 | +src_unpack() { |
| 97 | + [ -n "${EGIT_REPO_URI}" ] && git-r3_src_unpack |
| 98 | + default |
| 99 | +} |
| 100 | + |
| 101 | +src_configure() { |
| 102 | + # Get job count from MAKEOPTS '-j' flag. Use for Lisp builds and Ninja. |
| 103 | + export CLASP_BUILD_JOBS=$(get_makeopts_jobs) |
| 104 | + |
| 105 | + strip-unsupported-flags |
| 106 | + # Clasp needs un-stripped binaries. |
| 107 | + filter-flags -Wl,-s |
| 108 | + filter-ldflags -s |
| 109 | + # Clasp build scripts set -fno-omit-fpointer where its needed. |
| 110 | + |
| 111 | + # Set up paths to LLVM components. |
| 112 | + llvm-r1_pkg_setup |
| 113 | + |
| 114 | + local myconf=( |
| 115 | + --ldflags="${LDFLAGS}" |
| 116 | + --jobs=${CLASP_BUILD_JOBS} |
| 117 | + --reproducible |
| 118 | + --build-path="${S}/build" |
| 119 | + --prefix="${EPREFIX}/usr" |
| 120 | + --bin-path="${EPREFIX}/usr/bin" |
| 121 | + --lib-path="${EPREFIX}/usr/$(get_libdir)/${PF}" |
| 122 | + --share-path="${EPREFIX}/usr/share/${PF}" |
| 123 | + --pkg-config=$(tc-getPKG_CONFIG) |
| 124 | + --ld="lld" |
| 125 | + --lisp=sbcl # Upstream really, really prefers SBCL |
| 126 | + ) |
| 127 | + |
| 128 | + # Yes, we get a pkgcheck VariableScope warning on {ED}, |
| 129 | + # Unfortunately, the Clasp koga script creates all of the ninja |
| 130 | + # scripts at src_configure time, and the generated scripts have no |
| 131 | + # provision for looking at DESTDIR at install time. This config |
| 132 | + # setting only affects the install-time script, and seems to be the |
| 133 | + # least-fragile way to handle it. |
| 134 | + myconf+=( --package-path="${ED}" ) |
| 135 | + |
| 136 | + # All needed sources are bundled in release tarballs |
| 137 | + [ "${PV}" != "9999" ] && myconf+=( --skip-sync ) |
| 138 | + |
| 139 | + use bcfaso && myconf+=( --build-mode=bytecode-faso ) |
| 140 | + |
| 141 | + edo ./koga "${myconf[@]}" |
| 142 | +} |
| 143 | + |
| 144 | +src_compile() { |
| 145 | + edob eninja -C "${S}/build" |
| 146 | +} |
| 147 | + |
| 148 | +src_test() { |
| 149 | + # False positives from backtrace tests |
| 150 | + #eninja -C "${S}/build" test |
| 151 | + edo "${S}/build/boehmprecise/clasp" --norc --disable-debugger --non-interactive \ |
| 152 | + --eval '(ext:quit (if (eql (* 6 7) 42) 0 1))' |
| 153 | +} |
| 154 | + |
| 155 | +src_install() { |
| 156 | + eninja -C "${S}/build" install |
| 157 | + dodoc ${DOCS[@]} |
| 158 | + dodoc -r licenses |
| 159 | + [ -e "${MANDOCS}" ] && doman ${MANDOCS[@]} |
| 160 | +} |
0 commit comments