Skip to content

Commit

Permalink
Improve Makefile, add multiple targets
Browse files Browse the repository at this point in the history
Adds targets to do things like:
* build
* install
* vendor

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
  • Loading branch information
seemethere committed Mar 9, 2018
1 parent 16cf268 commit 7e25da7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vendor/
_vendor-*/
dist/
dist/
bin/
33 changes: 29 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
.PHONY: default clean
DEP="$(shell go env GOPATH)/bin/dep"
PREFIX?=/usr/local/bin
LDFLAGS:=-ldflags '-X main.version=$(shell git rev-parse --abbrev-ref HEAD) -X main.commit=$(shell git rev-parse HEAD) -X "main.goversion=$(shell go version)"'

default:
go install -ldflags '-X main.version=$(shell git rev-parse --abbrev-ref HEAD) -X main.commit=$(shell git rev-parse HEAD) -X "main.goversion=$(shell go version)"' github.com/fossas/fossa-cli/cmd/fossa
all: build

$(DEP): ## Grab golang/dep utility
go get github.com/golang/dep/cmd/dep

.PHONY: build
build: bin/fossa

bin/fossa:
mkdir -p $$(dirname $@)
go build -o $@ $(LDFLAGS) github.com/fossas/fossa-cli/cmd/fossa

$(PREFIX)/fossa: bin/fossa
mv $< $@

vendor: $(DEP)
$< ensure -v -update

.PHONY: install
install: $(PREFIX)/fossa

.PHONY: uninstall
uninstall:
rm $(PREFIX)/fossa

.PHONY: clean
clean:
rm -f $(GOPATH)/bin/fossa
rm -f bin/fossa

0 comments on commit 7e25da7

Please sign in to comment.