77 lines
2.2 KiB
Bash
Executable File
77 lines
2.2 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"
|
|
|
|
runtime_api="$(php -i | sed -n 's/^PHP API => //p' | head -n 1)"
|
|
config_api="$(php-config --phpapi)"
|
|
phpize_api="$(phpize --version | sed -n 's/^PHP Api Version:[[:space:]]*//p' | head -n 1)"
|
|
|
|
if [[ -z "$runtime_api" || -z "$config_api" || -z "$phpize_api" \
|
|
|| "$runtime_api" != "$config_api" || "$runtime_api" != "$phpize_api" ]]; then
|
|
cat >&2 <<EOF
|
|
PHP build tools do not match the active PHP runtime.
|
|
|
|
php API: ${runtime_api:-unknown}
|
|
php-config API: ${config_api:-unknown}
|
|
phpize API: ${phpize_api:-unknown}
|
|
|
|
Install the development package matching the active PHP version and select its
|
|
phpize and php-config commands before building.
|
|
EOF
|
|
exit 1
|
|
fi
|
|
|
|
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 --clean >/dev/null 2>&1 || true
|
|
phpize
|
|
./configure
|
|
make
|
|
)
|
|
|
|
cat <<EOF
|
|
|
|
Native extensions built:
|
|
$third_party/liboqs-php/build/oqsphp.so
|
|
$third_party/php-skein/modules/skein.so
|
|
|
|
Do not add these paths directly to php.ini.
|
|
Run sudo ./install-linux.sh to install and enable both modules.
|
|
EOF
|