| 
									
										
										
										
											2016-07-07 01:40:58 -07:00
										 |  |  | BUILD_VERBOSE := -v | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-14 14:50:14 -07:00
										 |  |  | TEST_VERBOSE := -v | 
					
						
							| 
									
										
										
										
											2016-06-06 12:49:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | all: coredns | 
					
						
							| 
									
										
										
										
											2016-08-05 18:19:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | # Phony this to ensure we always build the binary.
 | 
					
						
							|  |  |  | # TODO: Add .go file dependencies.
 | 
					
						
							|  |  |  | .PHONY: coredns | 
					
						
							| 
									
										
										
										
											2017-07-26 02:24:01 -07:00
										 |  |  | coredns: check godeps | 
					
						
							| 
									
										
										
										
											2017-07-27 14:34:56 -07:00
										 |  |  | 	CGO_ENABLED=0 go build $(BUILD_VERBOSE) -ldflags="-s -w" | 
					
						
							| 
									
										
										
										
											2016-04-13 20:14:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 11:07:44 -07:00
										 |  |  | .PHONY: deps | 
					
						
							| 
									
										
										
										
											2017-07-26 02:24:01 -07:00
										 |  |  | deps: core/zmiddleware.go core/dnsserver/zdirectives.go godeps | 
					
						
							| 
									
										
										
										
											2017-03-05 14:17:05 -08:00
										 |  |  | 	go get -u github.com/golang/lint/golint | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: check | 
					
						
							|  |  |  | check: fmt deps | 
					
						
							| 
									
										
										
										
											2016-04-28 11:07:44 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | .PHONY: test | 
					
						
							| 
									
										
										
										
											2017-03-05 14:17:05 -08:00
										 |  |  | test: check | 
					
						
							| 
									
										
										
										
											2016-11-05 14:38:49 +00:00
										 |  |  | 	go test -race $(TEST_VERBOSE) ./test ./middleware/... | 
					
						
							| 
									
										
										
										
											2016-04-28 11:07:44 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-14 14:50:14 -07:00
										 |  |  | .PHONY: testk8s | 
					
						
							| 
									
										
										
										
											2017-03-05 14:17:05 -08:00
										 |  |  | testk8s: check | 
					
						
							| 
									
										
										
										
											2016-10-17 18:37:56 +01:00
										 |  |  | 	go test -race $(TEST_VERBOSE) -tags=k8s -run 'TestKubernetes' ./test ./middleware/kubernetes/... | 
					
						
							| 
									
										
										
										
											2016-08-05 18:19:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-26 02:24:01 -07:00
										 |  |  | .PHONY: godeps | 
					
						
							|  |  |  | godeps: | 
					
						
							| 
									
										
										
										
											2017-06-03 08:27:41 +01:00
										 |  |  | 	go get github.com/mholt/caddy | 
					
						
							| 
									
										
										
										
											2017-07-26 02:24:01 -07:00
										 |  |  | 	go get github.com/miekg/dns | 
					
						
							|  |  |  | 	go get golang.org/x/net/context | 
					
						
							|  |  |  | 	go get golang.org/x/text | 
					
						
							| 
									
										
										
										
											2017-06-03 08:27:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-26 14:22:48 +08:00
										 |  |  | .PHONY: coverage | 
					
						
							| 
									
										
										
										
											2017-03-05 14:17:05 -08:00
										 |  |  | coverage: check | 
					
						
							| 
									
										
										
										
											2016-09-26 14:22:48 +08:00
										 |  |  | 	set -e -x | 
					
						
							|  |  |  | 	echo "" > coverage.txt | 
					
						
							|  |  |  | 	for d in `go list ./... | grep -v vendor`; do \
 | 
					
						
							| 
									
										
										
										
											2016-09-27 07:57:04 +08:00
										 |  |  | 		go test $(TEST_VERBOSE)  -tags 'etcd k8s' -race -coverprofile=cover.out -covermode=atomic -bench=. $$d || exit 1; \
 | 
					
						
							|  |  |  | 		if [ -f cover.out ]; then \
 | 
					
						
							|  |  |  | 			cat cover.out >> coverage.txt; \
 | 
					
						
							|  |  |  | 			rm cover.out; \
 | 
					
						
							| 
									
										
										
										
											2016-09-26 14:22:48 +08:00
										 |  |  | 		fi; \
 | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 11:07:44 -07:00
										 |  |  | .PHONY: clean | 
					
						
							|  |  |  | clean: | 
					
						
							|  |  |  | 	go clean | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | 	rm -f coredns | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-16 12:12:19 -05:00
										 |  |  | core/zmiddleware.go core/dnsserver/zdirectives.go: middleware.cfg | 
					
						
							|  |  |  | 	go generate coredns.go | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-31 12:25:02 -05:00
										 |  |  | .PHONY: gen | 
					
						
							|  |  |  | gen: | 
					
						
							| 
									
										
										
										
											2017-02-14 19:23:18 +00:00
										 |  |  | 	go generate coredns.go | 
					
						
							| 
									
										
										
										
											2017-01-31 12:25:02 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-22 10:28:04 -08:00
										 |  |  | .PHONY: fmt | 
					
						
							|  |  |  | fmt: | 
					
						
							|  |  |  | 	## run go fmt | 
					
						
							| 
									
										
										
										
											2017-05-05 15:33:18 -04:00
										 |  |  | 	@test -z "$$(find . -type d | grep -vE '(/vendor|^\.$$|/.git|/.travis)' | xargs gofmt -s -l  | tee /dev/stderr)" || \
 | 
					
						
							| 
									
										
										
										
											2017-02-22 10:28:04 -08:00
										 |  |  | 		(echo "please format Go code with 'gofmt -s -w'" && false) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 14:17:05 -08:00
										 |  |  | .PHONY: lint | 
					
						
							|  |  |  | lint: deps | 
					
						
							|  |  |  | 	## run go lint, suggestion only (not enforced) | 
					
						
							| 
									
										
										
										
											2017-06-02 02:25:00 -04:00
										 |  |  | 	@test -z "$$(find . -type d | grep -vE '(/vendor|^\.$$|/.git|/.travis)' | grep -vE '(^\./pb)' | xargs golint \
 | 
					
						
							|  |  |  | 		| grep -vE "context\.Context should be the first parameter of a function" | tee /dev/stderr)"
 | 
					
						
							| 
									
										
										
										
											2017-03-05 14:17:05 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | .PHONY: distclean | 
					
						
							|  |  |  | distclean: clean | 
					
						
							|  |  |  | 	# Clean all dependencies and build artifacts | 
					
						
							|  |  |  | 	find $(GOPATH)/pkg -maxdepth 1 -mindepth 1 | xargs rm -rf | 
					
						
							|  |  |  | 	find $(GOPATH)/bin -maxdepth 1 -mindepth 1 | xargs rm -rf | 
					
						
							| 
									
										
										
										
											2016-11-07 14:12:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | 	find $(GOPATH)/src -maxdepth 1 -mindepth 1 | grep -v github | xargs rm -rf | 
					
						
							|  |  |  | 	find $(GOPATH)/src -maxdepth 2 -mindepth 2 | grep -v miekg | xargs rm -rf | 
					
						
							|  |  |  | 	find $(GOPATH)/src/github.com/miekg -maxdepth 1 -mindepth 1 \! -name \*coredns\* | xargs rm -rf |