Skip to content

Instantly share code, notes, and snippets.

@sohlich
Forked from dnishimura/Makefile.golang
Last active November 6, 2016 05:24
Show Gist options
  • Save sohlich/f89a2fa39a79172d984c to your computer and use it in GitHub Desktop.
Save sohlich/f89a2fa39a79172d984c to your computer and use it in GitHub Desktop.
Makefile for Golang projects
BUILDPATH=$(CURDIR)
GO=$(shell which go)
GOBUILD=$(GO) build
GOCLEAN=$(GO) clean
GOGET=$(GO) get
EXENAME=main
export GOPATH=$(CURDIR)
myname:
@echo "I am a makefile"
makedir:
@echo "start building tree..."
@if [ ! -d $(BUILDPATH)/bin ] ; then mkdir -p $(BUILDPATH)/bin ; fi
@if [ ! -d $(BUILDPATH)/pkg ] ; then mkdir -p $(BUILDPATH)/pkg ; fi
get:
@$(GOGET) github.com/gorilla/mux
@$(GOGET) github.com/go-sql-driver/mysql
@$(GOGET) github.com/Sirupsen/logrus
build:
@echo "start building..."
$(GOBUILD) $(EXENAME)
@echo "Yay! all DONE!"
clean:
@echo "cleanning"
@rm -rf $(BUILDPATH)/bin/$(EXENAME)
@rm -rf $(BUILDPATH)/pkg
@rm -rf $(BUILDPATH)/src/github.com
all: makedir get build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment