.PHONY: all prepare build grpc_api humanizer stage_watcher xray_cli worker yodax secret_search boxer log4j_finder yadi_os

all: prepare build

ARCADIA_ROOT := $(shell arc root)

prepare:
	mkdir -p /srv/xray/bin
	mkdir -p /srv/xray/checks

grpc_api:
	ya make -o /srv/xray/build -r $(ARCADIA_ROOT)/security/xray/cmd/grpc-api
	ln -sf /srv/xray/build/security/xray/cmd/grpc-api/grpc-api /srv/xray/bin/grpc-api

humanizer:
	ya make -o /srv/xray/build -r $(ARCADIA_ROOT)/security/xray/cmd/humanizer
	ln -sf /srv/xray/build/security/xray/cmd/humanizer/humanizer /srv/xray/bin/humanizer

stage_watcher:
	ya make -o /srv/xray/build -r $(ARCADIA_ROOT)/security/xray/cmd/stage-watcher
	ln -sf /srv/xray/build/security/xray/cmd/stage-watcher/stage-watcher /srv/xray/bin/stage-watcher

xray_cli:
	ya make -o /srv/xray/build -r $(ARCADIA_ROOT)/security/xray/cmd/xray-cli
	ln -sf /srv/xray/build/security/xray/cmd/xray-cli/xray-cli /srv/xray/bin/xray-cli

worker:
	ya make -o /srv/xray/build -r $(ARCADIA_ROOT)/security/xray/cmd/worker
	ln -sf /srv/xray/build/security/xray/cmd/worker/worker /srv/xray/bin/worker

yodax:
	ya make --musl -o /srv/xray/checks/build -r $(ARCADIA_ROOT)/security/yodax/bin
	ln -sf build/security/yodax/bin/yodax /srv/xray/checks/yodax

secret_search:
	ya make --musl -o /srv/xray/checks/build -r $(ARCADIA_ROOT)/security/ant-secret/secret-search/bin
	ln -sf build/security/ant-secret/secret-search/bin/secret-search /srv/xray/checks/secret-search

boxer:
	ya make -DCGO_ENABLED=0 -o /srv/xray/checks/build -r $(ARCADIA_ROOT)/security/xray/cmd/boxer
	ln -sf build/security/xray/cmd/boxer/boxer /srv/xray/checks/boxer

log4j_finder:
	ya make -DCGO_ENABLED=0 -o /srv/xray/checks/build -r $(ARCADIA_ROOT)/security/xray/cmd/log4j-finder
	ln -sf build/security/xray/cmd/log4j-finder/log4j-finder /srv/xray/checks/log4j-finder

spring4shell_finder:
	ya make -DCGO_ENABLED=0 -o /srv/xray/checks/build -r $(ARCADIA_ROOT)/security/xray/cmd/spring4shell-finder
	ln -sf build/security/xray/cmd/spring4shell-finder/spring4shell-finder /srv/xray/checks/spring4shell-finder

yadi_os:
	ya make -DCGO_ENABLED=0 -o /srv/xray/checks/build -r $(ARCADIA_ROOT)/security/yadi/yadi-os/cmd/yadi-os
	ln -sf build/security/yadi/yadi-os/cmd/yadi-os/yadi-os /srv/xray/checks/yadi-os

build: grpc_api stage_watcher humanizer xray_cli worker yodax secret_search boxer log4j_finder yadi_os
