Host snippets with a git backend. Like Gists but OpenSource. https://gist.sigpipe.me/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. LDFLAGS += -X "dev.sigpipe.me/dashie/git.txt/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
  2. LDFLAGS += -X "dev.sigpipe.me/dashie/git.txt/setting.BuildGitHash=$(shell git rev-parse HEAD)"
  3. OS := $(shell uname)
  4. ifeq ($(OS), Windows_NT)
  5. EXECUTABLE := git_txt.exe
  6. else
  7. EXECUTABLE := git_txt
  8. endif
  9. DATA_FILES := $(shell find conf | sed 's/ /\\ /g')
  10. DIST := dist
  11. BUILD_FLAGS:=-o $(EXECUTABLE) -v
  12. TAGS=sqlite
  13. NOW=$(shell date -u '+%Y%m%d%I%M%S')
  14. GO ?= go
  15. GOVET=$(GO) vet
  16. GOLINT=golint -set_exit_status
  17. GOFMT ?= gofmt -s
  18. GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
  19. PACKAGES ?= $(filter-out dev.sigpipe.me/dashie/git.txt/integrations,$(shell go list ./... | grep -v /vendor/))
  20. PACKAGES_ALL ?= $(shell go list ./... | grep -v /vendor/)
  21. SOURCES ?= $(shell find . -name "*.go" -type f)
  22. XGO_DEPS = "--deps=https://s3.sigpipe.me/tarballs/1-mingw-libgnurx-2.5.1-src.tar.gz https://s3.sigpipe.me/tarballs/2-file-5.32.tar.gz"
  23. ifneq ($(DRONE_TAG),)
  24. VERSION ?= $(subst v,,$(DRONE_TAG))
  25. else
  26. ifneq ($(DRONE_BRANCH),)
  27. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  28. else
  29. VERSION ?= master
  30. endif
  31. endif
  32. ### Targets build and checks
  33. .PHONY: build clean
  34. all: build
  35. web: build
  36. ./$(EXECUTABLE) web
  37. vet:
  38. $(GOVET) $(PACKAGES_ALL)
  39. lint:
  40. @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  41. $(GO) get -u github.com/golang/lint/golint; \
  42. fi
  43. for PKG in $(PACKAGES_ALL); do golint -set_exit_status $$PKG || exit 1; done;
  44. build:
  45. $(GO) build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)'
  46. build-dev: vet
  47. $(GO) build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)'
  48. build-dev-race: vet
  49. $(GO) build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -race -tags '$(TAGS)'
  50. clean: clean-mac
  51. $(GO) clean -i ./...
  52. rm -f $(EXECUTABLE)
  53. clean-mac:
  54. find . -name ".DS_Store" -delete
  55. .PHONY: misspell-check
  56. misspell-check:
  57. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  58. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  59. fi
  60. misspell -error -i unknwon $(GOFILES)
  61. .PHONY: misspell
  62. misspell:
  63. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  64. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  65. fi
  66. misspell -w -i unknwon $(GOFILES)
  67. .PHONY: fmt
  68. fmt:
  69. $(GOFMT) -w $(GOFILES)
  70. .PHONY: fmt-check
  71. fmt-check:
  72. # get all go files and run go fmt on them
  73. @diff=$$($(GOFMT) -d $(GOFILES)); \
  74. if [ -n "$$diff" ]; then \
  75. echo "Please run 'make fmt' and commit the result:"; \
  76. echo "$${diff}"; \
  77. exit 1; \
  78. fi;
  79. ### Targets for tests
  80. # Use PACKAGES instead of PACKAGES_ALL because the integrations tests are run separately
  81. test: fmt-check
  82. $(GO) test -cover -v $(PACKAGES)
  83. ### Targets for releases
  84. .PHONY: release
  85. release: release-dirs release-linux release-copy release-check
  86. .PHONY: release-dirs
  87. release-dirs:
  88. mkdir -p $(DIST)/binaries $(DIST)/release
  89. .PHONY: release-windows
  90. release-windows:
  91. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  92. $(GO) get -u github.com/karalabe/xgo; \
  93. fi
  94. xgo $(XGO_DEPS) --image=xgo-git2go-windows -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out git.txt-$(VERSION) .
  95. ifeq ($(CI),drone)
  96. mv /build/* $(DIST)/binaries
  97. endif
  98. .PHONY: release-linux
  99. release-linux:
  100. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  101. $(GO) get -u github.com/karalabe/xgo; \
  102. fi
  103. xgo $(XGO_DEPS) --image=xgo-git2go-linux -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out git.txt-$(VERSION) .
  104. ifeq ($(CI),drone)
  105. mv /build/* $(DIST)/binaries
  106. endif
  107. # No git2go image available for the moment
  108. .PHONY: release-darwin
  109. release-darwin:
  110. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  111. $(GO) get -u github.com/karalabe/xgo; \
  112. fi
  113. xgo $(XGO_DEPS) -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out git.txt-$(VERSION) .
  114. ifeq ($(CI),drone)
  115. mv /build/* $(DIST)/binaries
  116. endif
  117. .PHONY: release-copy
  118. release-copy:
  119. $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
  120. .PHONY: release-check
  121. release-check:
  122. cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  123. # This is an ugly hack, we will not need that when xgo will support cmake and sources-order
  124. release-lx64: release-dirs release-build-lx64 release-copy release-check release-pack-lx64
  125. release-build-lx64:
  126. cp $(EXECUTABLE) $(DIST)/binaries/$(EXECUTABLE)-linux-x86_64
  127. cp -r conf $(DIST)/release/
  128. cp README.md LICENSE* $(DIST)/release/
  129. release-pack-lx64:
  130. cd $(DIST)/release; tar czvf git.txt_$(VERSION).tgz $(EXECUTABLE)-linux-x86_64 conf README.md LICENSE*