aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2020-08-03 21:58:25 +0200
committerGuilhem Moulin <guilhem@fripost.org>2020-08-03 22:31:19 +0200
commit615f98315ce17751a703d4933ae690befdae82e1 (patch)
tree0f701451c7907864298136875c1d15377a861d3f /Makefile
parent0cf8517bea1e939d7054e682cde24767e7ed6e04 (diff)
Makefile: Major refactoring, add install and uninstall targets.
Honor BUILD_DOCDIR and DESTDIR variables.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile59
1 files changed, 35 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index 0aa3046..6bfa739 100644
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,41 @@
-MANPAGES = lacme-accountd.1 lacme.1
+DESTDIR ?= /usr/local
+BUILD_DOCDIR ?= .
+MANUAL_FILES = $(addprefix $(BUILD_DOCDIR)/,$(patsubst ./%.md,%,$(wildcard ./*.[1-9].md)))
-all: ${MANPAGES}
+all: manual
+doc: manual
+
+manual: $(MANUAL_FILES)
# upper case the headers and remove the links
-%.1: %.md
- @pandoc -f markdown -t json "$<" | \
- jq -f fixman.jq | \
- 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): $(BUILD_DOCDIR)/%: ./%.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)/lib
+datarootdir ?= $(prefix)/share
+sysconfdir ?= $(prefix)/etc
+mandir ?= $(datarootdir)/man
+man1dir ?= $(mandir)/man1
+
+install: all
+ install -m0644 -vDt $(sysconfdir)/lacme config/*.conf snippets/*.conf
+ install -vd $(sysconfdir)/lacme/lacme-certs.conf.d
+ install -m0644 -vDt $(datarootdir)/lacme certs/lets-encrypt-x[1-4]-cross-signed.pem
+ install -m0755 -vDt $(libexecdir)/lacme ./client ./webserver
+ install -m0644 -vDt $(man1dir) $(BUILD_DOCDIR)/lacme-accountd.1 $(BUILD_DOCDIR)/lacme.1
+ install -m0644 -vDt $(bindir) ./lacme-accountd
+ install -m0644 -vDt $(sbindir) ./lacme
+
+uninstall:
+ rm -vf -- $(bindir)/lacme-accountd $(sbindir)/lacme
+ rm -vf -- $(man1dir)/lacme-accountd.1 $(man1dir)/lacme.1
+ rm -rvf -- $(sysconfdir)/lacme $(datarootdir)/lacme $(libexecdir)/lacme
clean:
- rm -vf ${MANPAGES}
+ rm -vf -- $(MANUAL_FILES)
-.PHONY: all install clean
+.PHONY: all doc manual install uninstall clean