|
| 1 | +# Copyright 1999-2022 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=7 |
| 5 | +WX_GTK_VER="3.0-gtk3" |
| 6 | + |
| 7 | +inherit elisp-common flag-o-matic java-pkg-opt-2 systemd toolchain-funcs wxwidgets |
| 8 | + |
| 9 | +# NOTE: If you need symlinks for binaries please tell maintainers or |
| 10 | +# open up a bug to let it be created. |
| 11 | + |
| 12 | +UPSTREAM_V="$(ver_cut 1-2)" |
| 13 | + |
| 14 | +DESCRIPTION="Erlang programming language, runtime environment and libraries (OTP)" |
| 15 | +HOMEPAGE="https://www.erlang.org/" |
| 16 | +SRC_URI="https://github.com/erlang/otp/archive/OTP-${PV}.tar.gz -> ${P}.tar.gz |
| 17 | + https://github.com/erlang/otp/releases/download/OTP-${UPSTREAM_V}/otp_doc_man_${UPSTREAM_V}.tar.gz -> ${PN}_doc_man_${UPSTREAM_V}.tar.gz |
| 18 | + doc? ( https://github.com/erlang/otp/releases/download/OTP-${UPSTREAM_V}/otp_doc_html_${UPSTREAM_V}.tar.gz -> ${PN}_doc_html_${UPSTREAM_V}.tar.gz )" |
| 19 | + |
| 20 | +LICENSE="Apache-2.0" |
| 21 | +# We use this subslot because Compiled HiPE Code can be loaded on the exact |
| 22 | +# same build of ERTS that was used when compiling the code. See |
| 23 | +# http://erlang.org/doc/system_principles/misc.html for more information. |
| 24 | +SLOT="0/${PV}" |
| 25 | +KEYWORDS="amd64 ~arm ~arm64 ~hppa ~ia64 ppc ppc64 ~riscv sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris" |
| 26 | +IUSE="doc emacs java +kpoll odbc sctp ssl systemd tk wxwidgets" |
| 27 | + |
| 28 | +RDEPEND=" |
| 29 | + acct-group/epmd |
| 30 | + acct-user/epmd |
| 31 | + sys-libs/ncurses:0 |
| 32 | + sys-libs/zlib |
| 33 | + emacs? ( >=app-editors/emacs-23.1:* ) |
| 34 | + java? ( >=virtual/jdk-1.8:* ) |
| 35 | + odbc? ( dev-db/unixODBC ) |
| 36 | + sctp? ( net-misc/lksctp-tools ) |
| 37 | + ssl? ( >=dev-libs/openssl-0.9.7d:0= ) |
| 38 | + systemd? ( sys-apps/systemd ) |
| 39 | + wxwidgets? ( x11-libs/wxGTK:${WX_GTK_VER}[X,opengl] ) |
| 40 | +" |
| 41 | +DEPEND="${RDEPEND} |
| 42 | + dev-lang/perl |
| 43 | +" |
| 44 | + |
| 45 | +S="${WORKDIR}/otp-OTP-${PV}" |
| 46 | + |
| 47 | +PATCHES=( |
| 48 | + "${FILESDIR}"/${PN}-22.0-dont-ignore-LDFLAGS.patch |
| 49 | + "${FILESDIR}"/${PN}-24.0.2-serial-configure.patch |
| 50 | +) |
| 51 | + |
| 52 | +SITEFILE=50"${PN}"-gentoo.el |
| 53 | + |
| 54 | +src_prepare() { |
| 55 | + default |
| 56 | + |
| 57 | + tc-export AR CPP CXX LD |
| 58 | + |
| 59 | + # bug #797886: erlang's VM does unsafe casts for ints |
| 60 | + # to pointers and back. This breaks on gcc-11 -flto. |
| 61 | + append-flags -fno-strict-aliasing |
| 62 | +} |
| 63 | + |
| 64 | +src_configure() { |
| 65 | + use wxwidgets && setup-wxwidgets |
| 66 | + |
| 67 | + local myconf=( |
| 68 | + --disable-builtin-zlib |
| 69 | + |
| 70 | + # don't search for static zlib |
| 71 | + --with-ssl-zlib=no |
| 72 | + |
| 73 | + $(use_enable kpoll kernel-poll) |
| 74 | + $(use_with java javac) |
| 75 | + $(use_enable sctp) |
| 76 | + $(use_with ssl ssl) |
| 77 | + $(use_enable ssl dynamic-ssl-lib) |
| 78 | + $(use_enable systemd) |
| 79 | + $(usex wxwidgets "--with-wx-config=${WX_CONFIG}" "--with-wxdir=/dev/null") |
| 80 | + ) |
| 81 | + econf "${myconf[@]}" |
| 82 | +} |
| 83 | + |
| 84 | +src_compile() { |
| 85 | + emake |
| 86 | + |
| 87 | + if use emacs ; then |
| 88 | + pushd lib/tools/emacs &>/dev/null || die |
| 89 | + elisp-compile *.el |
| 90 | + popd &>/dev/null || die |
| 91 | + fi |
| 92 | +} |
| 93 | + |
| 94 | +extract_version() { |
| 95 | + local path="$1" |
| 96 | + local var_name="$2" |
| 97 | + sed -n -e "/^${var_name} = \(.*\)$/s::\1:p" "${S}/${path}/vsn.mk" || die "extract_version() failed" |
| 98 | +} |
| 99 | + |
| 100 | +src_install() { |
| 101 | + local erl_libdir_rel="$(get_libdir)/erlang" |
| 102 | + local erl_libdir="/usr/${erl_libdir_rel}" |
| 103 | + local erl_interface_ver="$(extract_version lib/erl_interface EI_VSN)" |
| 104 | + local erl_erts_ver="$(extract_version erts VSN)" |
| 105 | + local my_manpath="/usr/share/${PN}/man" |
| 106 | + |
| 107 | + [[ -z "${erl_erts_ver}" ]] && die "Couldn't determine erts version" |
| 108 | + [[ -z "${erl_interface_ver}" ]] && die "Couldn't determine interface version" |
| 109 | + |
| 110 | + emake INSTALL_PREFIX="${D}" install |
| 111 | + |
| 112 | + if use doc ; then |
| 113 | + # Note: we explicitly install docs into: |
| 114 | + # /usr/share/doc/${PF}/{doc,lib,erts-*} |
| 115 | + # To maintain that layout we gather everything in 'html-docs'. |
| 116 | + # See bug #684376. |
| 117 | + mkdir html-docs || die |
| 118 | + mv "${WORKDIR}"/doc "${WORKDIR}"/lib "${WORKDIR}"/erts-* html-docs/ || die |
| 119 | + local DOCS=( "AUTHORS" "HOWTO"/* "README.md" "CONTRIBUTING.md" html-docs/. ) |
| 120 | + docompress -x /usr/share/doc/${PF} |
| 121 | + else |
| 122 | + local DOCS=("README.md") |
| 123 | + fi |
| 124 | + |
| 125 | + einstalldocs |
| 126 | + |
| 127 | + dosym "../${erl_libdir_rel}/bin/erl" /usr/bin/erl |
| 128 | + dosym "../${erl_libdir_rel}/bin/erlc" /usr/bin/erlc |
| 129 | + dosym "../${erl_libdir_rel}/bin/escript" /usr/bin/escript |
| 130 | + dosym "../${erl_libdir_rel}/lib/erl_interface-${erl_interface_ver}/bin/erl_call" /usr/bin/erl_call |
| 131 | + dosym "../${erl_libdir_rel}/erts-${erl_erts_ver}/bin/beam.smp" /usr/bin/beam.smp |
| 132 | + |
| 133 | + ## Clean up the no longer needed files |
| 134 | + rm "${ED}/${erl_libdir}/Install" || die |
| 135 | + |
| 136 | + insinto "${my_manpath}" |
| 137 | + doins -r "${WORKDIR}"/man/* |
| 138 | + # extend MANPATH, so the normal man command can find it |
| 139 | + # see bug 189639 |
| 140 | + newenvd - "90erlang" <<-_EOF_ |
| 141 | + MANPATH="${my_manpath}" |
| 142 | + _EOF_ |
| 143 | + |
| 144 | + if use emacs ; then |
| 145 | + elisp-install erlang lib/tools/emacs/*.{el,elc} |
| 146 | + sed -e "s:/usr/share:${EPREFIX}/usr/share:g" \ |
| 147 | + "${FILESDIR}/${SITEFILE}" > "${T}/${SITEFILE}" || die |
| 148 | + elisp-site-file-install "${T}/${SITEFILE}" |
| 149 | + fi |
| 150 | + |
| 151 | + newinitd "${FILESDIR}"/epmd.init-r2 epmd |
| 152 | + newconfd "${FILESDIR}"/epmd.confd-r2 epmd |
| 153 | + use systemd && systemd_newunit "${FILESDIR}"/epmd.service-r1 epmd.service |
| 154 | +} |
| 155 | + |
| 156 | +pkg_postinst() { |
| 157 | + use emacs && elisp-site-regen |
| 158 | +} |
| 159 | + |
| 160 | +pkg_postrm() { |
| 161 | + use emacs && elisp-site-regen |
| 162 | +} |
0 commit comments