-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile
102 lines (82 loc) · 3.64 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
100
101
102
# These targets are those you might want to override at install time
INSTALLPROG=install
INSTALLROOT=
INSTALLARGS=
PREFIX=/usr/local
BINDIR=bin
BINPERM=0755
# Might use: MANDIR=share/man
MANDIR=man
MANSECTDIR=man1
MANPERM=0644
PERL5BIN=`sh ./find-perl58.sh`
SED=sed
CHMOD=chmod
RM=rm
# These you probably don't want to adjust
SCRIPTNAME=sieve-connect
MANPAGE=sieve-connect.1
SCRIPTSRC=sieve-connect.pre.pl
SCRIPTDIST=sieve-connect.pl
TARPREFIX=sieve-connect
DISTFILES=$(SCRIPTDIST) $(MANPAGE) ChangeLog Makefile README.md LICENSE TODO find-perl58.sh
GPG=gpg
PGPSIGNKEY=0x4D1E900E14C1CC04
# ======================================================================
# Targets for builders/installers
all: $(SCRIPTNAME)
install: all install-bin install-man
install-bin: $(SCRIPTNAME)
$(INSTALLPROG) -m $(BINPERM) $(INSTALLARGS) $(SCRIPTNAME) $(INSTALLROOT)$(PREFIX)/$(BINDIR)/./
# making the man-page is dependent upon files not distributed, so they're
# regenerated, so we don't list it as a dependency here -- instead we
# assume that the maintainer created it for us (as a tarball depenency)
install-man:
$(INSTALLPROG) -m $(MANPERM) $(INSTALLARGS) $(MANPAGE) $(INSTALLROOT)$(PREFIX)/$(MANDIR)/$(MANSECTDIR)/./
bin $(SCRIPTNAME): $(SCRIPTDIST)
$(SED) <"$(SCRIPTDIST)" >"$(SCRIPTNAME)" "1s:/.*:$(PERL5BIN):"
$(CHMOD) +x "$(SCRIPTNAME)"
clean:
$(RM) -f "./$(SCRIPTNAME)"
# This target is for GNU make but being defined here does not prevent BSD make
# from using this file (the target won't work on BSD, but that's okay).
# Where BSD lets you `make -V VARNAME` to print the value of a variable instead
# of building a target, this gives GNU make a target `print-VARNAME` to print
# the value. I have so missed this when using GNU make.
#
# This rule comes from a comment on
# <http://blog.jgc.org/2015/04/the-one-line-you-should-add-to-every.html>
# where the commenter provided the shell meta-character-safe version.
print-%: ; @echo '$(subst ','\'',$*=$($*))'
# ======================================================================
# Targets after here are for distributors
METAFILES= repo-generate .git/HEAD
dist: tarball pgpsig
# The presence of SCRIPTSRC and git rules breaks install from outside the git
# repository; we fix it by just ripping out the distributors section from the
# tarball Makefile. So "makefile" in git and for use when making a release.
# "Makefile" for distribution. BSD make prefers "makefile" to "Makefile", so
# we can still use distributor targets when both are present.
Makefile: makefile
sed '/Targets after here are for distributors/,$$d' < makefile > Makefile
$(SCRIPTDIST): $(SCRIPTSRC) versionfile
@echo "embedding version number into distribution form of script"
./repo-generate versionfilter $(SCRIPTSRC) $(SCRIPTDIST)
# This can use non-portable commands, so shove into subdir
tarball: $(DISTFILES) versionfile $(METAFILES)
@echo "checking copyright years up to date ..."
./repo-generate copyright $(SCRIPTSRC) LICENSE
pax -w -s ",^,$(TARPREFIX)-`cat versionfile`/," $(DISTFILES) > $(TARPREFIX)-`cat versionfile`.tar
bzip2 -9 $(TARPREFIX)-`cat versionfile`.tar
pgpsig: tarball versionfile
$(GPG) -a --detach-sign --default-key $(PGPSIGNKEY) $(TARPREFIX)-`cat versionfile`.tar.bz2
man $(MANPAGE): $(SCRIPTDIST) datefile versionfile
pod2man -n "$(SCRIPTNAME)" -c '' -d "`cat datefile`" -r "`cat versionfile`" "$(SCRIPTDIST)" >"$(MANPAGE)"
# filter is against spammers (see README)
ChangeLog: $(METAFILES)
./repo-generate changelog > ChangeLog
datefile versionfile: $(METAFILES)
./repo-generate version > versionfile
./repo-generate date > datefile
distclean: clean
$(RM) -f "./$(MANPAGE)" ./ChangeLog ./versionfile ./datefile ./$(SCRIPTDIST) ./Makefile