git » chasquid » commit 60ed30e

Add a Makefile

author Alberto Bertogli
2016-10-22 17:36:45 UTC
committer Alberto Bertogli
2016-11-01 23:55:56 UTC
parent c87c5ec1bcae04bc48032b251b040a8cd13d6a6f

Add a Makefile

This patch introduces a Makefile to make it easier to build with version
information, and run all the tests together.

It's just for convenience, plain go commands continue to work just fine.

.gitignore +5 -0
Makefile +40 -0

diff --git a/.gitignore b/.gitignore
index 79a0a55..9bb463a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,12 @@
 
 # The binaries.
 chasquid
+chasquid-util
+smtp-check
+spf-check
 cmd/chasquid-util/chasquid-util
+cmd/smtp-check/smtp-check
+cmd/spf-check/spf-check
 
 # Exclude any .pem files, to prevent accidentally including test keys and
 # certificates.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..02c23cb
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,40 @@
+
+ifndef VERSION
+    VERSION = `git describe --always --long --dirty`
+endif
+
+# https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal
+ifndef SOURCE_DATE_EPOCH
+    SOURCE_DATE_EPOCH = `git log -1 --format=%ct`
+endif
+
+
+default: chasquid
+
+all: chasquid chasquid-util smtp-check spf-check
+
+
+chasquid:
+	go build -ldflags="\
+		-X main.version=${VERSION} \
+		-X main.sourceDateTs=${SOURCE_DATE_EPOCH} \
+		" ${GOFLAGS}
+
+
+chasquid-util:
+	go build ${GOFLAGS} ./cmd/chasquid-util/
+
+smtp-check:
+	go build ${GOFLAGS} ./cmd/smtp-check/
+
+spf-check:
+	go build ${GOFLAGS} ./cmd/spf-check/
+
+
+test:
+	go test ${GOFLAGS} ./...
+	setsid -w ./test/run.sh
+	setsid -w ./cmd/chasquid-util/test.sh
+
+
+.PHONY: chasquid chasquid-util smtp-check spf-check test