# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=uthash
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.3.0
pkgrel=1
pkgdesc="C preprocessor implementations of a hash table and a linked list (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://troydhanson.github.io/uthash/"
msys2_repository_url="https://github.com/troydhanson/uthash"
msys2_references=(
  'archlinux: uthash'
)
license=('BSD')
source=("https://github.com/troydhanson/uthash/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('e10382ab75518bad8319eb922ad04f907cb20cccb451a3aa980c9d005e661acc')
noextract=("${_realname}-${pkgver}.tar.gz")

prepare() {
  echo "Extracting ${_realname}-${pkgver}.tar.gz ..."
  tar -xzf ${_realname}-${pkgver}.tar.gz || true
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}/src"

  # create directory for header files
  install -dm755 "${pkgdir}"${MINGW_PREFIX}/include/

  # install header files in ${MINGW_PREFIX}/include
  for h in *.h; do
      install -m 644 ${h} "${pkgdir}"${MINGW_PREFIX}/include/
  done

  # install license file
  install -D -m644 "${srcdir}"/${_realname}-${pkgver}/LICENSE "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
