# Maintainer: @naveen521kk on Github <naveen521kk@gmail.com>

_realname=dnslookup
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.11.1
pkgrel=1
pkgdesc='Simple command line utility to make DNS lookups (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/ameshkov/dnslookup"
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-go" "${MINGW_PACKAGE_PREFIX}-cc" "git")
optdepends=("git: To interact with repositories")
options=('!strip')
source=("$url/archive/v$pkgver/$_realname-$pkgver.tar.gz")
sha256sums=('31967c89406aa6da5f69c563815e58478b530c8e55f0d995065a363f68d5e535')

build() {
    cd "${_realname}-$pkgver"
    export GOOS=windows
    export GOROOT=${MINGW_PREFIX}/lib/go
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GO_LDFLAGS="-s -w"
    export GOFLAGS="-trimpath -mod=readonly -modcacherw -ldflags=-linkmode=external"

    make VERSION=$pkgver build
}

check(){
    cd "${_realname}-$pkgver"
    make test
}

package() {
    cd "${_realname}-$pkgver"
    install -Dm755 "dnslookup.exe" "${pkgdir}${MINGW_PREFIX}/bin/dnslookup.exe"
    install -Dm644 "LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
    install -Dm644 "README.md" "${pkgdir}${MINGW_PREFIX}/share/doc/${_realname}/README.md"
}
