dev-qt/qtx11extras: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / dev-libs / openssl-compat / openssl-compat-1.0.2u-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="7"
5
6 inherit flag-o-matic toolchain-funcs multilib multilib-minimal
7
8 # openssl-1.0.2-patches-1.6 contain additional CVE patches
9 # which got fixed with this release.
10 # Please use 1.7 version number when rolling a new tarball!
11 PATCH_SET="openssl-1.0.2-patches-1.5"
12
13 MY_P=openssl-${PV/_/-}
14
15 # This patch set is based on the following files from Fedora 25,
16 # see https://src.fedoraproject.org/rpms/openssl/blob/25/f/openssl.spec
17 # for more details:
18 # - hobble-openssl (SOURCE1)
19 # - ec_curve.c (SOURCE12) -- MODIFIED
20 # - ectest.c (SOURCE13)
21 # - openssl-1.1.1-ec-curves.patch (PATCH37) -- MODIFIED
22 BINDIST_PATCH_SET="openssl-1.0.2t-bindist-1.0.tar.xz"
23
24 DESCRIPTION="full-strength general purpose cryptography library (including SSL and TLS)"
25 HOMEPAGE="https://www.openssl.org/"
26 SRC_URI="mirror://openssl/source/${MY_P}.tar.gz
27         bindist? (
28                 mirror://gentoo/${BINDIST_PATCH_SET}
29                 https://dev.gentoo.org/~whissi/dist/openssl/${BINDIST_PATCH_SET}
30         )
31         !vanilla? (
32                 mirror://gentoo/${PATCH_SET}.tar.xz
33                 https://dev.gentoo.org/~chutzpah/dist/openssl/${PATCH_SET}.tar.xz
34                 https://dev.gentoo.org/~whissi/dist/openssl/${PATCH_SET}.tar.xz
35                 https://dev.gentoo.org/~polynomial-c/dist/${PATCH_SET}.tar.xz
36         )
37         https://dev.gentoo.org/~whissi/dist/openssl/openssl-compat-1.0.2u-versioned-symbols.patch.gz"
38
39 LICENSE="openssl"
40 SLOT="1.0.0"
41 KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc x86 ~x86-linux"
42 IUSE="+asm bindist gmp kerberos rfc3779 sctp cpu_flags_x86_sse2 sslv2 +sslv3 static-libs test +tls-heartbeat vanilla zlib"
43
44 RESTRICT="!bindist? ( bindist )
45         test"
46
47 RDEPEND="gmp? ( >=dev-libs/gmp-5.1.3-r1[static-libs(+)?,${MULTILIB_USEDEP}] )
48         kerberos? ( >=app-crypt/mit-krb5-1.11.4[${MULTILIB_USEDEP}] )
49         zlib? ( >=sys-libs/zlib-1.2.8-r1[static-libs(+)?,${MULTILIB_USEDEP}] )
50         !=dev-libs/openssl-1.0.2*:0
51         !dev-libs/openssl:1.0.0"
52 DEPEND="${RDEPEND}"
53 BDEPEND="
54         >=dev-lang/perl-5
55         sctp? ( >=net-misc/lksctp-tools-1.0.12 )
56         test? (
57                 sys-apps/diffutils
58                 sys-devel/bc
59         )"
60
61 # Do not install any docs
62 DOCS=()
63
64 S="${WORKDIR}/${MY_P}"
65
66 MULTILIB_WRAPPED_HEADERS=(
67         usr/include/openssl/opensslconf.h
68 )
69
70 src_prepare() {
71         mv "${WORKDIR}"/openssl-compat-1.0.2u-versioned-symbols.patch "${WORKDIR}"/patch || die
72
73         if use bindist; then
74                 mv "${WORKDIR}"/bindist-patches/hobble-openssl "${WORKDIR}" || die
75                 bash "${WORKDIR}"/hobble-openssl || die
76
77                 cp -f "${WORKDIR}"/bindist-patches/ec_curve.c "${S}"/crypto/ec/ || die
78                 cp -f "${WORKDIR}"/bindist-patches/ectest.c "${S}"/crypto/ec/ || die
79
80                 eapply "${WORKDIR}"/bindist-patches/ec-curves.patch
81
82                 # Also see the configure parts below:
83                 # enable-ec \
84                 # $(use_ssl !bindist ec2m) \
85                 # $(use_ssl !bindist srp) \
86         fi
87
88         # keep this in sync with app-misc/c_rehash
89         SSL_CNF_DIR="/etc/ssl"
90
91         # Make sure we only ever touch Makefile.org and avoid patching a file
92         # that gets blown away anyways by the Configure script in src_configure
93         rm -f Makefile
94
95         if ! use vanilla ; then
96                 eapply "${WORKDIR}"/patch/*.patch
97         fi
98
99         eapply_user
100
101         # disable fips in the build
102         # make sure the man pages are suffixed #302165
103         # don't bother building man pages if they're disabled
104         sed -i \
105                 -e '/DIRS/s: fips : :g' \
106                 -e '/^MANSUFFIX/s:=.*:=ssl:' \
107                 -e '/^MAKEDEPPROG/s:=.*:=$(CC):' \
108                 -e $(has noman FEATURES \
109                         && echo '/^install:/s:install_docs::' \
110                         || echo '/^MANDIR=/s:=.*:='${EPREFIX}'/usr/share/man:') \
111                 Makefile.org \
112                 || die
113         # show the actual commands in the log
114         sed -i '/^SET_X/s:=.*:=set -x:' Makefile.shared
115
116         # since we're forcing $(CC) as makedep anyway, just fix
117         # the conditional as always-on
118         # helps clang (#417795), and versioned gcc (#499818)
119         # this breaks build with 1.0.2p, not sure if it is needed anymore
120         #sed -i 's/expr.*MAKEDEPEND.*;/true;/' util/domd || die
121
122         # quiet out unknown driver argument warnings since openssl
123         # doesn't have well-split CFLAGS and we're making it even worse
124         # and 'make depend' uses -Werror for added fun (#417795 again)
125         [[ ${CC} == *clang* ]] && append-flags -Qunused-arguments
126
127         # allow openssl to be cross-compiled
128         cp "${FILESDIR}"/gentoo.config-1.0.2 gentoo.config || die
129         chmod a+rx gentoo.config || die
130
131         append-flags -fno-strict-aliasing
132         append-flags $(test-flags-CC -Wa,--noexecstack)
133         append-cppflags -DOPENSSL_NO_BUF_FREELISTS
134
135         sed -i '1s,^:$,#!'${EPREFIX}'/usr/bin/perl,' Configure #141906
136         # The config script does stupid stuff to prompt the user.  Kill it.
137         sed -i '/stty -icanon min 0 time 50; read waste/d' config || die
138         ./config --test-sanity || die "I AM NOT SANE"
139
140         multilib_copy_sources
141 }
142
143 multilib_src_configure() {
144         unset APPS #197996
145         unset SCRIPTS #312551
146         unset CROSS_COMPILE #311473
147
148         tc-export CC AR RANLIB RC
149
150         # Clean out patent-or-otherwise-encumbered code
151         # Camellia: Royalty Free            https://en.wikipedia.org/wiki/Camellia_(cipher)
152         # IDEA:     Expired                 https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm
153         # EC:       ????????? ??/??/2015    https://en.wikipedia.org/wiki/Elliptic_Curve_Cryptography
154         # MDC2:     Expired                 https://en.wikipedia.org/wiki/MDC-2
155         # RC5:      Expired                 https://en.wikipedia.org/wiki/RC5
156
157         use_ssl() { usex $1 "enable-${2:-$1}" "no-${2:-$1}" " ${*:3}" ; }
158         echoit() { echo "$@" ; "$@" ; }
159
160         local krb5=$(has_version app-crypt/mit-krb5 && echo "MIT" || echo "Heimdal")
161
162         # See if our toolchain supports __uint128_t.  If so, it's 64bit
163         # friendly and can use the nicely optimized code paths. #460790
164         local ec_nistp_64_gcc_128
165         # Disable it for now though #469976
166         #if ! use bindist ; then
167         #       echo "__uint128_t i;" > "${T}"/128.c
168         #       if ${CC} ${CFLAGS} -c "${T}"/128.c -o /dev/null >&/dev/null ; then
169         #               ec_nistp_64_gcc_128="enable-ec_nistp_64_gcc_128"
170         #       fi
171         #fi
172
173         # https://github.com/openssl/openssl/issues/2286
174         if use ia64 ; then
175                 replace-flags -g3 -g2
176                 replace-flags -ggdb3 -ggdb2
177         fi
178
179         local sslout=$(./gentoo.config)
180         einfo "Use configuration ${sslout:-(openssl knows best)}"
181         local config="Configure"
182         [[ -z ${sslout} ]] && config="config"
183
184         # Fedora hobbled-EC needs 'no-ec2m', 'no-srp'
185         # Make sure user flags don't get added *yet* to avoid duplicated
186         # flags.
187         CFLAGS= LDFLAGS= echoit \
188         ./${config} \
189                 ${sslout} \
190                 $(use cpu_flags_x86_sse2 || echo "no-sse2") \
191                 enable-camellia \
192                 enable-ec \
193                 $(use_ssl !bindist ec2m) \
194                 $(use_ssl !bindist srp) \
195                 ${ec_nistp_64_gcc_128} \
196                 enable-idea \
197                 enable-mdc2 \
198                 enable-rc5 \
199                 enable-tlsext \
200                 $(use_ssl asm) \
201                 $(use_ssl gmp gmp -lgmp) \
202                 $(use_ssl kerberos krb5 --with-krb5-flavor=${krb5}) \
203                 $(use_ssl rfc3779) \
204                 $(use_ssl sctp) \
205                 $(use_ssl sslv2 ssl2) \
206                 $(use_ssl sslv3 ssl3) \
207                 $(use_ssl tls-heartbeat heartbeats) \
208                 $(use_ssl zlib) \
209                 --prefix="${EPREFIX}"/usr \
210                 --openssldir="${EPREFIX}"${SSL_CNF_DIR} \
211                 --libdir=$(get_libdir) \
212                 shared threads \
213                 || die
214
215         # Clean out hardcoded flags that openssl uses
216         local DEFAULT_CFLAGS=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
217                 -e 's:^CFLAG=::' \
218                 -e 's:\(^\| \)-fomit-frame-pointer::g' \
219                 -e 's:\(^\| \)-O[^ ]*::g' \
220                 -e 's:\(^\| \)-march=[^ ]*::g' \
221                 -e 's:\(^\| \)-mcpu=[^ ]*::g' \
222                 -e 's:\(^\| \)-m[^ ]*::g' \
223                 -e 's:^ *::' \
224                 -e 's: *$::' \
225                 -e 's: \+: :g' \
226                 -e 's:\\:\\\\:g'
227         )
228
229         # Now insert clean default flags with user flags
230         sed -i \
231                 -e "/^CFLAG/s|=.*|=${DEFAULT_CFLAGS} ${CFLAGS}|" \
232                 -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" \
233                 Makefile || die
234 }
235
236 multilib_src_compile() {
237         # depend is needed to use $confopts; it also doesn't matter
238         # that it's -j1 as the code itself serializes subdirs
239         emake -j1 V=1 depend
240         emake build_libs
241 }
242
243 multilib_src_test() {
244         emake -j1 test
245 }
246
247 multilib_src_install() {
248         dolib.so lib{crypto,ssl}.so.${SLOT}
249 }