Skip to content

Commit

Permalink
[add] Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
cloverstd committed Jun 28, 2017
1 parent 654660a commit e6fa2a8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/

dist
*.tar.gz
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.SILENT :
.PHONY : tcping clean fmt

TAG:=`git describe --abbrev=0 --tags`
GITCOMMIT:=`git rev-parse HEAD`
LDFLAGS:=-X main.version=$(TAG) -X main.gitCommit=$(GITCOMMIT)

all: tcping

tcping:
echo "Building tcping"
go install -ldflags "$(LDFLAGS)"

dist-clean:
rm -rf dist
rm -f tcping-*.tar.gz

dist: dist-clean
mkdir -p dist/alpine-linux/amd64 && GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -a -tags netgo -installsuffix netgo -o dist/alpine-linux/amd64/tcping
mkdir -p dist/linux/amd64 && GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o dist/linux/amd64/tcping
mkdir -p dist/linux/armel && GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "$(LDFLAGS)" -o dist/linux/armel/tcping
mkdir -p dist/linux/armhf && GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "$(LDFLAGS)" -o dist/linux/armhf/tcping
mkdir -p dist/darwin/amd64 && GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o dist/darwin/amd64/tcping

release: dist
tar -cvzf tcping-alpine-linux-amd64-$(TAG).tar.gz -C dist/alpine-linux/amd64 tcping
tar -cvzf tcping-linux-amd64-$(TAG).tar.gz -C dist/linux/amd64 tcping
tar -cvzf tcping-linux-armel-$(TAG).tar.gz -C dist/linux/armel tcping
tar -cvzf tcping-linux-armhf-$(TAG).tar.gz -C dist/linux/armhf tcping
tar -cvzf tcping-darwin-amd64-$(TAG).tar.gz -C dist/darwin/amd64 tcping
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (

var (
showVersion bool
version = "dev"
version string
gitCommit string
counter int
timeout string
interval string
Expand Down Expand Up @@ -44,6 +45,7 @@ var rootCmd = cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
if showVersion {
fmt.Printf("version: %s\n", version)
fmt.Printf("git: %s\n", gitCommit)
return
}
if len(args) != 2 && len(args) != 1 {
Expand Down

0 comments on commit e6fa2a8

Please sign in to comment.