2020-10-19 14:20:49 +00:00
|
|
|
NAME=dnscrypt
|
|
|
|
BASE_BUILDDIR=build
|
|
|
|
BUILDNAME=$(GOOS)-$(GOARCH)$(GOARM)
|
|
|
|
BUILDDIR=$(BASE_BUILDDIR)/$(BUILDNAME)
|
|
|
|
VERSION?=dev
|
|
|
|
|
|
|
|
ifeq ($(GOOS),windows)
|
|
|
|
ext=.exe
|
|
|
|
archiveCmd=zip -9 -r $(NAME)-$(BUILDNAME)-$(VERSION).zip $(BUILDNAME)
|
|
|
|
else
|
|
|
|
ext=
|
|
|
|
archiveCmd=tar czpvf $(NAME)-$(BUILDNAME)-$(VERSION).tar.gz $(BUILDNAME)
|
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: default
|
|
|
|
default: build
|
|
|
|
|
|
|
|
build: clean test
|
|
|
|
go build -ldflags "-X main.VersionString=$(VERSION)" -o $(NAME)$(ext) ./cmd
|
|
|
|
|
|
|
|
release: check-env-release
|
|
|
|
mkdir -p $(BUILDDIR)
|
|
|
|
cp LICENSE $(BUILDDIR)/
|
|
|
|
cp README.md $(BUILDDIR)/
|
2020-11-30 16:40:06 +00:00
|
|
|
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags "-X main.VersionString=$(VERSION)" -o $(BUILDDIR)/$(NAME)$(ext) ./cmd/
|
2020-10-19 14:20:49 +00:00
|
|
|
cd $(BASE_BUILDDIR) ; $(archiveCmd)
|
|
|
|
|
|
|
|
test:
|
|
|
|
go test -race -v -bench=. ./...
|
|
|
|
|
|
|
|
clean:
|
|
|
|
go clean
|
|
|
|
rm -rf $(BASE_BUILDDIR)
|
|
|
|
|
|
|
|
check-env-release:
|
|
|
|
@ if [ "$(GOOS)" = "" ]; then \
|
|
|
|
echo "Environment variable GOOS not set"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
@ if [ "$(GOARCH)" = "" ]; then \
|
|
|
|
echo "Environment variable GOOS not set"; \
|
|
|
|
exit 1; \
|
2020-11-30 16:40:06 +00:00
|
|
|
fi
|