forked from codetainerapp/codetainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·140 lines (116 loc) · 3.71 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
NAME="codetainer"
DESCRIPTION=""
WEBSITE="http://codetainer.org"
SHA := $(shell git rev-parse --short HEAD)
VERSION=$(shell cat $(NAME).go | grep "Version =" | sed 's/Version\ \=//' | sed 's/"//g' | tr -d '[[:space:]]')
CWD=$(shell pwd)
GITHUB_USER=codetainerapp
CCOS=linux
CCARCH=386 amd64
CCOUTPUT="pkg/{{.OS}}-{{.Arch}}/$(NAME)"
NO_COLOR=\033[0m
OK_COLOR=\033[32;01m
ERROR_COLOR=\033[31;01m
WARN_COLOR=\033[33;01m
DEPS = $(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...)
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
ECHO=echo
else
ECHO=/bin/echo -e
endif
all: bindata
@mkdir -p bin/
@$(ECHO) "$(OK_COLOR)==> Building $(NAME) $(VERSION) ($(SHA)) $(NO_COLOR)"
@godep go build -o bin/$(NAME) -ldflags "-w -s -X main.Build=$(SHA)" cmd/*.go
@mkdir -p bin/util/
@$(ECHO) "$(OK_COLOR)==> Building utils $(NO_COLOR)"
@godep go build -o bin/util/files cmd/util/files.go
@chmod +x bin/$(NAME)
@chmod +x bin/util/*
@$(ECHO) "$(OK_COLOR)==> Done building$(NO_COLOR)"
build: bindata all
@$(ECHO) "$(OK_COLOR)==> Installing dependencies$(NO_COLOR)"
@godep get
updatedeps:
@$(ECHO) "$(OK_COLOR)==> Updating all dependencies$(NO_COLOR)"
@go get -d -v ./...
@echo $(DEPS) | xargs -n1 go get -d
@godep update ...
bindata:
@$(ECHO) "$(OK_COLOR)==> Embedding assets$(NO_COLOR)"
@go-bindata -pkg="codetainer" web/...
test:
@$(ECHO) "$(OK_COLOR)==> Testing $(NAME)...$(NO_COLOR)"
godep go test ./... -v
goxBuild:
@CGO_ENABLED=1 gox -os="$(CCOS)" -arch="$(CCARCH)" -build-toolchain
gox:
@$(ECHO) "$(OK_COLOR)==> Cross compiling $(NAME)$(NO_COLOR)"
@mkdir -p Godeps/_workspace/src/github.com/$(GITHUB_USER)/$(NAME)
@cp -R *.go Godeps/_workspace/src/github.com/$(GITHUB_USER)/$(NAME)
@CGO_ENABLED=1 GOPATH=$(shell godep path) gox -ldflags "-s" -os="$(CCOS)" -arch="$(CCARCH)" -output=$(CCOUTPUT) cmd/*.go
@rm -rf Godeps/_workspace/src/github.com/$(GITHUB_USER)/$(NAME)
release: clean all test gox setup package
@for os in $(CCOS); do \
for arch in $(CCARCH); do \
cd pkg/$$os-$$arch/; \
tar -zcvf ../../release/$(NAME)-$$os-$$arch.tar.gz $(NAME)* > /dev/null 2>&1; \
cd ../../; \
done \
done
@$(ECHO) "$(OK_COLOR)==> Done cross compiling $(NAME)$(NO_COLOR)"
clean:
@$(ECHO) "$(OK_COLOR)==> Cleaning$(NO_COLOR)"
@rm -rf Godeps/_workspace/src/github.com/$(GITHUB_USER)/$(NAME)
@rm -rf .Version
@rm -rf bindata.go
@rm -rf bin/
@rm -rf pkg/
@rm -rf release/
@rm -rf package/
setup:
@$(ECHO) "$(OK_COLOR)==> Building packages $(NAME)$(NO_COLOR)"
@echo $(VERSION) > .Version
@mkdir -p pkg/
@mkdir -p package/root/usr/bin
@cp -R pkg/linux-amd64/$(NAME) package/root/usr/bin
@mkdir -p release/
package: deb386 debamd64
debamd64:
fpm -s dir -t deb -n $(NAME) -v $(VERSION) -p release/$(NAME)-amd64.deb \
--deb-priority optional --category admin \
--force \
--deb-compression bzip2 \
--url $(WEBSITE) \
--description $(DESCRIPTION) \
-m "codetainer <[email protected]>" \
--vendor "Codetainer" -a amd64 \
--exclude */**.gitkeep \
package/root/=/
deb386:
fpm -s dir -t deb -n $(NAME) -v $(VERSION) -p release/$(NAME)-386.deb \
--deb-priority optional --category admin \
--force \
--deb-compression bzip2 \
--url $(WEBSITE) \
--description $(DESCRIPTION) \
-m "codetainer <[email protected]>" \
--vendor "Codetainer" -a 386 \
--exclude */**.gitkeep \
package/root/=/
install: clean all
mkdir -p $(GOPATH)/bin/util
cp -r ./bin/codetainer $(GOPATH)/bin
cp -r ./bin/util/* $(GOPATH)/bin/util/
install_deps:
go get github.com/tools/godep
go get github.com/mitchellh/gox
go get -u github.com/jteeuwen/go-bindata/...
uninstall: clean
tar:
docs:
mkdir -p doc/
@go get -u github.com/go-swagger/go-swagger/cmd/swagger
$(GOPATH)/bin/swagger generate spec > doc/swagger.json
.PHONY: all clean deps