all:
	go run make.go -v autoDev

assets:
	go run make.go -v assets

auto:
	go run make.go -v auto

test: vale
	go test -race -v --tags "velomain server_vql" ./...

test_less: vale
	go test -race -v --tags "velomain server_vql" ./... 2>&1 | less

golden:
	./output/velociraptor -v --config artifacts/testdata/windows/test.config.yaml golden artifacts/testdata/server/testcases/ --env srcDir=`pwd` --filter=${GOLDEN}

debug_golden:
	dlv debug --init ./scripts/dlv.init --build-flags="-tags 'velomain server_vql extras'" ./bin/ -- --config artifacts/testdata/windows/test.config.yaml golden artifacts/testdata/server/testcases/ --env srcDir=`pwd` --disable_alarm -v --debug --filter=${GOLDEN}

references:
	./output/velociraptor vql export docs/references/vql.yaml > docs/references/vql.yaml.tmp
	mv docs/references/vql.yaml.tmp docs/references/vql.yaml

release:
	go run make.go -v release

# Basic darwin binary - no yara.
darwin:
	go run make.go -v DarwinBase

darwin_intel:
	go run make.go -v Darwin

darwin_m1:
	go run make.go -v DarwinM1

linux_m1:
	go run make.go -v LinuxM1

linux_sumo:
	go run make.go -v LinuxSumo

linux_arm64:
	go run make.go -v LinuxArm64

# For raspberi pi.
linux_armf:
	go run make.go -v LinuxArmhf

linux_musl:
	go run make.go -v LinuxMusl

linux_musl_debug:
	go run make.go -v LinuxMuslDebug

linux_debug:
	go run make.go -v LinuxDebug

linux:
	go run make.go -v linux

linux_bare:
	go run make.go -v linuxBare

freebsd:
	go run make.go -v freebsd

# A target that builds a regular windows binary and places it in
# output/velociraptor.exe
windows:
	go run make.go -v windowsDev

# Windows client without a gui.
windows_bare:
	go run make.go -v windowsBare

# A 32 bit windows binary.
windowsx86:
	go run make.go -v windowsx86

# An AMD64 Windows binary with all optional plugins enabled.
windows_sumo:
	go run make.go -v WindowsSumo

# A Windows binary for Windows on Arm64 (e.g. Snapdragon)
windows_arm64:
	go run make.go -v WindowsArm64

# A Windows binary for Windows on Arm64 (e.g. Snapdragon) includes all
# optional plugins
windows_arm64_sumo:
	go run make.go -v WindowsArm64Sumo

# A build with the race detector enabled.
windows_test:
	go run make.go -v WindowsTest

# Clean all build artifacts (e.g. assets, GUI etc)
clean:
	go run make.go -v clean

# Clean downloaded cross compiler toolchains.
clean_toolchain:
	go run make.go -v cleantoolchains

generate:
	go generate ./vql/windows/
	go generate ./api/mock/

check:
	staticcheck ./...

check_versions:
	python3 -X utf8 ./scripts/check_versions.py 3

debug:
	dlv debug --init ./scripts/dlv.init --wd=. --build-flags="-tags 'velomain server_vql extras'" ./bin/ -- frontend --disable-panic-guard -v --debug

debug_minion:
	dlv debug --init ./scripts/dlv.init --wd=. --build-flags="-tags 'velomain server_vql extras'" ./bin/ -- frontend --disable-panic-guard -v --debug --minion --config.frontend-bind-port 8005 --debug_port 6061

debug_client:
	dlv debug --init ./scripts/dlv.init --build-flags="-tags 'velomain server_vql extras'" ./bin/ -- client -v --debug --debug_port 6061

# Do this after fetching the build artifacts with `gh run download <RunID>`
UpdateCIArtifacts:
	mv artifact/server/* artifacts/testdata/server/testcases/
	mv artifact/windows/* artifacts/testdata/windows/

UpdateCerts:
	cp /etc/ssl/certs/ca-certificates.crt crypto/ca-certificates.crt
	fileb0x crypto/b0x.yaml

# Use this to prepare artifact packs at specific versions:
# First git checkout origin/v0.6.3
archive_artifacts:
	zip -r release_artifacts_$(basename "$(git status | head -1)").zip artifacts/definitions/ -i \*.yaml

translations:
	python3 ./scripts/find_i8n_translations.py ./gui/velociraptor/src/components/i8n/

config_check:
	go run -tags config_check ./docs/references/sample_config/main.go ./docs/references/server.config.yaml

deadcode:
	go run make.go -v deadcode

api_check:
	python ./scripts/api_checker.py .

# Build the docker container
container:
	go run make.go -v container

# Only vale changes from master
vale:
	time vale `git diff --name-only --diff-filter=AM origin/master`
