aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: a4098def6dac5a018c381371de55abf1f8407f51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
DESTDIR ?= /usr/local
BUILDDIR ?= ./build
MANUAL_FILES = $(addprefix $(BUILDDIR)/,$(patsubst ./%.md,%,$(wildcard ./*.[1-9].md)))

all: manual $(addprefix $(BUILDDIR)/,lacme lacme-accountd client webserver $(wildcard certs/* config/* snippets/*) certs/ca-certificates.crt)
doc: manual

manual: $(MANUAL_FILES)

# upper case the headers and remove the links
$(MANUAL_FILES): $(BUILDDIR)/%: $(BUILDDIR)/%.md
	pandoc -f markdown -t json -- "$<" | ./pandoc2man.jq | pandoc -s -f json -t man -o "$@"

# used for validation, see https://letsencrypt.org/certificates/
$(BUILDDIR)/certs/ca-certificates.crt: \
        certs/letsencryptauthorityx[34].pem \
        certs/lets-encrypt-x[34]-cross-signed.pem \
        certs/lets-encrypt-r[34].pem \
        certs/lets-encrypt-r[34]-cross-signed.pem \
        certs/lets-encrypt-e[12].pem
	mkdir -pv -- $(BUILDDIR)/certs
	cat $^ >$@

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 $(BUILDDIR)/certs/*
	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 -rvf -- $(BUILDDIR)

.PHONY: all doc manual install uninstall clean