1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 09:15:14 +01:00
wireguard-go/Makefile

43 lines
1.5 KiB
Makefile
Raw Normal View History

2018-05-15 02:15:16 +02:00
PREFIX ?= /usr
DESTDIR ?=
BINDIR ?= $(PREFIX)/bin
2018-10-12 01:12:00 +02:00
export GOPATH ?= $(CURDIR)/.gopath
2018-10-12 01:45:33 +02:00
export GO111MODULE := on
2018-10-12 01:12:00 +02:00
2018-10-17 21:45:16 +02:00
all: generate-version-and-build
2018-05-15 02:15:16 +02:00
2018-10-12 01:12:00 +02:00
ifeq ($(shell go env GOOS)|$(wildcard .git),linux|)
2018-05-20 03:18:47 +02:00
$(error Do not build this for Linux. Instead use the Linux kernel module. See wireguard.com/install/ for more info.)
else ifeq ($(shell go env GOOS),linux)
2018-10-12 01:12:00 +02:00
ireallywantobuildon_linux.go:
@printf "WARNING: This software is meant for use on non-Linux\nsystems. For Linux, please use the kernel module\ninstead. See wireguard.com/install/ for more info.\n\n" >&2
@printf 'package main\nconst UseTheKernelModuleInstead = 0xdeadbabe\n' > "$@"
clean-ireallywantobuildon_linux.go:
@rm -f ireallywantobuildon_linux.go
.PHONY: clean-ireallywantobuildon_linux.go
clean: clean-ireallywantobuildon_linux.go
wireguard-go: ireallywantobuildon_linux.go
2018-05-20 03:18:47 +02:00
endif
2018-10-12 01:12:00 +02:00
MAKEFLAGS += --no-print-directory
2018-10-12 01:12:00 +02:00
generate-version-and-build:
2018-05-24 01:52:22 +02:00
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
tag="$$(git describe --dirty 2>/dev/null)" && \
2019-03-03 04:04:41 +01:00
ver="$$(printf 'package device\nconst WireGuardGoVersion = "%s"\n' "$$tag")" && \
[ "$$(cat device/version.go 2>/dev/null)" != "$$ver" ] && \
echo "$$ver" > device/version.go && \
git update-index --assume-unchanged device/version.go || true
2018-10-12 01:12:00 +02:00
@$(MAKE) wireguard-go
2018-05-24 01:52:22 +02:00
2018-10-09 18:11:36 +02:00
wireguard-go: $(wildcard *.go) $(wildcard */*.go)
go build -v -o "$@"
2018-05-15 02:15:16 +02:00
install: wireguard-go
2018-10-09 18:11:36 +02:00
@install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 "$<" "$(DESTDIR)$(BINDIR)/wireguard-go"
clean:
rm -f wireguard-go
2018-10-17 21:45:16 +02:00
.PHONY: all clean install generate-version-and-build