-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
73 lines (55 loc) · 2.01 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Set an output prefix, which is the local directory if not specified
PREFIX?=$(shell pwd)
# Populate version variables
# Add to compile time flags
APOSTILLE_PKG := github.com/docker/apostille
APOSTILLE_VERSION := $(shell cat APOSTILLE_VERSION)
GITCOMMIT := $(shell git rev-parse --short HEAD)
GITUNTRACKEDCHANGES := $(shell git status --porcelain --untracked-files=no)
ifneq ($(GITUNTRACKEDCHANGES),)
GITCOMMIT := $(GITCOMMIT)-dirty
endif
CTIMEVAR=-X $(APOSTILLE_PKG)/version.GitCommit=$(GITCOMMIT) \
-X $(APOSTILLE_PKG)/version.ApostilleVersion=$(APOSTILLE_VERSION)
GO_LDFLAGS=-ldflags "-w $(CTIMEVAR)"
GO_LDFLAGS_STATIC=-ldflags "-w $(CTIMEVAR) -extldflags -static"
GOOSES = darwin linux
APOSTILLE_BUILDTAGS ?= pkcs11
APOSTILLEDIR := /go/src/github.com/docker/apostille
GO_VERSION := $(shell go version | grep "1\.\([7-9]\|1[0-9]\)\(\.[0-9]+\)*\|devel")
INTEGRATION_PATH=bin/integration.sh
# check to make sure we have the right version. development versions of Go are
# not officially supported, but allowed for building
ifeq ($(strip $(GO_VERSION))$(SKIPENVCHECK),)
$(error Bad Go version - please install Go >= 1.7)
endif
GLIDE := $(shell command -v glide -v 2> /dev/null)
ifndef GLIDE
$(shell go get -u github.com/Masterminds/glide)
endif
_empty :=
_space := $(empty) $(empty)
PKGS ?= $(shell go list -tags "${APOSTILLE_BUILDTAGS}" ./... | grep -v /vendor/ | tr '\n' ' ')
.PHONY: clean all build test integration integration-postgres
all: clean build test
${PREFIX}/bin/apostille: APOSTILLE_VERSION $(shell find . -type f -name '*.go')
@echo "+ $@"
@go build -tags ${APOSTILLE_BUILDTAGS} -o $@ ${GO_LDFLAGS} ./cmd/apostille
update-deps:
@glide up -v
build:
@echo "+ $@"
@go install -tags "${APOSTILLE_BUILDTAGS}" -v ${GO_LDFLAGS} $(PKGS)
clean:
@echo "+ $@"
@rm -rf "${PREFIX}/bin/apostille"
test:
@echo "+ $@"
@go test `glide novendor`
integration:
@echo "+ $@"
$(INTEGRATION_PATH) mysql
integration-postgres:
@echo "+ $@"
$(INTEGRATION_PATH) postgresql
test-all: test integration integration-postgres