2 # Jailhouse, a Linux-based partitioning hypervisor
4 # Copyright (c) Siemens AG, 2013
5 # Copyright (c) Valentine Sinitsyn, 2014
8 # Jan Kiszka <jan.kiszka@siemens.com>
9 # Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
11 # This work is licensed under the terms of the GNU GPL, version 2. See
12 # the COPYING file in the top-level directory.
15 LINUXINCLUDE := -I$(src)/arch/$(SRCARCH)/include -I$(src)/include
16 KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \
17 -Wmissing-declarations -Wmissing-prototypes \
18 -fno-strict-aliasing -fno-pic -fno-common \
19 -fno-stack-protector -fno-builtin-ffsl
22 KBUILD_CFLAGS += -mcmodel=kernel
23 KBUILD_CPPFLAGS += -m64
24 BUILD_VARIANTS := amd intel
27 ifneq ($(wildcard $(obj)/include/jailhouse/config.h),)
28 KBUILD_CFLAGS += -include $(obj)/include/jailhouse/config.h
31 CORE_OBJECTS = setup.o printk.o paging.o control.o lib.o
33 define filechk_version
34 $(src)/../scripts/gen_version_h $(src)/..
37 clean-files := $(obj)/include/jailhouse/version.h
39 # This derives from the Linux kernel's asm-offsets.h generation infrastructure
42 "/^=>/{s:=>#\(.*\):/* \1 */:; \
43 s:^=>\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
44 s:^=>\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
48 quiet_cmd_defines = GEN $@
51 echo "#ifndef _GENERATED_ASM_DEFINES_H"; \
52 echo "#define _GENERATED_ASM_DEFINES_H"; \
54 echo " * This file is autogenerated. If you need to change it,"; \
55 echo " * edit arch/$(SRCARCH)/asm-defines.c instead."; \
57 echo " * ALL MANUAL CHANGES TO THIS FILE WILL BE LOST!"; \
60 sed -ne $(sed-y) $<; \
65 defines-file := include/generated/asm-defines.h
67 targets := $(defines-file)
69 $(obj)/arch/$(SRCARCH)/asm-defines.s: $(src)/arch/$(SRCARCH)/asm-defines.c
70 $(call if_changed_dep,cc_s_c)
72 $(obj)/$(defines-file): $(obj)/arch/$(SRCARCH)/asm-defines.s
73 $(Q)mkdir -p $(dir $@)
76 $(obj)/include/jailhouse/version.h: $(src)/Makefile FORCE
77 $(call filechk,version)
79 $(foreach co,$(CORE_OBJECTS),\
80 $(eval $(obj)/$(co): $(obj)/$(defines-file)))
82 $(obj)/setup.o: $(obj)/include/jailhouse/version.h
84 arch-builtin: $(obj)/$(defines-file) FORCE
85 $(Q)$(MAKE) $(build)=$(obj)/arch/$(SRCARCH)
89 define BUILD_JAILHOUSE_template
90 always += jailhouse$(1).bin
92 hypervisor$(1)-y := $$(CORE_OBJECTS) arch/$$(SRCARCH)/built-in$(1).o \
94 targets += $$(hypervisor$(1)-y)
96 # Need fake recipe here so make will consider this a volatile target
97 $$(obj)/arch/$$(SRCARCH)/built-in$(1).o: arch-builtin
100 HYPERVISOR$(1)_OBJS = $$(addprefix $$(obj)/,$$(hypervisor$(1)-y))
102 LDFLAGS_hypervisor$(1).o := -T
104 targets += hypervisor$(1).o
105 $$(obj)/hypervisor$(1).o: $$(src)/hypervisor.lds $$(HYPERVISOR$(1)_OBJS)
106 $$(call if_changed,ld)
108 OBJCOPYFLAGS_jailhouse$(1).bin := -O binary -R .eh_frame
110 targets += jailhouse$(1).bin
111 $$(obj)/jailhouse$(1).bin: $$(obj)/hypervisor$(1).o
112 $$(call if_changed,objcopy)
115 ifneq ($(BUILD_VARIANTS),)
116 $(foreach variant,$(BUILD_VARIANTS),\
117 $(eval $(call BUILD_JAILHOUSE_template,-$(variant))))
119 $(eval $(call BUILD_JAILHOUSE_template,))