about summary refs log tree commit diff
path: root/Makefile
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-01-22 08:07:58 -0800
committerFranck Cuny <franck@fcuny.net>2024-01-22 08:07:58 -0800
commitffd20492d19f547de3456249ed374ba752c2e1ab (patch)
tree90f587e26e77dfd28147e830fa0d87bf7ade28dd /Makefile
parentdisable linter for yaml (diff)
downloadworld-ffd20492d19f547de3456249ed374ba752c2e1ab.tar.gz
build all the binaries using a Makefile
Add a Makefile to build the local binaries. Rename all the commands
without a dash.

We can build the commands with `make all` or by being explicit, for
example `make bin/x509-info`.

Add a common package to keep track of build information (commit and
build date) so we can reuse the same pattern across all the commands.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile24
1 files changed, 24 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9e28dc2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+.PHONY: all build-binaries clean
+
+all: build-binaries
+
+BUILD_DIR=bin
+
+VERSION=$(shell git describe --tag --always --dirty)
+BUILD_DATE ?= $(shell TZ=UTC0 date +%Y-%m-%dT%H:%M:%SZ)
+
+PKG:=github.com/fcuny/world
+
+BINARIES = bin/x509-info bin/flake-info
+
+ALL_BINARIES = $(foreach binary, $(BINARIES), ./$(binary))
+
+bin/%:
+	go build -o $@ \
+		-ldflags "-X $(PKG)/internal/version.Version=${VERSION} -X $(PKG)/internal/version.BuildDate=${BUILD_DATE}" \
+		-trimpath ./cmd/$(subst -,,$*)
+
+build-binaries: $(ALL_BINARIES)
+
+clean:
+	rm -rf bin/