1 # SPDX-License-Identifier: GPL-2.0+
4 ifeq ("$(origin CC)", "default")
7 ifeq ("$(origin V)", "command line")
10 SAY = @echo '$(strip $(1))'
26 SLOGAN := the minimal snapshot manager
28 EMAIL := maan@tuebingen.mpg.de
29 COPYRIGHT_YEAR := 2024
30 URL := http://people.tuebingen.mpg.de/maan/$(PACKAGE)/
31 CLONE_URL := git://git.tuebingen.mpg.de/$(PACKAGE)
32 GITWEB_URL := http://git.tuebingen.mpg.de/$(PACKAGE).git
33 HOME_URL := http://people.tuebingen.mpg.de/maan/
35 LICENSE_URL := https://www.gnu.org/licenses/gpl-3.0-standalone.html
36 LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
38 units := misma util version misma.lsg
39 deps := $(addprefix $(B)/, $(addsuffix .d, $(units)))
40 objs := $(addprefix $(B)/, $(addsuffix .o, $(units)))
42 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
43 ifeq ($(findstring README, $(MAKECMDGOALS)),)
45 -include $(B)/config.mak
51 XCPPFLAGS += -Wunused-macros
52 XCPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
53 XCPPFLAGS += -DPACKAGE='"$(PACKAGE)"'
54 XCPPFLAGS += -DAUTHOR='"$(AUTHOR)"'
55 XCPPFLAGS += -DEMAIL='"$(EMAIL)"'
56 XCPPFLAGS += -DURL='"$(URL)"'
57 XCPPFLAGS += -DCLONE_URL='"$(CLONE_URL)"'
58 XCPPFLAGS += -DGITWEB_URL='"$(GITWEB_URL)"'
59 XCPPFLAGS += -DHOME_URL='"$(HOME_URL)"'
60 XCPPFLAGS += -DGET_VERSION='$(PACKAGE)_version'
61 XCPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
62 XCPPFLAGS += -DBUILD_DATE='"$(build_date)"'
63 XCPPFLAGS += -DCC_VERSION='"$(cc_version)"'
64 XCPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
65 XCPPFLAGS += -DLICENSE='"$(LICENSE)"'
66 XCPPFLAGS += -DLICENSE_URL='"$(LICENSE_URL)"'
69 XCFLAGS += -fno-strict-aliasing
72 XCFLAGS += -Wundef -W -Wuninitialized
73 XCFLAGS += -Wchar-subscripts
74 XCFLAGS += -Werror-implicit-function-declaration
75 XCFLAGS += -Wmissing-noreturn
76 XCFLAGS += -Wbad-function-cast
77 XCFLAGS += -Wredundant-decls
78 XCFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
79 XCFLAGS += -Wdeclaration-after-statement
80 XCFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
81 XCFLAGS += -fdata-sections -ffunction-sections
82 XCFLAGS += -Wstrict-prototypes
84 XCFLAGS += -Wunused -Wall
85 XCFLAGS += -Wformat-signedness
86 XCFLAGS += -Wdiscarded-qualifiers
88 XLDFLAGS := -Wl,--gc-sections
89 version_file := $(B)/version.c
90 GIT_VERSION := $(shell $(MKDIR_P) $(B) && ./version-gen.sh $(PACKAGE) $(version_file))
92 CC_CMD = $(CC) -c -o $@ $(XCPPFLAGS) $(CPPFLAGS) \
93 $(XCFLAGS) $(CFLAGS) -MMD -MF $(B)/$(*F).d -MT $@
95 $(objs): misma.h $(B)/misma.lsg.h Makefile
100 $(B)/config.h.in: configure.ac | $(B)
103 autoheader -f ../configure.ac
104 $(B)/configure.sh: configure.ac | $(B)
107 autoconf ../configure.ac > configure.sh
108 $(CHMOD) 755 configure.sh
109 $(B)/config.status: $(B)/configure.sh | $(B)
112 if test -x config.status; then \
113 ./config.status --quiet --recheck; \
115 ./configure.sh --no-create; \
117 $(B)/config.mak $(B)/config.h: $(B)/config.status config.mak.in $(B)/config.h.in
120 ln -f ../config.mak.in
122 test -f config.h && touch config.h
124 define DESCRIPTION1 :=
125 PACKAGE() is an open source application which maintains snapshots of one
126 or more thin provisioned logical volumes on Linux systems.
129 define DESCRIPTION2 :=
130 Snapshots are created and removed automatically according to the
131 configured schedule. Old snapshots are replaced so that the time
132 between two consecutive snapshots doubles at each step. To prevent data
133 or metadata space exhaustion, the available space of the underlying
134 thin pools is monitored periodically and snapshots are removed early
135 when space gets tight.
138 define DESCRIPTION3 :=
139 Besides the run subcommand which implements snapshot scheduling and
140 free space monitoring, PACKAGE() supports additional subcommands
141 to list existing snapshots and the utilization of the thin pools,
142 or to create/remove snapshots manually.
147 $(M4) -D "AUTHOR=$(AUTHOR)" -D "COPYRIGHT_YEAR=$(COPYRIGHT_YEAR)" \
148 -D "PACKAGE=$(PACKAGE)" \
149 -D "SLOGAN=$(SLOGAN)" \
150 -D "EMAIL=$(EMAIL)" \
152 -D "CLONE_URL=$(CLONE_URL)" \
153 -D "GITWEB_URL=$(GITWEB_URL)" \
154 -D "HOME_URL=$(HOME_URL)" \
155 -D "LICENSE=$(LICENSE)" \
156 -D "LICENSE_URL=$(LICENSE_URL)" \
157 -D "DESCRIPTION1=$(DESCRIPTION1)" \
158 -D "DESCRIPTION2=$(DESCRIPTION2)" \
159 -D "DESCRIPTION3=$(DESCRIPTION3)"
162 $(B)/logo.svg: index.html.m4 Makefile
163 $(M4_CMD) -D MODE=svg $< > $@
164 $(B)/index.html: index.html.m4 Makefile
166 $(B)/misma.suite: misma.suite.m4 Makefile
168 $(B)/%.lsg.c: $(B)/%.suite
170 $(LOPSUBGEN) --gen-c --output-dir $(B) < $<
171 $(B)/%.lsg.h: $(B)/%.suite
173 $(LOPSUBGEN) --gen-header --output-dir $(B) < $<
174 %.8: $(B)/%.suite $(B)/version.c
176 $(LOPSUBGEN) --gen-man=$(*F).8 --version-string $(GIT_VERSION) < $<
178 $(GROFF) -m man -Thtml -Wbreak < $< > $@
188 $(CC) -o $@ $^ $(XLDFLAGS) $(LDFLAGS) -llopsub -lm
189 $(B)/$(PACKAGE): $(objs)
190 $(call SAY, LD-STATIC $@)
191 $(CC) -static -o $@ $^ $(XLDFLAGS) $(LDFLAGS) -llopsub -lm
193 mandir := $(datarootdir)/man/man8
195 INSTALL_PROGRAM ?= $(INSTALL) -m 755
196 INSTALL_DATA ?= $(INSTALL) -m 644
197 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
200 install install-strip: all
201 $(MKDIR_P) $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)
202 $(INSTALL_PROGRAM) $(strip_option) misma $(DESTDIR)$(sbindir)
203 $(INSTALL_DATA) misma.8 $(DESTDIR)$(mandir)
206 $(RM) $(B)/*.o $(all)
210 git clean -dfqx > /dev/null 2>&1
213 $(PACKAGE) - $(SLOGAN)
224 | git clone URL: $(CLONE_URL)
225 | gitweb: $(GITWEB_URL)
226 | author's home page: $(HOME_URL)
227 | Send feedback to: $(AUTHOR) <$(EMAIL)>
231 Open source, licensed under the $(LICENSE) license.
235 See misma.suite.m4. Or build the man page with \"make\" and run
240 This package requires m4, autoconf, gnu make, gcc or clang, and
241 lopsub. The configure script checks if all dependencies are installed
242 and prints a meaningful error message if one of them is missing.
246 Run \"make\" to build the package with the default settings. Run
247 \"./configure -h\" to list configuration options.
251 Run \"sudo make install\" to install to /usr/local. To install to
252 /somewhere/else, run \"./configure --prefix /somewhere/else && make\"
257 @printf '%s\n' "$(README)"
259 .PRECIOUS: $(B)/%.lsg.c $(B)/%.lsg.h $(B)/%.8
260 .PHONY: all clean install distclean maintainer-clean README
261 -include Makefile.local