Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. # Copyright 2024 The tk9.0-go Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style
  3. # license that can be found in the LICENSE file.
  4. .PHONY: all clean edit editor test work w65 lib_win lib_linux_ccgo lib_linux_purego \
  5. lib_darwin lib_freebsd build_all_targets demo examples xvfb
  6. TCL_TAR = tcl-core9.0.1-src.tar.gz
  7. TCL_TAR_URL = http://prdownloads.sourceforge.net/tcl/$(TCL_TAR)
  8. TK_TAR = tk9.0.1-src.tar.gz
  9. TK_TAR_URL = http://prdownloads.sourceforge.net/tcl/$(TK_TAR)
  10. TK_IMG_TAR = Img-2.0.1.tar.gz
  11. TK_IMG_URL = http://prdownloads.sourceforge.net/tkimg/$(TK_IMG_TAR)
  12. GOOS = $(shell go env GOOS)
  13. GOARCH = $(shell go env GOARCH)
  14. WIN32 = embed/windows/386
  15. WIN64 = embed/windows/amd64
  16. WINARM64 = embed/windows/arm64
  17. GOMAXPROCS = $(shell go run internal/cpus.go 2>&1)
  18. PWD = $(shell pwd)
  19. all:
  20. golint 2>&1
  21. staticcheck 2>&1
  22. $(shell for f in _examples/*.go ; do go build -o /dev/null $$f ; done)
  23. build_all_targets:
  24. GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build ./...
  25. GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go test -o /dev/null -c
  26. GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build ./...
  27. GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go test -o /dev/null -c
  28. GOOS=freebsd GOARCH=amd64 CGO_ENABLED=0 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" ./...
  29. GOOS=freebsd GOARCH=amd64 CGO_ENABLED=0 go test -o /dev/null -c -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std"
  30. GOOS=freebsd GOARCH=arm64 CGO_ENABLED=0 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" ./...
  31. GOOS=freebsd GOARCH=arm64 CGO_ENABLED=0 go test -o /dev/null -c -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std"
  32. GOOS=linux GOARCH=386 CGO_ENABLED=0 go build ./...
  33. GOOS=linux GOARCH=386 CGO_ENABLED=0 go test -o /dev/null -c
  34. GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build ./...
  35. GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go test -o /dev/null -c
  36. GOOS=linux GOARCH=arm CGO_ENABLED=0 go build ./...
  37. GOOS=linux GOARCH=arm CGO_ENABLED=0 go test -o /dev/null -c
  38. GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build ./...
  39. GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go test -o /dev/null -c
  40. GOOS=linux GOARCH=loong64 CGO_ENABLED=0 go build ./...
  41. GOOS=linux GOARCH=loong64 CGO_ENABLED=0 go test -o /dev/null -c
  42. GOOS=linux GOARCH=ppc64le CGO_ENABLED=0 go build ./...
  43. GOOS=linux GOARCH=ppc64le CGO_ENABLED=0 go test -o /dev/null -c
  44. GOOS=linux GOARCH=riscv64 CGO_ENABLED=0 go build ./...
  45. GOOS=linux GOARCH=riscv64 CGO_ENABLED=0 go test -o /dev/null -c
  46. GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build ./...
  47. GOOS=linux GOARCH=s390x CGO_ENABLED=0 go test -o /dev/null -c
  48. GOOS=windows GOARCH=386 CGO_ENABLED=0 go build ./...
  49. GOOS=windows GOARCH=386 CGO_ENABLED=0 go test -o /dev/null -c
  50. GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./...
  51. GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go test -o /dev/null -c
  52. GOOS=windows GOARCH=arm64 CGO_ENABLED=0 go build ./...
  53. GOOS=windows GOARCH=arm64 CGO_ENABLED=0 go test -o /dev/null -c
  54. clean:
  55. rm -f log-* cpu.test mem.test *.out go.work*
  56. go clean
  57. download:
  58. @if [ ! -f $(TCL_TAR) ]; then wget $(TCL_TAR_URL) ; fi
  59. @if [ ! -f $(TK_TAR) ]; then wget $(TK_TAR_URL) ; fi
  60. @if [ ! -f $(TK_IMG_TAR) ]; then wget $(TK_IMG_URL) ; fi
  61. edit:
  62. @if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile go.mod builder.json *.go & fi
  63. editor:
  64. go test -vet=off -c -o /dev/null
  65. go build -v -o /dev/null generator.go
  66. @go run generator.go > /dev/null
  67. gofmt -l -s -w .
  68. go build -v -o /dev/null
  69. go build -v -o /dev/null ./vnc
  70. go build -v -o /dev/null ./themes/azure
  71. test:
  72. go test -vet=off -v -timeout 24h -count=1
  73. work:
  74. rm -f go.work*
  75. go work init
  76. go work use .
  77. lib_win: lib_win64 lib_win32 lib_winarm64
  78. git status
  79. lib_win64: download
  80. if [ "$(GOOS)" != "linux" ]; then exit 1 ; fi
  81. if [ "$(GOARCH)" != "amd64" ]; then exit 1 ; fi
  82. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/ $(WIN64)
  83. mkdir -p $(WIN64)
  84. tar xf $(TCL_TAR)
  85. tar xf $(TK_TAR)
  86. tar xf $(TK_IMG_TAR)
  87. patch Img-2.0.1/tiff/tiff.c internal/tiff.c.patch
  88. sh -c "cd tcl9.0.1/win ; ./configure --build=x86_64-linux-gnu --host=x86_64-w64-mingw32"
  89. make -C tcl9.0.1/win -j$(GOMAXPROCS)
  90. cp -v tcl9.0.1/win/*.dll $(WIN64)
  91. sh -c "cd tk9.0.1/win ; ./configure --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --with-tcl=$(PWD)/tcl9.0.1/win"
  92. make -C tk9.0.1/win -j$(GOMAXPROCS)
  93. cp -v tk9.0.1/win/tcl9tk90.dll tk9.0.1/win/libtk9.0.1.zip $(WIN64)
  94. sh -c "cd Img-2.0.1 ; ./configure --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --with-tcl=$(PWD)/tcl9.0.1/win --with-tk=$(PWD)/tk9.0.1/win"
  95. make -C Img-2.0.1 -j$(GOMAXPROCS)
  96. find Img-2.0.1 -name \*.dll -exec cp {} $(WIN64) \;
  97. go run internal/shasig.go -goos=windows -goarch=amd64 tk_windows_amd64.go
  98. gofmt -l -s -w tk_windows_amd64.go
  99. zip -j $(WIN64)/lib.zip.tmp $(WIN64)/*.dll $(WIN64)/*.zip
  100. rm -f $(WIN64)/*.dll $(WIN64)/*.zip
  101. mv $(WIN64)/lib.zip.tmp $(WIN64)/lib.zip
  102. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/
  103. GOOS=windows GOARCH=amd64 go build -v
  104. git status
  105. lib_win32: download
  106. if [ "$(GOOS)" != "linux" ]; then exit 1 ; fi
  107. if [ "$(GOARCH)" != "amd64" ]; then exit 1 ; fi
  108. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/ $(WIN32)
  109. mkdir -p $(WIN32)
  110. tar xf $(TCL_TAR)
  111. tar xf $(TK_TAR)
  112. tar xf $(TK_IMG_TAR)
  113. patch Img-2.0.1/tiff/tiff.c internal/tiff.c.patch
  114. sh -c "cd tcl9.0.1/win ; ./configure --build=x86_64-linux-gnu --host=i686-w64-mingw32"
  115. make -C tcl9.0.1/win -j$(GOMAXPROCS)
  116. cp -v tcl9.0.1/win/*.dll $(WIN32)
  117. sh -c "cd tk9.0.1/win ; ./configure --build=x86_64-linux-gnu --host=i686-w64-mingw32 --with-tcl=$(PWD)/tcl9.0.1/win"
  118. make -C tk9.0.1/win -j$(GOMAXPROCS)
  119. cp -v tk9.0.1/win/tcl9tk90.dll tk9.0.1/win/libtk9.0.1.zip $(WIN32)
  120. sh -c "cd Img-2.0.1 ; ./configure --build=x86_64-linux-gnu --host=i686-w64-mingw32 --with-tcl=$(PWD)/tcl9.0.1/win --with-tk=$(PWD)/tk9.0.1/win"
  121. make -C Img-2.0.1 -j$(GOMAXPROCS)
  122. find Img-2.0.1 -name \*.dll -exec cp {} $(WIN32) \;
  123. go run internal/shasig.go -goos=windows -goarch=386 tk_windows_386.go
  124. gofmt -l -s -w tk_windows_386.go
  125. zip -j $(WIN32)/lib.zip.tmp $(WIN32)/*.dll $(WIN32)/*.zip
  126. rm -f $(WIN32)/*.dll $(WIN32)/*.zip
  127. mv $(WIN32)/lib.zip.tmp $(WIN32)/lib.zip
  128. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/
  129. GOOS=windows GOARCH=386 go build -v
  130. git status
  131. lib_winarm64: download
  132. if [ "$(GOOS)" != "linux" ]; then exit 1 ; fi
  133. if [ "$(GOARCH)" != "amd64" ]; then exit 1 ; fi
  134. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/ $(WINARM64)
  135. mkdir -p $(WINARM64)
  136. tar xf $(TCL_TAR)
  137. tar xf $(TK_TAR)
  138. tar xf $(TK_IMG_TAR)
  139. patch Img-2.0.1/tiff/tiff.c internal/tiff.c.patch
  140. patch Img-2.0.1/base/tkimg.h internal/tkimg.h.patch
  141. sh -c "cd tcl9.0.1/win ; ./configure --build=x86_64-linux-gnu --host=aarch64-w64-mingw32 --enable-64bit=arm64"
  142. make -C tcl9.0.1/win -j$(GOMAXPROCS)
  143. cp -v tcl9.0.1/win/*.dll $(WINARM64)
  144. sh -c "cd tk9.0.1/win ; ./configure --build=x86_64-linux-gnu --host=aarch64-w64-mingw32 --enable-64bit=arm64 --with-tcl=$(PWD)/tcl9.0.1/win"
  145. make -C tk9.0.1/win -j$(GOMAXPROCS)
  146. cp -v tk9.0.1/win/tcl9tk90.dll tk9.0.1/win/libtk9.0.1.zip $(WINARM64)
  147. sh -c "cd Img-2.0.1 ; ./configure --build=x86_64-linux-gnu --host=aarch64-w64-mingw32 --enable-64bit=arm64 --with-tcl=$(PWD)/tcl9.0.1/win --with-tk=$(PWD)/tk9.0.1/win"
  148. make -C Img-2.0.1 -j$(GOMAXPROCS)
  149. find Img-2.0.1 -name \*.dll -exec cp {} $(WINARM64) \;
  150. go run internal/shasig.go -goos=windows -goarch=arm64 tk_windows_arm64.go
  151. gofmt -l -s -w tk_windows_arm64.go
  152. zip -j $(WINARM64)/lib.zip.tmp $(WINARM64)/*.dll $(WINARM64)/*.zip
  153. rm -f $(WINARM64)/*.dll $(WINARM64)/*.zip
  154. mv $(WINARM64)/lib.zip.tmp $(WINARM64)/lib.zip
  155. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/
  156. GOOS=windows GOARCH=arm64 go build -v
  157. git status
  158. lib_linux_ccgo: download
  159. if [ "$(GOOS)" != "linux" ]; then exit 1 ; fi
  160. rm -rf Img-2.0.1/ internal/img/img_$(GOOS)_$(GOARCH).go
  161. mkdir -p embed/$(GOOS)/$(GOARCH)
  162. tar xf $(TK_IMG_TAR)
  163. patch Img-2.0.1/compat/libpng/pngpriv.h internal/pngpriv.h.patch
  164. patch Img-2.0.1/compat/libtiff/libtiff/tif_dirinfo.c internal/tif_dirinfo.c.patch
  165. sh -c "cd Img-2.0.1 ; ./configure \
  166. --with-tcl=$(HOME)/.config/ccgo/v4/libtcl9.0/linux/$(GOARCH)/tcl9.0.1/unix/ \
  167. --with-tk=$(HOME)/.config/ccgo/v4/libtk9.0/linux/$(GOARCH)/tk9.0.1/unix/"
  168. ccgo \
  169. -ignore-unsupported-alignment \
  170. -exec make -C Img-2.0.1 -j$(GOMAXPROCS)
  171. mkdir -p internal/img
  172. ./img_ccgo.sh
  173. rm -rf Img-2.0.1/
  174. go build -v
  175. git status
  176. lib_linux_purego: download
  177. if [ "$(GOOS)" != "linux" ]; then exit 1 ; fi
  178. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/ embed/$(GOOS)/$(GOARCH)
  179. mkdir -p embed/$(GOOS)/$(GOARCH)
  180. tar xf $(TCL_TAR)
  181. tar xf $(TK_TAR)
  182. tar xf $(TK_IMG_TAR)
  183. sh -c "cd tcl9.0.1/unix ; ./configure --disable-dll-unloading"
  184. make -C tcl9.0.1/unix -j$(GOMAXPROCS)
  185. cp -v tcl9.0.1/unix/*.so embed/$(GOOS)/$(GOARCH)
  186. sh -c "cd tk9.0.1/unix ; ./configure --with-tcl=$(PWD)/tcl9.0.1/unix"
  187. make -C tk9.0.1/unix -j$(GOMAXPROCS)
  188. cp -v tk9.0.1/unix/*.so tk9.0.1/unix/libtk9.0.1.zip embed/$(GOOS)/$(GOARCH)
  189. sh -c "cd Img-2.0.1 ; ./configure --with-tcl=$(PWD)/tcl9.0.1/unix --with-tk=$(PWD)/tk9.0.1/unix"
  190. make -C Img-2.0.1 -j$(GOMAXPROCS)
  191. find Img-2.0.1 -name \*.so -exec cp {} embed/$(GOOS)/$(GOARCH) \;
  192. go run internal/shasig.go - tk_$(GOOS)_$(GOARCH).go
  193. gofmt -l -s -w tk_$(GOOS)_$(GOARCH).go
  194. zip -j embed/$(GOOS)/$(GOARCH)/lib.zip.tmp embed/$(GOOS)/$(GOARCH)/*
  195. rm -f embed/$(GOOS)/$(GOARCH)/*.so embed/$(GOOS)/$(GOARCH)/*.zip
  196. mv embed/$(GOOS)/$(GOARCH)/lib.zip.tmp embed/$(GOOS)/$(GOARCH)/lib.zip
  197. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/
  198. go build -v
  199. git status
  200. lib_darwin: download
  201. if [ "$(GOOS)" != "darwin" ]; then exit 1 ; fi
  202. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/ embed/$(GOOS)/$(GOARCH)
  203. mkdir -p embed/$(GOOS)/$(GOARCH)
  204. tar xf $(TCL_TAR)
  205. tar xf $(TK_TAR)
  206. tar xf $(TK_IMG_TAR)
  207. sh -c "cd tcl9.0.1/unix ; ./configure"
  208. make -C tcl9.0.1/unix -j$(GOMAXPROCS)
  209. cp -v tcl9.0.1/unix/*.dylib embed/$(GOOS)/$(GOARCH)
  210. sh -c "cd tk9.0.1/unix ; ./configure --with-tcl=$(PWD)/tcl9.0.1/unix --enable-aqua"
  211. make -C tk9.0.1/unix -j$(GOMAXPROCS)
  212. cp -v tk9.0.1/unix/*.dylib tk9.0.1/unix/libtk9.0.1.zip embed/$(GOOS)/$(GOARCH)
  213. sh -c "cd Img-2.0.1 ; ./configure --with-tcl=$(PWD)/tcl9.0.1/unix --with-tk=$(PWD)/tk9.0.1/unix"
  214. make -C Img-2.0.1 -j$(GOMAXPROCS)
  215. find Img-2.0.1 -name \*.dylib -exec cp {} embed/$(GOOS)/$(GOARCH) \;
  216. go run internal/shasig.go - tk_$(GOOS)_$(GOARCH).go
  217. gofmt -l -s -w tk_$(GOOS)_$(GOARCH).go
  218. zip -j embed/$(GOOS)/$(GOARCH)/lib.zip.tmp embed/$(GOOS)/$(GOARCH)/*
  219. rm -f embed/$(GOOS)/$(GOARCH)/*.dylib embed/$(GOOS)/$(GOARCH)/*.zip
  220. mv embed/$(GOOS)/$(GOARCH)/lib.zip.tmp embed/$(GOOS)/$(GOARCH)/lib.zip
  221. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/
  222. go build -v
  223. git status
  224. # use gmake
  225. lib_freebsd: download
  226. if [ "$(GOOS)" != "freebsd" ]; then exit 1 ; fi
  227. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/ embed/$(GOOS)/$(GOARCH)
  228. mkdir -p embed/$(GOOS)/$(GOARCH)
  229. tar xf $(TCL_TAR)
  230. tar xf $(TK_TAR)
  231. tar xf $(TK_IMG_TAR)
  232. sh -c "cd tcl9.0.1/unix ; ./configure --disable-dll-unloading"
  233. make -C tcl9.0.1/unix -j$(GOMAXPROCS)
  234. cp -v tcl9.0.1/unix/*.so embed/$(GOOS)/$(GOARCH)
  235. sh -c "cd tk9.0.1/unix ; ./configure --with-tcl=$(PWD)/tcl9.0.1/unix"
  236. make -C tk9.0.1/unix -j$(GOMAXPROCS)
  237. cp -v tk9.0.1/unix/*.so tk9.0.1/unix/libtk9.0.1.zip embed/$(GOOS)/$(GOARCH)
  238. sh -c "cd Img-2.0.1 ; ./configure --with-tcl=$(PWD)/tcl9.0.1/unix --with-tk=$(PWD)/tk9.0.1/unix"
  239. make -C Img-2.0.1 -j$(GOMAXPROCS)
  240. find Img-2.0.1 -name \*.so -exec cp {} embed/$(GOOS)/$(GOARCH) \;
  241. go run internal/shasig.go - tk_$(GOOS)_$(GOARCH).go
  242. gofmt -l -s -w tk_$(GOOS)_$(GOARCH).go
  243. zip -j embed/$(GOOS)/$(GOARCH)/lib.zip.tmp embed/$(GOOS)/$(GOARCH)/*
  244. rm -f embed/$(GOOS)/$(GOARCH)/*.so embed/$(GOOS)/$(GOARCH)/*.zip
  245. mv embed/$(GOOS)/$(GOARCH)/lib.zip.tmp embed/$(GOOS)/$(GOARCH)/lib.zip
  246. rm -rf tcl9.0.1/ tk9.0.1/ Img-2.0.1/
  247. go build -v
  248. git status
  249. demo:
  250. cd _examples && go run demo.go
  251. examples:
  252. ./examples.sh
  253. xvfb:
  254. MODERNC_BUILDER=1 DISPLAY= XVFB_DISPLAY=:6060 go test -v -timeout 24h