Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. VERSION := 0.9.5.3
  2. .PHONY: lint vis clean common client server passwd subpkgs install uninstall reinstall
  3. ## Tag version of binaries with build info wrt.
  4. ## GO111MODULE(=on) and vendor/ setup vs. $GOPATH pkg builds
  5. ############################################################
  6. ifeq ($(shell go env GOMOD),)
  7. MTAG=
  8. else
  9. MTAG="-m"
  10. endif
  11. # If available, one may build 'garbled' binaries
  12. # See https://github.com/burrowers/garble.git
  13. ifeq ($(GARBLE),y)
  14. GO=garble -literals -tiny -debugdir=garbled
  15. else
  16. GO=go
  17. endif
  18. ifneq ($(VENDOR),)
  19. GOBUILDOPTS :=-v -mod vendor
  20. VTAG = "-v"
  21. else
  22. GOBUILDOPTS=
  23. VTAG =
  24. endif
  25. ############################################################
  26. GIT_COMMIT := $(shell git rev-list -1 HEAD)
  27. #ifeq ($(BUILDOPTS),)
  28. BUILDOPTS :=$(BUILDOPTS)"$(GOBUILDOPTS) -ldflags \"-X main.version=$(VERSION)$(MTAG)$(VTAG) -X main.gitCommit=$(GIT_COMMIT)\""
  29. #endif
  30. SUBPKGS = logger spinsult xsnet
  31. TOOLS = xs xsd
  32. SUBDIRS = $(LIBS) $(TOOLS)
  33. ifeq ($(GOOS),)
  34. GOOS=$(shell go env GOOS)
  35. endif
  36. ifeq ($(GOOS),windows)
  37. ifeq ($(MSYSTEM),MSYS)
  38. WIN_MSYS=1
  39. endif
  40. endif
  41. INSTPREFIX = /usr/local
  42. all: common client server
  43. clean:
  44. @echo "Make: $(MAKE)"
  45. go clean .
  46. for d in $(SUBDIRS); do\
  47. $(MAKE) -C $$d clean;\
  48. done
  49. subpkgs:
  50. for d in $(SUBPKGS); do\
  51. $(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
  52. done
  53. tools:
  54. for d in $(TOOLS); do\
  55. $(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
  56. done
  57. common:
  58. $(GO) build .
  59. go install .
  60. client: common
  61. $(MAKE) BUILDOPTS=$(BUILDOPTS) -C xs
  62. server: common
  63. ifeq ($(MSYSTEM),MSYS)
  64. echo "Build of xsd server for Windows not yet supported"
  65. else
  66. $(MAKE) BUILDOPTS=$(BUILDOPTS) -C xsd
  67. endif
  68. vis:
  69. @which go-callvis >/dev/null 2>&1; \
  70. stat=$$?; if [ $$stat -ne "0" ]; then \
  71. /bin/echo "go-callvis not found. Run go get https://github.com/TrueFurby/go-callvis to install."; \
  72. else \
  73. $(MAKE) -C xs vis;\
  74. $(MAKE) -C xsd vis;\
  75. fi
  76. lint:
  77. $(MAKE) -C xsd lint
  78. $(MAKE) -C xs lint
  79. reinstall: uninstall install
  80. install:
  81. echo "WIN_MSYS:" $(WIN_MSYS)
  82. ifdef WIN_MSYS
  83. cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xs
  84. cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xc
  85. cp xs/xs $(INSTPREFIX)/bin/_xs
  86. cp xs/xs $(INSTPREFIX)/bin/_xc
  87. echo "Install of xsd server for Windows not yet supported"
  88. else
  89. cp xs/xs $(INSTPREFIX)/bin
  90. cd $(INSTPREFIX)/bin && ln -s xs xc && cd -
  91. cp xsd/xsd $(INSTPREFIX)/sbin
  92. endif
  93. uninstall:
  94. rm -f $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/xc \
  95. $(INSTPREFIX)/bin/_xs $(INSTPREFIX)/bin/_xc
  96. ifndef $(WIN_MSYS)
  97. rm -f $(INSTPREFIX)/sbin/xsd
  98. endif