# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=docker-compose
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.0.1
pkgrel=1
pkgdesc="Define and run multi-container applications with Docker (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.docker.com/"
msys2_repository_url="https://github.com/docker/compose"
msys2_references=(
  'anitya: 6185'
  'archlinux: docker-compose'
  'aur: docker-compose-git'
  'gentoo: app-containers/docker-compose'
  'purl: pkg:golang/github.com/docker/compose/v5'
)
license=("spdx:Apache-2.0")
makedepends=("${MINGW_PACKAGE_PREFIX}-go")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/docker/compose/archive/v${pkgver}.tar.gz")
sha256sums=('e48ebd8c71bb805c0b97b9705ac03513e9a0c872fa73cb0525141d0f49148b5e')

build() {
  cd "compose-${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"
  case "${CARCH}" in
    x86_64)
      GOFLAGS+=" -buildmode=pie"
      ;;
  esac
  go build -ldflags "${GO_LDFLAGS}" -trimpath -tags "e2e,kube" -o compose.exe ./cmd
}

package() {
  cd "compose-${pkgver}"
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
  install -Dm755 compose.exe "${pkgdir}${MINGW_PREFIX}/bin/docker-compose.exe"
}
