dev-libs/leatherman: 1.12.0 stable amd64/x86 with cleanup
[gentoo.git] / dev-libs / openssl-compat / openssl-compat-0.9.8z_p8-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # this ebuild is only for the libcrypto.so.0.9.8 and libssl.so.0.9.8 SONAME for ABI compat
5
6 EAPI="6"
7
8 inherit eutils flag-o-matic toolchain-funcs multilib multilib-minimal
9
10 #PLEVEL=$(printf "\\$(printf '%03o' $((${PV##*_p} + 96)))")
11 PLEVEL='h' # _p8 -> tr '[1-9]' '[a-i]' -> 'h'
12 MY_PV=${PV/_p*/${PLEVEL}}
13 MY_P=openssl-${MY_PV}
14 S="${WORKDIR}/${MY_P}"
15 DESCRIPTION="Toolkit for SSL v2/v3 and TLS v1"
16 HOMEPAGE="https://www.openssl.org/"
17 SRC_URI="mirror://openssl/source/${MY_P}.tar.gz"
18
19 LICENSE="openssl"
20 SLOT="0.9.8"
21 KEYWORDS="~alpha amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc x86"
22 IUSE="bindist gmp kerberos cpu_flags_x86_sse2 test zlib"
23 RESTRICT="!bindist? ( bindist )
24         test"
25
26 RDEPEND="gmp? ( >=dev-libs/gmp-5.1.3-r1[${MULTILIB_USEDEP}] )
27         zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
28         kerberos? ( >=app-crypt/mit-krb5-1.11.4[${MULTILIB_USEDEP}] )
29         !=dev-libs/openssl-0.9.8*:0
30         !dev-libs/openssl:0.9.8"
31 DEPEND="${RDEPEND}
32         >=dev-lang/perl-5
33         test? (
34                 sys-apps/diffutils
35                 sys-devel/bc
36         )"
37
38 # Do not install any docs
39 DOCS=()
40
41 PATCHES=(
42         "${FILESDIR}"/openssl-0.9.8e-bsd-sparc64.patch
43         "${FILESDIR}"/openssl-0.9.8h-ldflags.patch #181438
44         "${FILESDIR}"/openssl-0.9.8m-binutils.patch #289130
45         "${FILESDIR}"/openssl-0.9.8z_p8-perl-5.26.patch
46 )
47
48 src_prepare() {
49         default
50
51         # disable fips in the build
52         # make sure the man pages are suffixed #302165
53         # don't bother building man pages if they're disabled
54         sed -i \
55                 -e '/DIRS/s: fips : :g' \
56                 -e '/^MANSUFFIX/s:=.*:=ssl:' \
57                 -e '/^MAKEDEPPROG/s:=.*:=$(CC):' \
58                 -e $(has noman FEATURES \
59                         && echo '/^install:/s:install_docs::' \
60                         || echo '/^MANDIR=/s:=.*:=/usr/share/man:') \
61                 Makefile{,.org} \
62                 || die
63         # show the actual commands in the log
64         sed -i '/^SET_X/s:=.*:=set -x:' Makefile.shared || die
65         # update the enginedir path.
66         # punt broken config we don't care about as it fails sanity check.
67         sed -i \
68                 -e '/^"debug-ben-debug-64"/d' \
69                 -e "/foo.*engines/s|/lib/engines|/$(get_libdir)/engines|" \
70                 Configure || die
71
72         # since we're forcing $(CC) as makedep anyway, just fix
73         # the conditional as always-on
74         # helps clang (#417795), and versioned gcc (#499818)
75         sed -i 's/expr.*MAKEDEPEND.*;/true;/' util/domd || die
76
77         # quiet out unknown driver argument warnings since openssl
78         # doesn't have well-split CFLAGS and we're making it even worse
79         # and 'make depend' uses -Werror for added fun (#417795 again)
80         [[ ${CC} == *clang* ]] && append-flags -Qunused-arguments
81
82         # allow openssl to be cross-compiled
83         cp "${FILESDIR}"/gentoo.config-0.9.8 gentoo.config || die "cp cross-compile failed"
84         chmod a+rx gentoo.config || die
85
86         append-flags -fno-strict-aliasing
87         append-flags -Wa,--noexecstack
88
89         sed -i '1s,^:$,#!/usr/bin/perl,' Configure || die #141906
90         sed -i '/^"debug-bodo/d' Configure || die # 0.9.8za shipped broken
91         ./config --test-sanity || die "I AM NOT SANE"
92
93         multilib_copy_sources
94 }
95
96 multilib_src_configure() {
97         unset APPS #197996
98         unset SCRIPTS #312551
99
100         tc-export CC AR RANLIB
101
102         # Clean out patent-or-otherwise-encumbered code
103         # Camellia: Royalty Free            https://en.wikipedia.org/wiki/Camellia_(cipher)
104         # IDEA:     Expired                 https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm
105         # EC:       ????????? ??/??/2015    https://en.wikipedia.org/wiki/Elliptic_Curve_Cryptography
106         # MDC2:     Expired                 https://en.wikipedia.org/wiki/MDC-2
107         # RC5:      5,724,428 03/03/2015    https://en.wikipedia.org/wiki/RC5
108
109         use_ssl() { use $1 && echo "enable-${2:-$1} ${*:3}" || echo "no-${2:-$1}" ; }
110         echoit() { echo "$@" ; "$@" ; }
111
112         local krb5=$(has_version app-crypt/mit-krb5 && echo "MIT" || echo "Heimdal")
113
114         local sslout=$(./gentoo.config)
115         einfo "Use configuration ${sslout:-(openssl knows best)}"
116         local config="Configure"
117         [[ -z ${sslout} ]] && config="config"
118
119         echoit \
120         ./${config} \
121                 ${sslout} \
122                 $(use cpu_flags_x86_sse2 || echo "no-sse2") \
123                 enable-camellia \
124                 $(use_ssl !bindist ec) \
125                 enable-idea \
126                 enable-mdc2 \
127                 $(use_ssl !bindist rc5) \
128                 enable-tlsext \
129                 $(use_ssl gmp gmp -lgmp) \
130                 $(use_ssl kerberos krb5 --with-krb5-flavor=${krb5}) \
131                 $(use_ssl zlib) \
132                 --prefix=/usr \
133                 --openssldir=/etc/ssl \
134                 shared threads \
135                 || die "Configure failed"
136
137         # Clean out hardcoded flags that openssl uses
138         local CFLAG=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
139                 -e 's:^CFLAG=::' \
140                 -e 's:-fomit-frame-pointer ::g' \
141                 -e 's:-O[0-9] ::g' \
142                 -e 's:-march=[-a-z0-9]* ::g' \
143                 -e 's:-mcpu=[-a-z0-9]* ::g' \
144                 -e 's:-m[a-z0-9]* ::g' \
145         )
146         sed -i \
147                 -e "/^LIBDIR=/s|=.*|=$(get_libdir)|" \
148                 -e "/^CFLAG/s|=.*|=${CFLAG} ${CFLAGS}|" \
149                 -e "/^SHARED_LDFLAGS=/s|$| ${LDFLAGS}|" \
150                 Makefile || die
151 }
152
153 multilib_src_compile() {
154         # depend is needed to use $confopts
155         emake -j1 depend
156         emake -j1 build_libs
157 }
158
159 multilib_src_test() {
160         emake -j1 test
161 }
162
163 multilib_src_install() {
164         dolib.so lib{crypto,ssl}.so.0.9.8
165 }