Skip to content

Commit e6fa2a8

Browse files
committed
[add] Makefile
1 parent 654660a commit e6fa2a8

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.dll
4+
*.so
5+
*.dylib
6+
7+
# Test binary, build with `go test -c`
8+
*.test
9+
10+
# Output of the go coverage tool, specifically when used with LiteIDE
11+
*.out
12+
13+
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
14+
.glide/
15+
16+
dist
17+
*.tar.gz

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.SILENT :
2+
.PHONY : tcping clean fmt
3+
4+
TAG:=`git describe --abbrev=0 --tags`
5+
GITCOMMIT:=`git rev-parse HEAD`
6+
LDFLAGS:=-X main.version=$(TAG) -X main.gitCommit=$(GITCOMMIT)
7+
8+
all: tcping
9+
10+
tcping:
11+
echo "Building tcping"
12+
go install -ldflags "$(LDFLAGS)"
13+
14+
dist-clean:
15+
rm -rf dist
16+
rm -f tcping-*.tar.gz
17+
18+
dist: dist-clean
19+
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
20+
mkdir -p dist/linux/amd64 && GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o dist/linux/amd64/tcping
21+
mkdir -p dist/linux/armel && GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "$(LDFLAGS)" -o dist/linux/armel/tcping
22+
mkdir -p dist/linux/armhf && GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "$(LDFLAGS)" -o dist/linux/armhf/tcping
23+
mkdir -p dist/darwin/amd64 && GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o dist/darwin/amd64/tcping
24+
25+
release: dist
26+
tar -cvzf tcping-alpine-linux-amd64-$(TAG).tar.gz -C dist/alpine-linux/amd64 tcping
27+
tar -cvzf tcping-linux-amd64-$(TAG).tar.gz -C dist/linux/amd64 tcping
28+
tar -cvzf tcping-linux-armel-$(TAG).tar.gz -C dist/linux/armel tcping
29+
tar -cvzf tcping-linux-armhf-$(TAG).tar.gz -C dist/linux/armhf tcping
30+
tar -cvzf tcping-darwin-amd64-$(TAG).tar.gz -C dist/darwin/amd64 tcping

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515

1616
var (
1717
showVersion bool
18-
version = "dev"
18+
version string
19+
gitCommit string
1920
counter int
2021
timeout string
2122
interval string
@@ -44,6 +45,7 @@ var rootCmd = cobra.Command{
4445
Run: func(cmd *cobra.Command, args []string) {
4546
if showVersion {
4647
fmt.Printf("version: %s\n", version)
48+
fmt.Printf("git: %s\n", gitCommit)
4749
return
4850
}
4951
if len(args) != 2 && len(args) != 1 {

0 commit comments

Comments
 (0)