realtimetraffic/Makefile

53 lines
1.9 KiB
Makefile
Raw Normal View History

PWD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2014-03-09 16:53:21 +01:00
GOPKG = github.com/longsleep/realtimetraffic
2014-03-09 16:53:21 +01:00
GOPATH = "$(CURDIR)/vendor:$(CURDIR)"
SYSTEM_GOPATH = /usr/share/gocode/src/
2014-03-09 16:53:21 +01:00
DIST := $(PWD)/dist
2014-03-09 16:53:21 +01:00
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")
2014-03-09 16:53:21 +01:00
all: build
2014-03-09 16:53:21 +01:00
$(DIST_SRC):
mkdir -p $@
2014-03-09 16:53:21 +01:00
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
2014-03-09 16:53:21 +01:00
goget:
# if [ -z "$(DEB_BUILDING)" ]; then GOPATH=$(GOPATH) go get github.com/rogpeppe/godeps; fi
# 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)
2014-03-09 16:53:21 +01:00
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
2014-03-09 16:53:21 +01:00
generate-dev:
GOPATH=$(GOPATH) $(CURDIR)/vendor/bin/go-bindata -dev -prefix "client/static/" -pkg client -o client/bindata.go client/static/...; fi
2014-03-09 16:53:21 +01:00
binary:
GOPATH=$(GOPATH) go build -o bin/realtimetrafficd realtimetrafficd/*.go
2014-03-09 16:53:21 +01:00
build: goget generate binary
2014-03-09 16:53:21 +01:00
format:
find $(FOLDERS) \( -name "*.go" ! -name "bindata.go" \) -print0 | xargs -0 -n 1 go fmt
2014-03-09 16:53:21 +01:00
dependencies.tsv:
set -e ;\
TMP=$$(mktemp -d) ;\
cp -r $(CURDIR)/vendor $$TMP ;\
GOPATH=$$TMP/vendor:$(CURDIR) $(CURDIR)/vendor/bin/godeps $(GOPKG)/wlan > $(CURDIR)/dependencies.tsv ;\
rm -rf $$TMP ;\
2014-03-09 16:53:21 +01:00
.PHONY: all dist_gopath goget generate generate-dev binary dependencies.tsv