Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. PROGNAME = dtlspipe
  2. OUTSUFFIX = bin/$(PROGNAME)
  3. VERSION := $(shell git describe)
  4. BUILDOPTS = -a -tags netgo -trimpath -asmflags -trimpath
  5. LDFLAGS = -ldflags '-s -w -extldflags "-static" -X main.version=$(VERSION)'
  6. LDFLAGS_NATIVE = -ldflags '-s -w -X main.version=$(VERSION)'
  7. MAIN_PACKAGE = ./cmd/$(PROGNAME)
  8. NDK_CC_ARM = $(abspath ../../ndk-toolchain-arm/bin/arm-linux-androideabi-gcc)
  9. NDK_CC_ARM64 = $(abspath ../../ndk-toolchain-arm64/bin/aarch64-linux-android21-clang)
  10. GO := go
  11. src = $(wildcard *.go */*.go */*/*.go go.mod go.sum)
  12. native: bin-native
  13. all: bin-linux-amd64 bin-linux-386 bin-linux-arm bin-linux-arm64 \
  14. bin-linux-mips bin-linux-mipsle bin-linux-mips64 bin-linux-mips64le \
  15. bin-freebsd-amd64 bin-freebsd-386 bin-freebsd-arm bin-freebsd-arm64 \
  16. bin-netbsd-amd64 bin-netbsd-386 bin-netbsd-arm bin-netbsd-arm64 \
  17. bin-openbsd-amd64 bin-openbsd-386 bin-openbsd-arm bin-openbsd-arm64 \
  18. bin-darwin-amd64 bin-darwin-arm64 \
  19. bin-windows-amd64 bin-windows-386 bin-windows-arm
  20. allplus: all \
  21. bin-android-arm bin-android-arm64
  22. bin-native: $(OUTSUFFIX)
  23. bin-linux-amd64: $(OUTSUFFIX).linux-amd64
  24. bin-linux-386: $(OUTSUFFIX).linux-386
  25. bin-linux-arm: $(OUTSUFFIX).linux-arm
  26. bin-linux-arm64: $(OUTSUFFIX).linux-arm64
  27. bin-linux-mips: $(OUTSUFFIX).linux-mips
  28. bin-linux-mipsle: $(OUTSUFFIX).linux-mipsle
  29. bin-linux-mips64: $(OUTSUFFIX).linux-mips64
  30. bin-linux-mips64le: $(OUTSUFFIX).linux-mips64le
  31. bin-freebsd-amd64: $(OUTSUFFIX).freebsd-amd64
  32. bin-freebsd-386: $(OUTSUFFIX).freebsd-386
  33. bin-freebsd-arm: $(OUTSUFFIX).freebsd-arm
  34. bin-freebsd-arm64: $(OUTSUFFIX).freebsd-arm64
  35. bin-netbsd-amd64: $(OUTSUFFIX).netbsd-amd64
  36. bin-netbsd-386: $(OUTSUFFIX).netbsd-386
  37. bin-netbsd-arm: $(OUTSUFFIX).netbsd-arm
  38. bin-netbsd-arm64: $(OUTSUFFIX).netbsd-arm64
  39. bin-openbsd-amd64: $(OUTSUFFIX).openbsd-amd64
  40. bin-openbsd-386: $(OUTSUFFIX).openbsd-386
  41. bin-openbsd-arm: $(OUTSUFFIX).openbsd-arm
  42. bin-openbsd-arm64: $(OUTSUFFIX).openbsd-arm64
  43. bin-darwin-amd64: $(OUTSUFFIX).darwin-amd64
  44. bin-darwin-arm64: $(OUTSUFFIX).darwin-arm64
  45. bin-windows-amd64: $(OUTSUFFIX).windows-amd64.exe
  46. bin-windows-386: $(OUTSUFFIX).windows-386.exe
  47. bin-windows-arm: $(OUTSUFFIX).windows-arm.exe
  48. bin-android-arm: $(OUTSUFFIX).android-arm
  49. bin-android-arm64: $(OUTSUFFIX).android-arm64
  50. $(OUTSUFFIX): $(src)
  51. $(GO) build $(LDFLAGS_NATIVE) -o $@ $(MAIN_PACKAGE)
  52. $(OUTSUFFIX).linux-amd64: $(src)
  53. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  54. $(OUTSUFFIX).linux-386: $(src)
  55. CGO_ENABLED=0 GOOS=linux GOARCH=386 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  56. $(OUTSUFFIX).linux-arm: $(src)
  57. CGO_ENABLED=0 GOOS=linux GOARCH=arm $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  58. $(OUTSUFFIX).linux-arm64: $(src)
  59. CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  60. $(OUTSUFFIX).linux-mips: $(src)
  61. CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  62. $(OUTSUFFIX).linux-mips64: $(src)
  63. CGO_ENABLED=0 GOOS=linux GOARCH=mips64 GOMIPS=softfloat $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  64. $(OUTSUFFIX).linux-mipsle: $(src)
  65. CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  66. $(OUTSUFFIX).linux-mips64le: $(src)
  67. CGO_ENABLED=0 GOOS=linux GOARCH=mips64le GOMIPS=softfloat $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  68. $(OUTSUFFIX).freebsd-amd64: $(src)
  69. CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  70. $(OUTSUFFIX).freebsd-386: $(src)
  71. CGO_ENABLED=0 GOOS=freebsd GOARCH=386 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  72. $(OUTSUFFIX).freebsd-arm: $(src)
  73. CGO_ENABLED=0 GOOS=freebsd GOARCH=arm $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  74. $(OUTSUFFIX).freebsd-arm64: $(src)
  75. CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  76. $(OUTSUFFIX).netbsd-amd64: $(src)
  77. CGO_ENABLED=0 GOOS=netbsd GOARCH=amd64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  78. $(OUTSUFFIX).netbsd-386: $(src)
  79. CGO_ENABLED=0 GOOS=netbsd GOARCH=386 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  80. $(OUTSUFFIX).netbsd-arm: $(src)
  81. CGO_ENABLED=0 GOOS=netbsd GOARCH=arm $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  82. $(OUTSUFFIX).netbsd-arm64: $(src)
  83. CGO_ENABLED=0 GOOS=netbsd GOARCH=arm64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  84. $(OUTSUFFIX).openbsd-amd64: $(src)
  85. CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  86. $(OUTSUFFIX).openbsd-386: $(src)
  87. CGO_ENABLED=0 GOOS=openbsd GOARCH=386 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  88. $(OUTSUFFIX).openbsd-arm: $(src)
  89. CGO_ENABLED=0 GOOS=openbsd GOARCH=arm $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  90. $(OUTSUFFIX).openbsd-arm64: $(src)
  91. CGO_ENABLED=0 GOOS=openbsd GOARCH=arm64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  92. $(OUTSUFFIX).darwin-amd64: $(src)
  93. CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  94. $(OUTSUFFIX).darwin-arm64: $(src)
  95. CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  96. $(OUTSUFFIX).windows-amd64.exe: $(src)
  97. CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  98. $(OUTSUFFIX).windows-386.exe: $(src)
  99. CGO_ENABLED=0 GOOS=windows GOARCH=386 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  100. $(OUTSUFFIX).windows-arm.exe: $(src)
  101. CGO_ENABLED=0 GOOS=windows GOARCH=arm GOARM=7 $(GO) build $(BUILDOPTS) $(LDFLAGS) -o $@ $(MAIN_PACKAGE)
  102. $(OUTSUFFIX).android-arm: $(src)
  103. CC=$(NDK_CC_ARM) CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 $(GO) build $(LDFLAGS_NATIVE) -o $@ $(MAIN_PACKAGE)
  104. $(OUTSUFFIX).android-arm64: $(src)
  105. CC=$(NDK_CC_ARM64) CGO_ENABLED=1 GOOS=android GOARCH=arm64 $(GO) build $(LDFLAGS_NATIVE) -o $@ $(MAIN_PACKAGE)
  106. clean:
  107. rm -f bin/*
  108. fmt:
  109. $(GO) fmt ./...
  110. run:
  111. $(GO) run $(LDFLAGS) $(MAIN_PACKAGE)
  112. install:
  113. $(GO) install $(LDFLAGS_NATIVE) $(MAIN_PACKAGE)
  114. .PHONY: clean all native fmt install \
  115. bin-native \
  116. bin-linux-amd64 \
  117. bin-linux-386 \
  118. bin-linux-arm \
  119. bin-linux-arm64 \
  120. bin-linux-mips \
  121. bin-linux-mipsle \
  122. bin-linux-mips64 \
  123. bin-linux-mips64le \
  124. bin-freebsd-amd64 \
  125. bin-freebsd-386 \
  126. bin-freebsd-arm \
  127. bin-freebsd-arm64 \
  128. bin-netbsd-amd64 \
  129. bin-netbsd-386 \
  130. bin-netbsd-arm \
  131. bin-netbsd-arm64 \
  132. bin-openbsd-amd64 \
  133. bin-openbsd-386 \
  134. bin-openbsd-arm \
  135. bin-openbsd-arm64 \
  136. bin-darwin-amd64 \
  137. bin-darwin-arm64 \
  138. bin-windows-amd64 \
  139. bin-windows-386 \
  140. bin-windows-arm \
  141. bin-android-arm \
  142. bin-android-arm64