2018-08-30 14:25:33 +00:00
|
|
|
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
|
|
|
|
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)))
|
2018-09-21 17:01:55 +00:00
|
|
|
GOPATH := $(mkfile_dir)/build/gopath
|
2018-10-10 14:56:48 +00:00
|
|
|
JSFILES = $(shell find client -path client/node_modules -prune -o -type f -name '*.js')
|
|
|
|
STATIC = build/static/index.html
|
2018-08-30 14:25:33 +00:00
|
|
|
|
|
|
|
.PHONY: all build clean
|
|
|
|
all: build
|
|
|
|
|
|
|
|
build: AdguardDNS coredns
|
|
|
|
|
2018-09-21 17:01:55 +00:00
|
|
|
client/node_modules: client/package.json client/package-lock.json
|
2018-09-07 13:14:25 +00:00
|
|
|
npm --prefix client install
|
2018-09-21 17:01:55 +00:00
|
|
|
touch client/node_modules
|
|
|
|
|
2018-10-10 14:56:48 +00:00
|
|
|
$(STATIC): $(JSFILES) client/node_modules
|
2018-09-07 13:14:25 +00:00
|
|
|
npm --prefix client run build-prod
|
2018-08-30 14:25:33 +00:00
|
|
|
|
|
|
|
AdguardDNS: $(STATIC) *.go
|
2018-09-26 15:26:24 +00:00
|
|
|
mkdir -p $(GOPATH)/src/github.com/AdguardTeam
|
2018-10-09 22:23:32 +00:00
|
|
|
if [ ! -h $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS ]; then rm -rf $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS && ln -fs ../../../../.. $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS; fi
|
2018-09-21 17:01:55 +00:00
|
|
|
GOPATH=$(GOPATH) go get -v -d .
|
|
|
|
GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go get -v github.com/gobuffalo/packr/...
|
|
|
|
mkdir -p $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS/build/static ## work around packr bug
|
|
|
|
GOPATH=$(GOPATH) PATH=$(GOPATH)/bin:$(PATH) packr build -ldflags="-X main.VersionString=$(GIT_VERSION)" -o AdguardDNS
|
2018-08-30 14:25:33 +00:00
|
|
|
|
|
|
|
coredns: coredns_plugin/*.go dnsfilter/*.go
|
2018-09-21 17:01:55 +00:00
|
|
|
GOPATH=$(GOPATH) go get -v -d github.com/coredns/coredns
|
2018-09-10 14:46:42 +00:00
|
|
|
cd $(GOPATH)/src/github.com/prometheus/client_golang && git checkout -q v0.8.0
|
2018-09-05 18:22:14 +00:00
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && perl -p -i.bak -e 's/^(trace|route53|federation|kubernetes|etcd):.*//' plugin.cfg
|
2018-08-30 16:05:03 +00: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-10-05 04:25:44 +00:00
|
|
|
perl -0777 -p -i.bak -e 's/pprofOnce.Do\(func\(\) {(.*)}\)/\1/ms' $(GOPATH)/src/github.com/coredns/coredns/plugin/pprof/setup.go
|
|
|
|
perl -0777 -p -i.bak -e 's/c.OnShutdown/c.OnRestart/' $(GOPATH)/src/github.com/coredns/coredns/plugin/pprof/setup.go
|
2018-09-21 17:01:55 +00:00
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go generate
|
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) go get -v -d .
|
|
|
|
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) go build -o $(mkfile_dir)/coredns
|
2018-08-30 14:25:33 +00:00
|
|
|
|
|
|
|
clean:
|
2018-09-21 17:01:55 +00:00
|
|
|
$(MAKE) cleanfast
|
2018-09-25 16:25:54 +00:00
|
|
|
rm -rf build
|
|
|
|
rm -rf client/node_modules
|
2018-09-21 17:01:55 +00:00
|
|
|
|
|
|
|
cleanfast:
|
2018-09-25 16:25:54 +00:00
|
|
|
rm -f coredns AdguardDNS
|