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