#!/usr/bin/env bash

cp -r ${BUILD_PREFIX}/share/libtool/build-aux/config.* ./nspr/build/autoconf/.

export CPU_ARCH=aarch64

cd nspr

sed -ri 's#^(RELEASE_BINS =).*#\1#' pr/src/misc/Makefile.in
sed -i 's#$(LIBRARY) ##'            config/rules.mk

./configure --prefix="${PREFIX}" --enable-64bit --disable-debug --enable-optimize --with-pthreads \
  -with-arch=toolchain-default --build=aarch64-apple-darwin20.4.0 --host=aarch64-apple-darwin20.4.0 \
  --with-mozilla --enable-ipv6 --enable-strip --enable-macos-target=${MACOSX_DEPLOYMENT_TARGET} || (cat config.log; false)

make -j $CPU_COUNT
make install
