-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
30 lines (25 loc) · 880 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
BUILD_TARGET ?= *.go
APP_NAME := bosh-complete
OUTPUT_NAME ?= $(APP_NAME)
SHELL := /bin/bash
COMMIT_HASH := $(shell git log --pretty='format:%h' -n 1)
DIRTY_LINE := $(shell git diff --shortstat 2> /dev/null | tail -n1)
ifneq ("$(DIRTY_LINE)", "")
DIRTY := +
endif
#Don't lead this with a v
VERSION ?= development
LDFLAGS := -X "github.com/thomasmitchell/bosh-complete/version.Version=$(VERSION)-$(COMMIT_HASH)$(DIRTY)"
BUILD := go build -v -ldflags='$(LDFLAGS)' -o $(OUTPUT_NAME) $(BUILD_TARGET)
.PHONY: build darwin linux all clean
.DEFAULT: build
build:
@echo $(VERSION)-$(COMMIT_HASH)$(DIRTY)
GOOS=$(GOOS) GOARCH=amd64 $(BUILD)
darwin:
GOOS=darwin OUTPUT_NAME=$(APP_NAME)-darwin VERSION="$(VERSION)" $(MAKE)
linux:
GOOS=linux OUTPUT_NAME=$(APP_NAME)-linux VERSION="$(VERSION)" $(MAKE)
all: darwin linux
clean:
rm -f $(APP_NAME) $(APP_NAME)-darwin $(APP_NAME)-linux