#### Control part variable.
_NODE_PREFIX=/usr/lib/node-${PKGVER%%.*}

abinfo "Configuring Node.js ..."
"$SRCDIR"/configure \
    --prefix=${_NODE_PREFIX} \
    --ninja \
    --shared-ada \
    --shared-brotli \
    --shared-cares \
    --shared-http-parser \
    --shared-http-parser-libname llhttp \
    --shared-libuv \
    --shared-nghttp2 \
    --shared-nghttp3 \
    --shared-ngtcp2 \
    --shared-openssl \
    --shared-simdutf \
    --shared-sqlite \
    --shared-zstd \
    --shared-zlib \
    --with-intl=system-icu \
    $NODE_FLAGS_ARCH

abinfo "Building Node.js ..."
make "$MAKEFLAGS"

abinfo "Installing Node.js ..."
make install \
    DESTDIR="$PKGDIR"

abinfo "Installing node-gyp ..."
install -Dvm755 \
   "$PKGDIR"/${_NODE_PREFIX}/lib/node_modules/npm/bin/node-gyp-bin/node-gyp \
   "$PKGDIR"/${_NODE_PREFIX}/bin/node-gyp
sed -e 's|"`dirname "$0"`/../../|"`dirname "$0"`/../lib/node-${PKGVER%%.*}/lib/node_modules/npm/|' \
    -i "$PKGDIR"/${_NODE_PREFIX}/bin/node-gyp

abinfo "Creating Corepack shims..."
PATH="$PATH:"$PKGDIR"/${_NODE_PREFIX}/bin" \
"$PKGDIR"/${_NODE_PREFIX}/bin/corepack \
    enable
