]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tools: Add installation rules
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 27 Aug 2014 18:35:15 +0000 (20:35 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Aug 2014 18:08:51 +0000 (20:08 +0200)
This installs the jailhouse tool, its helper scripts and the template
files to standard, configurable directories. We patch the config
generator on installation so that the target version is aware of the
chosen data directory.

Note that installing the bash completion is left up to the user. There
is apparently no distro-independent way to achieve this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools/Makefile

index 5a8659e94b156f00f477b50e6cfc7288849bc993..9d24a9d132e83ee5868439821715bb8a26a53c37 100644 (file)
 
 prefix      ?= /usr/local
 exec_prefix ?= $(prefix)
+bindir      ?= $(exec_prefix)/bin
 libexecdir  ?= $(exec_prefix)/libexec
+datarootdir ?= $(prefix)/share
+datadir     ?= $(datarootdir)
 
 ifeq ($(V),1)
        Q =
@@ -20,6 +23,11 @@ else
        Q = @
 endif
 
+INSTALL         ?= install
+INSTALL_PROGRAM ?= $(INSTALL)
+INSTALL_DATA    ?= $(INSTALL) -m 644
+INSTALL_DIR     ?= $(INSTALL) -d -m 755
+
 CC = $(CROSS_COMPILE)gcc
 
 CFLAGS = -g -O3 -I.. -I../hypervisor/include -DLIBEXECDIR=\"$(libexecdir)\" \
@@ -27,16 +35,28 @@ CFLAGS = -g -O3 -I.. -I../hypervisor/include -DLIBEXECDIR=\"$(libexecdir)\" \
 
 TARGETS := jailhouse
 
+INST_TARGETS := $(TARGETS)
+HELPERS := \
+       jailhouse-cell-list \
+       jailhouse-cell-stats \
+       jailhouse-config-create
+TEMPLATES := jailhouse-config-collect.tmpl root-cell-config.c.tmpl
+
 HAS_PYTHON_MAKO := \
        $(shell python -c "from mako.template import Template" 2>/dev/null \
        && echo yes)
 
 ifeq ($(strip $(HAS_PYTHON_MAKO)), yes)
        TARGETS += jailhouse-config-collect
+       HELPERS += jailhouse-config-collect
 else
        TARGETS += no_python_mako
 endif
 
+define patch_datadir_var
+       sed -i 's|^datadir = None|datadir = "$(datadir)"|' $1
+endef
+
 all: $(TARGETS)
 
 jailhouse: jailhouse.c ../jailhouse.h ../hypervisor/include/jailhouse/cell-config.h
@@ -46,7 +66,21 @@ jailhouse-config-collect: jailhouse-config-create jailhouse-config-collect.tmpl
        ./$< -g $@
        $(Q)chmod +x $@
 
-.PHONY: clean no_python_mako
+install-bin: $(INST_TARGETS)
+       $(INSTALL_DIR) $(DESTDIR)$(bindir)
+       $(INSTALL_PROGRAM) $^ $(DESTDIR)$(bindir)
+
+install-libexec: $(HELPERS)
+       $(INSTALL_DIR) $(DESTDIR)$(libexecdir)/jailhouse
+       $(INSTALL_PROGRAM) $^ $(DESTDIR)$(libexecdir)/jailhouse
+       $(Q)$(call patch_datadir_var, \
+             $(DESTDIR)$(libexecdir)/jailhouse/jailhouse-config-create)
+
+install-data: $(TEMPLATES)
+       $(INSTALL_DIR) $(DESTDIR)$(datadir)/jailhouse
+       $(INSTALL_DATA) $^ $(DESTDIR)$(datadir)/jailhouse
+
+install: install-bin install-libexec install-data
 
 clean:
        rm -f $(TARGETS)
@@ -56,3 +90,5 @@ no_python_mako:
                  "configurations on remote machines" \
                  "(\"jailhouse-conf-collect\"). You need Python and the" \
                  "Mako library for it.\n"
+
+.PHONY: install install-bin install-libexec install-data clean no_python_mako