-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
49 lines (36 loc) · 1.84 KB
/
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
43
44
45
46
47
48
49
SHELL := /bin/bash
# Default version number to the shorthand git commit hash if not set at the
# command line.
VER := $(or $(VER),$(shell git log -1 --format="%h"))
COMMIT := $(shell git log -1 --format="%h - %ae")
DATE := $(shell date -u)
VERSION := $(VER) (commit $(COMMIT)) $(DATE)
GOSOURCES := $(shell find . \( -name '*.go' \))
INCLUDES := $(shell find include \( -name '*' \) | sed 's/ /\\ /g')
# Default atomics repo to redcanaryco/master if not set at the command line.
ATOMICS_REPO := $(or $(ATOMICS_REPO),redcanaryco/master)
THISFILE := $(lastword $(MAKEFILE_LIST))
THISDIR := $(shell dirname $(realpath $(THISFILE)))
GOBIN := $(THISDIR)/bin
# Prepend this repo's bin directory to our path since we'll want to
# install some build tools there for use during the build process.
PATH := $(GOBIN):$(PATH)
# Export GOBIN env variable so `go install` picks it up correctly.
export GOBIN
all:
clean:
-rm bin/goart*
-rm -rf include/atomics
.PHONY: download-atomics
download-atomics:
./download-atomics.sh $(ATOMICS_REPO)
bin/goart: $(GOSOURCES) download-atomics
mkdir -p bin
CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-X 'actshad.dev/go-atomicredteam.Version=$(VERSION)' -X 'actshad.dev/go-atomicredteam.REPO=$(ATOMICS_REPO)' -s -w" -trimpath -o bin/goart cmd/main.go
bin/goart-darwin: $(GOSOURCES) download-atomics
mkdir -p bin
CGO_ENABLED=0 GOOS=darwin go build -a -ldflags="-X 'actshad.dev/go-atomicredteam.Version=$(VERSION)' -X 'actshad.dev/go-atomicredteam.REPO=$(ATOMICS_REPO)' -s -w" -trimpath -o bin/goart-darwin cmd/main.go
bin/goart.exe: $(GOSOURCES) download-atomics
mkdir -p bin
CGO_ENABLED=0 GOOS=windows go build -a -ldflags="-X 'actshad.dev/go-atomicredteam.Version=$(VERSION)' -X 'actshad.dev/go-atomicredteam.REPO=$(ATOMICS_REPO)' -s -w" -trimpath -o bin/goart.exe cmd/main.go
release: bin/goart bin/goart-darwin bin/goart.exe