chiark / gitweb /
Makefile: Clean up the version stamp file.
[distorted-dkim] / Makefile
1 ### -*-makefile-*-
2
3 ###--------------------------------------------------------------------------
4 ### User-serviceable parts.
5
6 ## Installation directories.
7 prefix                   = /usr/local
8 exec_prefix              = ${prefix}
9 bindir                   = ${exec_prefix}/bin
10 datadir                  = ${prefix}/share
11 mandir                   = ${datadir}/man
12 man1dir                  = ${mandir}/man1
13
14 ## User configuration.
15 -include config.mk
16
17 ###--------------------------------------------------------------------------
18 ### Machinery.
19
20 ## Preliminaries.
21 all:
22 clean::
23 .PHONY: all clean
24 .SECONDEXPANSION:
25
26 force:
27 .PHONY: force
28
29 ## Layout.
30 INSTDIRS                 =
31
32 INSTDIRS                += bin
33 bin_FILES                =
34 bin_INSTCMD              = install -t$(bindir) -m755
35
36 INSTDIRS                += man1
37 man1_FILES               =
38 man1_INSTCMD             = install -t$(man1dir) -m644
39
40 ## Version number.
41 VERSION                 := $(shell git describe --always --abbrev=4 --dirty=+)
42 -include version-stamp.mk
43 ifneq ($(VERSION),$(OLD_VERSION))
44   FORCE_VERSION          = force
45 else
46   FORCE_VERSION          =
47 endif
48 version-stamp.mk: $(FORCE_VERSION)
49         echo "OLD_VERSION = $(VERSION)" >$@.new && mv $@.new $@
50 clean::; rm version-stamp.mk
51
52 ## The main program.
53 bin_FILES               += dkim-keys
54 dkim-keys: dkim-keys.in version-stamp.mk
55         sed 's/@VERSION@/$(VERSION)/g' $< >$@.new && \
56                 chmod +x $@.new && mv $@.new $@
57
58 ## The manual.
59 man1_FILES              += dkim-keys.1
60 dkim-keys.1: dkim-keys.in version-stamp.mk
61         pod2man -s1 -dkim-keys -r"$(VERSION)" \
62                          -c"distorted.org.uk utilities" \
63                         $< >$@.new && \
64                 mv $@.new $@
65
66 ## Building.
67 TARGETS                  = $(foreach d,$(INSTDIRS), $($d_FILES))
68 all: $(TARGETS)
69 clean::; rm -f $(TARGETS)
70
71 ## Installation.
72 %/:; install -d $@
73
74 INSTALLS                 = $(addprefix install/, $(INSTDIRS))
75 install: $(INSTALLS)
76 $(INSTALLS): install/%: $$($$*_FILES) | $$($$*dir)/
77         $($*_INSTCMD) $+
78
79 UNINSTALLS               = $(addprefix uninstall/, $(INSTDIRS))
80 uninstall: $(UNINSTALLS)
81 $(UNINSTALLS): uninstall/%:
82         rm -f $(addprefix $($*dir)/,$($*_FILES))
83 .PHONY: install $(INSTALLS) uninstall $(UNINSTALLS)