aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile97
1 files changed, 50 insertions, 47 deletions
diff --git a/Makefile b/Makefile
index 5d421bf..757a581 100644
--- a/Makefile
+++ b/Makefile
@@ -1,53 +1,56 @@
-MANPAGES = lacme-accountd.1 lacme.1
+DESTDIR ?= /usr/local
+BUILDDIR ?= ./build
+MANUAL_FILES = $(addprefix $(BUILDDIR)/,$(patsubst ./%.md,%,$(wildcard ./*.[1-9].md)))
-all: ${MANPAGES}
+all: manual $(addprefix $(BUILDDIR)/,lacme lacme-accountd client webserver $(wildcard config/* snippets/*))
+doc: manual
+
+manual: $(MANUAL_FILES)
# upper case the headers and remove the links
-%.1: %.md
- @pandoc -f markdown -t json "$<" | \
- jq " \
- def fixheaders: \
- if .t == \"Header\" then \
- .c[2][] |= (if .t == \"Str\" then .c |= ascii_upcase else . end)\
- else \
- . \
- end; \
- def fixlinks: \
- if type == \"object\" then \
- if .t == \"Link\" then \
- if .c[2][0][0:7] == \"mailto:\" then . else .c[1][] end \
- else \
- map_values(fixlinks) \
- end \
- else if type == \"array\" then \
- map(fixlinks) \
- else \
- . \
- end \
- end; \
- { \"pandoc-api-version\" \
- , meta \
- , blocks: .blocks | map(fixheaders) | map(fixlinks) \
- }" | \
- pandoc -s -f json -t man+smart -o "$@"
-
-install: ${MANPAGES}
- install -d $(DESTDIR)/etc/lacme
- install -d $(DESTDIR)/etc/lacme/lacme-certs.conf.d
- install -m0644 -t $(DESTDIR)/etc/lacme config/*.conf
- install -m0644 -t $(DESTDIR)/etc/lacme snippets/*.conf
- install -d $(DESTDIR)/usr/share/lacme
- install -m0644 -t $(DESTDIR)/usr/share/lacme certs/lets-encrypt-x[1-4]-cross-signed.pem
- install -d $(DESTDIR)/usr/lib/lacme
- install -m0755 -t $(DESTDIR)/usr/lib/lacme client webserver
- install -d $(DESTDIR)/usr/share/man/man1
- install -m0644 -t $(DESTDIR)/usr/share/man/man1 lacme-accountd.1 lacme.1
- install -d $(DESTDIR)/usr/bin
- install -m0644 -t $(DESTDIR)/usr/bin lacme-accountd
- install -d $(DESTDIR)/usr/sbin
- install -m0644 -t $(DESTDIR)/usr/bin lacme
+$(MANUAL_FILES): $(BUILDDIR)/%: $(BUILDDIR)/%.md
+ pandoc -f markdown -t json -- "$<" | ./pandoc2man.jq | pandoc -s -f json -t man -o "$@"
+
+prefix ?= $(DESTDIR)
+exec_prefix ?= $(prefix)
+bindir ?= $(exec_prefix)/bin
+sbindir ?= $(exec_prefix)/sbin
+libexecdir ?= $(exec_prefix)/libexec
+datarootdir ?= $(prefix)/share
+datadir ?= $(datarootdir)
+sysconfdir ?= $(prefix)/etc
+localstatedir =? $(prefix)/var
+runstatedir ?= $(localstatedir)/run
+mandir ?= $(datarootdir)/man
+man1dir ?= $(mandir)/man1
+man8dir ?= $(mandir)/man8
+
+$(BUILDDIR)/%: %
+ mkdir -pv -- $(dir $@)
+ cp --no-dereference --preserve=mode,links,xattr -vfT -- "$<" "$@"
+ sed -i "s#@@bindir@@#$(bindir)#g; \
+ s#@@sbindir@@#$(sbindir)#g; \
+ s#@@libexecdir@@#$(libexecdir)#g; \
+ s#@@datadir@@#$(datadir)#g; \
+ s#@@runstatedir@@#$(runstatedir)#g; \
+ s#@@sysconfdir@@#$(sysconfdir)#g;" -- "$@"
+
+install: all
+ install -m0644 -vDt $(sysconfdir)/lacme $(BUILDDIR)/config/*.conf $(BUILDDIR)/snippets/*.conf
+ install -vd $(sysconfdir)/lacme/lacme-certs.conf.d
+ install -m0644 -vDt $(datadir)/lacme certs/lets-encrypt-x[1-4]-cross-signed.pem
+ install -m0755 -vDt $(libexecdir)/lacme $(BUILDDIR)/client $(BUILDDIR)/webserver
+ install -m0644 -vDt $(man1dir) $(BUILDDIR)/lacme-accountd.1
+ install -m0644 -vDt $(man8dir) $(BUILDDIR)/lacme.8
+ install -m0644 -vDt $(bindir) $(BUILDDIR)/lacme-accountd
+ install -m0644 -vDt $(sbindir) $(BUILDDIR)/lacme
+
+uninstall:
+ rm -vf -- $(bindir)/lacme-accountd $(sbindir)/lacme
+ rm -vf -- $(man1dir)/lacme-accountd.1 $(man8dir)/lacme.8
+ rm -rvf -- $(sysconfdir)/lacme $(datadir)/lacme $(libexecdir)/lacme
clean:
- rm -vf ${MANPAGES}
+ rm -rvf -- $(BUILDDIR)
-.PHONY: all install clean
+.PHONY: all doc manual install uninstall clean