Makefile 1.21 KB
Newer Older
Sophie Brun's avatar
Sophie Brun committed
1
TARGET=bettercap
Sophie Brun's avatar
Sophie Brun committed
2
PACKAGES=core firewall log modules network packets session tls
Sophie Brun's avatar
Sophie Brun committed
3

Sophie Brun's avatar
Sophie Brun committed
4
all: deps build
Sophie Brun's avatar
Sophie Brun committed
5

Sophie Brun's avatar
Sophie Brun committed
6 7
deps: godep golint gomegacheck
	@dep ensure
Sophie Brun's avatar
Sophie Brun committed
8 9 10 11

build: resources
	@go build -o $(TARGET) .

Sophie Brun's avatar
Sophie Brun committed
12
resources: network/manuf.go
Sophie Brun's avatar
Sophie Brun committed
13

Sophie Brun's avatar
Sophie Brun committed
14 15
network/manuf.go:
	@python ./network/make_manuf.py
Sophie Brun's avatar
Sophie Brun committed
16 17

clean:
Sophie Brun's avatar
Sophie Brun committed
18
	@rm -rf $(TARGET)
Sophie Brun's avatar
Sophie Brun committed
19
	@rm -rf build
Sophie Brun's avatar
Sophie Brun committed
20

Sophie Brun's avatar
Sophie Brun committed
21
install:
Sophie Brun's avatar
Sophie Brun committed
22
	@mkdir -p /usr/local/share/bettercap/caplets
Sophie Brun's avatar
Sophie Brun committed
23 24
	@cp bettercap /usr/local/bin/

Sophie Brun's avatar
Sophie Brun committed
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 50 51 52 53 54 55 56
docker:
	@docker build -t bettercap:latest .

# Go 1.9 doesn't support test coverage on multiple packages, while
# Go 1.10 does, let's keep it 1.9 compatible in order not to break
# travis
test: deps
	@echo "mode: atomic" > coverage.profile
	@for pkg in $(PACKAGES); do \
		go fmt ./$$pkg ; \
		go vet ./$$pkg ; \
		megacheck ./$$pkg ; \
		touch $$pkg.profile ; \
		go test -race ./$$pkg -coverprofile=$$pkg.profile -covermode=atomic; \
		tail -n +2 $$pkg.profile >> coverage.profile && rm -rf $$pkg.profile ; \
	done

html_coverage: test
	@go tool cover -html=coverage.profile -o coverage.profile.html

benchmark: server_deps
	@go test ./... -v -run=doNotRunTests -bench=. -benchmem

# tools
godep:
	@go get -u github.com/golang/dep/...

golint:
	@go get github.com/golang/lint/golint

gomegacheck:
	@go get honnef.co/go/tools/cmd/megacheck