PROXYBUILDS = windows-amd64
# linux-amd64 linux-arm64 linux-arm darwin-amd64 darwin-arm64 windows-arm64

all:
	test -z "$(gofmt -l .)"
	go version >go-version.txt
	make -j4 $(PROXYBUILDS:%=proxybuild-%)

proxybuild-%:
	make proxybuild GOOS=$(word 1,$(subst -, ,$*)) GOARCH=$(word 2,$(subst -, ,$*))

ifeq ($(GOOS),windows)
    BINEXT := .exe
endif

proxybuild: websockproxy-$(GOOS)-$(GOARCH)$(BINEXT)

websockproxy-%: go.* *.go
	GOOS=$(GOOS) GOARCH=$(GOARCH) go build \
	"-ldflags=-s -w -buildid=" -buildvcs=false -trimpath  -mod=readonly -modcacherw \
	-o $@

clean:
	rm -f go-version.txt websockproxy-*

run:
	go run main.go