# Description: Widely used set of C/C++ libraries providing Unicode and Globalization support
# URL: https://icu.unicode.org
# Maintainer: Tim Biermann, tbier at posteo dot de
# Optional: clang lld

name=icu
version=74.2
release=2
source=(https://github.com/unicode-org/icu/releases/download/release-${version//./-}/icu4c-${version/./_}-src.tgz
  ICU-22132.patch)

build() {
  cd icu/source

  # icu tries to use clang by default, only do so if installed
  prt-get isinst clang lld && LDFLAGS+=' -fuse-ld=lld -flto=thin'
  prt-get isinst clang && export CC=clang CXX=clang++ AR=llvm-ar NM=llvm-nm RANLIB=llvm-ranlib || \
    export CC=gcc CXX=g++

  patch -Np1 -i $SRC/ICU-22132.patch
  export CFLAGS="$CFLAGS -fno-strict-aliasing"
  export CXXFLAGS="$CFLAGS"
  echo $CFLAGS $CXXFLAGS

  CONFIG_SHELL=/bin/bash \
  ./configure \
    --prefix=/usr \
    --mandir=/usr/share/man \
    --disable-samples \
    --disable-tests

  make
  make -j1 DESTDIR=$PKG install
}
