|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +. ${CONFIG:-config} |
| 4 | + |
| 5 | +export OPENSSL="openssl-1.1.1s" |
| 6 | +export URL_OPENSSL=${URL_OPENSSL:-"URL https://ftp.openssl.org/source/$OPENSSL.tar.gz"} |
| 7 | +export HASH_OPENSSL="URL_HASH SHA256=c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa" |
| 8 | + |
| 9 | +. scripts/emsdk-fetch.sh |
| 10 | + |
| 11 | +if [ -f openssl.patched ] |
| 12 | +then |
| 13 | + echo " |
| 14 | + already patched for $PREFIX |
| 15 | + " |
| 16 | +else |
| 17 | + wget -c $URL_OPENSSL |
| 18 | + tar xvfz $OPENSSL.tar.gz |
| 19 | + pushd $OPENSSL |
| 20 | + patch -p1 <<END |
| 21 | +--- openssl-1.1.1n/Configurations/10-main.conf 2022-03-15 14:37:47.000000000 +0000 |
| 22 | ++++ openssl-1.1.1n-fixed/Configurations/10-main.conf 2022-04-05 10:48:27.348576840 +0000 |
| 23 | +@@ -657,7 +657,8 @@ |
| 24 | + }, |
| 25 | + "linux-generic64" => { |
| 26 | + inherit_from => [ "linux-generic32" ], |
| 27 | +- bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", |
| 28 | ++ bn_ops => "SIXTY_FOUR_BIT RC4_CHAR", |
| 29 | ++ lib_cppflags => add("-DBN_DIV2W"), |
| 30 | + }, |
| 31 | +
|
| 32 | + "linux-ppc" => { |
| 33 | +diff -urN openssl-1.1.1n/crypto/rand/rand_unix.c openssl-1.1.1n-fixed/crypto/rand/rand_unix.c |
| 34 | +--- openssl-1.1.1n/crypto/rand/rand_unix.c 2022-04-05 10:54:21.980130409 +0000 |
| 35 | ++++ openssl-1.1.1n-fixed/crypto/rand/rand_unix.c 2022-04-05 09:27:47.960526811 +0000 |
| 36 | +@@ -369,7 +369,7 @@ |
| 37 | + * Note: Sometimes getentropy() can be provided but not implemented |
| 38 | + * internally. So we need to check errno for ENOSYS |
| 39 | + */ |
| 40 | +-# if defined(__GNUC__) && __GNUC__>=2 && defined(__ELF__) && !defined(__hpux) |
| 41 | ++# if defined(__EMSCRIPTEN__) |
| 42 | + extern int getentropy(void *buffer, size_t length) __attribute__((weak)); |
| 43 | +
|
| 44 | + if (getentropy != NULL) { |
| 45 | +END |
| 46 | + |
| 47 | + touch ../openssl.patched |
| 48 | + popd |
| 49 | +fi |
| 50 | + |
| 51 | +if [ -f $PREFIX/lib/libssl.a ] |
| 52 | +then |
| 53 | + echo " |
| 54 | + already built in $PREFIX/lib/libssl.a |
| 55 | + " |
| 56 | +else |
| 57 | + pushd $OPENSSL |
| 58 | + emconfigure ./Configure linux-generic64 \ |
| 59 | + no-asm \ |
| 60 | + no-engine \ |
| 61 | + no-hw \ |
| 62 | + no-weak-ssl-ciphers \ |
| 63 | + no-dtls \ |
| 64 | + no-shared \ |
| 65 | + no-dso \ |
| 66 | + -DPEDANTIC \ |
| 67 | + --prefix="$PREFIX" --openssldir=/home/web_user |
| 68 | + |
| 69 | + sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile |
| 70 | + emmake make build_generated libssl.a libcrypto.a |
| 71 | + cp -r include/openssl "$PREFIX/include" |
| 72 | + cp libcrypto.a libssl.a "$PREFIX/lib" |
| 73 | + popd |
| 74 | +fi |
0 commit comments