# SPDX-License-Identifier: GPL-2.0+ .SUFFIXES: MAKEFLAGS += -Rr ifeq ("$(origin CC)", "default") CC := cc endif ifeq ("$(origin V)", "command line") SAY = else SAY = @echo '$(strip $(1))' endif .ONESHELL: .SHELLFLAGS := -ec PREFIX ?= /usr/local INSTALL ?= install MKDIR_P := mkdir -p RM := rm -f CHMOD := chmod GROFF := groff B := build all := misma misma.8 all: $(all) PACKAGE := misma SLOGAN := the minimal snapshot manager AUTHOR := Andre Noll EMAIL := maan@tuebingen.mpg.de COPYRIGHT_YEAR := 2024 URL := http://people.tuebingen.mpg.de/maan/$(PACKAGE)/ CLONE_URL := git://git.tuebingen.mpg.de/$(PACKAGE) GITWEB_URL := http://git.tuebingen.mpg.de/$(PACKAGE).git HOME_URL := http://people.tuebingen.mpg.de/maan/ LICENSE := GPL-2.0+ LICENSE_URL := https://www.gnu.org/licenses/gpl-3.0-standalone.html LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG units := misma util version misma.lsg deps := $(addprefix $(B)/, $(addsuffix .d, $(units))) objs := $(addprefix $(B)/, $(addsuffix .o, $(units))) ifeq ($(findstring clean, $(MAKECMDGOALS)),) ifeq ($(findstring README, $(MAKECMDGOALS)),) -include $(deps) -include $(B)/config.mak endif endif XCPPFLAGS := XCPPFLAGS += -I$(B) XCPPFLAGS += -Wunused-macros XCPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"' XCPPFLAGS += -DPACKAGE='"$(PACKAGE)"' XCPPFLAGS += -DAUTHOR='"$(AUTHOR)"' XCPPFLAGS += -DEMAIL='"$(EMAIL)"' XCPPFLAGS += -DURL='"$(URL)"' XCPPFLAGS += -DCLONE_URL='"$(CLONE_URL)"' XCPPFLAGS += -DGITWEB_URL='"$(GITWEB_URL)"' XCPPFLAGS += -DHOME_URL='"$(HOME_URL)"' XCPPFLAGS += -DGET_VERSION='$(PACKAGE)_version' XCPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)' XCPPFLAGS += -DBUILD_DATE='"$(build_date)"' XCPPFLAGS += -DCC_VERSION='"$(cc_version)"' XCPPFLAGS += -DUNAME_RS='"$(uname_rs)"' XCPPFLAGS += -DLICENSE='"$(LICENSE)"' XCPPFLAGS += -DLICENSE_URL='"$(LICENSE_URL)"' XCFLAGS := XCFLAGS += -fno-strict-aliasing XCFLAGS += -g XCFLAGS += -Os XCFLAGS += -Wundef -W -Wuninitialized XCFLAGS += -Wchar-subscripts XCFLAGS += -Werror-implicit-function-declaration XCFLAGS += -Wmissing-noreturn XCFLAGS += -Wbad-function-cast XCFLAGS += -Wredundant-decls XCFLAGS += -Wno-sign-compare -Wno-unknown-pragmas XCFLAGS += -Wdeclaration-after-statement XCFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute XCFLAGS += -fdata-sections -ffunction-sections XCFLAGS += -Wstrict-prototypes XCFLAGS += -Wshadow XCFLAGS += -Wunused -Wall XCFLAGS += -Wformat-signedness XCFLAGS += -Wdiscarded-qualifiers XLDFLAGS := -Wl,--gc-sections version_file := $(B)/version.c GIT_VERSION := $(shell $(MKDIR_P) $(B) && ./version-gen.sh $(PACKAGE) $(version_file)) CC_CMD = $(CC) -c -o $@ $(XCPPFLAGS) $(CPPFLAGS) \ $(XCFLAGS) $(CFLAGS) -MMD -MF $(B)/$(*F).d -MT $@ $(objs): misma.h $(B)/misma.lsg.h Makefile $(B): @$(MKDIR_P) $@ $(B)/config.h.in: configure.ac | $(B) $(call SAY, AH $<) cd $(B) autoheader -f ../configure.ac $(B)/configure.sh: configure.ac | $(B) $(call SAY, AC $<) cd $(B) autoconf ../configure.ac > configure.sh $(CHMOD) 755 configure.sh $(B)/config.status: $(B)/configure.sh | $(B) $(call SAY, SH $<) cd $(B) if test -x config.status; then \ ./config.status --quiet --recheck; \ else \ ./configure.sh --no-create; \ fi $(B)/config.mak $(B)/config.h: $(B)/config.status config.mak.in $(B)/config.h.in $(call SAY, CS $@) cd $(B) ln -f ../config.mak.in ./config.status -q test -f config.h && touch config.h define DESCRIPTION1 := PACKAGE() is an open source application which maintains snapshots of one or more thin provisioned logical volumes on Linux systems. endef define DESCRIPTION2 := Snapshots are created and removed automatically according to the configured schedule. Old snapshots are replaced so that the time between two consecutive snapshots doubles at each step. To prevent data or metadata space exhaustion, the available space of the underlying thin pools is monitored periodically and snapshots are removed early when space gets tight. endef define DESCRIPTION3 := Besides the run subcommand which implements snapshot scheduling and free space monitoring, PACKAGE() supports additional subcommands to list existing snapshots and the utilization of the thin pools, or to create/remove snapshots manually. endef define M4_CMD = $(call SAY, M4 $<) $(M4) -D "AUTHOR=$(AUTHOR)" -D "COPYRIGHT_YEAR=$(COPYRIGHT_YEAR)" \ -D "PACKAGE=$(PACKAGE)" \ -D "SLOGAN=$(SLOGAN)" \ -D "EMAIL=$(EMAIL)" \ -D "URL=$(URL)" \ -D "CLONE_URL=$(CLONE_URL)" \ -D "GITWEB_URL=$(GITWEB_URL)" \ -D "HOME_URL=$(HOME_URL)" \ -D "LICENSE=$(LICENSE)" \ -D "LICENSE_URL=$(LICENSE_URL)" \ -D "DESCRIPTION1=$(DESCRIPTION1)" \ -D "DESCRIPTION2=$(DESCRIPTION2)" \ -D "DESCRIPTION3=$(DESCRIPTION3)" endef $(B)/logo.svg: index.html.m4 Makefile $(M4_CMD) -D MODE=svg $< > $@ $(B)/index.html: index.html.m4 Makefile $(M4_CMD) $< > $@ $(B)/misma.suite: misma.suite.m4 Makefile $(M4_CMD) $< > $@ $(B)/%.lsg.c: $(B)/%.suite $(call SAY, LSGC $<) $(LOPSUBGEN) --gen-c --output-dir $(B) < $< $(B)/%.lsg.h: $(B)/%.suite $(call SAY, LSGH $<) $(LOPSUBGEN) --gen-header --output-dir $(B) < $< %.8: $(B)/%.suite $(B)/version.c $(call SAY, LSGM $<) $(LOPSUBGEN) --gen-man=$(*F).8 --version-string $(GIT_VERSION) < $< $(B)/%.8.html: %.8 $(GROFF) -m man -Thtml -Wbreak < $< > $@ $(B)/%.o: %.c | $(B) $(call SAY, CC $<) $(CC_CMD) $< $(B)/%.o: $(B)/%.c $(call SAY, CC $<) $(CC_CMD) $< $(PACKAGE): $(objs) $(call SAY, LD $@) $(CC) -o $@ $^ $(XLDFLAGS) $(LDFLAGS) -llopsub -lm $(B)/$(PACKAGE): $(objs) $(call SAY, LD-STATIC $@) $(CC) -static -o $@ $^ $(XLDFLAGS) $(LDFLAGS) -llopsub -lm mandir := $(datarootdir)/man/man8 INSTALL ?= install INSTALL_PROGRAM ?= $(INSTALL) -m 755 INSTALL_DATA ?= $(INSTALL) -m 644 ifneq ($(findstring strip, $(MAKECMDGOALS)),) strip_option := -s endif install install-strip: all $(MKDIR_P) $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir) $(INSTALL_PROGRAM) $(strip_option) misma $(DESTDIR)$(sbindir) $(INSTALL_DATA) misma.8 $(DESTDIR)$(mandir) clean: $(RM) $(B)/*.o $(all) distclean: clean $(RM) -r $(B) maintainer-clean: git clean -dfqx > /dev/null 2>&1 define README := $(PACKAGE) - $(SLOGAN) $(DESCRIPTION1) $(DESCRIPTION2) $(DESCRIPTION3) Resources ~~~~~~~~~ | web page: $(URL) | git clone URL: $(CLONE_URL) | gitweb: $(GITWEB_URL) | author's home page: $(HOME_URL) | Send feedback to: $(AUTHOR) <$(EMAIL)> License ~~~~~~~ Open source, licensed under the $(LICENSE) license. Documentation ~~~~~~~~~~~~~ See misma.suite.m4. Or build the man page with \"make\" and run \"man -l misma.8\". Dependencies ~~~~~~~~~~~~ This package requires m4, autoconf, gnu make, gcc or clang, and lopsub. The configure script checks if all dependencies are installed and prints a meaningful error message if one of them is missing. Building ~~~~~~~~ Run \"make\" to build the package with the default settings. Run \"./configure -h\" to list configuration options. Installation ~~~~~~~~~~~~ Run \"sudo make install\" to install to /usr/local. To install to /somewhere/else, run \"./configure --prefix /somewhere/else && make\" first. endef README: @printf '%s\n' "$(README)" .PRECIOUS: $(B)/%.lsg.c $(B)/%.lsg.h $(B)/%.8 .PHONY: all clean install distclean maintainer-clean README -include Makefile.local