Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. VERSION := 0.9.3-pre
  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
  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. vis:
  62. @which go-callvis >/dev/null 2>&1; \
  63. stat=$$?; if [ $$stat -ne "0" ]; then \
  64. /bin/echo "go-callvis not found. Run go get https://github.com/TrueFurby/go-callvis to install."; \
  65. else \
  66. $(MAKE) -C xs vis;\
  67. $(MAKE) -C xsd vis;\
  68. fi
  69. lint:
  70. $(MAKE) -C xsd lint
  71. $(MAKE) -C xs lint
  72. reinstall: uninstall install
  73. install:
  74. echo "WIN_MSYS:" $(WIN_MSYS)
  75. ifdef WIN_MSYS
  76. cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xs
  77. cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xc
  78. cp xs/xs $(INSTPREFIX)/bin/_xs
  79. cp xs/xs $(INSTPREFIX)/bin/_xc
  80. echo "Install of xsd server for Windows not yet supported"
  81. else
  82. cp xs/xs $(INSTPREFIX)/bin
  83. cd $(INSTPREFIX)/bin && ln -s xs xc && cd -
  84. cp xsd/xsd $(INSTPREFIX)/sbin
  85. endif
  86. uninstall:
  87. rm -f $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/xc \
  88. $(INSTPREFIX)/bin/_xs $(INSTPREFIX)/bin/_xc
  89. ifndef $(WIN_MSYS)
  90. rm -f $(INSTPREFIX)/sbin/xsd
  91. endif