aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 45 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7da46b1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+DESTDIR ?=
+PREFIX ?= $(HOME)/.local
+BINDIR ?= $(PREFIX)/bin
+MANDIR ?= $(PREFIX)/share/man
+
+VERSION ?= $(shell git rev-parse HEAD)
+
+PROGRAMS = silentct-mac silentct-mon
+SRC_DIRS = $(patsubst %,cmd/%,$(PROGRAMS))
+
+all: build man
+
+.PHONY: build
+build: $(PROGRAMS)
+
+$(PROGRAMS):
+ @mkdir -p build
+ go build -o build/$@ $(patsubst %,cmd/%/main.go,$@)
+
+man: $(patsubst %,man-%,$(PROGRAMS))
+
+man-%: build
+ help2man \
+ --no-info --version-string=$(VERSION) \
+ --include=cmd/$*/name.help2man \
+ --include=cmd/$*/examples.help2man \
+ --include=cmd/$*/see-also.help2man \
+ --include=docs/help2man/return-codes.help2man \
+ --include=docs/help2man/reporting-bugs.help2man \
+ -o build/$*.1 build/$*
+
+install: all
+ @mkdir -p $(DESTDIR)$(BINDIR)
+ @mkdir -p $(DESTDIR)$(MANDIR)/man1
+ install -m 755 $(patsubst %,build/%,$(PROGRAMS)) $(DESTDIR)$(BINDIR)
+ install -m 644 $(patsubst %,build/%.1,$(PROGRAMS)) $(DESTDIR)$(MANDIR)/man1
+
+.PHONY: uninstall
+uninstall:
+ rm -f $(patsubst %,$(DESTDIR)$(BINDIR)/%,$(PROGRAMS))
+ rm -f $(patsubst %,$(DESTDIR)$(MANDIR)/man1/%.1,$(PROGRAMS))
+
+.PHONY: clean
+clean:
+ rm -rf build