diff --git a/Makefile b/Makefile index ea74ba8..6fb931b 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,6 @@ PWD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) UPX ?= $(shell command -v upx 2>/dev/null) # Make sure it is uxp 3.94 or higher (https://github.com/upx/upx/releases) GOARCH ?= $(shell go env GOARCH) -GOPKG = github.com/longsleep/realtimetraffic -GOPATH = "$(CURDIR)/vendor:$(CURDIR)" -SYSTEM_GOPATH = /usr/share/gocode/src/ VERSION = $(shell git describe --tags --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || echo git) BUILDSTAMP = $(shell date -u '+%Y-%m-%dT%T%z') @@ -14,35 +11,30 @@ DIST_SRC := $(DIST)/src FOLDERS = $(shell find -mindepth 1 -maxdepth 1 -type d -not -path "*.git" -not -path "*debian" -not -path "*vendor" -not -path "*doc" -not -path "*bin") +export GO111MODULE=on + all: build $(DIST_SRC): mkdir -p $@ -dist_gopath: $(DIST_SRC) - if [ -d "$(SYSTEM_GOPATH)" ]; then find $(SYSTEM_GOPATH) -mindepth 1 -maxdepth 1 -type d \ - -exec ln -sf {} $(DIST_SRC) \; ; fi - if [ ! -d "$(SYSTEM_GOPATH)" ]; then find $(CURDIR)/vendor/src -mindepth 1 -maxdepth 1 -type d \ - -exec ln -sf {} $(DIST_SRC) \; ; fi +generate: mods client/bindata.go -godeps: - if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) go get github.com/rogpeppe/godeps; fi +client/bindata.go: bin/go-bindata + bin/go-bindata -prefix "client/static/" -pkg client -o client/bindata.go client/static/... -goget: godeps - if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/godeps -u dependencies.tsv; fi - mkdir -p $(shell dirname "$(CURDIR)/vendor/src/$(GOPKG)") - rm -f $(CURDIR)/vendor/src/$(GOPKG) - ln -sf $(PWD) $(CURDIR)/vendor/src/$(GOPKG) +generate-dev: bin/go-bindata + bin/go-bindata -dev -prefix "client/static/" -pkg client -o client/bindata.go client/static/... -generate: - if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) go get github.com/jteeuwen/go-bindata/...; fi - if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/go-bindata -prefix "client/static/" -pkg client -o client/bindata.go client/static/...; fi +mods: go.mod go.sum + go mod download + go mod verify -generate-dev: - GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/go-bindata -dev -prefix "client/static/" -pkg client -o client/bindata.go client/static/...; fi +bin/go-bindata: + go build -v -o bin/go-bindata github.com/kevinburke/go-bindata/go-bindata -binary-%: generate - GOPATH=$(GOPATH) GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 \ +binary-%: mods generate client/bindata.go + GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 \ go build \ -ldflags="-s -w \ -X main.Version=$(VERSION) \ @@ -53,7 +45,7 @@ binary-%: generate binary: binary-$(GOARCH) cp -va bin/realtimetrafficd_$(GOARCH) bin/realtimetrafficd -build: goget binary +build: binary $(DIST)/realtimetrafficd-$(VERSION)_%: binary-$(GOARCH) @mkdir -p $(DIST) @@ -73,11 +65,4 @@ release: release-amd64 release-armhf release-arm64 format: find $(FOLDERS) \( -name "*.go" ! -name "bindata.go" \) -print0 | xargs -0 -n 1 go fmt -dependencies.tsv: godeps - set -e ;\ - TMP=$$(mktemp -d) ;\ - cp -r $(CURDIR)/vendor $$TMP ;\ - GOPATH=$$TMP/vendor:$(CURDIR) $(CURDIR)/vendor/bin/godeps $(GOPKG)/realtimetrafficd > $(CURDIR)/dependencies.tsv ;\ - rm -rf $$TMP ;\ - -.PHONY: all dist_gopath godeps goget generate generate-dev binary dependencies.tsv build release +.PHONY: all client/bindata.go mods generate-dev binary build release diff --git a/dependencies.tsv b/dependencies.tsv deleted file mode 100644 index c4bdd2a..0000000 --- a/dependencies.tsv +++ /dev/null @@ -1,2 +0,0 @@ -github.com/elazarl/go-bindata-assetfs git 30f82fa23fd844bd5bb1e5f216db87fd77b5eb43 2017-02-27T21:27:28Z -github.com/gorilla/websocket git 119002ce0495aa7a8f388544d740e1bdc8829513 2014-02-18T05:22:10Z diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..034c3b8 --- /dev/null +++ b/go.mod @@ -0,0 +1,7 @@ +module github.com/longsleep/realtimetraffic + +require ( + github.com/elazarl/go-bindata-assetfs v1.0.0 + github.com/gorilla/websocket v0.0.0-20140218052210-119002ce0495 + github.com/kevinburke/go-bindata v3.11.0+incompatible // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..b82d05d --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= +github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= +github.com/gorilla/websocket v0.0.0-20140218052210-119002ce0495 h1:RNs7p7jyGHgTpOAgO0ZdhQRgucB1WO2BHmFGMOhQzyk= +github.com/gorilla/websocket v0.0.0-20140218052210-119002ce0495/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/kevinburke/go-bindata v3.11.0+incompatible h1:GiPs9jxaG2xY1B5Dt/d/yHUOMlTk14uS35VcmHrdo4I= +github.com/kevinburke/go-bindata v3.11.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=