# SPDX-License-Identifier: GPL-2.0-only .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 B := build all := micoforia micoforia.8 all: $(all) PACKAGE := micoforia SLOGAN := Minimal Containers for Instant Availability AUTHOR := Andre Noll EMAIL := maan@tuebingen.mpg.de COPYRIGHT_YEAR := 2019 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 := GNU GPL version 3 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 := micoforia util version micoforia.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 += -fsanitize=undefined XCFLAGS += -fdata-sections -ffunction-sections XCFLAGS += -Wstrict-prototypes XCFLAGS += -Wshadow XCFLAGS += -Wunused -Wall XCFLAGS += -Wformat-signedness XCFLAGS += -Wdiscarded-qualifiers XLDFLAGS := -lubsan -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): m7a.h $(B)/micoforia.lsg.h $(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 a lightweight container implementation for Linux. It consists of a single program which reads a single configuration file that describes all containers. $(PACKAGE) was written with performance and simplicity in mind, and is designed for trusted in-house web application hosting. endef define DESCRIPTION2 := Like other container frameworks, $(PACKAGE) employs Linux namespaces for isolation and cgroup controllers to limit the resource utilization of the containers. Networking is implemented through bridging and virtual ethernet device pairs. There is built-in support for the cpu, memory, I/O and device controllers. Further customization is possible via startup hooks. For example, the startup hook could activate additional cgroup controllers, make the container enter a different namespace, and mount additional file systems. endef define DESCRIPTION3 := The micoforia program supports a couple of subcommands. Besides the start subcommand which starts one or more containers, there are subcommands for listing, killing or rebooting containers. endef # dependency on config.mak is because the command below depends on $(M4) $(B)/index.html $(B)/micoforia.suite: $(B)/%: %.m4 Makefile $(B)/config.mak $(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)" $< > $@ $(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)/%.o: %.c | $(B) $(call SAY, CC $<) $(CC_CMD) $< $(B)/%.o: $(B)/%.c $(call SAY, CC $<) $(CC_CMD) $< micoforia: $(objs) $(call SAY, LD $@) $(CC) -o $@ $^ $(XLDFLAGS) $(LDFLAGS) -llopsub -lmnl -lutil -lcap 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) micoforia $(DESTDIR)$(sbindir) $(INSTALL_DATA) micoforia.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). Documentation ~~~~~~~~~~~~~ See micoforia.suite.m4. Or build the man page with \"make\" and run \"man -l micoforia.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