Update makefile to build only one binary instead of two

This commit is contained in:
Eugene Bujak 2018-10-12 03:54:22 +03:00
parent bad88961e9
commit 7ff89baf45
1 changed files with 5 additions and 14 deletions

View File

@ -10,7 +10,7 @@ STATIC = build/static/index.html
.PHONY: all build clean .PHONY: all build clean
all: build all: build
build: AdguardDNS coredns build: AdguardDNS
client/node_modules: client/package.json client/package-lock.json client/node_modules: client/package.json client/package-lock.json
npm --prefix client install npm --prefix client install
@ -19,25 +19,16 @@ client/node_modules: client/package.json client/package-lock.json
$(STATIC): $(JSFILES) client/node_modules $(STATIC): $(JSFILES) client/node_modules
npm --prefix client run build-prod npm --prefix client run build-prod
AdguardDNS: $(STATIC) *.go AdguardDNS: $(STATIC) *.go coredns_plugin/*.go dnsfilter/*.go
mkdir -p $(GOPATH)/src/github.com/AdguardTeam mkdir -p $(GOPATH)/src/github.com/AdguardTeam
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 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
GOPATH=$(GOPATH) go get -v -d . GOPATH=$(GOPATH) go get -v -d .
GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go get -v github.com/gobuffalo/packr/... 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 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 cd $(GOPATH)/src/github.com/prometheus/client_golang && git reset --hard v0.8.0
coredns: coredns_plugin/*.go dnsfilter/*.go
GOPATH=$(GOPATH) go get -v -d github.com/coredns/coredns
cd $(GOPATH)/src/github.com/prometheus/client_golang && git checkout -q v0.8.0
cd $(GOPATH)/src/github.com/coredns/coredns && perl -p -i.bak -e 's/^(trace|route53|federation|kubernetes|etcd):.*//' plugin.cfg
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
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/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 perl -0777 -p -i.bak -e 's/c.OnShutdown/c.OnRestart/' $(GOPATH)/src/github.com/coredns/coredns/plugin/pprof/setup.go
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go generate GOPATH=$(GOPATH) PATH=$(GOPATH)/bin:$(PATH) packr build -ldflags="-X main.VersionString=$(GIT_VERSION)" -o AdguardDNS
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
clean: clean:
$(MAKE) cleanfast $(MAKE) cleanfast
@ -45,4 +36,4 @@ clean:
rm -rf client/node_modules rm -rf client/node_modules
cleanfast: cleanfast:
rm -f coredns AdguardDNS rm -f AdguardDNS