Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. APP := miniflux
  2. VERSION := $(shell git rev-parse --short HEAD)
  3. BUILD_DATE := `date +%FT%T%z`
  4. LD_FLAGS := "-s -w -X 'miniflux.app/version.Version=$(VERSION)' -X 'miniflux.app/version.BuildDate=$(BUILD_DATE)'"
  5. PKG_LIST := $(shell go list ./... | grep -v /vendor/)
  6. DB_URL := postgres://postgres:postgres@localhost/miniflux_test?sslmode=disable
  7. export GO111MODULE=on
  8. .PHONY: generate
  9. .PHONY: miniflux
  10. .PHONY: linux-amd64
  11. .PHONY: linux-armv8
  12. .PHONY: linux-armv7
  13. .PHONY: linux-armv6
  14. .PHONY: linux-armv5
  15. .PHONY: darwin-amd64
  16. .PHONY: freebsd-amd64
  17. .PHONY: openbsd-amd64
  18. .PHONY: windows-amd64
  19. .PHONY: netbsd-amd64
  20. .PHONY: linux-x86
  21. .PHONY: darwin-x86
  22. .PHONY: freebsd-x86
  23. .PHONY: netbsd-x86
  24. .PHONY: openbsd-x86
  25. .PHONY: windows-x86
  26. .PHONY: build run clean test lint integration-test clean-integration-test
  27. generate:
  28. @ go generate -mod=vendor
  29. miniflux: generate
  30. @ go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP) main.go
  31. linux-amd64: generate
  32. @ GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-amd64 main.go
  33. linux-armv8: generate
  34. @ GOOS=linux GOARCH=arm64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-armv8 main.go
  35. linux-armv7: generate
  36. @ GOOS=linux GOARCH=arm GOARM=7 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-armv7 main.go
  37. linux-armv6: generate
  38. @ GOOS=linux GOARCH=arm GOARM=6 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-armv6 main.go
  39. linux-armv5: generate
  40. @ GOOS=linux GOARCH=arm GOARM=5 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-armv5 main.go
  41. darwin-amd64: generate
  42. @ GOOS=darwin GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-darwin-amd64 main.go
  43. freebsd-amd64: generate
  44. @ GOOS=freebsd GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-freebsd-amd64 main.go
  45. openbsd-amd64: generate
  46. @ GOOS=openbsd GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-openbsd-amd64 main.go
  47. windows-amd64: generate
  48. @ GOOS=windows GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-windows-amd64 main.go
  49. build: linux-amd64 linux-armv8 linux-armv7 linux-armv6 linux-armv5 darwin-amd64 freebsd-amd64 openbsd-amd64 windows-amd64
  50. # NOTE: unsupported targets
  51. netbsd-amd64: generate
  52. @ GOOS=netbsd GOARCH=amd64 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-netbsd-amd64 main.go
  53. linux-x86: generate
  54. @ GOOS=linux GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-linux-x86 main.go
  55. darwin-x86: generate
  56. @ GOOS=darwin GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-darwin-x86 main.go
  57. freebsd-x86: generate
  58. @ GOOS=freebsd GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-freebsd-x86 main.go
  59. netbsd-x86: generate
  60. @ GOOS=netbsd GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-netbsd-x86 main.go
  61. openbsd-x86: generate
  62. @ GOOS=openbsd GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-freebsd-x86 main.go
  63. windows-x86: generate
  64. @ GOOS=windows GOARCH=386 go build -mod=vendor -ldflags=$(LD_FLAGS) -o $(APP)-windows-x86 main.go
  65. run: generate
  66. @ go run -mod=vendor main.go -debug
  67. clean:
  68. @ rm -f $(APP)-* $(APP)
  69. test:
  70. go test -mod=vendor -cover -race -count=1 ./...
  71. lint:
  72. @ golint -set_exit_status ${PKG_LIST}
  73. integration-test:
  74. psql -U postgres -c 'drop database if exists miniflux_test;'
  75. psql -U postgres -c 'create database miniflux_test;'
  76. DATABASE_URL=$(DB_URL) go run -mod=vendor main.go -migrate
  77. DATABASE_URL=$(DB_URL) ADMIN_USERNAME=admin ADMIN_PASSWORD=test123 go run -mod=vendor main.go -create-admin
  78. go build -mod=vendor -o miniflux-test main.go
  79. DATABASE_URL=$(DB_URL) ./miniflux-test -debug >/tmp/miniflux.log 2>&1 & echo "$$!" > "/tmp/miniflux.pid"
  80. while ! echo exit | nc localhost 8080; do sleep 1; done >/dev/null
  81. go test -mod=vendor -v -tags=integration -count=1 miniflux.app/tests || cat /tmp/miniflux.log
  82. clean-integration-test:
  83. @ kill -9 `cat /tmp/miniflux.pid`
  84. @ rm -f /tmp/miniflux.pid /tmp/miniflux.log
  85. @ rm miniflux-test
  86. @ psql -U postgres -c 'drop database if exists miniflux_test;'