CURDIR=$(shell pwd)
BINDIR=${CURDIR}/bin
GOVER=$(shell go version | perl -nle '/(go\d\S+)/; print $$1;')

LINTVER=v1.60.3
LINTBIN=bin/golangci-lint

bindir:
	mkdir -p ${BINDIR}

.PHONY: .bin-deps
.bin-deps: bindir
	$(info Installing binary dependencies...)
	GOBIN=$(BINDIR) go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 && \
    GOBIN=$(BINDIR) go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0 && \
    GOBIN=$(BINDIR) go install github.com/envoyproxy/protoc-gen-validate@v1.0.4 && \
    GOBIN=$(BINDIR) go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.19.1 && \
    GOBIN=$(BINDIR) go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.19.1 && \
    GOBIN=$(BINDIR) go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 && \
	GOBIN=$(BINDIR) go install github.com/gojuno/minimock/v3/cmd/minimock@v3.4.0

	$(info Installing golangci-lint...)
	test -f ${LINTBIN} || \
		(GOBIN=${BINDIR} go install github.com/golangci/golangci-lint/cmd/golangci-lint@${LINTVER} && \
		mv ${BINDIR}/golangci-lint ${LINTBIN})

	$(info Installing goose binary...)
	GOBIN=$(BINDIR) go install github.com/pressly/goose/v3/cmd/goose@v3.24.1

	$(info Installing sqlc binary...)
	GOBIN=$(BINDIR) CGO_ENABLED=0 go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.29.0
