]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tooling: extracts common install-definitions into a central include
authorBenjamin Block <bebl@mageta.org>
Wed, 3 Sep 2014 12:53:17 +0000 (14:53 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Mon, 8 Sep 2014 11:34:12 +0000 (13:34 +0200)
After adding install-rules to the tools- and root-Makefile we have some
redundancies in some variables and definitions (e.g.: $(INSTALL)). To fix
this, extract all duplications and general definitions concerning the
install-process into one central Makefile-include `install.mk`.

This also unifies the way directories are created for
installation-rules. Previously we would just create them every time
without checking if that is needed. Now we add them as prerequisite to
the install-rule and generate a rule for each of them in `install.mk`.
This way `make` will figure out if the need to be created. This also
lowers the verboseness of the Makefile.

Signed-off-by: Benjamin Block <bebl@mageta.org>
[Jan: moved install.mk to scripts folder]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Makefile
scripts/install.mk [new file with mode: 0644]
tools/Makefile

index d7beede4828afaf9effe2063a560db503a938565..9a3f3a1c498a2694a77a6d7636189befd02978d5 100644 (file)
--- a/Makefile
+++ b/Makefile
 # the COPYING file in the top-level directory.
 #
 
-firmwaredir ?= /lib/firmware
-
-# all directories listed here will be created using a generic rule below
-INSTALL_DIRECTORIES := $(DESTDIR)$(firmwaredir)
-
-INSTALL      ?= install
-INSTALL_DATA ?= $(INSTALL) -m 644
-INSTALL_DIR  ?= $(INSTALL) -d -m 755
-
 # no recipes above this one (also no includes)
 all: modules tools
 
+# includes installation-related variables and definitions
+include scripts/install.mk
+
 # out-of-tree build for our kernel-module, firmware and inmates
 KDIR ?= /lib/modules/`uname -r`/build
 
@@ -43,16 +37,12 @@ clean:
        $(run-kbuild)
        $(MAKE) -C tools $@
 
-# create all necessary install-directories
-$(INSTALL_DIRECTORIES):
-       $(INSTALL_DIR) $@
-
 modules_install: modules
        $(run-kbuild)
        depmod -aq
 
 firmware_install: hypervisor/jailhouse.bin $(DESTDIR)$(firmwaredir)
-       $(INSTALL_DATA) $(filter-out $(lastword $^),$^) $(lastword $^)
+       $(INSTALL_DATA) $^
 
 install: modules_install firmware_install
        $(MAKE) -C tools $@
diff --git a/scripts/install.mk b/scripts/install.mk
new file mode 100644 (file)
index 0000000..c35b12f
--- /dev/null
@@ -0,0 +1,42 @@
+#
+# Jailhouse, a Linux-based partitioning hypervisor
+#
+# Copyright (c) Siemens AG, 2014
+#
+# Authors:
+#  Jan Kiszka <jan.kiszka@siemens.com>
+#  Benjamin Block <bebl@mageta.org>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+
+prefix      ?= /usr/local
+exec_prefix ?= $(prefix)
+bindir      ?= $(exec_prefix)/bin
+libexecdir  ?= $(exec_prefix)/libexec
+datarootdir ?= $(prefix)/share
+datadir     ?= $(datarootdir)
+firmwaredir ?= /lib/firmware
+
+# all directories listed here will be created using a generic rule below
+INSTALL_DIRECTORIES := $(prefix)       \
+                      $(exec_prefix)   \
+                      $(bindir)        \
+                      $(libexecdir)    \
+                      $(datarootdir)   \
+                      $(datadir)       \
+                      $(firmwaredir)
+
+INSTALL         ?= install
+INSTALL_PROGRAM ?= $(INSTALL)
+INSTALL_DATA    ?= $(INSTALL) -m 644
+INSTALL_DIR     ?= $(INSTALL) -d -m 755
+
+# creates a rule for each dir in $(INSTALL_DIRECTORIES) under the current
+# $(DESTDIR) and additionally to that for each of these dirs a subdir named
+# `jailhouse`. These can be used as prerequirement for install-rules and will
+# thus be created on demand (or not at all if not used in that way).
+$(sort $(INSTALL_DIRECTORIES:%=$(DESTDIR)%) \
+       $(INSTALL_DIRECTORIES:%=$(DESTDIR)%/jailhouse)):
+       $(INSTALL_DIR) $@
index 2649b1cd32de9bda1967e78538621010919419f7..5b2290113961463c0b9ade7a9ea3b9078db7d244 100644 (file)
 # the COPYING file in the top-level directory.
 #
 
-prefix      ?= /usr/local
-exec_prefix ?= $(prefix)
-bindir      ?= $(exec_prefix)/bin
-libexecdir  ?= $(exec_prefix)/libexec
-datarootdir ?= $(prefix)/share
-datadir     ?= $(datarootdir)
-
 ifeq ($(V),1)
        Q =
 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.. -DLIBEXECDIR=\"$(libexecdir)\" \
@@ -58,8 +46,12 @@ define patch_datadir_var
        sed -i 's|^datadir = None|datadir = "$(datadir)"|' $1
 endef
 
+# no recipes above this one (also no includes)
 all: $(TARGETS)
 
+# includes installation-related variables and definitions
+include ../scripts/install.mk
+
 jailhouse: jailhouse.c ../jailhouse.h ../VERSION
        $(CC) $(CFLAGS) -o $@ $<
 
@@ -67,19 +59,15 @@ jailhouse-config-collect: jailhouse-config-create jailhouse-config-collect.tmpl
        ./$< -g $@
        $(Q)chmod +x $@
 
-install-bin: $(INST_TARGETS)
-       $(INSTALL_DIR) $(DESTDIR)$(bindir)
-       $(INSTALL_PROGRAM) $^ $(DESTDIR)$(bindir)
+install-bin: $(INST_TARGETS) $(DESTDIR)$(bindir)
+       $(INSTALL_PROGRAM) $^
 
-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-libexec: $(HELPERS) $(DESTDIR)$(libexecdir)/jailhouse
+       $(INSTALL_PROGRAM) $^
+       $(Q)$(call patch_datadir_var, $(lastword $^)/jailhouse-config-create)
 
-install-data: $(TEMPLATES)
-       $(INSTALL_DIR) $(DESTDIR)$(datadir)/jailhouse
-       $(INSTALL_DATA) $^ $(DESTDIR)$(datadir)/jailhouse
+install-data: $(TEMPLATES) $(DESTDIR)$(datadir)/jailhouse
+       $(INSTALL_DATA) $^
 
 install: install-bin install-libexec install-data