Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
  2. IMAGE_NAME := mtg
  3. APP_NAME := $(IMAGE_NAME)
  4. GOMETALINTER := gometalinter
  5. VENDOR_FILES := $(shell find "$(ROOT_DIR)/vendor" 2>/dev/null || echo -n "vendor")
  6. CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,windows,darwin,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
  7. APP_DEPS := version.go $(VENDOR_FILES)
  8. COMMON_BUILD_FLAGS := -ldflags="-s -w"
  9. # -----------------------------------------------------------------------------
  10. $(APP_NAME): $(APP_DEPS)
  11. @go build $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  12. static-$(APP_NAME): $(APP_DEPS)
  13. @env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  14. $(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
  15. $(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
  16. $(APP_NAME)-%: $(APP_DEPS) ccbuilds
  17. @env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
  18. go build \
  19. $(COMMON_BUILD_FLAGS) \
  20. -o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
  21. ccbuilds:
  22. @rm -rf ./ccbuilds && mkdir -p ./ccbuilds
  23. version.go:
  24. @go generate main.go
  25. vendor: Gopkg.lock Gopkg.toml install-cli
  26. @dep ensure
  27. # -----------------------------------------------------------------------------
  28. .PHONY: all
  29. all: $(APP_NAME)
  30. .PHONY: static
  31. static: static-$(APP_NAME)
  32. .PHONY: crosscompile
  33. crosscompile: $(CC_BINARIES)
  34. .PHONY: crosscompile-dir
  35. crosscompile-dir:
  36. @rm -rf "$(CC_DIR)" && mkdir -p "$(CC_DIR)"
  37. .PHONY: test
  38. test: vendor install-cli version.go
  39. @go test -v ./...
  40. .PHONY: lint
  41. lint: vendor install-cli version.go
  42. @$(GOMETALINTER) --deadline=2m ./...
  43. .PHONY: clean
  44. clean:
  45. @git clean -xfd && \
  46. git reset --hard >/dev/null && \
  47. git submodule foreach --recursive sh -c 'git clean -xfd && git reset --hard' >/dev/null
  48. .PHONY: docker
  49. docker:
  50. @docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
  51. .PHONY: install-cli
  52. install-cli: install-dep install-lint
  53. .PHONY: install-dep
  54. install-dep:
  55. @go get github.com/golang/dep/cmd/dep
  56. .PHONY: install-lint
  57. install-lint:
  58. @go get gopkg.in/alecthomas/gometalinter.v2 && \
  59. $(GOMETALINTER) --install >/dev/null