1 # SPDX-License-Identifier: GPL-2.0-only
4 ifeq ("$(origin CC)", "default")
7 ifeq ("$(origin V)", "command line")
10 SAY = @echo '$(strip $(1))'
21 all := micoforia micoforia.8
25 SLOGAN := Minimal Containers for Instant Availability
27 EMAIL := maan@tuebingen.mpg.de
28 COPYRIGHT_YEAR := 2019
29 URL := http://people.tuebingen.mpg.de/maan/$(PACKAGE)/
30 CLONE_URL := git://git.tuebingen.mpg.de/$(PACKAGE)
31 GITWEB_URL := http://git.tuebingen.mpg.de/$(PACKAGE).git
32 HOME_URL := http://people.tuebingen.mpg.de/maan/
33 LICENSE := GNU GPL version 3
34 LICENSE_URL := https://www.gnu.org/licenses/gpl-3.0-standalone.html
35 LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
37 units := micoforia util version micoforia.lsg
38 deps := $(addprefix $(B)/, $(addsuffix .d, $(units)))
39 objs := $(addprefix $(B)/, $(addsuffix .o, $(units)))
41 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
42 ifeq ($(findstring README, $(MAKECMDGOALS)),)
44 -include $(B)/config.mak
50 XCPPFLAGS += -Wunused-macros
51 XCPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
52 XCPPFLAGS += -DPACKAGE='"$(PACKAGE)"'
53 XCPPFLAGS += -DAUTHOR='"$(AUTHOR)"'
54 XCPPFLAGS += -DEMAIL='"$(EMAIL)"'
55 XCPPFLAGS += -DURL='"$(URL)"'
56 XCPPFLAGS += -DCLONE_URL='"$(CLONE_URL)"'
57 XCPPFLAGS += -DGITWEB_URL='"$(GITWEB_URL)"'
58 XCPPFLAGS += -DHOME_URL='"$(HOME_URL)"'
59 XCPPFLAGS += -DGET_VERSION='$(PACKAGE)_version'
60 XCPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
61 XCPPFLAGS += -DBUILD_DATE='"$(build_date)"'
62 XCPPFLAGS += -DCC_VERSION='"$(cc_version)"'
63 XCPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
64 XCPPFLAGS += -DLICENSE='"$(LICENSE)"'
65 XCPPFLAGS += -DLICENSE_URL='"$(LICENSE_URL)"'
68 XCFLAGS += -fno-strict-aliasing
71 XCFLAGS += -Wundef -W -Wuninitialized
72 XCFLAGS += -Wchar-subscripts
73 XCFLAGS += -Werror-implicit-function-declaration
74 XCFLAGS += -Wmissing-noreturn
75 XCFLAGS += -Wbad-function-cast
76 XCFLAGS += -Wredundant-decls
77 XCFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
78 XCFLAGS += -Wdeclaration-after-statement
79 XCFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
80 XCFLAGS += -fsanitize=undefined
81 XCFLAGS += -fdata-sections -ffunction-sections
82 XCFLAGS += -Wstrict-prototypes
84 XCFLAGS += -Wunused -Wall
85 XCFLAGS += -Wformat-signedness
86 XCFLAGS += -Wdiscarded-qualifiers
88 XLDFLAGS := -lubsan -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): m7a.h $(B)/micoforia.lsg.h
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 a lightweight container implementation for Linux.
126 It consists of a single program which reads a single configuration
127 file that describes all containers. $(PACKAGE) was written with
128 performance and simplicity in mind, and is designed for trusted
129 in-house web application hosting.
132 define DESCRIPTION2 :=
133 Like other container frameworks, $(PACKAGE) employs Linux namespaces
134 for isolation and cgroup controllers to limit the resource utilization
135 of the containers. Networking is implemented through bridging and
136 virtual ethernet device pairs. There is built-in support for the cpu,
137 memory, I/O and device controllers. Further customization is possible
138 via startup hooks. For example, the startup hook could activate
139 additional cgroup controllers, make the container enter a different
140 namespace, and mount additional file systems.
143 define DESCRIPTION3 :=
144 The micoforia program supports a couple of subcommands. Besides
145 the start subcommand which starts one or more containers, there are
146 subcommands for listing, killing or rebooting containers.
149 # dependency on config.mak is because the command below depends on $(M4)
150 $(B)/index.html $(B)/micoforia.suite: $(B)/%: %.m4 Makefile $(B)/config.mak
152 $(M4) -D "AUTHOR=$(AUTHOR)" -D "COPYRIGHT_YEAR=$(COPYRIGHT_YEAR)" \
153 -D "PACKAGE=$(PACKAGE)" \
154 -D "SLOGAN=$(SLOGAN)" \
155 -D "EMAIL=$(EMAIL)" \
157 -D "CLONE_URL=$(CLONE_URL)" \
158 -D "GITWEB_URL=$(GITWEB_URL)" \
159 -D "HOME_URL=$(HOME_URL)" \
160 -D "LICENSE=$(LICENSE)" \
161 -D "LICENSE_URL=$(LICENSE_URL)" \
162 -D "DESCRIPTION1=$(DESCRIPTION1)" \
163 -D "DESCRIPTION2=$(DESCRIPTION2)" \
164 -D "DESCRIPTION3=$(DESCRIPTION3)" $< > $@
165 $(B)/%.lsg.c: $(B)/%.suite
167 $(LOPSUBGEN) --gen-c --output-dir $(B) < $<
168 $(B)/%.lsg.h: $(B)/%.suite
170 $(LOPSUBGEN) --gen-header --output-dir $(B) < $<
171 %.8: $(B)/%.suite $(B)/version.c
173 $(LOPSUBGEN) --gen-man=$(*F).8 --version-string $(GIT_VERSION) < $<
183 $(CC) -o $@ $^ $(XLDFLAGS) $(LDFLAGS) -llopsub -lmnl -lutil -lcap
185 mandir := $(datarootdir)/man/man8
187 INSTALL_PROGRAM ?= $(INSTALL) -m 755
188 INSTALL_DATA ?= $(INSTALL) -m 644
189 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
192 install install-strip: all
193 $(MKDIR_P) $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)
194 $(INSTALL_PROGRAM) $(strip_option) micoforia $(DESTDIR)$(sbindir)
195 $(INSTALL_DATA) micoforia.8 $(DESTDIR)$(mandir)
198 $(RM) $(B)/*.o $(all)
202 git clean -dfqx > /dev/null 2>&1
205 $(PACKAGE) - $(SLOGAN)
216 | git clone URL: $(CLONE_URL)
217 | gitweb: $(GITWEB_URL)
218 | author's home page: $(HOME_URL)
219 | Send feedback to: $(AUTHOR) <$(EMAIL)>
223 Open source, licensed under the $(LICENSE).
227 See micoforia.suite.m4. Or build the man page with \"make\" and run
228 \"man -l micoforia.8\".
232 This package requires m4, autoconf, gnu make, gcc or clang, and
233 lopsub. The configure script checks if all dependencies are installed
234 and prints a meaningful error message if one of them is missing.
238 Run \"make\" to build the package with the default settings. Run
239 \"./configure -h\" to list configuration options.
243 Run \"sudo make install\" to install to /usr/local. To install to
244 /somewhere/else, run \"./configure --prefix /somewhere/else && make\"
249 @printf '%s\n' "$(README)"
251 .PRECIOUS: $(B)/%.lsg.c $(B)/%.lsg.h $(B)/%.8
252 .PHONY: all clean install distclean maintainer-clean README
253 -include Makefile.local