From 615f98315ce17751a703d4933ae690befdae82e1 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 3 Aug 2020 21:58:25 +0200 Subject: Makefile: Major refactoring, add install and uninstall targets. Honor BUILD_DOCDIR and DESTDIR variables. --- Makefile | 59 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 24 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3