AdGuardDNS/Makefile

92 lines
3.2 KiB
Makefile
Raw Normal View History

2022-08-26 14:18:35 +03:00
# Keep the Makefile POSIX-compliant. We currently allow hyphens in
# target names, but that may change in the future.
#
# See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
.POSIX:
2022-12-29 15:36:26 +03:00
# This comment is used to simplify checking local copies of the
2022-11-29 18:20:10 +03:00
# Makefile. Bump this number every time a significant change is made to
# this Makefile.
2022-12-29 15:36:26 +03:00
#
2024-10-14 17:44:24 +03:00
# AdGuard-Project-Version: 9
2022-11-29 18:20:10 +03:00
2023-08-08 18:31:48 +03:00
# Don't name these macros "GO" etc., because GNU Make apparently makes
2022-11-29 18:20:10 +03:00
# them exported environment variables with the literal value of
# "${GO:-go}" and so on, which is not what we need. Use a dot in the
# name to make sure that users don't have an environment variable with
# the same name.
2022-08-26 14:18:35 +03:00
#
# See https://unix.stackexchange.com/q/646255/105635.
GO.MACRO = $${GO:-go}
2022-11-29 18:20:10 +03:00
VERBOSE.MACRO = $${VERBOSE:-0}
2022-08-26 14:18:35 +03:00
2024-10-14 17:44:24 +03:00
BRANCH = $${BRANCH:-$$(git rev-parse --abbrev-ref HEAD)}
2022-11-29 18:20:10 +03:00
GOAMD64 = v1
2024-06-07 14:27:46 +03:00
GOPROXY = https://proxy.golang.org|direct
2024-10-14 17:44:24 +03:00
GOTELEMETRY = off
2024-11-08 16:26:22 +03:00
GOTOOLCHAIN = go1.23.2
2022-11-29 18:20:10 +03:00
RACE = 0
2024-10-14 17:44:24 +03:00
REVISION = $${REVISION:-$$(git rev-parse --short HEAD)}
2022-11-29 18:20:10 +03:00
VERSION = 0
2022-08-26 14:18:35 +03:00
2024-10-14 17:44:24 +03:00
ENV = env \
BRANCH="$(BRANCH)" \
GO="$(GO.MACRO)" \
GOAMD64='$(GOAMD64)' \
GOPROXY='$(GOPROXY)' \
GOTELEMETRY='$(GOTELEMETRY)' \
GOTOOLCHAIN='$(GOTOOLCHAIN)' \
PATH="$${PWD}/bin:$$("$(GO.MACRO)" env GOPATH)/bin:$${PATH}" \
RACE='$(RACE)' \
REVISION="$(REVISION)" \
VERBOSE="$(VERBOSE.MACRO)" \
VERSION="$(VERSION)" \
# Keep the line above blank.
ENV_MISC = env \
PATH="$${PWD}/bin:$$("$(GO.MACRO)" env GOPATH)/bin:$${PATH}" \
VERBOSE="$(VERBOSE.MACRO)" \
2022-08-26 14:18:35 +03:00
# Keep the line above blank.
2022-11-29 18:20:10 +03:00
# Keep this target first, so that a naked make invocation triggers a
# full build.
2022-08-26 14:18:35 +03:00
build: go-deps go-build
2022-11-29 18:20:10 +03:00
init: ; git config core.hooksPath ./scripts/hooks
2022-08-26 14:18:35 +03:00
test: go-test
2024-10-14 17:44:24 +03:00
go-bench: ; $(ENV) "$(SHELL)" ./scripts/make/go-bench.sh
go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
go-env: ; $(ENV) "$(GO.MACRO)" env
go-fuzz: ; $(ENV) "$(SHELL)" ./scripts/make/go-fuzz.sh
go-gen: ; $(ENV) "$(SHELL)" ./scripts/make/go-gen.sh
go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
go-test: ; $(ENV) RACE='1' "$(SHELL)" ./scripts/make/go-test.sh
go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh
go-upd-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-upd-tools.sh
2024-03-11 12:21:07 +03:00
2022-08-26 14:18:35 +03:00
go-check: go-tools go-lint go-test
# A quick check to make sure that all operating systems relevant to the
# development of the project can be typechecked and built successfully.
go-os-check:
2024-10-14 17:44:24 +03:00
$(ENV) GOOS='darwin' "$(GO.MACRO)" vet ./internal/... ./internal/dnsserver/...
$(ENV) GOOS='linux' "$(GO.MACRO)" vet ./internal/... ./internal/dnsserver/...
2022-08-26 14:18:35 +03:00
# Additionally, check the AdGuard Home OSs in the dnsserver module.
2024-10-14 17:44:24 +03:00
$(ENV) GOOS='freebsd' "$(GO.MACRO)" vet ./internal/dnsserver/...
$(ENV) GOOS='openbsd' "$(GO.MACRO)" vet ./internal/dnsserver/...
$(ENV) GOOS='windows' "$(GO.MACRO)" vet ./internal/dnsserver/...
txt-lint: ; $(ENV) "$(SHELL)" ./scripts/make/txt-lint.sh
md-lint: ; $(ENV_MISC) "$(SHELL)" ./scripts/make/md-lint.sh
sh-lint: ; $(ENV_MISC) "$(SHELL)" ./scripts/make/sh-lint.sh
2022-08-26 14:18:35 +03:00
2024-10-14 17:44:24 +03:00
# Targets related to AdGuard DNS start here.
2022-08-26 14:18:35 +03:00
sync-github: ; $(ENV) "$(SHELL)" ./scripts/make/github-sync.sh