2015-05-10 20:43:42 +00:00
|
|
|
.PHONY: all clean env test bench gox test-integration
|
2014-08-05 21:13:19 +00:00
|
|
|
|
2015-05-10 20:43:42 +00:00
|
|
|
TMPGOPATH=$(PWD)/.gopath
|
|
|
|
VENDORPATH=$(PWD)/Godeps/_workspace
|
|
|
|
BASE=github.com/restic/restic
|
|
|
|
BASEPATH=$(TMPGOPATH)/src/$(BASE)
|
2015-01-14 16:32:37 +00:00
|
|
|
|
2015-05-10 20:43:42 +00:00
|
|
|
GOPATH=$(TMPGOPATH):$(VENDORPATH)
|
2015-01-14 16:32:37 +00:00
|
|
|
|
2015-05-10 20:43:42 +00:00
|
|
|
GOTESTFLAGS ?= -v
|
|
|
|
GOX_OS ?= linux darwin openbsd freebsd
|
|
|
|
SFTP_PATH ?= /usr/lib/ssh/sftp-server
|
|
|
|
|
2015-05-11 19:09:32 +00:00
|
|
|
CMDS=$(patsubst cmd/%,%,$(wildcard cmd/*))
|
|
|
|
CMDS_DEBUG=$(patsubst %,%.debug,$(CMDS))
|
|
|
|
|
2015-05-14 09:11:30 +00:00
|
|
|
SOURCE=$(wildcard *.go) $(wildcard */*.go) $(wildcard */*/*.go)
|
|
|
|
|
2015-05-10 20:43:42 +00:00
|
|
|
export GOPATH GOX_OS
|
|
|
|
|
|
|
|
all: restic
|
|
|
|
|
|
|
|
.gopath:
|
|
|
|
mkdir -p .gopath/src/github.com/restic
|
2015-05-14 09:10:01 +00:00
|
|
|
ln -snf ../../../.. .gopath/src/github.com/restic/restic
|
2015-05-10 20:43:42 +00:00
|
|
|
|
2015-05-14 09:11:30 +00:00
|
|
|
%: cmd/% .gopath $(SOURCE)
|
2015-05-10 20:43:42 +00:00
|
|
|
cd $(BASEPATH) && \
|
2015-05-11 19:09:32 +00:00
|
|
|
go build -a -ldflags "-s" -o $@ ./$<
|
2015-05-10 20:43:42 +00:00
|
|
|
|
2015-05-14 09:11:30 +00:00
|
|
|
%.debug: cmd/% .gopath $(SOURCE)
|
2015-05-10 20:43:42 +00:00
|
|
|
cd $(BASEPATH) && \
|
2015-05-11 19:09:32 +00:00
|
|
|
go build -a -tags debug -ldflags "-s" -o $@ ./$<
|
2014-08-05 21:13:19 +00:00
|
|
|
|
|
|
|
clean:
|
2015-05-11 19:09:32 +00:00
|
|
|
rm -rf .gopath $(CMDS) $(CMDS_DEBUG) *.cov restic_*
|
2015-01-14 20:36:33 +00:00
|
|
|
go clean ./...
|
2015-05-10 20:43:42 +00:00
|
|
|
|
|
|
|
test: .gopath
|
|
|
|
cd $(BASEPATH) && \
|
|
|
|
go test $(GOTESTFLAGS) ./...
|
|
|
|
|
|
|
|
bench: .gopath
|
|
|
|
cd $(BASEPATH) && \
|
2015-05-11 16:26:56 +00:00
|
|
|
go test $(GOTESTFLAGS) -bench ./...
|
2015-05-10 20:43:42 +00:00
|
|
|
|
2015-05-14 09:11:30 +00:00
|
|
|
gox: .gopath $(SOURCE)
|
2015-05-10 20:43:42 +00:00
|
|
|
cd $(BASEPATH) && \
|
|
|
|
gox -verbose -os "$(GOX_OS)" ./cmd/restic
|
|
|
|
|
2015-05-09 20:40:10 +00:00
|
|
|
test-integration: .gopath
|
|
|
|
cd $(BASEPATH) && go test $(GOTESTFLAGS) \
|
|
|
|
./backend \
|
|
|
|
-cover -covermode=count -coverprofile=integration-sftp.cov \
|
2015-06-05 20:33:39 +00:00
|
|
|
-test.integration \
|
2015-05-09 20:40:10 +00:00
|
|
|
-test.sftppath=$(SFTP_PATH)
|
|
|
|
|
|
|
|
cd $(BASEPATH) && go test $(GOTESTFLAGS) \
|
|
|
|
./cmd/restic \
|
|
|
|
-cover -covermode=count -coverprofile=integration.cov \
|
2015-06-05 20:33:39 +00:00
|
|
|
-test.integration \
|
2015-05-09 20:40:10 +00:00
|
|
|
-test.datafile=$(PWD)/testsuite/fake-data.tar.gz
|
|
|
|
|
|
|
|
all.cov: .gopath $(SOURCE) test-integration
|
2015-05-10 20:43:42 +00:00
|
|
|
cd $(BASEPATH) && \
|
2015-05-09 20:40:10 +00:00
|
|
|
go list ./... | while read pkg; do \
|
|
|
|
go test -covermode=count -coverprofile=$$(echo $$pkg | base64).cov $$pkg; \
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "mode: count" > all.cov
|
|
|
|
tail -q -n +2 *.cov >> all.cov
|
2015-05-10 20:43:42 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
@echo export GOPATH=\"$(GOPATH)\"
|
2015-05-11 19:10:36 +00:00
|
|
|
|
|
|
|
goenv:
|
|
|
|
go env
|
|
|
|
|
|
|
|
list: .gopath
|
|
|
|
cd $(BASEPATH) && \
|
|
|
|
go list ./...
|