Skip to content

Instantly share code, notes, and snippets.

@vgangireddyin
Last active June 5, 2016 16:03
Show Gist options
  • Save vgangireddyin/72f4fe96170642816d7be17d8a90ca56 to your computer and use it in GitHub Desktop.
Save vgangireddyin/72f4fe96170642816d7be17d8a90ca56 to your computer and use it in GitHub Desktop.
Basic Makefile for Golang
BUILDPATH=$(CURDIR)
GO=$(shell which go)
GOINSTALL=$(GO) install
GOCLEAN=$(GO) clean
GOGET=$(GO) get
EXENAME=main
export GOPATH=$(BUILDPATH)
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
@if [ ! -d $(BUILDPATH)/src ]; \
then \
mkdir -p $(BUILDPATH)/src;\
fi
get:
@echo "getting all dependencies"
$(GOGET)
build:
$(GOINSTALL) $(EXENAME)
@echo "build sucessfully"
clean:
@rm -rf $(BUILDPATH)/bin/$(EXENAME)
@rm -rf $(BUILDPATH)/pkg
all: makedir get build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment