# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Lars Kanis <lars@greiz-reinsdorf.de>

_realname=freetds
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.5.6
pkgrel=1
pkgdesc="A free implementation of Sybase's DB-Library, CT-Library and ODBC libraries (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.freetds.org/'
msys2_repository_url='https://github.com/FreeTDS/freetds/'
msys2_changelog_url='https://www.freetds.org/news.html'
msys2_documentation_url='https://www.freetds.org/docs.html'
msys2_issue_tracker_url='https://github.com/FreeTDS/freetds/issues/'
msys2_references=(
  'archlinux: freetds'
  "cpe: cpe:/a:freetds:freetds"
  'gentoo: dev-db/freetds'
)
license=('spdx:LGPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-libiconv")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
source=(https://www.freetds.org/files/stable/freetds-${pkgver}.tar.gz)
sha256sums=('4d4a6ae271dd944531db5b10e110540d020bf99d9986237c8ac5137d894d4149')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../freetds-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --includedir=${MINGW_PREFIX}/include/${_realname} \
    --enable-static \
    --enable-shared \
    --with-openssl \
    --enable-sspi

  make
}

package () {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
