blob: 8819e19ec47c1a1d384b20761aded413d2b54bae [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001SUMMARY = "Secure Socket Layer"
2DESCRIPTION = "Secure Socket Layer (SSL) binary and related cryptographic tools."
3HOMEPAGE = "http://www.openssl.org/"
4BUGTRACKER = "http://www.openssl.org/news/vulnerabilities.html"
5SECTION = "libs/network"
6
7# "openssl" here actually means both OpenSSL and SSLeay licenses apply
8# (see meta/files/common-licenses/OpenSSL to which "openssl" is SPDXLICENSEMAPped)
9LICENSE = "openssl"
10LIC_FILES_CHKSUM = "file://LICENSE;md5=d343e62fc9c833710bbbed25f27364c8"
11
12DEPENDS = "hostperl-runtime-native"
13
14SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
15 file://run-ptest \
16 file://0001-skip-test_symbol_presence.patch \
17 file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \
18 file://afalg.patch \
Brad Bishop19323692019-04-05 15:28:33 -040019 "
20
21SRC_URI_append_class-nativesdk = " \
22 file://environment.d-openssl.sh \
23 "
24
Brad Bishopa34c0302019-09-23 22:34:48 -040025SRC_URI[md5sum] = "3be209000dbc7e1b95bcdf47980a3baa"
26SRC_URI[sha256sum] = "1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2"
Brad Bishop19323692019-04-05 15:28:33 -040027
Brad Bishop96ff1982019-08-19 13:50:42 -040028inherit lib_package multilib_header multilib_script ptest
29MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash"
Brad Bishop19323692019-04-05 15:28:33 -040030
31PACKAGECONFIG ?= ""
32PACKAGECONFIG_class-native = ""
33PACKAGECONFIG_class-nativesdk = ""
34
35PACKAGECONFIG[cryptodev-linux] = "enable-devcryptoeng,disable-devcryptoeng,cryptodev-linux"
36
37B = "${WORKDIR}/build"
38do_configure[cleandirs] = "${B}"
39
40#| ./libcrypto.so: undefined reference to `getcontext'
41#| ./libcrypto.so: undefined reference to `setcontext'
42#| ./libcrypto.so: undefined reference to `makecontext'
43EXTRA_OECONF_append_libc-musl = " no-async"
44EXTRA_OECONF_append_libc-musl_powerpc64 = " no-asm"
45
Brad Bishopa34c0302019-09-23 22:34:48 -040046# adding devrandom prevents openssl from using getrandom() which is not available on older glibc versions
Brad Bishop19323692019-04-05 15:28:33 -040047# (native versions can be built with newer glibc, but then relocated onto a system with older glibc)
Brad Bishopa34c0302019-09-23 22:34:48 -040048EXTRA_OECONF_class-native = "--with-rand-seed=os,devrandom"
49EXTRA_OECONF_class-nativesdk = "--with-rand-seed=os,devrandom"
Brad Bishop19323692019-04-05 15:28:33 -040050
51# Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate.
52CFLAGS_append_class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
53CFLAGS_append_class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
54
55do_configure () {
56 os=${HOST_OS}
57 case $os in
58 linux-gnueabi |\
59 linux-gnuspe |\
60 linux-musleabi |\
61 linux-muslspe |\
62 linux-musl )
63 os=linux
64 ;;
65 *)
66 ;;
67 esac
68 target="$os-${HOST_ARCH}"
69 case $target in
70 linux-arm*)
71 target=linux-armv4
72 ;;
73 linux-aarch64*)
74 target=linux-aarch64
75 ;;
76 linux-i?86 | linux-viac3)
77 target=linux-x86
78 ;;
79 linux-gnux32-x86_64 | linux-muslx32-x86_64 )
80 target=linux-x32
81 ;;
82 linux-gnu64-x86_64)
83 target=linux-x86_64
84 ;;
85 linux-mips | linux-mipsel)
86 # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags
87 target="linux-mips32 ${TARGET_CC_ARCH}"
88 ;;
89 linux-gnun32-mips*)
90 target=linux-mips64
91 ;;
92 linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el)
93 target=linux64-mips64
94 ;;
95 linux-microblaze* | linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*)
96 target=linux-generic32
97 ;;
98 linux-powerpc)
99 target=linux-ppc
100 ;;
101 linux-powerpc64)
102 target=linux-ppc64
103 ;;
104 linux-riscv32)
105 target=linux-generic32
106 ;;
107 linux-riscv64)
108 target=linux-generic64
109 ;;
110 linux-sparc | linux-supersparc)
111 target=linux-sparcv9
112 ;;
113 esac
114
115 useprefix=${prefix}
116 if [ "x$useprefix" = "x" ]; then
117 useprefix=/
118 fi
119 # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the
120 # environment variables set by bitbake. Adjust the environment variables instead.
121 PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \
122 perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} --prefix=$useprefix --openssldir=${libdir}/ssl-1.1 --libdir=${libdir} $target
123 perl ${B}/configdata.pm --dump
124}
125
126do_install () {
127 oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install
128
129 oe_multilib_header openssl/opensslconf.h
130
131 # Create SSL structure for packages such as ca-certificates which
132 # contain hard-coded paths to /etc/ssl. Debian does the same.
133 install -d ${D}${sysconfdir}/ssl
134 mv ${D}${libdir}/ssl-1.1/certs \
135 ${D}${libdir}/ssl-1.1/private \
136 ${D}${libdir}/ssl-1.1/openssl.cnf \
137 ${D}${sysconfdir}/ssl/
138
139 # Although absolute symlinks would be OK for the target, they become
140 # invalid if native or nativesdk are relocated from sstate.
141 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-1.1/certs
142 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-1.1/private
143 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-1.1/openssl.cnf
144}
145
146do_install_append_class-native () {
147 create_wrapper ${D}${bindir}/openssl \
148 OPENSSL_CONF=${libdir}/ssl-1.1/openssl.cnf \
149 SSL_CERT_DIR=${libdir}/ssl-1.1/certs \
150 SSL_CERT_FILE=${libdir}/ssl-1.1/cert.pem \
Brad Bishop64c979e2019-11-04 13:55:29 -0500151 OPENSSL_ENGINES=${libdir}/engines-1.1
Brad Bishop19323692019-04-05 15:28:33 -0400152}
153
154do_install_append_class-nativesdk () {
155 mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
156 install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
157 sed 's|/usr/lib/ssl/|/usr/lib/ssl-1.1/|g' -i ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
158}
159
160PTEST_BUILD_HOST_FILES += "configdata.pm"
161PTEST_BUILD_HOST_PATTERN = "perl_version ="
162do_install_ptest () {
163 # Prune the build tree
164 rm -f ${B}/fuzz/*.* ${B}/test/*.*
165
166 cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH}
167 cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH}
168
169 # For test_shlibload
Brad Bishop15ae2502019-06-18 21:44:24 -0400170 ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/
171 ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/
Brad Bishop19323692019-04-05 15:28:33 -0400172
173 install -d ${D}${PTEST_PATH}/apps
174 ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps
175 install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps
176 install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps
177
178 install -d ${D}${PTEST_PATH}/engines
179 install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines
180}
181
182# Add the openssl.cnf file to the openssl-conf package. Make the libcrypto
183# package RRECOMMENDS on this package. This will enable the configuration
184# file to be installed for both the openssl-bin package and the libcrypto
185# package since the openssl-bin package depends on the libcrypto package.
186
187PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc"
188
189FILES_libcrypto = "${libdir}/libcrypto${SOLIBS}"
190FILES_libssl = "${libdir}/libssl${SOLIBS}"
191FILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
192FILES_${PN}-engines = "${libdir}/engines-1.1"
193FILES_${PN}-misc = "${libdir}/ssl-1.1/misc"
194FILES_${PN} =+ "${libdir}/ssl-1.1/*"
195FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh"
196
197CONFFILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
198
199RRECOMMENDS_libcrypto += "openssl-conf"
200RDEPENDS_${PN}-ptest += "openssl-bin perl perl-modules bash"
201
Brad Bishop19323692019-04-05 15:28:33 -0400202BBCLASSEXTEND = "native nativesdk"
Brad Bishop96ff1982019-08-19 13:50:42 -0400203
204CVE_PRODUCT = "openssl:openssl"