2018-08-30 15:25:33 +01:00
|
|
|
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
|
|
|
|
GOPATH := $(shell go env GOPATH)
|
|
|
|
NATIVE_GOOS = $(shell unset GOOS; go env GOOS)
|
|
|
|
NATIVE_GOARCH = $(shell unset GOARCH; go env GOARCH)
|
|
|
|
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
mkfile_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
|
|
|
|
STATIC := build/static/bundle.css build/static/bundle.js build/static/index.html
|
|
|
|
|
|
|
|
.PHONY: all build clean
|
|
|
|
all: build
|
|
|
|
|
|
|
|
build: AdguardDNS coredns
|
|
|
|
|
|
|
|
$(STATIC):
|
2018-08-31 16:11:45 +01:00
|
|
|
cd client; npm install
|
|
|
|
cd client; npm run build-prod
|
2018-08-30 15:25:33 +01:00
|
|
|
|
|
|
|
AdguardDNS: $(STATIC) *.go
|
|
|
|
echo mkfile_dir = $(mkfile_dir)
|
|
|
|
go get -v -d .
|
|
|
|
GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go get -v github.com/gobuffalo/packr/...
|
|
|
|
PATH=$(GOPATH)/bin:$(PATH) packr build -ldflags="-X main.VersionString=$(GIT_VERSION)" -o AdguardDNS
|
|
|
|
|
|
|
|
coredns: coredns_plugin/*.go dnsfilter/*.go
|
|
|
|
echo mkfile_dir = $(mkfile_dir)
|
|
|
|
go get -v -d github.com/coredns/coredns
|
2018-09-05 19:22:14 +01:00
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && perl -p -i.bak -e 's/^(trace|route53|federation|kubernetes|etcd):.*//' plugin.cfg
|
2018-08-30 17:05:03 +01:00
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && grep -q '^dnsfilter:' plugin.cfg || perl -p -i.bak -e 's|^log:log|log:log\ndnsfilter:github.com/AdguardTeam/AdguardDNS/coredns_plugin|' plugin.cfg
|
|
|
|
grep '^dnsfilter:' $(GOPATH)/src/github.com/coredns/coredns/plugin.cfg ## used to check that plugin.cfg was successfully edited by sed
|
2018-08-30 15:25:33 +01:00
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go generate
|
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && go get -v -d .
|
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && go build -o $(mkfile_dir)/coredns
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -vf coredns AdguardDNS
|