2025-09-04 19:21:53 +03:00
|
|
|
# Keep the Makefile POSIX-compliant. We currently allow hyphens in target
|
|
|
|
|
# names, but that may change in the future.
|
2020-07-09 19:54:53 +03:00
|
|
|
#
|
2024-11-08 17:18:16 +03:00
|
|
|
# See https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html.
|
2020-12-30 18:26:25 +03:00
|
|
|
.POSIX:
|
|
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
# This comment is used to simplify checking local copies of the Makefile. Bump
|
|
|
|
|
# this number every time a significant change is made to this Makefile.
|
2023-02-21 17:07:12 +03:00
|
|
|
#
|
2026-02-09 15:31:24 +00:00
|
|
|
# AdGuard-Project-Version: 12
|
2023-02-21 17:07:12 +03:00
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
# Don't name these macros "GO" etc., because GNU Make apparently makes 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.
|
2023-02-21 17:07:12 +03:00
|
|
|
#
|
|
|
|
|
# See https://unix.stackexchange.com/q/646255/105635.
|
|
|
|
|
GO.MACRO = $${GO:-go}
|
|
|
|
|
VERBOSE.MACRO = $${VERBOSE:-0}
|
|
|
|
|
|
2020-12-30 18:26:25 +03:00
|
|
|
CHANNEL = development
|
|
|
|
|
CLIENT_DIR = client
|
2024-09-11 19:39:54 +03:00
|
|
|
DEPLOY_SCRIPT_PATH = not/a/real/path
|
2020-12-30 18:26:25 +03:00
|
|
|
DIST_DIR = dist
|
2023-10-09 13:24:52 +03:00
|
|
|
GOAMD64 = v1
|
2024-08-20 18:38:04 +03:00
|
|
|
GOPROXY = https://proxy.golang.org|direct
|
|
|
|
|
GOTELEMETRY = off
|
2026-03-13 13:21:20 +00:00
|
|
|
GOTOOLCHAIN = go1.26.1
|
2020-12-30 20:36:57 +03:00
|
|
|
GPG_KEY = devteam@adguard.com
|
2020-12-30 18:26:25 +03:00
|
|
|
GPG_KEY_PASSPHRASE = not-a-real-password
|
|
|
|
|
NPM = npm
|
|
|
|
|
NPM_FLAGS = --prefix $(CLIENT_DIR)
|
2025-02-26 19:37:52 +03:00
|
|
|
NPM_INSTALL_FLAGS = $(NPM_FLAGS) --quiet --no-progress
|
2021-04-02 13:44:55 +03:00
|
|
|
RACE = 0
|
2024-11-08 17:18:16 +03:00
|
|
|
REVISION = $${REVISION:-$$(git rev-parse --short HEAD)}
|
2020-12-30 18:26:25 +03:00
|
|
|
SIGN = 1
|
2024-09-11 19:39:54 +03:00
|
|
|
SIGNER_API_KEY = not-a-real-key
|
2020-12-30 18:26:25 +03:00
|
|
|
VERSION = v0.0.0
|
|
|
|
|
|
2022-10-04 16:02:55 +03:00
|
|
|
NEXTAPI = 0
|
2022-04-26 20:50:09 +03:00
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
# Macros for the build-release target. If FRONTEND_PREBUILT is 0, the default,
|
|
|
|
|
# the macro $(BUILD_RELEASE_DEPS_$(FRONTEND_PREBUILT)) expands into
|
|
|
|
|
# BUILD_RELEASE_DEPS_0, and so both frontend and backend dependencies are
|
|
|
|
|
# fetched and the frontend is built. Otherwise, if FRONTEND_PREBUILT is 1, only
|
|
|
|
|
# backend dependencies are fetched and the frontend isn't rebuilt.
|
2021-05-21 14:55:42 +03:00
|
|
|
#
|
2025-09-04 19:21:53 +03:00
|
|
|
# TODO(a.garipov): We could probably do that from .../build-release.sh, but that
|
|
|
|
|
# would mean either calling make from inside make or duplicating commands in two
|
|
|
|
|
# places, both of which don't seem to me like nice solutions.
|
2021-05-21 14:55:42 +03:00
|
|
|
FRONTEND_PREBUILT = 0
|
|
|
|
|
BUILD_RELEASE_DEPS_0 = deps js-build
|
|
|
|
|
BUILD_RELEASE_DEPS_1 = go-deps
|
|
|
|
|
|
2026-02-09 15:31:24 +00:00
|
|
|
# TODO(f.setrakov): Remove the bin directory from the paths, as it is no longer
|
|
|
|
|
# needed.
|
|
|
|
|
ENV = env \
|
|
|
|
|
CHANNEL='$(CHANNEL)' \
|
2024-09-11 19:39:54 +03:00
|
|
|
DEPLOY_SCRIPT_PATH='$(DEPLOY_SCRIPT_PATH)' \
|
2026-02-09 15:31:24 +00:00
|
|
|
DIST_DIR='$(DIST_DIR)' \
|
|
|
|
|
GO="$(GO.MACRO)" \
|
|
|
|
|
GOAMD64='$(GOAMD64)' \
|
|
|
|
|
GOPROXY='$(GOPROXY)' \
|
|
|
|
|
GOTELEMETRY='$(GOTELEMETRY)' \
|
|
|
|
|
GOTOOLCHAIN='$(GOTOOLCHAIN)' \
|
|
|
|
|
GPG_KEY='$(GPG_KEY)' \
|
|
|
|
|
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)' \
|
|
|
|
|
NEXTAPI='$(NEXTAPI)' \
|
|
|
|
|
PATH="$${PWD}/bin:$$("$(GO.MACRO)" env GOPATH)/bin:$${PATH}" \
|
|
|
|
|
RACE='$(RACE)' \
|
|
|
|
|
REVISION="$(REVISION)" \
|
|
|
|
|
SIGN='$(SIGN)' \
|
2024-09-11 19:39:54 +03:00
|
|
|
SIGNER_API_KEY='$(SIGNER_API_KEY)' \
|
2026-02-09 15:31:24 +00:00
|
|
|
VERBOSE="$(VERBOSE.MACRO)" \
|
|
|
|
|
VERSION="$(VERSION)" \
|
2024-08-20 18:38:04 +03:00
|
|
|
|
|
|
|
|
# Keep the line above blank.
|
|
|
|
|
|
2026-02-09 15:31:24 +00:00
|
|
|
ENV_MISC = env \
|
|
|
|
|
PATH="$${PWD}/bin:$$("$(GO.MACRO)" env GOPATH)/bin:$${PATH}" \
|
|
|
|
|
VERBOSE="$(VERBOSE.MACRO)" \
|
2020-12-30 18:26:25 +03:00
|
|
|
|
|
|
|
|
# Keep the line above blank.
|
|
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
# Keep this target first, so that a naked make invocation triggers a full build.
|
|
|
|
|
.PHONY: build
|
2020-12-30 18:26:25 +03:00
|
|
|
build: deps quick-build
|
|
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
.PHONY: init
|
2024-11-08 17:18:16 +03:00
|
|
|
init: ; git config core.hooksPath ./scripts/hooks
|
|
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
.PHONY: quick-build
|
2020-12-30 18:26:25 +03:00
|
|
|
quick-build: js-build go-build
|
|
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
.PHONY: deps lint test
|
2020-12-30 18:26:25 +03:00
|
|
|
deps: js-deps go-deps
|
2020-12-08 18:23:35 +03:00
|
|
|
lint: js-lint go-lint
|
|
|
|
|
test: js-test go-test
|
|
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
# Here and below, keep $(SHELL) in quotes, because on Windows this will expand
|
|
|
|
|
# to something like "C:/Program Files/Git/usr/bin/sh.exe".
|
|
|
|
|
.PHONY: build-docker
|
2020-12-30 18:26:25 +03:00
|
|
|
build-docker: ; $(ENV) "$(SHELL)" ./scripts/make/build-docker.sh
|
|
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
.PHONY: build-release
|
2021-05-21 14:55:42 +03:00
|
|
|
build-release: $(BUILD_RELEASE_DEPS_$(FRONTEND_PREBUILT))
|
2020-12-30 18:26:25 +03:00
|
|
|
$(ENV) "$(SHELL)" ./scripts/make/build-release.sh
|
|
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
.PHONY: js-build js-deps js-typecheck js-lint js-test js-test-e2e
|
2025-02-26 19:37:52 +03:00
|
|
|
js-build: ; $(NPM) $(NPM_FLAGS) run build-prod
|
|
|
|
|
js-deps: ; $(NPM) $(NPM_INSTALL_FLAGS) ci
|
|
|
|
|
js-typecheck: ; $(NPM) $(NPM_FLAGS) run typecheck
|
|
|
|
|
js-lint: ; $(NPM) $(NPM_FLAGS) run lint
|
|
|
|
|
js-test: ; $(NPM) $(NPM_FLAGS) run test
|
|
|
|
|
js-test-e2e: ; $(NPM) $(NPM_FLAGS) run test:e2e
|
2020-07-09 19:54:53 +03:00
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
# TODO(a.garipov): Think about making RACE='1' the default for all targets.
|
2026-02-09 15:31:24 +00:00
|
|
|
.PHONY: go-bench go-build go-deps go-env go-fuzz go-lint go-test go-upd-tools
|
2025-09-04 19:21:53 +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-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
|
|
|
|
|
go-test: ; $(ENV) RACE='1' "$(SHELL)" ./scripts/make/go-test.sh
|
|
|
|
|
go-upd-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-upd-tools.sh
|
|
|
|
|
|
|
|
|
|
.PHONY: go-check
|
2026-02-09 15:31:24 +00:00
|
|
|
go-check: go-lint go-test
|
2021-01-27 18:32:13 +03:00
|
|
|
|
2024-08-20 18:38:04 +03:00
|
|
|
# A quick check to make sure that all operating systems relevant to the
|
|
|
|
|
# development of the project can be typechecked and built successfully.
|
2026-02-04 11:56:59 +00:00
|
|
|
#
|
|
|
|
|
# NOTE: It is also important to check on both 32- and 64-bit systems.
|
2025-09-04 19:21:53 +03:00
|
|
|
.PHONY: go-os-check
|
2021-04-08 20:42:04 +03:00
|
|
|
go-os-check:
|
2026-02-04 11:56:59 +00:00
|
|
|
$(ENV) GOOS='darwin' "$(GO.MACRO)" vet ./...
|
|
|
|
|
$(ENV) GOOS='freebsd' "$(GO.MACRO)" vet ./...
|
|
|
|
|
$(ENV) GOOS='openbsd' "$(GO.MACRO)" vet ./...
|
|
|
|
|
$(ENV) GOOS='windows' "$(GO.MACRO)" vet ./...
|
|
|
|
|
|
|
|
|
|
$(ENV) GOARCH='amd64' GOOS='linux' "$(GO.MACRO)" vet ./...
|
|
|
|
|
$(ENV) GOARCH='386' GOOS='linux' "$(GO.MACRO)" vet ./...
|
2021-05-19 20:31:20 +03:00
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
.PHONY: txt-lint
|
2023-02-21 17:07:12 +03:00
|
|
|
txt-lint: ; $(ENV) "$(SHELL)" ./scripts/make/txt-lint.sh
|
2024-08-20 18:38:04 +03:00
|
|
|
|
2025-09-04 19:21:53 +03:00
|
|
|
.PHONY: md-lint sh-lint
|
2026-02-09 15:31:24 +00:00
|
|
|
md-lint: ; $(ENV_MISC) "$(SHELL)" ./scripts/make/md-lint.sh
|
|
|
|
|
sh-lint: ; $(ENV_MISC) "$(SHELL)" ./scripts/make/sh-lint.sh
|
2024-11-08 17:18:16 +03:00
|
|
|
|
2025-03-28 14:54:02 +03:00
|
|
|
# TODO(a.garipov): Re-add openapi-lint.
|