]> rtime.felk.cvut.cz Git - jailhouse.git/blob - tools/Makefile
13fc67175e22e6c2313f8453b2dec8cb590d6fb1
[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 prefix      ?= /usr/local
14 exec_prefix ?= $(prefix)
15 bindir      ?= $(exec_prefix)/bin
16 libexecdir  ?= $(exec_prefix)/libexec
17 datarootdir ?= $(prefix)/share
18 datadir     ?= $(datarootdir)
19
20 ifeq ($(V),1)
21         Q =
22 else
23         Q = @
24 endif
25
26 INSTALL         ?= install
27 INSTALL_PROGRAM ?= $(INSTALL)
28 INSTALL_DATA    ?= $(INSTALL) -m 644
29 INSTALL_DIR     ?= $(INSTALL) -d -m 755
30
31 CC = $(CROSS_COMPILE)gcc
32
33 CFLAGS = -g -O3 -I.. -DLIBEXECDIR=\"$(libexecdir)\" \
34         -Wall -Wmissing-declarations -Wmissing-prototypes
35
36 TARGETS := jailhouse
37
38 INST_TARGETS := $(TARGETS)
39 HELPERS := \
40         jailhouse-cell-list \
41         jailhouse-cell-stats \
42         jailhouse-config-create
43 TEMPLATES := jailhouse-config-collect.tmpl root-cell-config.c.tmpl
44
45 HAS_PYTHON_MAKO := \
46         $(shell python -c "from mako.template import Template" 2>/dev/null \
47         && echo yes)
48
49 ifeq ($(strip $(HAS_PYTHON_MAKO)), yes)
50         TARGETS += jailhouse-config-collect
51         HELPERS += jailhouse-config-collect
52 else
53         TARGETS += no_python_mako
54 endif
55
56 define patch_datadir_var
57         sed -i 's|^datadir = None|datadir = "$(datadir)"|' $1
58 endef
59
60 all: $(TARGETS)
61
62 jailhouse: jailhouse.c ../jailhouse.h
63         $(CC) $(CFLAGS) -o $@ $<
64
65 jailhouse-config-collect: jailhouse-config-create jailhouse-config-collect.tmpl
66         ./$< -g $@
67         $(Q)chmod +x $@
68
69 install-bin: $(INST_TARGETS)
70         $(INSTALL_DIR) $(DESTDIR)$(bindir)
71         $(INSTALL_PROGRAM) $^ $(DESTDIR)$(bindir)
72
73 install-libexec: $(HELPERS)
74         $(INSTALL_DIR) $(DESTDIR)$(libexecdir)/jailhouse
75         $(INSTALL_PROGRAM) $^ $(DESTDIR)$(libexecdir)/jailhouse
76         $(Q)$(call patch_datadir_var, \
77               $(DESTDIR)$(libexecdir)/jailhouse/jailhouse-config-create)
78
79 install-data: $(TEMPLATES)
80         $(INSTALL_DIR) $(DESTDIR)$(datadir)/jailhouse
81         $(INSTALL_DATA) $^ $(DESTDIR)$(datadir)/jailhouse
82
83 install: install-bin install-libexec install-data
84
85 clean:
86         rm -f $(TARGETS)
87
88 no_python_mako:
89         @echo -ne "WARNING: Could not create the helper script to generate" \
90                   "configurations on remote machines" \
91                   "(\"jailhouse-conf-collect\"). You need Python and the" \
92                   "Mako library for it.\n"
93
94 .PHONY: install install-bin install-libexec install-data clean no_python_mako