echoip/Makefile
antonc42 e1e6dba31b changed env var in makefile to builtin var
makefile was using the environment variable PWD. this can be
problematic if using 'sudo' as the PWD variable is not passed through.
however GNU make has a builtin CURDIR variable for the current working
directory that does work with 'sudo'.
2019-01-04 09:56:16 -06:00

34 lines
729 B
Makefile

OS := $(shell uname)
ifeq ($(OS),Linux)
TAR_OPTS := --wildcards
endif
all: deps lint test install
deps:
go get ./...
test: deps
go test ./...
vet: deps
go vet ./...
check-fmt:
bash -c "diff --line-format='%L' <(echo -n) <(gofmt -d -s .)"
lint: check-fmt vet
install: deps
go install ./...
databases := GeoLite2-City GeoLite2-Country
$(databases):
mkdir -p data
curl -fsSL -m 30 https://geolite.maxmind.com/download/geoip/database/$@.tar.gz | tar $(TAR_OPTS) --strip-components=1 -C $(CURDIR)/data -xzf - '*.mmdb'
test ! -f data/GeoLite2-City.mmdb || mv data/GeoLite2-City.mmdb data/city.mmdb
test ! -f data/GeoLite2-Country.mmdb || mv data/GeoLite2-Country.mmdb data/country.mmdb
geoip-download: $(databases)