buildDateTime = $(shell date '+%Y-%m-%d %H:%M:%S')
gitCommitCode = $(shell git rev-parse --short HEAD)
goVersion = $(shell go version)

run: build
	./deployments/pbx-panel --level 5 web -c ./configs/config.yaml
build: swagger
	go build -tags "swagger apidoc socketio_client_tool manager panel" -o ./deployments/pbx-panel ./cmd/main.go
release: 
	GOOS=linux GOARCH=amd64 go build -tags "panel" -ldflags "-X 'main.buildDateTime=$(buildDateTime)' -X 'main.gitCommitCode=$(gitCommitCode)' -X 'main.goVersion=${goVersion}' -s -w" -o ./deployments/pbx-panel ./cmd/main.go
release-32: 
	GOOS=linux GOARCH=386 go build -tags "panel" -ldflags "-X 'main.buildDateTime=$(buildDateTime)' -X 'main.gitCommitCode=$(gitCommitCode)' -X 'main.goVersion=${goVersion}' -s -w" -o ./deployments/pbx-panel-32 ./cmd/main.go
	
swagger:
	swag init -g ../internal/app/http_server/swagger/swagger.go --dir ./api --exclude ./api/admin --output ./web/swagger

release-arm: 
	GOOS=linux GOARCH=arm go build -tags "panel" -ldflags "-X 'main.buildDateTime=$(buildDateTime)' -X 'main.gitCommitCode=$(gitCommitCode)' -X 'main.goVersion=${goVersion}' -s -w" -o ./deployments/pbx-panel-arm ./cmd/main.go
	
apidoc:
	apidoc -i api -f ".go" -o web/www/apidoc

upx:
	upx -9 --lzma ./deployments/pbx-panel

scp:
	scp deployments/pbx-panel root@192.168.18.252:/usr/local/pbx-webserver/deployments

