-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
159 lines (132 loc) · 3.36 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Makefile to build dnsmasq blacklist
SHELL=/usr/bin/env bash
# Go parameters
EXECUTABLE=pixelserv
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOCMD=go
GOGET=$(GOCMD) get
GOTEST=$(GOCMD) test
# Executables
GSED=$(shell which gsed || which sed) -i.bak -e
PKG=edgeos-$(EXECUTABLE)
# Environment variables
AWS=aws
COPYRIGHT=s/Copyright © 20../Copyright © $(shell date +"%Y")/g
COVERALLS_TOKEN=W6VHc8ZFpwbfTzT3xoluEWbKkrsKT1w25
DATE=$(shell date -u '+%Y-%m-%d_%I:%M:%S%p')
GIT=$(shell git rev-parse --short HEAD)
LIC=LICENSE
PAYLOAD=./.payload
README=README.md
READMEHDR=README.header
SCRIPTS=/config/scripts
OLDVER=$(shell cat ./OLDVERSION)
VER=$(shell cat ./VERSION)
VERSIONS=s/edgeos-$(EXECUTABLE)_$(OLDVER)_/edgeos-$(EXECUTABLE)_$(VER)_/g
BADGE=s/version-v$(OLDVER)-green.svg/version-v$(VER)-green.svg/g
TAG="v$(VER)"
.PHONY: all clean deps mips coverage copyright docs readme
all: clean deps mips coverage copyright docs readme
.PHONY: amd64
amd64:
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(EXECUTABLE).amd64 \
-ldflags \
"-X main.build=$(DATE) \
-X main.githash=$(GIT) \
-X main.version=$(VER) \
-s -w" -v
.PHONY: build
build: clean amd64 mips copyright docs readme
.PHONY: cdeps
cdeps:
# dep status -dot | dot -T png | open -f -a /Applications/Preview.app
go mod tidy
.PHONY: clean
clean:
$(GOCLEAN)
find . -name "$(EXECUTABLE).{mips,mipsel}" -type f \
-o -name debug -type f \
-o -name "*.deb" -type f \
-o -name debug.test -type f \
-o -name "*.tgz" -type f \
| xargs rm
.PHONY: copyright
copyright:
$(GSED) '$(COPYRIGHT)' $(README)
$(GSED) '$(COPYRIGHT)' $(LIC)
.PHONY: coverage
coverage:
./testcoverage
.PHONY: dep-stat
dep-stat:
dep status
.PHONY: deps
deps:
# dep ensure -update
go mod tidy
.PHONY: docs
docs: version readme
.PHONY: mips
mips: mips64 mipsle
.PHONY: mips64
mips64:
GOOS=linux GOARCH=mips64 $(GOBUILD) -o $(EXECUTABLE).mips \
-ldflags \
"-X main.build=$(DATE) \
-X main.githash=$(GIT) \
-X main.version=$(VER) \
-s -w" -v
.PHONY: mipsle
mipsle:
GOOS=linux GOARCH=mipsle $(GOBUILD) -o $(EXECUTABLE).mipsel \
-ldflags \
"-X main.build=$(DATE) \
-X main.githash=$(GIT) \
-X main.version=$(VER) \
-s -w" -v
.PHONY: pkgs
pkgs: pkg-mips pkg-mipsel
.PHONY: pkg-mips
pkg-mips: clean deps mips coverage copyright docs readme
cp $(EXECUTABLE).mips $(PAYLOAD)$(SCRIPTS)/$(EXECUTABLE) \
&& ./make_deb $(EXECUTABLE) mips
.PHONY: pkg-mipsel
pkg-mipsel: clean deps mipsle coverage copyright docs readme
cp $(EXECUTABLE).mipsel $(PAYLOAD)$(SCRIPTS)/$(EXECUTABLE) \
&& ./make_deb $(EXECUTABLE) mipsel
.PHONY: readme
readme: version
cat README.header > README.md
godocdown github.com/britannic/$(EXECUTABLE) >> README.md
.PHONY: tags
tags:
git push origin --tags
.PHONY: version
version:
$(GSED) '$(BADGE)' $(READMEHDR)
$(GSED) '$(VERSIONS)' $(READMEHDR)
cat ./VERSION > ./OLDVERSION
.PHONY: release
release: all commit push
@echo Released $(TAG)
.PHONY: commit
commit:
@echo Committing release $(TAG)
git commit -am"Release $(TAG)"
git tag $(TAG)
.PHONY: push
push:
@echo Pushing release $(TAG) to master
git push --tags
git push
.PHONY: repo
repo: pkgs
@echo Pushing repository $(TAG) to $(AWS)
scp $(PKG)_$(VER)_*.deb $(AWS):/tmp
./aws.sh $(AWS) $(PKG)_$(VER)_ $(TAG)
.PHONY: upload
upload: pkgs
scp $(PKG)_$(VER)_mips.deb dev1:/tmp
scp $(PKG)_$(VER)_mipsel.deb er-x:/tmp
scp $(PKG)_$(VER)_mips.deb ubnt:/tmp