-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
49 lines (35 loc) · 1.31 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
SOURCES = $(shell find ./ -type f -name '*.go' | grep -vE './(build|vendor)/' )
FILTERS ?= geoip noop ldapauth
PLUGINS = $(shell for t in $(FILTERS); do echo build/filter_$$t.so; done )
CURRENT_VERSION = $(shell git tag | sort -V | tail -n1)
VERSION ?= $(CURRENT_VERSION)
COMMIT_HASH = $(shell git rev-parse --short HEAD)
XGOPATH = $(HOME)/go
default: plugins
plugins: deps $(PLUGINS) checks
geoipdb: GeoLite2-Country.mmdb
GeoLite2-Country.mmdb: GeoLite2-Country.tar.gz
tar xvzf GeoLite2-Country.tar.gz --wildcards --strip-components=1 '*/GeoLite2-Country.mmdb'
GeoLite2-Country.tar.gz:
wget -O GeoLite2-Country.tar.gz http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz
deps:
go get -t github.com/zalando/skipper
# glide update
glide install
checks: vet fmt tests
tests: geoipdb
go test -run LoadPlugin
vet: $(SOURCES)
go vet $(shell for t in $(FILTERS); do echo ./$$t/...; done )
fmt: $(SOURCES)
@if [ "$$(gofmt -d $(SOURCES))" != "" ]; then false; else true; fi
test:
go test -v
$(PLUGINS): $(SOURCES)
mkdir -p build/
MODULE=$(shell basename $@ .so | sed -e 's/filter_//' ); \
go build -buildmode=plugin -o $@ $$MODULE/$$MODULE.go
clean:
rm -f build/*.so
realclean: clean
rm -f GeoLite2-Country.mmdb GeoLite2-Country.tar.gz