.PHONY: all test

COMMIT := $(shell git rev-parse --short HEAD)
TD_COMMIT := "5bbfc1cf5dab94f82e02f3430ded7241d4653551"
VERSION := "v2.0.0-dev"
MAKEOPTS := "-j4"

# GOTAGS=signal_legacy builds the OMEMO cgo bindings against the pre-fork
# libsignal-protocol-c instead of libomemo-c (e.g. on Debian bullseye, which
# only packages the former) - legacy/siacs OMEMO only, no modern OMEMO 1/2.
GOTAGS :=

all:
	mkdir -p release
	go build -ldflags "-X main.commit=${COMMIT}" -tags "${GOTAGS}" -o release/telegabber

test:
	go test -tags "${GOTAGS}" -v ./config ./ ./telegram ./xmpp ./xmpp/gateway ./persistence ./telegram/formatter ./badger

lint:
	$(GOPATH)/bin/golint ./...

build_indocker:
	docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "VERSION=${VERSION}" --build-arg "MAKEOPTS=${MAKEOPTS}" --output=release --target binaries .

build_indocker_staging:
	DOCKER_BUILDKIT=1 docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "MAKEOPTS=${MAKEOPTS}" --network host --output=release --target binaries -f staging.Dockerfile .

build_tdlib:
	DOCKER_BUILDKIT=1 docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "MAKEOPTS=${MAKEOPTS}" --output=tdlib --target binaries -f tdlib.Dockerfile .
