diff --git a/Makefile b/Makefile
index b585092eb6df1661ea22751425b10f6d9748ace9..00c7defcbdd8746846b64c48977ab951aabeed23 100644
--- a/Makefile
+++ b/Makefile
@@ -1,33 +1,24 @@
-PROJ="poke"
-ORG_PATH="github.com/coreos"
-REPO_PATH="$(ORG_PATH)/$(PROJ)"
+PROJ=poke
+ORG_PATH=github.com/coreos
+REPO_PATH=$(ORG_PATH)/$(PROJ)
 export PATH := $(PWD)/bin:$(PATH)
 
 export GOBIN=$(PWD)/bin
 export GO15VENDOREXPERIMENT=1
+export CGO_ENABLED:=0
+
+LD_FLAGS="-w -X $(REPO_PATH)/version.Version=$(shell ./scripts/git-version)"
 
 GOOS=$(shell go env GOOS)
 GOARCH=$(shell go env GOARCH)
 
-COMMIT=$(shell git rev-parse HEAD)
-
-# check if the current commit has a matching tag
-TAG=$(shell git describe --exact-match --abbrev=0 --tags $(COMMIT) 2> /dev/null || true)
-
-ifeq ($(TAG),)
-	VERSION=$(TAG)
-else
-	VERSION=$(COMMIT)
-endif
-
-
 build: bin/poke bin/example-app
 
 bin/poke: FORCE
-	@go install $(REPO_PATH)/cmd/poke
+	@go install -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/poke
 
 bin/example-app: FORCE
-	@go install $(REPO_PATH)/cmd/example-app
+	@go install -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/example-app
 
 test:
 	@go test $(shell go list ./... | grep -v '/vendor/')
diff --git a/cmd/poke/version.go b/cmd/poke/version.go
index bd8146e5c6f8acd55187b4022581b24a174f781b..e7fbfa75aa45d8fa1a5393048e714f9914a0405c 100644
--- a/cmd/poke/version.go
+++ b/cmd/poke/version.go
@@ -10,9 +10,12 @@ import (
 
 func commandVersion() *cobra.Command {
 	return &cobra.Command{
-		Use: "version",
+		Use:   "version",
+		Short: "Print the version and exit",
 		Run: func(cmd *cobra.Command, args []string) {
-			fmt.Printf(`v%s %s %s %s
+			fmt.Printf(`dex Version:%s
+Go Version: %s
+Go OS/ARCH: %s %s
 `, version.Version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
 		},
 	}
diff --git a/scripts/git-version b/scripts/git-version
new file mode 100755
index 0000000000000000000000000000000000000000..f0710e57580ba511197759cdd483353b89b1ce93
--- /dev/null
+++ b/scripts/git-version
@@ -0,0 +1,21 @@
+#!/bin/bash -e
+
+# parse the current git commit hash
+COMMIT=`git rev-parse HEAD`
+
+# check if the current commit has a matching tag
+TAG=$(git describe --exact-match --abbrev=0 --tags ${COMMIT} 2> /dev/null || true)
+
+# use the matching tag as the version, if available
+if [ -z "$TAG" ]; then
+    VERSION=$COMMIT
+else
+    VERSION=$TAG
+fi
+
+# check for changed files (not untracked files)
+if [ -n "$(git diff --shortstat 2> /dev/null | tail -n1)" ]; then
+    VERSION="${VERSION}-dirty"
+fi
+
+echo $VERSION
\ No newline at end of file
diff --git a/version/version.go b/version/version.go
index a9bce62006bb44f088c2fc2f643749059bbcee2c..04f684a57400eeec87fa3fac206b868555c156b2 100644
--- a/version/version.go
+++ b/version/version.go
@@ -1,5 +1,5 @@
 // Package version contains version information for this app.
 package version
 
-// Version is the semantic version of the server.
-const Version = "0.1.0"
+// Version is set by the build scripts.
+var Version = "was not built properly"