]> rtime.felk.cvut.cz Git - jailhouse.git/blob - tools/Makefile
6e4fa265b825a9e2a58f4193580d3eb8c2d3c968
[jailhouse.git] / tools / Makefile
1 #
2 # Jailhouse, a Linux-based partitioning hypervisor
3 #
4 # Copyright (c) Siemens AG, 2013, 2014
5 #
6 # Authors:
7 #  Jan Kiszka <jan.kiszka@siemens.com>
8 #
9 # This work is licensed under the terms of the GNU GPL, version 2.  See
10 # the COPYING file in the top-level directory.
11 #
12
13 ifeq ($(V),1)
14         Q =
15 else
16         Q = @
17 endif
18
19 CC = $(CROSS_COMPILE)gcc
20
21 CFLAGS = -g -O3 -I.. -DLIBEXECDIR=\"$(libexecdir)\" \
22         -Wall -Wmissing-declarations -Wmissing-prototypes \
23         -DJAILHOUSE_VERSION=\"$(shell cat ../VERSION)\"
24
25 TARGETS := jailhouse
26
27 INST_TARGETS := $(TARGETS)
28 HELPERS := \
29         jailhouse-cell-list \
30         jailhouse-cell-stats \
31         jailhouse-config-create
32 TEMPLATES := jailhouse-config-collect.tmpl root-cell-config.c.tmpl
33
34 HAS_PYTHON_MAKO := \
35         $(shell python -c "from mako.template import Template" 2>/dev/null \
36         && echo yes)
37
38 ifeq ($(strip $(HAS_PYTHON_MAKO)), yes)
39         TARGETS += jailhouse-config-collect
40         HELPERS += jailhouse-config-collect
41 else
42         TARGETS += no_python_mako
43 endif
44
45 define patch_datadir_var
46         sed -i 's|^datadir = None|datadir = "$(datadir)"|' $1
47 endef
48
49 # no recipes above this one (also no includes)
50 all: $(TARGETS)
51
52 # includes installation-related variables and definitions
53 include ../scripts/install.mk
54
55 jailhouse: jailhouse.c ../jailhouse.h ../VERSION
56         $(CC) $(CFLAGS) -o $@ $<
57
58 jailhouse-config-collect: jailhouse-config-create jailhouse-config-collect.tmpl
59         ./$< -g $@
60         $(Q)chmod +x $@
61
62 install-bin: $(INST_TARGETS) $(DESTDIR)$(sbindir)
63         $(INSTALL_PROGRAM) $^
64
65 install-libexec: $(HELPERS) $(DESTDIR)$(libexecdir)/jailhouse
66         $(INSTALL_PROGRAM) $^
67         $(Q)$(call patch_datadir_var, $(lastword $^)/jailhouse-config-create)
68
69 install-data: $(TEMPLATES) $(DESTDIR)$(datadir)/jailhouse
70         $(INSTALL_DATA) $^
71
72 install: install-bin install-libexec install-data
73
74 clean:
75         rm -f $(TARGETS)
76
77 no_python_mako:
78         @echo -ne "WARNING: Could not create the helper script to generate" \
79                   "configurations on remote machines" \
80                   "(\"jailhouse-conf-collect\"). You need Python and the" \
81                   "Mako library for it.\n"
82
83 .PHONY: install install-bin install-libexec install-data clean no_python_mako