Contractless-PHP-Modules/build-linux.sh

58 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
third_party="$root/native/third-party"
mkdir -p "$third_party"
if [[ ! -d "$third_party/liboqs/.git" ]]; then
git clone --depth 1 https://github.com/open-quantum-safe/liboqs.git \
"$third_party/liboqs"
fi
cmake -S "$third_party/liboqs" -B "$third_party/liboqs/build" -GNinja \
-DBUILD_SHARED_LIBS=OFF \
-DOQS_BUILD_ONLY_LIB=ON \
-DOQS_MINIMAL_BUILD="SIG_falcon_padded_512"
ninja -C "$third_party/liboqs/build"
if [[ ! -d "$third_party/liboqs-php/.git" ]]; then
git clone --depth 1 https://github.com/Muzosh/liboqs-php.git \
"$third_party/liboqs-php"
fi
(
cd "$third_party/liboqs-php"
if git apply --check "$root/oqsphp-contractless.patch"; then
git apply "$root/oqsphp-contractless.patch"
elif ! git apply --reverse --check "$root/oqsphp-contractless.patch"; then
echo "The Contractless liboqs-php patch cannot be applied cleanly." >&2
exit 1
fi
LIBOQS_ROOT="$third_party/liboqs" bash build.sh
)
if [[ ! -d "$third_party/php-skein/.git" ]]; then
git clone --depth 1 https://github.com/jedisct1/PHP-Skein-Hash.git \
"$third_party/php-skein"
fi
(
cd "$third_party/php-skein"
phpize
./configure
make
)
cat <<EOF
Native extensions built:
$third_party/liboqs-php/build/oqsphp.so
$third_party/php-skein/modules/skein.so
Add both absolute paths to php.ini:
extension=$third_party/liboqs-php/build/oqsphp.so
extension=$third_party/php-skein/modules/skein.so
EOF