forked from arnika-project/arnika
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (32 loc) · 1.3 KB
/
Copy pathMakefile
File metadata and controls
41 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Define the name of the application and its version
NAME := arnika
VERSION := $(shell git describe --tags --always)
# Define the Go compiler and other tools
GO = go
# Build flags
GO_BUILD_VARS := CGO_ENABLED=0 GOEXPERIMENT=runtimesecret
BUILD_FLAGS = -trimpath -ldflags "-w -s -extldflags=-Wl,-Bsymbolic -X 'main.Version=$(VERSION)' -X 'main.APPName=$(NAME)'"
BINARY_NAME ?= arnika
BUILD_DIR ?= build
# Optional Go build tags selecting the key writer backend (see KEYCONTROL.md):
# (empty) -> netlink, local WireGuard via wgctrl [default]
# wireguard_netlink -> netlink (explicit)
# wireguard_mikrotik -> MikroTik RouterOS REST API
# Usage: make build BUILD_TAGS=wireguard_mikrotik
BUILD_TAGS ?=
TAGS_FLAG := $(if $(BUILD_TAGS),-tags "$(BUILD_TAGS)",)
# Default target: build the binary
default: build
# Build rule: create a new executable
build:
@echo "Building $(BINARY_NAME)$(if $(BUILD_TAGS), (tags: $(BUILD_TAGS)),)"
$(GO_BUILD_VARS) $(GO) build $(BUILD_FLAGS) $(TAGS_FLAG) -o $(BUILD_DIR)/$(BINARY_NAME) .
# Convenience targets for each key writer backend
build-netlink:
$(MAKE) build BUILD_TAGS=wireguard_netlink
build-mikrotik:
$(MAKE) build BUILD_TAGS=wireguard_mikrotik
# Clean rule: remove build artifacts
clean:
rm -rf $(BUILD_DIR)/*
.PHONY: default build build-netlink build-mikrotik clean