-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (33 loc) · 944 Bytes
/
Makefile
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
39
40
41
42
.PHONY: all build clean help version
.DEFAULT_GOAL: build
#
# Variables
#
ARCHITECTURES=386 amd64
BINARY=wikiipsum
PLATFORMS=darwin linux windows
VERSION = $(shell \
git -C . describe --tags 2> /dev/null || \
git -C . rev-parse --short HEAD 2> /dev/null || \
echo "unknown" \
)
#
# Targets
#
clean: ## Remove binary files.
rm -fv $(BINARY)*
## Compile binaries for all OS.
all:
$(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build -o $(BINARY)-$(VERSION)-$(GOOS)-$(GOARCH) -ldflags="-X 'main.Version=$(VERSION)'")))
build: ## Compile a binary.
go build -o $(BINARY) -ldflags="-X 'main.Version=$(VERSION)'"
help: ## Show help.
@echo
@echo ' Usage:'
@echo ' make <target>'
@echo
@echo ' Targets:'
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
@echo
version: ## Print version.
@echo $(VERSION)