Makefile.example 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. Skip to content
  2. This repository
  3. Search
  4. Pull requests
  5. Issues
  6. Marketplace
  7. Explore
  8. @dongcj
  9. Sign out
  10. 1
  11. 1 6 dmportella/powerdns
  12. forked from jgreat/powerdns
  13. Code Issues 1 Pull requests 0 Projects 0 Insights
  14. powerdns/makefile
  15. 7cb21fd on 12 May 2017
  16. @dmportella dmportella updated vet code
  17. 168 lines (135 sloc) 6.39 KB
  18. APPNAME?="powerdns"
  19. REPONAME?="dmportella"
  20. TEST?=$$(go list ./... | grep -v '/vendor/')
  21. VETARGS?=-all
  22. GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
  23. REV?=$$(git rev-parse --short HEAD)
  24. BRANCH?=$$(git rev-parse --abbrev-ref HEAD)
  25. BUILDFILES?=$$(find bin -mindepth 1 -maxdepth 1 -type f)
  26. VERSION?="0.0.0"
  27. DOCKER_REPO?="${REPONAME}/${APPNAME}"
  28. TOKEN?=""
  29. XC_OS=$$(go env GOOS)
  30. XC_ARCH=$$(go env GOARCH)
  31. default: lazy
  32. lazy: version fmt lint vet test
  33. # Git commands
  34. save:
  35. @git add -A
  36. @git commit -S
  37. @git status
  38. push:
  39. @git push origin ${BRANCH}
  40. subtree-pull:
  41. @git log | grep git-subtree-dir | awk '{print $2}'
  42. @git subtree pull --prefix=website/public git@github.com:${REPONAME}/${APPNAME}.git gh-pages
  43. subtree-push:
  44. @git log | grep git-subtree-dir | awk '{print $2}'
  45. @git subtree push --prefix=website/public git@github.com:${REPONAME}/${APPNAME}.git gh-pages
  46. update:
  47. @git pull origin ${BRANCH}
  48. vendor:
  49. @govendor add +external
  50. vendor-update:
  51. @govendor update +external
  52. version:
  53. @echo "SOFTWARE VERSION"
  54. @echo "\tbranch:\t\t" ${BRANCH}
  55. @echo "\trevision:\t" ${REV}
  56. @echo "\tversion:\t" ${VERSION}
  57. ci: tools build
  58. @echo "CI BUILD..."
  59. tools:
  60. @echo "GO TOOLS installation..."
  61. @go get -u github.com/kardianos/govendor
  62. @go get -u golang.org/x/tools/cmd/cover
  63. @go get -u github.com/golang/lint/golint
  64. build: version test
  65. @echo "GO BUILD..."
  66. @CGO_ENABLED=0 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=${XC_OS}/${XC_ARCH}" -v -o ./bin/${APPNAME} .
  67. buildonly:
  68. @CGO_ENABLED=0 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=${XC_OS}/${XC_ARCH}" -v -o ./bin/${APPNAME} .
  69. crosscompile: linux-build darwin-build freebsd-build windows-build tar-everything shasums
  70. @echo "crosscompile done..."
  71. docker:
  72. @if [ -e "bin/linux-amd64/${APPNAME}" ]; then \
  73. docker build -t ${DOCKER_REPO}:${VERSION} -q --build-arg CONT_IMG_VER=${VERSION} --build-arg BINARY=bin/linux-amd64/${APPNAME} . ; \
  74. docker tag ${DOCKER_REPO}:${VERSION} ${DOCKER_REPO}:latest ; \
  75. else \
  76. echo "Please run crosscompile before running docker command." ; \
  77. exit 1 ; \
  78. fi
  79. docker-run:
  80. @docker run -it --rm -v /etc/ssl/certs/:/etc/ssl/certs/ --name ${APPNAME} ${DOCKER_REPO}:latest -t ${TOKEN} -verbose
  81. tar-everything:
  82. @echo "tar-everything..."
  83. @tar -zcvf bin/${APPNAME}-linux-386-${VERSION}.tgz bin/linux-386
  84. @tar -zcvf bin/${APPNAME}-linux-amd64-${VERSION}.tgz bin/linux-amd64
  85. @tar -zcvf bin/${APPNAME}-linux-arm-${VERSION}.tgz bin/linux-arm
  86. @tar -zcvf bin/${APPNAME}-darwin-386-${VERSION}.tgz bin/darwin-386
  87. @tar -zcvf bin/${APPNAME}-darwin-amd64-${VERSION}.tgz bin/darwin-amd64
  88. @tar -zcvf bin/${APPNAME}-freebsd-386-${VERSION}.tgz bin/freebsd-386
  89. @tar -zcvf bin/${APPNAME}-freebsd-amd64-${VERSION}.tgz bin/freebsd-amd64
  90. @zip -9 -y -r bin/${APPNAME}-windows-386-${VERSION}.zip bin/windows-386
  91. @zip -9 -y -r bin/${APPNAME}-windows-amd64-${VERSION}.zip bin/windows-amd64
  92. shasums:
  93. @shasum -a 256 $(BUILDFILES) > bin/${APPNAME}-${VERSION}.shasums
  94. gpg:
  95. @gpg --output bin/${APPNAME}-${VERSION}.sig --detach-sig bin/${APPNAME}-${VERSION}.shasums
  96. gpg-verify:
  97. @gpg --verify bin/${APPNAME}-${VERSION}.sig bin/${APPNAME}-${VERSION}.shasums
  98. linux-build:
  99. @echo "linux build... 386"
  100. @CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=linux/386" -v -o ./bin/linux-386/${APPNAME} . 2>/dev/null
  101. @echo "linux build... amd64"
  102. @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=linux/amd64" -v -o ./bin/linux-amd64/${APPNAME} . 2>/dev/null
  103. @echo "linux build... arm"
  104. @CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=linux/arm" -v -o ./bin/linux-arm/${APPNAME} . 2>/dev/null
  105. darwin-build:
  106. @echo "darwin build... 386"
  107. @CGO_ENABLED=0 GOOS=darwin GOARCH=386 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=darwin/386" -v -o ./bin/darwin-386/${APPNAME} . 2>/dev/null
  108. @echo "darwin build... amd64"
  109. @CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=darwin/amd64" -v -o ./bin/darwin-amd64/${APPNAME} . 2>/dev/null
  110. freebsd-build:
  111. @echo "freebsd build... 386"
  112. @CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=freebsd/386" -v -o ./bin/freebsd-386/${APPNAME} . 2>/dev/null
  113. @echo "freebsd build... amd64"
  114. @CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=freebsd/amd64" -v -o ./bin/freebsd-amd64/${APPNAME} . 2>/dev/null
  115. windows-build:
  116. @echo "windows build... 386"
  117. @CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=windows/386" -v -o ./bin/windows-386/${APPNAME}.exe . 2>/dev/null
  118. @echo "windows build... amd64"
  119. @CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH} -X main.OSArch=windows/amd64" -v -o ./bin/windows-amd64/${APPNAME}.exe . 2>/dev/null
  120. lint:
  121. @echo "GO LINT..."
  122. @for pkg in $$(go list ./... |grep -v /vendor/) ; do \
  123. golint -set_exit_status $$pkg ; \
  124. done
  125. test: fmt generate lint vet
  126. @echo "GO TEST..."
  127. @go test $(TEST) $(TESTARGS) -v -timeout=30s -parallel=4 -bench=. -benchmem -cover
  128. cover:
  129. @echo "GO TOOL COVER..."
  130. @go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
  131. go get -u golang.org/x/tools/cmd/cover; \
  132. fi
  133. @go test $(TEST) -coverprofile=coverage.out
  134. @go tool cover -html=coverage.out
  135. @rm coverage.out
  136. generate:
  137. @echo "GO GENERATE..."
  138. @go generate $(go list ./... | grep -v /vendor/) ./
  139. # vet runs the Go source code static analysis tool `vet` to find
  140. # any common errors.
  141. vet:
  142. @echo "GO VET..."
  143. @govendor vet +l; if [ $$? -eq 1 ]; then \
  144. echo ""; \
  145. echo "Vet found suspicious constructs. Please check the reported constructs"; \
  146. echo "and fix them if necessary before submitting the code for review."; \
  147. exit 1; \
  148. fi
  149. fmt:
  150. @echo "GO FMT..."
  151. @gofmt -w -s $(GOFMT_FILES)
  152. .PHONY: tools default
  153. ? 2018 GitHub, Inc.
  154. Terms
  155. Privacy
  156. Security
  157. Status
  158. Help
  159. Contact GitHub
  160. API
  161. Training
  162. Shop
  163. Blog
  164. About
  165. Press h to open a hovercard with more details.