blob: 5d419772f9d5ca041f51b34401fa369daf3740f8 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001SUMMARY = "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 | SSLeay" dual license
8LICENSE = "openssl"
Brad Bishop220d5532018-08-14 00:59:39 +01009LIC_FILES_CHKSUM = "file://LICENSE;md5=f475368924827d06d4b416111c8bdb77"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050010
Brad Bishop220d5532018-08-14 00:59:39 +010011DEPENDS = "hostperl-runtime-native"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012DEPENDS_append_class-target = " openssl-native"
13
14PROVIDES += "openssl10"
15
16SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
Brad Bishop220d5532018-08-14 00:59:39 +010017 file://run-ptest \
18 file://openssl-c_rehash.sh \
19 file://configure-targets.patch \
20 file://shared-libs.patch \
21 file://oe-ldflags.patch \
22 file://engines-install-in-libdir-ssl.patch \
23 file://debian1.0.2/block_diginotar.patch \
24 file://debian1.0.2/block_digicert_malaysia.patch \
25 file://debian/c_rehash-compat.patch \
26 file://debian/debian-targets.patch \
27 file://debian/man-dir.patch \
28 file://debian/man-section.patch \
29 file://debian/no-rpath.patch \
30 file://debian/no-symbolic.patch \
31 file://debian/pic.patch \
32 file://debian1.0.2/version-script.patch \
33 file://debian1.0.2/soname.patch \
34 file://openssl_fix_for_x32.patch \
35 file://openssl-fix-des.pod-error.patch \
36 file://Makefiles-ptest.patch \
37 file://ptest-deps.patch \
38 file://ptest_makefile_deps.patch \
39 file://configure-musl-target.patch \
40 file://parallel.patch \
41 file://Use-SHA256-not-MD5-as-default-digest.patch \
42 file://0001-Fix-build-with-clang-using-external-assembler.patch \
43 file://0001-openssl-force-soft-link-to-avoid-rare-race.patch \
44 file://0001-allow-manpages-to-be-disabled.patch \
45 "
46
47SRC_URI_append_class-target = " \
48 file://reproducible-cflags.patch \
49 file://reproducible-mkbuildinf.patch \
50 "
51
52SRC_URI_append_class-nativesdk = " \
53 file://environment.d-openssl.sh \
54 "
55
56SRC_URI[md5sum] = "ac5eb30bf5798aa14b1ae6d0e7da58df"
57SRC_URI[sha256sum] = "50a98e07b1a89eb8f6a99477f262df71c6fa7bef77df4dc83025a2845c827d00"
58
59UPSTREAM_CHECK_REGEX = "openssl-(?P<pver>1\.0.+)\.tar"
60
61inherit pkgconfig siteinfo multilib_header ptest relative_symlinks manpages
Brad Bishopd7bf8c12018-02-25 22:55:05 -050062
63PACKAGECONFIG ?= "cryptodev-linux"
Brad Bishop220d5532018-08-14 00:59:39 +010064PACKAGECONFIG_class-native = ""
65PACKAGECONFIG_class-nativesdk = ""
66
Brad Bishopd7bf8c12018-02-25 22:55:05 -050067PACKAGECONFIG[cryptodev-linux] = "-DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS,,cryptodev-linux"
Brad Bishop220d5532018-08-14 00:59:39 +010068PACKAGECONFIG[manpages] = ",,,"
69PACKAGECONFIG[perl] = ",,,"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050070
71# Remove this to enable SSLv3. SSLv3 is defaulted to disabled due to the POODLE
72# vulnerability
Brad Bishop220d5532018-08-14 00:59:39 +010073EXTRA_OECONF = "no-ssl3"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050074
Brad Bishop220d5532018-08-14 00:59:39 +010075EXTRA_OEMAKE = "${@bb.utils.contains('PACKAGECONFIG', 'manpages', '', 'OE_DISABLE_MANPAGES=1', d)}"
76
77export OE_LDFLAGS = "${LDFLAGS}"
78
79# openssl fails with ccache: https://bugzilla.yoctoproject.org/show_bug.cgi?id=12810
80CCACHE = ""
81
82TERMIO ?= "-DTERMIO"
83TERMIO_libc-musl = "-DTERMIOS"
84
85CFLAG = "${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', '-DL_ENDIAN', '-DB_ENDIAN', d)} \
86 ${TERMIO} ${CFLAGS} -Wall"
87
88# Avoid binaries being marked as requiring an executable stack since they don't
89# (and it causes issues with SELinux)
90CFLAG += "-Wa,--noexecstack"
91
92CFLAG_append_class-native = " -fPIC"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050093
94do_configure () {
Brad Bishop220d5532018-08-14 00:59:39 +010095 # The crypto_use_bigint patch means that perl's bignum module needs to be
96 # installed, but some distributions (for example Fedora 23) don't ship it by
97 # default. As the resulting error is very misleading check for bignum before
98 # building.
99 if ! perl -Mbigint -e true; then
100 bbfatal "The perl module 'bignum' was not found but this is required to build openssl. Please install this module (often packaged as perl-bignum) and re-run bitbake."
101 fi
102
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500103 ln -sf apps/openssl.pod crypto/crypto.pod ssl/ssl.pod doc/
104
105 os=${HOST_OS}
106 case $os in
107 linux-gnueabi |\
108 linux-gnuspe |\
109 linux-musleabi |\
110 linux-muslspe |\
111 linux-musl )
112 os=linux
113 ;;
Brad Bishop220d5532018-08-14 00:59:39 +0100114 *)
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500115 ;;
116 esac
117 target="$os-${HOST_ARCH}"
118 case $target in
119 linux-arm)
120 target=linux-armv4
121 ;;
122 linux-armeb)
123 target=linux-elf-armeb
124 ;;
125 linux-aarch64*)
126 target=linux-aarch64
127 ;;
128 linux-sh3)
129 target=debian-sh3
130 ;;
131 linux-sh4)
132 target=debian-sh4
133 ;;
134 linux-i486)
135 target=debian-i386-i486
136 ;;
137 linux-i586 | linux-viac3)
138 target=debian-i386-i586
139 ;;
140 linux-i686)
141 target=debian-i386-i686/cmov
142 ;;
143 linux-gnux32-x86_64 | linux-muslx32-x86_64 )
144 target=linux-x32
145 ;;
146 linux-gnu64-x86_64)
147 target=linux-x86_64
148 ;;
149 linux-gnun32-mips*el)
150 target=debian-mipsn32el
151 ;;
152 linux-gnun32-mips*)
153 target=debian-mipsn32
154 ;;
155 linux-mips*64*el)
156 target=debian-mips64el
157 ;;
158 linux-mips*64*)
159 target=debian-mips64
160 ;;
161 linux-mips*el)
162 target=debian-mipsel
163 ;;
164 linux-mips*)
165 target=debian-mips
166 ;;
167 linux-microblaze*|linux-nios2*|linux-gnu*ilp32**)
168 target=linux-generic32
169 ;;
170 linux-powerpc)
171 target=linux-ppc
172 ;;
173 linux-powerpc64)
174 target=linux-ppc64
175 ;;
Brad Bishop316dfdd2018-06-25 12:45:53 -0400176 linux-riscv32)
177 target=linux-generic32
178 ;;
Brad Bishop220d5532018-08-14 00:59:39 +0100179 linux-riscv64)
180 target=linux-generic64
181 ;;
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500182 linux-supersparc)
183 target=linux-sparcv8
184 ;;
185 linux-sparc)
186 target=linux-sparcv8
187 ;;
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500188 esac
Brad Bishop220d5532018-08-14 00:59:39 +0100189
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500190 # inject machine-specific flags
191 sed -i -e "s|^\(\"$target\",\s*\"[^:]\+\):\([^:]\+\)|\1:${CFLAG}|g" Configure
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500192
Brad Bishop220d5532018-08-14 00:59:39 +0100193 useprefix=${prefix}
194 if [ "x$useprefix" = "x" ]; then
195 useprefix=/
196 fi
197 libdirleaf="$(echo ${libdir} | sed s:$useprefix::)"
198 perl ./Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} shared --prefix=$useprefix --openssldir=${libdir}/ssl --libdir=$libdirleaf $target
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500199}
200
201do_compile () {
202 oe_runmake depend
203 oe_runmake
204}
205
Brad Bishop220d5532018-08-14 00:59:39 +0100206do_compile_class-target () {
207 sed -i 's/\((OPENSSL=\)".*"/\1"openssl"/' Makefile
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500208 oe_runmake depend
Brad Bishop220d5532018-08-14 00:59:39 +0100209 cc_sanitized=$(echo "${CC} ${CFLAG}" | sed -e 's,--sysroot=${STAGING_DIR_TARGET},,g' -e 's|${DEBUG_PREFIX_MAP}||g' -e 's/[ \t]\+/ /g')
210 oe_runmake CC_INFO="$cc_sanitized"
211}
212
213do_compile_ptest () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500214 oe_runmake buildtest
215}
216
217do_install () {
218 # Create ${D}/${prefix} to fix parallel issues
219 mkdir -p ${D}/${prefix}/
220
221 oe_runmake INSTALL_PREFIX="${D}" MANDIR="${mandir}" install
222
223 oe_libinstall -so libcrypto ${D}${libdir}
224 oe_libinstall -so libssl ${D}${libdir}
225
226 install -d ${D}${includedir}
227 cp --dereference -R include/openssl ${D}${includedir}
228
229 install -Dm 0755 ${WORKDIR}/openssl-c_rehash.sh ${D}${bindir}/c_rehash
230 sed -i -e 's,/etc/openssl,${sysconfdir}/ssl,g' ${D}${bindir}/c_rehash
231
232 oe_multilib_header openssl/opensslconf.h
233 if [ "${@bb.utils.filter('PACKAGECONFIG', 'perl', d)}" ]; then
234 sed -i -e '1s,.*,#!${bindir}/env perl,' ${D}${libdir}/ssl/misc/CA.pl
235 sed -i -e '1s,.*,#!${bindir}/env perl,' ${D}${libdir}/ssl/misc/tsget
236 else
237 rm -f ${D}${libdir}/ssl/misc/CA.pl ${D}${libdir}/ssl/misc/tsget
238 fi
239
240 # Create SSL structure
241 install -d ${D}${sysconfdir}/ssl/
242 mv ${D}${libdir}/ssl/openssl.cnf \
243 ${D}${libdir}/ssl/certs \
244 ${D}${libdir}/ssl/private \
245 \
246 ${D}${sysconfdir}/ssl/
247 ln -sf ${sysconfdir}/ssl/certs ${D}${libdir}/ssl/certs
248 ln -sf ${sysconfdir}/ssl/private ${D}${libdir}/ssl/private
249 ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${libdir}/ssl/openssl.cnf
250
251 # Rename man pages to prefix openssl10-*
252 for f in `find ${D}${mandir} -type f`; do
253 mv $f $(dirname $f)/openssl10-$(basename $f)
254 done
255 for f in `find ${D}${mandir} -type l`; do
256 ln_f=`readlink $f`
257 rm -f $f
258 ln -s openssl10-$ln_f $(dirname $f)/openssl10-$(basename $f)
259 done
260}
261
262do_install_ptest () {
263 cp -r -L Makefile.org Makefile test ${D}${PTEST_PATH}
264
Brad Bishop220d5532018-08-14 00:59:39 +0100265 # Replace the path to native perl with the path to target perl
266 sed -i 's,^PERL=.*,PERL=${bindir}/perl,' ${D}${PTEST_PATH}/Makefile
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500267
268 cp Configure config e_os.h ${D}${PTEST_PATH}
269 cp -r -L include ${D}${PTEST_PATH}
270 ln -sf ${libdir}/libcrypto.a ${D}${PTEST_PATH}
271 ln -sf ${libdir}/libssl.a ${D}${PTEST_PATH}
272 mkdir -p ${D}${PTEST_PATH}/crypto
273 cp crypto/constant_time_locl.h ${D}${PTEST_PATH}/crypto
274 cp -r certs ${D}${PTEST_PATH}
275 mkdir -p ${D}${PTEST_PATH}/apps
276 ln -sf ${libdir}/ssl/misc/CA.sh ${D}${PTEST_PATH}/apps
277 ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${PTEST_PATH}/apps
278 ln -sf ${bindir}/openssl ${D}${PTEST_PATH}/apps
279 cp apps/server.pem ${D}${PTEST_PATH}/apps
280 cp apps/server2.pem ${D}${PTEST_PATH}/apps
281 mkdir -p ${D}${PTEST_PATH}/util
282 install util/opensslwrap.sh ${D}${PTEST_PATH}/util
283 install util/shlib_wrap.sh ${D}${PTEST_PATH}/util
284 # Time stamps are relevant for "make alltests", otherwise
285 # make may try to recompile binaries. Not only must the
286 # binary files be newer than the sources, they also must
287 # be more recent than the header files in /usr/include.
288 #
289 # Using "cp -a" is not sufficient, because do_install
290 # does not preserve the original time stamps.
291 #
292 # So instead of using the original file stamps, we set
293 # the current time for all files. Binaries will get
294 # modified again later when stripping them, but that's okay.
295 touch ${D}${PTEST_PATH}
296 find ${D}${PTEST_PATH} -type f -print0 | xargs --verbose -0 touch -r ${D}${PTEST_PATH}
297
298 # exclude binary files or the package won't install
299 for d in ssltest_old v3ext x509aux; do
300 rm -rf ${D}${libdir}/${BPN}/ptest/test/$d
301 done
302
303 # Remove build host references
304 sed -i \
Brad Bishop220d5532018-08-14 00:59:39 +0100305 -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \
306 -e 's|${DEBUG_PREFIX_MAP}||g' \
307 ${D}${PTEST_PATH}/Makefile ${D}${PTEST_PATH}/Configure
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500308}
309
310do_install_append_class-native() {
311 create_wrapper ${D}${bindir}/openssl \
312 OPENSSL_CONF=${libdir}/ssl/openssl.cnf \
313 SSL_CERT_DIR=${libdir}/ssl/certs \
314 SSL_CERT_FILE=${libdir}/ssl/cert.pem \
315 OPENSSL_ENGINES=${libdir}/ssl/engines
316}
317
Brad Bishop220d5532018-08-14 00:59:39 +0100318do_install_append_class-nativesdk() {
319 mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
320 install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
321}
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500322
Brad Bishop220d5532018-08-14 00:59:39 +0100323# Add the openssl.cnf file to the openssl-conf package. Make the libcrypto
324# package RRECOMMENDS on this package. This will enable the configuration
325# file to be installed for both the base openssl package and the libcrypto
326# package since the base openssl package depends on the libcrypto package.
327
328PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc"
329
330FILES_libcrypto = "${libdir}/libcrypto${SOLIBS}"
331FILES_libssl = "${libdir}/libssl${SOLIBS}"
332FILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
333FILES_${PN}-engines = "${libdir}/ssl/engines/*.so ${libdir}/engines"
334FILES_${PN}-misc = "${libdir}/ssl/misc"
335FILES_${PN} =+ "${libdir}/ssl/*"
336FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh"
337
338CONFFILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
339
340RRECOMMENDS_libcrypto += "openssl-conf"
341RDEPENDS_${PN}-misc = "${@bb.utils.filter('PACKAGECONFIG', 'perl', d)}"
342RDEPENDS_${PN}-ptest += "${PN}-misc make perl perl-module-filehandle bc"
343
344BBCLASSEXTEND = "native nativesdk"