-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
38 lines (31 loc) · 896 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
# Basic go commands
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GORUN=$(GOCMD) run
# App info
BINARY_NAME := baton
VERSION := 0.1.7
# Folders
OUTPUT_FOLDER := build
BINARY_OUTPUT := $(OUTPUT_FOLDER)/$(BINARY_NAME)
# Output platforms
PLATFORMS := windows linux darwin
os = $(word 1, $@)
# Make for all the platforms
.PHONY: $(PLATFORMS)
ifeq ($(OS),Windows_NT)
$(PLATFORMS): # If host is windows
set GOOS=$(os)&& set GOARCH=amd64&& $(GOBUILD) -o $(BINARY_OUTPUT)-$(VERSION)-$(os)-amd64$(if $(filter $(os),windows),.exe,) main.go
else
$(PLATFORMS): # else it's Linux/MacOS
GOOS=$(os) GOARCH=amd64 $(GOBUILD) -o $(BINARY_OUTPUT)-$(VERSION)-$(os)-amd64$(if $(filter $(os),windows),.exe,) main.go
endif
.PHONY: build
build: windows linux darwin
.PHONY: run
run:
$(GORUN) main.go
.DEFAULT_GOAL := build