aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2020-02-04 06:09:22 +0200
committerMarin Ivanov <[email protected]>2020-02-04 06:43:19 +0200
commitd2735b7f2d000fefe5b576bc3145a734c1dacfb8 (patch)
treed2293661abf77de0ec7e8b4634c5b93cf6a73330
parentf992c87e2fdfdee449c8ae3f11225f12316ef385 (diff)
Update build process
-rw-r--r--Makefile11
-rw-r--r--main.go4
-rw-r--r--setuid_unix.go2
-rw-r--r--setuid_windows.go2
4 files changed, 14 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 994382f..b1b4b0f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,16 @@
SRC = $(wildcard *.go)
+VERSION=$(shell git describe --tags)
+all: linux-amd64 darwin-amd64 windows-amd64
linux-amd64: build/tarpit-linux-amd64
-
+darwin-amd64: build/tarpit-darwin-amd64
windows-amd64: build/tarpit-windows-amd64.exe
build/tarpit-linux-amd64: $(SRC)
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o "$@" -ldflags '-extldflags "-static"'
+ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o "$@" -ldflags '-extldflags "-static" -X main.version=${VERSION}'
+
+build/tarpit-darwin-amd64: $(SRC)
+ CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -o "$@" -ldflags '-extldflags "-static" -X main.version=${VERSION}'
build/tarpit-windows-amd64.exe: $(SRC)
- GOOS=windows GOARCH=amd64 go build -o "$@"
+ GOOS=windows GOARCH=amd64 go build -o "$@" -ldflags '-extldflags "-static" -X main.version=${VERSION}'
diff --git a/main.go b/main.go
index 4033688..8aa9e96 100644
--- a/main.go
+++ b/main.go
@@ -10,7 +10,7 @@ import (
flag "github.com/spf13/pflag"
)
-var version = "0.1.0"
+var version string
const (
configErrorCode = 1
@@ -36,7 +36,7 @@ func main() {
flag.Parse()
if versionFlag {
- fmt.Println("Tarpit version", version)
+ fmt.Println("tarpit version", version)
return
}
diff --git a/setuid_unix.go b/setuid_unix.go
index be2db7b..8782a48 100644
--- a/setuid_unix.go
+++ b/setuid_unix.go
@@ -1,3 +1,5 @@
+// +build linux darwin
+
package main
import (
diff --git a/setuid_windows.go b/setuid_windows.go
index 63ccc73..277ed12 100644
--- a/setuid_windows.go
+++ b/setuid_windows.go
@@ -1,3 +1,5 @@
+// +build windows
+
package main
import (