Skip to content

Instantly share code, notes, and snippets.

@codeslinger
Created August 30, 2013 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeslinger/6390932 to your computer and use it in GitHub Desktop.
Save codeslinger/6390932 to your computer and use it in GitHub Desktop.
Makefile for Go projects
# vim:set ts=8 ai:
GOPATH := $(shell pwd)
BASE := github.com/me/myproject
TARGETS := target1 target2 target3
PACKAGES := util1 util2 target1 target2 target3
GOTESTOPTS := -v
GOGETOPTS := -v
all: compile
compile: $(TARGETS)
$(TARGETS):
@GOPATH=$(GOPATH) go install $(BASE)/$@
test:
@for pkg in $(PACKAGES); do \
GOPATH=$(GOPATH) go test $(GOTESTOPTS) $(BASE)/$$pkg; \
done
deps:
@GOPATH=$(GOPATH) go get $(GOGETOPTS) ./...
clean:
@for file in $(TARGETS); do \
rm -rf $(GOPATH)/bin/$$file; \
done; \
rm -rf $(GOPATH)/pkg/*
over: clean all
.PHONY: all compile test clean over
.PHONY: $(TARGETS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment