Makefile 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. VERSION := $(shell git describe --tags --abbrev=0 | tr -d '[:alpha:]')
  2. LDFLAGS := "-s -w -X github.com/cloudflare/cfssl/cli/version.version=$(VERSION)"
  3. export GOFLAGS := -mod=vendor
  4. export GOPROXY := off
  5. .PHONY: all
  6. all: bin/cfssl bin/cfssl-bundle bin/cfssl-certinfo bin/cfssl-newkey bin/cfssl-scan bin/cfssljson bin/mkbundle bin/multirootca
  7. bin/%: $(shell find . -type f -name '*.go')
  8. @mkdir -p $(dir $@)
  9. go build -ldflags $(LDFLAGS) -o $@ ./cmd/$(@F)
  10. .PHONY: install
  11. install: install-cfssl install-cfssl-bundle install-cfssl-certinfo install-cfssl-newkey install-cfssl-scan install-cfssljson install-mkbundle install-multirootca
  12. .PHONY: install-%
  13. install-%:
  14. go install ./cmd/$(@F:install-%=%)
  15. bin/rice: $(shell find . -type f -name '*.go')
  16. @mkdir -p $(dir $@)
  17. go build -o $@ ./vendor/github.com/GeertJohan/go.rice/rice
  18. bin/golint: $(shell find . -type f -name '*.go')
  19. @mkdir -p $(dir $@)
  20. go build -o $@ ./vendor/golang.org/x/lint/golint
  21. bin/goose: $(shell find . -type f -name '*.go')
  22. @mkdir -p $(dir $@)
  23. go build -o $@ ./vendor/bitbucket.org/liamstask/goose/cmd/goose
  24. .PHONY: clean
  25. clean:
  26. rm -rf bin *.deb *.rpm
  27. # Check that given variables are set and all have non-empty values,
  28. # die with an error otherwise.
  29. #
  30. # Params:
  31. # 1. Variable name(s) to test.
  32. # 2. (optional) Error message to print.
  33. #
  34. # cf: https://stackoverflow.com/questions/10858261/abort-makefile-if-variable-not-set
  35. check_defined = \
  36. $(strip $(foreach 1,$1, \
  37. $(call __check_defined,$1,$(strip $(value 2)))))
  38. __check_defined = \
  39. $(if $(value $1),, \
  40. $(error Undefined $1$(if $2, ($2))))
  41. .PHONY: snapshot
  42. snapshot:
  43. docker run --rm -v $(PWD):/workdir -w /workdir cbroglie/goreleaser-cgo:1.12.12-musl goreleaser --rm-dist --snapshot --skip-publish
  44. .PHONY: release
  45. release:
  46. @:$(call check_defined, GITHUB_TOKEN)
  47. docker run -e GITHUB_TOKEN=$(GITHUB_TOKEN) --rm -v $(PWD):/workdir -w /workdir cbroglie/goreleaser-cgo:1.12.12-musl goreleaser --rm-dist
  48. BUILD_PATH := $(CURDIR)/build
  49. INSTALL_PATH := $(BUILD_PATH)/usr/local/bin
  50. FPM = fakeroot fpm -C $(BUILD_PATH) \
  51. -a $(shell uname -m) \
  52. -s dir \
  53. -v $(VERSION) \
  54. --url 'https://github.com/cloudflare/cfssl' \
  55. --vendor Cloudflare \
  56. -n cfssl
  57. .PHONY: package
  58. package: package-deb package-rpm
  59. .PHONY: package-deb
  60. package-deb: all
  61. $(RM) -r build
  62. mkdir -p $(INSTALL_PATH)
  63. cp bin/* $(INSTALL_PATH)
  64. $(FPM) -t deb .
  65. .PHONY: package-rpm
  66. package-rpm: all
  67. $(RM) -r build
  68. mkdir -p $(INSTALL_PATH)
  69. cp bin/* $(INSTALL_PATH)
  70. $(FPM) -t rpm .