dae/Makefile

52 lines
1.5 KiB
Makefile
Raw Normal View History

2023-01-23 18:54:21 +07:00
#
# SPDX-License-Identifier: AGPL-3.0-only
2023-01-28 12:56:06 +07:00
# Copyright (c) since 2022, v2rayA Organization <team@v2raya.org>
2023-01-23 18:54:21 +07:00
#
# The development version of clang is distributed as the 'clang' binary,
# while stable/released versions have a version number attached.
# Pin the default clang to a stable version.
CLANG ?= clang
2023-01-23 18:54:21 +07:00
STRIP ?= llvm-strip
2023-01-28 17:32:42 +07:00
OUTPUT ?= dae
2023-01-27 01:10:27 +07:00
CFLAGS := -O2 -Wall -Werror $(CFLAGS)
2023-01-31 21:02:18 +07:00
TARGET ?= bpfel,bpfeb
2023-01-27 01:10:27 +07:00
# Get version from .git.
date=$(shell git log -1 --format="%cd" --date=short | sed s/-//g)
count=$(shell git rev-list --count HEAD)
commit=$(shell git rev-parse --short HEAD)
ifeq ($(wildcard .git/.),)
2023-01-28 12:52:31 +07:00
VERSION ?= unstable-0.nogit
2023-01-27 01:10:27 +07:00
else
2023-01-28 12:52:31 +07:00
VERSION ?= unstable-$(date).r$(count).$(commit)
2023-01-27 01:10:27 +07:00
endif
2023-01-23 18:54:21 +07:00
.PHONY: clean-ebpf bpf_objects ebpf dae
2023-01-23 19:01:24 +07:00
dae: ebpf
2023-01-28 17:32:42 +07:00
go build -o $(OUTPUT) -trimpath -ldflags "-s -w -X github.com/v2rayA/dae/cmd.Version=$(VERSION)" .
2023-01-23 18:54:21 +07:00
2023-01-31 17:33:47 +07:00
clean-ebpf:
2023-01-31 19:25:55 +07:00
rm -f component/control/bpf_bpf*.go && \
rm -f component/control/bpf_bpf*.o
2023-01-31 17:33:47 +07:00
bpf_objects:
2023-02-02 20:26:54 +07:00
unset GOOS && \
unset GOARCH && \
unset GOARM && \
if [ ! -f component/control/bpf_objects_wan_lan.go ]; then \
go run github.com/v2rayA/dae/cmd/internal/generate_bpf_objects/dummy -o component/control/bpf_objects_wan_lan.go; \
fi
2023-01-23 18:54:21 +07:00
# $BPF_CLANG is used in go:generate invocations.
2023-01-23 19:01:24 +07:00
ebpf: export BPF_CLANG := $(CLANG)
ebpf: export BPF_STRIP := $(STRIP)
ebpf: export BPF_CFLAGS := $(CFLAGS)
2023-01-31 19:25:55 +07:00
ebpf: export BPF_TARGET := $(TARGET)
ebpf: clean-ebpf bpf_objects
2023-01-28 17:32:42 +07:00
unset GOOS && \
unset GOARCH && \
unset GOARM && \
go generate ./component/control/control.go