]> git.tuebingen.mpg.de Git - dss.git/blob - Makefile
index.html: Inline the svg image.
[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 B := build
45 VERSION := $(shell $(MKDIR_P) $(B) && ./version-gen.sh $(PACKAGE) $(B)/version.c)
46 RM := rm -f
47 LSG := lopsubgen
48 GROFF := groff -m man -Thtml -P -l -P -r
49 GZIP := gzip -cfn9
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 c_source := $(PACKAGE) str file exec sig daemon df tv snap ipc
66 c_generated := $(B)/$(PACKAGE).lsg $(B)/version
67 objs := $(addsuffix .o, $(c_generated) $(addprefix $(B)/, $(c_source)))
68 deps := $(objs:.o=.d)
69 all := $(PACKAGE) $(PACKAGE).1.gz
70 www := $(B)/index.html $(B)/$(PACKAGE).1.html
71
72 all: $(all)
73 www: $(www)
74 man: $(PACKAGE).1.gz
75 $(objs): $(B)/$(PACKAGE).lsg.h Makefile
76 -include $(deps)
77
78 DSS_CPPFLAGS += -Wunused-macros
79 DSS_CPPFLAGS += -I$(B)
80
81 DSS_CFLAGS := -Wno-sign-compare -g -Wunused -Wundef
82 DSS_CFLAGS += -Wredundant-decls
83 DSS_CFLAGS += -Os
84 DSS_CFLAGS += -Wall
85 DSS_CFLAGS += -Wuninitialized
86 DSS_CFLAGS += -Wchar-subscripts
87 DSS_CFLAGS += -Wformat-security
88 DSS_CFLAGS += -Werror-implicit-function-declaration
89 DSS_CFLAGS += -Wmissing-format-attribute
90 DSS_CFLAGS += -Wunused-parameter
91 DSS_CFLAGS += -Wbad-function-cast
92 DSS_CFLAGS += -Wshadow
93
94 CC_CMD = $(CC) -c -o $@ $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) \
95                 -MMD -MF $(B)/$(*F).d -MT $@ $<
96
97 .ONESHELL:
98 .SHELLFLAGS := -ec
99 ifeq ("$(origin V)", "command line")
100         SAY =
101 else
102         SAY = @printf '%s\n' '$(strip $(1))'
103 endif
104 $(B)/version.c:
105         $(call SAY, VG $@)
106         ./version-gen.sh $(PACKAGE) version.c > /dev/null
107 $(PACKAGE): $(objs)
108         $(call SAY, LD $@)
109         $(CC) -o $@ $(objs) $(LDFLAGS) -llopsub
110 $(B)/%.o: $(B)/%.c
111         $(call SAY, CC $<)
112         $(CC_CMD)
113 $(B)/%.o: %.c
114         $(call SAY, CC $<)
115         $(CC_CMD)
116
117 .PHONY: all www clean install README
118 .PRECIOUS: $(B)/%.lsg.c $(B)/%.lsg.h $(B)/%.suite $(B)/%.1
119 $(B)/$(PACKAGE).suite: $(PACKAGE).suite.m4 Makefile
120         $(call SAY, M4 $<)
121         $(M4) $< > $@
122 $(B)/%.lsg.h: $(B)/%.suite
123         $(call SAY, LSGH $<)
124         $(LSG) --gen-h=$@ < $<
125 $(B)/%.lsg.c: $(B)/%.suite
126         $(call SAY, LSGC $<)
127         $(LSG) --gen-c=$@ < $<
128 $(B)/%.1: $(B)/%.suite
129         $(call SAY, LSGM $<)
130         $(LSG) --gen-man=$@ --version-string=$(VERSION) < $<
131 %.1.gz: $(B)/%.1
132         $(call SAY, GZIP $<)
133         $(GZIP) < $< > $@
134 $(B)/%.1.html: $(B)/%.1
135         $(call SAY, GROFF $<)
136         $(GROFF) $< > $@
137 $(B)/index.html: index.html.m4 Makefile
138         $(call SAY, M4 $@)
139         $(M4) $< > $@
140 clean:
141         $(call SAY, CLEAN)
142         $(RM) -r $(B) $(all)
143
144 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
145        strip_option := -s
146 endif
147 bindir := $(DESTDIR)$(PREFIX)/bin
148 mandir := $(DESTDIR)$(PREFIX)/share/man/man1
149 install install-strip: all
150         $(MKDIR_P) $(bindir) $(mandir)
151         $(INSTALL_PROGRAM) $(strip_option) $(PACKAGE) $(bindir)
152         $(INSTALL_DATA) $(PACKAGE).1.gz $(mandir)
153
154 define README :=
155 $(PACKAGE) - $(SLOGAN)
156
157 $(DESCRIPTION1)
158
159 $(DESCRIPTION2)
160
161 $(DESCRIPTION3)
162
163 Resources
164 ~~~~~~~~~
165 web page: $(PACKAGE_HOMEPAGE)
166 git clone URL: $(CLONE_URL)
167 gitweb: $(GITWEB_URL)
168 author home page: $(HOME_URL)
169 report bugs to: $(AUTHOR) <$(EMAIL)>
170 endef
171
172 README:
173         @printf '%s\n' "$(README)"
174
175 -include Makefile.local