-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (69 loc) · 2.76 KB
/
Makefile
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
# vi: set sw=8 ts=8 ai sm noet:
# user_bin_targets - what scripts to install if installing as non-root
user_bin_targets=stupidweasel slgw
# system_bin_targets - what scripts to install if installing as root
system_bin_targets=$(user_bin_targets) mailpostgw
system_dat_targets=lists.dat
# man8_targets - what man pages to install
man8_targets=stupidweasel.8 slgw.8 mailpostgw.8
# mailpost - where is the mailpost command
mailpost=/software/inn/bin/mailpost
# sudo - where is sudo
sudo=/usr/bin/sudo
# mailpost_as - what user should mailpost be run as
mailpost_as=news
# system_bindir - where should scripts be installed if installing as root
system_bindir=/usr/local/sbin
# system_datdir - where should data files be installed if installing as root
system_datdir=/usr/local/etc
# system_mandir - where should man pages be installed if installing as root
system_mandir=/usr/local/man
####################### END OF CONFIGURABLE OPTIONS #######################
ifeq ($(shell id -u), 0)
bindir=$(system_bindir)
datdir=$(system_datdir)
mandir=$(system_mandir)
symlinks=mailq mailrm
targets=$(system_bin_targets)
dat_targets=$(system_dat_targets)
else
bindir=$(HOME)/bin
datdir=$(HOME)/.config/stupidweasel
mandir=$(HOME)/man
symlinks=
targets=$(user_bin_targets)
dat_targets=
endif
man8_targets=$(addsuffix .8,$(targets))
sources=mailpostgw.in
all: check doc
check: $(addsuffix .chk,$(targets) $(sources))
doc: stupidweasel.8
all_targets=$(addprefix $(bindir)/,$(targets)) \
$(addprefix $(datdir)/,$(dat_targets)) \
$(addprefix $(mandir)/man8/,$(man8_targets))
install: $(all_targets)
ifneq (,$(findstring mailpostgw,$(all_targets)))
if test -f mailpostgw; then grep -q '$(datdir)' mailpostgw || (rm -f mailpostgw; make mailpostgw); else true; fi
endif
for i in $(symlinks); do (cd $(bindir) && if [ ! -f "$$i" ]; then ln -sf stupidweasel "$$i"; elif [ ! -L "$$i" ]; then echo "$$i not installed because it is a file" >&2; elif [ stupidweasel != "`readlink "$$i"`" ]; then echo "$$i not installed because it is a symlink to a different command" >&2; fi ); done
uninstall:
rm -f $(all_targets)
$(bindir)/%: %
perl -Tcw $< && install -m 755 $< $@
$(datdir):
mkdir -p $@
$(datdir)/%: %
install -m 644 $< $@
$(mandir)/man8:
mkdir -p $@
$(mandir)/man8/%: $(mandir)/man8 %
install -m 644 $* $@
mailpostgw: mailpostgw.in
sed -e '1a# DO NOT EDIT THIS FILE. Edit $< instead.' -e 's|@@NEWSUSER@@|$(mailpost_as)|g' -e 's|@@MAILPOST@@|$(mailpost)|g' -e 's|@@SUDO@@|$(sudo)|' -e 's|@@INPUT@@|$(datdir)/lists.dat|g' < $< > $@ && perl -Tcw $@
%.chk: %
perl -Tcw $<
%.8: %
perl -nle 'print /^(=head1)(.*)/s? "$$1\U$$2": $$_' $< | pod2man --utf8 --section 8 -c 'System Management Manual' -n "$(shell echo "$*"|tr '[:lower:]' '[:upper:]')" > $@
.DELETE_ON_ERROR:
.PHONEY: all check doc install test uninstall