This repository has been archived by the owner on Mar 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
81 lines (63 loc) · 2.12 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
74
75
76
77
78
79
80
81
# Package configuration
PROJECT = dockership
COMMANDS = dockershipd
DEPENDENCIES = \
github.com/jteeuwen/go-bindata/... \
# Environment
BASE_PATH := $(shell pwd)
BUILD_PATH := $(BASE_PATH)/build
VERSION ?= $(shell git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
BUILD ?= $(shell date)
ASSETS := static
# PACKAGES
PKG_OS = darwin linux
PKG_ARCH = amd64
PACKAGES = $(foreach os, $(PKG_OS), $(foreach arch, $(PKG_ARCH), $(os)_$(arch)))
PKG_CONTENT = README.md LICENSE
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOCLEAN = $(GOCMD) clean
GOGET = $(GOCMD) get
GOTEST = $(GOCMD) test
BINDATA = go-bindata
ifneq ($(origin TRAVIS_TAG), undefined)
VERSION := $(TRAVIS_TAG)
endif
.PHONY: dependencies $(DEPENDENCIES) packages $(PACKAGES)
all: test build
build-assets:
cd $(BASE_PATH)/client; npm install; npm install gulp -g; gulp javascript
assets:
cd $(BASE_PATH)/http; $(BINDATA) -pkg=http $(ASSETS)
dependencies: $(DEPENDENCIES)
$(GOGET) -d -v -t ./...
$(DEPENDENCIES):
$(GOGET) $@
build: dependencies build-assets assets $(COMMANDS)
$(COMMANDS): %: %.go
$(GOCMD) build -ldflags "-X main.version $(VERSION) -X main.build \"$(BUILD)\"" $@.go
full-test: dependencies
cd $(BASE_PATH)/http; $(BINDATA) -pkg=http --debug $(ASSETS)
cd $(BASE_PATH)/core; $(GOTEST) -v . --github --slow
cd $(BASE_PATH)/config; $(GOTEST) -v .
test: dependencies
cd $(BASE_PATH)/http; $(BINDATA) -pkg=http --debug $(ASSETS)
cd $(BASE_PATH)/core; $(GOTEST) -v .
cd $(BASE_PATH)/config; $(GOTEST) -v .
install: $(COMMANDS)
cp -rf $^ /usr/bin/
packages: clean dependencies build-assets assets $(PACKAGES)
$(PACKAGES):
cd $(BASE_PATH)
mkdir -p $(BUILD_PATH)/$(PROJECT)_$(VERSION)_$@
for cmd in $(COMMANDS); do \
GOOS=`echo $@ | sed 's/_.*//'` \
GOARCH=`echo $@ | sed 's/.*_//'` \
$(GOCMD) build -ldflags "-X main.version $(VERSION) -X main.build \"$(BUILD)\"" -o $(BUILD_PATH)/$(PROJECT)_$(VERSION)_$@/$${cmd} $${cmd}.go ; \
done
cp -rf $(PKG_CONTENT) $(BUILD_PATH)/$(PROJECT)_$(VERSION)_$@/
cd $(BUILD_PATH) && tar -cvzf $(BUILD_PATH)/$(PROJECT)_$(VERSION)_$@.tar.gz $(PROJECT)_$(VERSION)_$@/
clean:
rm -rf $(BUILD_PATH)
$(GOCLEAN) .