dev-lang/erlang: amd64 stable wrt bug #717826
[gentoo.git] / dev-lang / erlang / erlang-22.3.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 WX_GTK_VER="3.0"
6
7 inherit elisp-common java-pkg-opt-2 systemd 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         http://erlang.org/download/otp_doc_man_${UPSTREAM_V}.tar.gz -> ${PN}_doc_man_${UPSTREAM_V}.tar.gz
18         doc? ( http://erlang.org/download/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 sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris"
26 IUSE="doc emacs +hipe java +kpoll libressl 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? (
38                 !libressl? ( >=dev-libs/openssl-0.9.7d:0= )
39                 libressl? ( dev-libs/libressl:0= )
40         )
41         systemd? ( sys-apps/systemd )
42         tk? ( dev-lang/tk:0 )
43         wxwidgets? ( x11-libs/wxGTK:${WX_GTK_VER}[X,opengl] )
44 "
45 DEPEND="${RDEPEND}
46         dev-lang/perl
47 "
48
49 S="${WORKDIR}/otp-OTP-${PV}"
50
51 PATCHES=(
52         "${FILESDIR}/18.2.1-wx3.0.patch"
53         "${FILESDIR}/${PN}-22.0-dont-ignore-LDFLAGS.patch"
54 )
55
56 SITEFILE=50"${PN}"-gentoo.el
57
58 src_prepare() {
59         default
60
61         ./otp_build autoconf || die
62 }
63
64 src_configure() {
65         use wxwidgets && setup-wxwidgets
66
67         local myconf=(
68                 --disable-builtin-zlib
69                 $(use_enable hipe)
70                 $(use_enable kpoll kernel-poll)
71                 $(use_with java javac)
72                 $(use_enable sctp)
73                 $(use_with ssl ssl "${EPREFIX}"/usr)
74                 $(use_enable ssl dynamic-ssl-lib)
75                 $(use_enable systemd)
76                 $(usex wxwidgets "--with-wx-config=${WX_CONFIG}" "--with-wxdir=/dev/null")
77         )
78         econf "${myconf[@]}"
79 }
80
81 src_compile() {
82         emake
83
84         if use emacs ; then
85                 pushd lib/tools/emacs &>/dev/null || die
86                 elisp-compile *.el
87                 popd &>/dev/null || die
88         fi
89 }
90
91 extract_version() {
92         local path="$1"
93         local var_name="$2"
94         sed -n -e "/^${var_name} = \(.*\)$/s::\1:p" "${S}/${path}/vsn.mk" || die "extract_version() failed"
95 }
96
97 src_install() {
98         local erl_libdir_rel="$(get_libdir)/erlang"
99         local erl_libdir="/usr/${erl_libdir_rel}"
100         local erl_interface_ver="$(extract_version lib/erl_interface EI_VSN)"
101         local erl_erts_ver="$(extract_version erts VSN)"
102         local my_manpath="/usr/share/${PN}/man"
103
104         [[ -z "${erl_erts_ver}" ]] && die "Couldn't determine erts version"
105         [[ -z "${erl_interface_ver}" ]] && die "Couldn't determine interface version"
106
107         emake INSTALL_PREFIX="${D}" install
108
109         if use doc ; then
110                 # Note: we explicitly install docs into:
111                 #     /usr/share/doc/${PF}/{doc,lib,erts-*}
112                 # To maintain that layout we gather everything in 'html-docs'.
113                 # See bug #684376.
114                 mkdir html-docs || die
115                 mv "${WORKDIR}"/doc "${WORKDIR}"/lib "${WORKDIR}"/erts-* html-docs/ || die
116                 local DOCS=( "AUTHORS" "HOWTO"/* "README.md" "CONTRIBUTING.md" html-docs/. )
117                 docompress -x /usr/share/doc/${PF}
118         else
119                 local DOCS=("README.md")
120         fi
121
122         einstalldocs
123
124         dosym "../${erl_libdir_rel}/bin/erl" /usr/bin/erl
125         dosym "../${erl_libdir_rel}/bin/erlc" /usr/bin/erlc
126         dosym "../${erl_libdir_rel}/bin/escript" /usr/bin/escript
127         dosym "../${erl_libdir_rel}/lib/erl_interface-${erl_interface_ver}/bin/erl_call" /usr/bin/erl_call
128         dosym "../${erl_libdir_rel}/erts-${erl_erts_ver}/bin/beam.smp" /usr/bin/beam.smp
129
130         ## Clean up the no longer needed files
131         rm "${ED}/${erl_libdir}/Install" || die
132
133         insinto "${my_manpath}"
134         doins -r "${WORKDIR}"/man/*
135         # extend MANPATH, so the normal man command can find it
136         # see bug 189639
137         newenvd - "90erlang" <<-_EOF_
138                 MANPATH="${my_manpath}"
139         _EOF_
140
141         if use emacs ; then
142                 elisp-install erlang lib/tools/emacs/*.{el,elc}
143                 sed -e "s:/usr/share:${EPREFIX}/usr/share:g" \
144                         "${FILESDIR}/${SITEFILE}" > "${T}/${SITEFILE}" || die
145                 elisp-site-file-install "${T}/${SITEFILE}"
146         fi
147
148         newinitd "${FILESDIR}"/epmd.init-r2 epmd
149         newconfd "${FILESDIR}"/epmd.confd-r2 epmd
150         use systemd && systemd_newunit "${FILESDIR}"/epmd.service-r1 epmd.service
151 }
152
153 pkg_postinst() {
154         use emacs && elisp-site-regen
155 }
156
157 pkg_postrm() {
158         use emacs && elisp-site-regen
159 }