aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 74532be746fd40247a75034be1bda3eb117547c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
MAIN := cmd/micro/micro.go
NAME := micro
GO_SOURCES := $(shell find . -name '*.go')
VERSION_STRING := $(shell git describe --exact-match --tags --always HEAD 2>/dev/null || echo git-`git rev-parse --short=6 HEAD 2>/dev/null` || echo unknown)
GOBUILD_FLAGS := -ldflags "-X main.Version=$(VERSION_STRING)" -mod=mod
PACKAGES := $(shell go list ./...)

.PHONY: clean run parse bindir

build: bin/$(NAME)

build-win: bin/$(NAME).exe

run: build
	bin/$(NAME) input.micro

parse: build
	bin/$(NAME) -parse input.micro

vet:
	go vet $(PACKAGES)

bin/$(NAME): bindir $(GO_SOURCES)
	GOBIN="$(CURDIR)/bin" go build -o bin/$(NAME) $(GOBUILD_FLAGS) $(MAIN)

bin/$(NAME).exe: bindir $(GO_SOURCES)
	GOOS=windows GOARCH=386 CGO_ENABLED=1 CXX=i686-w64-mingw32-g++ CC=i686-w64-mingw32-gcc GOBIN="$(CURDIR)/bin" go build $(GOBUILD_FLAGS) -o bin/$(NAME).exe $(MAIN)

GO_TEST_FLAGS ?= ""
test:
	go test ./... -v $(GO_TEST_FLAGS)

bindir:
	mkdir -p ./bin

clean:
	rm -f bin/$(NAME) bin/$(NAME).exe