CC=go
BUILD=build -v
GCFLAGS=-gcflags '-e'
LDFLAGS=-ldflags '-s -w'
PROGRAM=duckycode
ENV=CGO_ENABLED=0

all: $(PROGRAM)

$(PROGRAM): clean codeqa
	$(ENV) $(CC) $(BUILD) $(LDFLAGS)

clean:
	$(CC) clean -x

codeqa: generate gofmt test

generate:
	$(CC) generate

gofmt:
	gofmt -w pkg/ main.go

test:
ifeq ($(shell go env GOARCH), $(shell go env GOHOSTARCH))
ifeq ($(shell go env GOOS), $(shell go env GOHOSTOS))
	$(CC) test ./...
else
	$(info skipping tests of other platforms)
endif
else
	$(info skipping tests of other platforms)
endif

.PHONY: vendor build clean codeqa generate gofmt test
