# Description: Evented I/O for V8 javascript.
# URL: https://nodejs.org/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: libnghttp2 libuv openssl zlib
# Optional: brotli c-ares icu

name=nodejs
version=21.7.3
release=1
source=(https://nodejs.org/dist/v$version/node-v$version.tar.xz
  system-c-ares.patch)

build() {
  cd node-v$version

  prt-get isinst brotli && PKGMK_NODEJS+=' --shared-brotli'
  prt-get isinst c-ares && PKGMK_NODEJS+=' --shared-cares'
  prt-get isinst c-ares && patch -Rp1 -i $SRC/system-c-ares.patch
  prt-get isinst icu && PKGMK_NODEJS+=' --with-intl=system-icu'

  ./configure ${PKGMK_NODEJS} \
    --prefix=/usr \
    --ninja \
    --without-npm \
    --shared-libuv \
    --shared-zlib \
    --shared-openssl \
    --shared-nghttp2 \
    --experimental-http-parser

  make
  make DESTDIR=$PKG install

  rm -r $PKG/usr/share/doc

  # clean up
  find $PKG -type f \( \
    -name 'README.md' -o \
    -name 'AUTHORS.md' -o \
    -name 'INSTALL.md' -o \
    -name 'TODO.org' -o \
    -name 'ChangeLog' -o \
    -name 'NEWS' \) -delete
}
