Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. VERSION := 0.9.0pre
  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. ifneq ($(VENDOR),)
  12. GOBUILDOPTS :=-v -mod vendor
  13. VTAG = "-v"
  14. else
  15. GOBUILDOPTS=
  16. VTAG =
  17. endif
  18. ############################################################
  19. GIT_COMMIT := $(shell git rev-list -1 HEAD)
  20. #ifeq ($(BUILDOPTS),)
  21. BUILDOPTS :=$(BUILDOPTS)"$(GOBUILDOPTS) -ldflags \"-X main.version=$(VERSION)$(MTAG)$(VTAG) -X main.gitCommit=$(GIT_COMMIT)\""
  22. #endif
  23. SUBPKGS = logger spinsult xsnet
  24. TOOLS = xs xsd
  25. SUBDIRS = $(LIBS) $(TOOLS)
  26. ifeq ($(GOOS),)
  27. GOOS=$(shell go env GOOS)
  28. endif
  29. ifeq ($(GOOS),windows)
  30. ifeq ($(MSYSTEM),MSYS)
  31. WIN_MSYS=1
  32. endif
  33. endif
  34. INSTPREFIX = /usr/local
  35. all: common client server #seccheck
  36. clean:
  37. @echo "Make: $(MAKE)"
  38. go clean .
  39. for d in $(SUBDIRS); do\
  40. $(MAKE) -C $$d clean;\
  41. done
  42. subpkgs:
  43. for d in $(SUBPKGS); do\
  44. $(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
  45. done
  46. tools:
  47. for d in $(TOOLS); do\
  48. $(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
  49. done
  50. common:
  51. go build .
  52. go install .
  53. client: common
  54. $(MAKE) BUILDOPTS=$(BUILDOPTS) -C xs
  55. server: common
  56. ifeq ($(MSYSTEM),MSYS)
  57. echo "Build of xsd server for Windows not yet supported"
  58. else
  59. $(MAKE) BUILDOPTS=$(BUILDOPTS) -C xsd
  60. endif
  61. #seccheck:
  62. # grep -r "logPlainText.*true" .
  63. # if [ $$? -eq 0 ]; then echo "WARNING plaintext debug is enabled"; exit 1; fi
  64. vis:
  65. @which go-callvis >/dev/null 2>&1; \
  66. stat=$$?; if [ $$stat -ne "0" ]; then \
  67. /bin/echo "go-callvis not found. Run go get https://github.com/TrueFurby/go-callvis to install."; \
  68. else \
  69. $(MAKE) -C xs vis;\
  70. $(MAKE) -C xsd vis;\
  71. fi
  72. lint:
  73. $(MAKE) -C xsd lint
  74. $(MAKE) -C xs lint
  75. reinstall: uninstall install
  76. install:
  77. echo "WIN_MSYS:" $(WIN_MSYS)
  78. ifdef WIN_MSYS
  79. cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xs
  80. cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xc
  81. cp xs/xs $(INSTPREFIX)/bin/_xs
  82. cp xs/xs $(INSTPREFIX)/bin/_xc
  83. echo "Install of xsd server for Windows not yet supported"
  84. else
  85. cp xs/xs $(INSTPREFIX)/bin
  86. cd $(INSTPREFIX)/bin && ln -s xs xc && cd -
  87. cp xsd/xsd $(INSTPREFIX)/sbin
  88. endif
  89. uninstall:
  90. rm -f $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/xc \
  91. $(INSTPREFIX)/bin/_xs $(INSTPREFIX)/bin/_xc
  92. ifndef $(WIN_MSYS)
  93. rm -f $(INSTPREFIX)/sbin/xsd
  94. endif