]> git.tuebingen.mpg.de Git - dss.git/blob - Makefile
2db46b2ae6ffb8fd473679106a94ba867e043213
[dss.git] / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2
3 PACKAGE := dss
4 SLOGAN := the dyadic snapshot scheduler
5 define DESCRIPTION1 :=
6         $(PACKAGE) maintains hardlink-based snapshots of a given directory on a
7         remote or local host using rsync's link-dest feature. The snapshots
8         are organized so that any snapshot can directly be deployed as an
9         (emergency) replacement for the primary system.
10 endef
11 define DESCRIPTION2 :=
12         $(PACKAGE) is admin friendly: It is easy to configure and needs little
13         attention after the initial setup. In particular, no full, incremental
14         or differential backups need to be configured, and there is no database
15         to maintain. $(PACKAGE) is also user-friendly: Assuming the snapshot server
16         allows read-only user access over the network, users can restore
17         accidentically removed files without admin intervention, using their
18         favorite file browser to copy files from the snapshot directory back
19         to the primary system.
20 endef
21 define DESCRIPTION3 :=
22         $(PACKAGE) keeps track of the age and the state of existing snapshots and
23         triggers snapshot creation and removal according to the configuration
24         settings. It tries to maintain a scheme where many recent snapshots
25         and few old snapshots exist, for example 16 snapshots newer than a
26         week, 8 snapshots between one and two weeks old, 4 snapshots between
27         two and three weeks old, and so on.
28 endef
29 AUTHOR := Andre Noll
30 EMAIL := maan@tuebingen.mpg.de
31 URL := https://people.tuebingen.mpg.de/maan/$(PACKAGE)/
32 CLONE_URL := https://git.tuebingen.mpg.de/$(PACKAGE)
33 GITWEB_URL := https://git.tuebingen.mpg.de/$(PACKAGE).git
34 PACKAGE_HOMEPAGE := https://people.tuebingen.mpg.de/maan/$(PACKAGE)/
35 HOME_URL := https://people.tuebingen.mpg.de/maan/
36 LICENSE := GPL-2.0
37 LICENSE_URL := https://www.gnu.org/licenses/
38
39 PREFIX ?= /usr/local
40 INSTALL ?= install
41 INSTALL_PROGRAM ?= $(INSTALL)
42 INSTALL_DATA ?= $(INSTALL) -m 644
43 MKDIR_P := mkdir -p
44 VERSION := $(shell ./version-gen.sh $(PACKAGE) version.c)
45 RM := rm -f
46 LSG := lopsubgen
47 GROFF := groff -m man -Thtml -P -l -P -r
48 GZIP := gzip -cfn9
49 units := $(PACKAGE) $(PACKAGE).lsg str file exec sig daemon df tv snap ipc version
50 M4 := m4 \
51         -D "AUTHOR=$(AUTHOR)" \
52         -D "PACKAGE=$(PACKAGE)" \
53         -D "SLOGAN=$(SLOGAN)" \
54         -D "EMAIL=$(EMAIL)" \
55         -D "URL=$(URL)" \
56         -D "CLONE_URL=$(CLONE_URL)" \
57         -D "GITWEB_URL=$(GITWEB_URL)" \
58         -D "HOME_URL=$(HOME_URL)" \
59         -D "PACKAGE_HOMEPAGE=$(PACKAGE_HOMEPAGE)" \
60         -D "LICENSE=$(LICENSE)" \
61         -D "LICENSE_URL=$(LICENSE_URL)" \
62         -D "DESCRIPTION1=$(DESCRIPTION1)" \
63         -D "DESCRIPTION2=$(DESCRIPTION2)" \
64         -D "DESCRIPTION3=$(DESCRIPTION3)"
65 objs := $(addsuffix .o, $(units))
66 deps := $(addsuffix .d, $(units))
67 all := $(PACKAGE) $(PACKAGE).1.gz
68
69 all: $(all)
70 man: $(PACKAGE).1.gz
71 $(objs): $(PACKAGE).lsg.h Makefile
72 -include $(deps)
73
74 DSS_CPPFLAGS += -Wunused-macros
75
76 DSS_CFLAGS := -Wno-sign-compare -g -Wunused -Wundef
77 DSS_CFLAGS += -Wredundant-decls
78 DSS_CFLAGS += -Os
79 DSS_CFLAGS += -Wall
80 DSS_CFLAGS += -Wuninitialized
81 DSS_CFLAGS += -Wchar-subscripts
82 DSS_CFLAGS += -Wformat-security
83 DSS_CFLAGS += -Werror-implicit-function-declaration
84 DSS_CFLAGS += -Wmissing-format-attribute
85 DSS_CFLAGS += -Wunused-parameter
86 DSS_CFLAGS += -Wbad-function-cast
87 DSS_CFLAGS += -Wshadow
88
89 .ONESHELL:
90 .SHELLFLAGS := -ec
91 ifeq ("$(origin V)", "command line")
92         SAY =
93 else
94         SAY = @printf '%s\n' '$(strip $(1))'
95 endif
96 version.c:
97         $(call SAY, VG $@)
98         ./version-gen.sh $(PACKAGE) version.c > /dev/null
99 $(PACKAGE): $(objs)
100         $(call SAY, LD $@)
101         $(CC) -o $@ $(objs) $(LDFLAGS) -llopsub
102 %.o: %.c
103         $(call SAY, CC $<)
104         $(CC) -c -o $@ $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) \
105                 -MMD -MF $(*F).d -MT $@ $<
106 .PHONY: all clean install README
107 .PRECIOUS: %.lsg.c %.lsg.h %.suite %.1
108 $(PACKAGE).suite: $(PACKAGE).suite.m4 Makefile
109         $(call SAY, M4 $<)
110         $(M4) $< > $@
111 %.lsg.h: %.suite
112         $(call SAY, LSGH $<)
113         $(LSG) --gen-h=$@ < $<
114 %.lsg.c: %.suite
115         $(call SAY, LSGC $<)
116         $(LSG) --gen-c=$@ < $<
117 %.1: %.suite
118         $(call SAY, LSGM $<)
119         $(LSG) --gen-man=$@ --version-string=$(VERSION) < $<
120 %.1.gz: %.1
121         $(call SAY, GZIP $<)
122         $(GZIP) < $< > $@
123 %.1.html: %.1
124         $(call SAY, GROFF $<)
125         $(GROFF) $< > $@
126 clean:
127         $(call SAY, CLEAN)
128         $(RM) *.[od] $(all) *.html $(PACKAGE).1 $(PACKAGE).suite \
129                 $(PACKAGE).lsg.[ch] version.c
130
131 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
132        strip_option := -s
133 endif
134 bindir := $(DESTDIR)$(PREFIX)/bin
135 mandir := $(DESTDIR)$(PREFIX)/share/man/man1
136 install install-strip: all
137         $(MKDIR_P) $(bindir) $(mandir)
138         $(INSTALL_PROGRAM) $(strip_option) $(PACKAGE) $(bindir)
139         $(INSTALL_DATA) $(PACKAGE).1.gz $(mandir)
140
141 define README :=
142 $(PACKAGE) - $(SLOGAN)
143
144 $(DESCRIPTION1)
145
146 $(DESCRIPTION2)
147
148 $(DESCRIPTION3)
149
150 Resources
151 ~~~~~~~~~
152 web page: $(PACKAGE_HOMEPAGE)
153 git clone URL: $(CLONE_URL)
154 gitweb: $(GITWEB_URL)
155 author home page: $(HOME_URL)
156 report bugs to: $(AUTHOR) <$(EMAIL)>
157 endef
158
159 README:
160         @printf '%s\n' "$(README)"
161
162 index.html.in: index.html.m4
163         $(call SAY, M4 $<)
164         $(M4) $< > $@
165 index.html: index.html.in INSTALL NEWS
166         $(call SAY, MD $@)
167         sed -e '/@README@/,$$d' index.html.in > $@
168         printf '<p> %s </p>\n' "$(DESCRIPTION1)" >> $@
169         printf '<p> %s </p>\n' "$(DESCRIPTION2)" >> $@
170         printf '<p> %s </p>\n' "$(DESCRIPTION3)" >> $@
171         sed -e '1,/@README@/d' -e '/@NEWS@/,$$d' index.html.in >> $@
172         markdown NEWS >> $@
173         sed -e '1,/@NEWS@/d' -e '/@INSTALL@/,$$d' index.html.in >> $@
174         markdown INSTALL >> $@
175         sed -e '1,/@INSTALL@/d' -e '/@MAN_PAGE@/,$$d' index.html.in >> $@
176
177 -include Makefile.local