aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 8defd89f60167c0b020a799675c4ce0d825f8522 (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
.POSIX:


pod2man = \
	share/man/man1/x.1 \
	share/man/man1/z.1 \


lisp-images = \
	$(XDG_DATA_HOME)/lisp-cli/clozure.image \
	$(XDG_DATA_HOME)/lisp-cli/clisp.image   \
	$(XDG_DATA_HOME)/lisp-cli/sbcl.image    \

derived-assets = \
	$(pod2man)                                        \
	$(XDG_STATE_HOME)/ssh/conn                        \
	$(XDG_CONFIG_HOME)/ssh/id_rsa.pub                 \
	$(XDG_CONFIG_HOME)/ssh/config                     \
	$(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf           \
	$(XDG_DATA_HOME)/common-lisp/source               \
	$(XDG_DATA_HOME)/euandreh/e.list.txt              \
	$(PRIV_STATEDIR)/postfix/relayhosts-maps.db       \
	$(PRIV_STATEDIR)/postfix/sasl-password.db         \
	$(HOME)/.ssh                                      \
	$(lisp-images)


all: $(derived-assets)


tilde:
	@cd $(PRIV_CONFIG) && $(MAKE)


share/man/man1/x.1 share/man/man1/z.1:
	pod2man bin/`basename $@ .1` > $@

share/man/man1/x.1: bin/x
share/man/man1/z.1: bin/z

$(XDG_STATE_HOME)/ssh/conn:
	mkdir -p $@

$(XDG_CONFIG_HOME)/ssh/id_rsa.pub:
	gpg --export-ssh-key eu@euandre.org > $@
	chmod 600 $@

$(XDG_CONFIG_HOME)/ssh/config: $(XDG_CONFIG_HOME)/ssh/config.tmpl
	envsubst < $(XDG_CONFIG_HOME)/ssh/config.tmpl > $@

$(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf: $(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf.tmpl
	cp $(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf.tmpl $@
	printf 'pinentry-program ' >> $@
	command -v pinentry-gtk-2  >> $@

$(HOME)/.ssh:
	ln -s $(XDG_CONFIG_HOME)/ssh $@

$(XDG_DATA_HOME)/common-lisp/source:
	ln -s $(SRC)/libre $@

$(XDG_DATA_HOME)/euandreh/e.list.txt: $(HOME)/Documents/txt/ opt/aux/gen-e-list.sh
	sh opt/aux/gen-e-list.sh > $@

$(PRIV_STATEDIR)/postfix/relayhosts-maps.db $(PRIV_STATEDIR)/postfix/sasl-password.db:
	postmap $(@D)/`basename $@ .db`

$(PRIV_STATEDIR)/postfix/sasl-password: tilde
$(PRIV_STATEDIR)/postfix/sasl-password.db:   $(PRIV_STATEDIR)/postfix/sasl-password
$(PRIV_STATEDIR)/postfix/relayhosts-maps.db: $(PRIV_STATEDIR)/postfix/relayhosts-maps

$(lisp-images): $(XDG_CONFIG_HOME)/lisp-cli/init.lisp bin/cl bin/li
	I=`echo $@ | awk -F/ '$$0=$$(NF)' | cut -d. -f1` && \
		li -vI $$I -E "(format t \"Image for \\\"$$I\\\" created.~%\")"



check-shellcheck:
	git ls-files | \
		sor 'test -f' | \
		xargs awk '/^#!\/bin\/sh$$/ { print FILENAME } { nextfile }' | \
		xargs shellcheck -x

check-perlcritic:
	git ls-files | \
		sor 'test -f' | \
		xargs awk '/^#!\/usr\/bin\/env perl$$/ { print FILENAME } { nextfile }' | \
		xargs perlcritic --exclude=subroutine

FIXME-excludes = \
	':(exclude)Makefile' \
	':(exclude)etc/git/ignore' \
	':(exclude)opt/aux/gen-e-list.sh'
check-fixme:
	if git grep FIXME -- $(FIXME-excludes); then \
		printf 'Leftover FIXME markers.\n' >&2; \
		exit 1; \
	fi

check-dirty-public:
	if ! git diff --quiet || ! git diff --quiet --staged; then \
		printf 'Dirty tilde repository.\n' >&2; \
		exit 1; \
	fi

check-dirty-private:
	if ! git -C $(PRIV_CONFIG) diff --quiet || \
			! git -C $(PRIV_CONFIG) diff --quiet --staged; then \
		printf 'Dirty private tilde repository.\n' >&2; \
		exit 1; \
	fi

check-opt:
	find opt/tests/ -name '*.sh' -exec sh {} +

check-pod:
	podchecker bin/z

check-sync:
	if git status --short --branch --porcelain | head -n1 | grep -E '(ahead|behind)'; then \
		printf 'Out of sync with origin.\n' >&2; \
		exit 1; \
	fi

check: check-shellcheck check-perlcritic check-fixme check-dirty-public        \
		check-dirty-private check-opt check-pod check-sync
	@cd $(PRIV_CONFIG) && $(MAKE) $@

clean:
	rm -f $(derived-assets)
	@cd $(PRIV_CONFIG) && $(MAKE) $@