]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/Makefile
arm: initialise hypervisor stage 1 MMU
[jailhouse.git] / hypervisor / Makefile
1 #
2 # Jailhouse, a Linux-based partitioning hypervisor
3 #
4 # Copyright (c) Siemens AG, 2013
5 # Copyright (c) Valentine Sinitsyn, 2014
6 #
7 # Authors:
8 #  Jan Kiszka <jan.kiszka@siemens.com>
9 #  Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
10 #
11 # This work is licensed under the terms of the GNU GPL, version 2.  See
12 # the COPYING file in the top-level directory.
13 #
14 # asm-defines.h generation code derived from Linux kernel.
15 #
16
17 LINUXINCLUDE := -I$(src)/arch/$(SRCARCH)/include -I$(src)/include
18 KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \
19                  -Wmissing-declarations -Wmissing-prototypes \
20                  -fno-strict-aliasing -fno-pic -fno-common \
21                  -fno-stack-protector -fno-builtin-ffsl
22
23 ifeq ($(SRCARCH),x86)
24 KBUILD_CFLAGS += -mcmodel=kernel
25 KBUILD_CPPFLAGS += -m64
26 BUILD_VARIANTS := amd intel
27 endif
28
29 ifeq ($(SRCARCH),arm)
30 KBUILD_CFLAGS += -marm
31 KBUILD_CPPFLAGS += -DARCH_LINK
32 endif
33
34 ifneq ($(wildcard $(obj)/include/jailhouse/config.h),)
35 KBUILD_CFLAGS += -include $(obj)/include/jailhouse/config.h
36 endif
37
38 CORE_OBJECTS = setup.o printk.o paging.o control.o lib.o
39
40 define filechk_config_mk
41 (                                                                       \
42         echo "\$$(foreach config,\$$(filter CONFIG_%,           \
43                 \$$(.VARIABLES)), \$$(eval undefine \$$(config)))";     \
44         if [ -f $(src)/include/jailhouse/config.h ]; then               \
45                 sed -e "/^#define \([^[:space:]]*\)[[:space:]]*1/!d"    \
46                     -e "s/^#define \([^[:space:]]*\)[[:space:]]*1/\1=y/" \
47                         $(src)/include/jailhouse/config.h;              \
48         fi                                                              \
49 )
50 endef
51
52 $(obj)/include/jailhouse/config.mk: Makefile FORCE
53         $(call filechk,config_mk)
54
55 define filechk_version
56         $(src)/../scripts/gen_version_h $(src)/..
57 endef
58
59 clean-files := $(obj)/include/jailhouse/config.mk \
60         $(obj)/include/jailhouse/version.h
61
62 define sed-y
63         "/^=>/{s:=>#\(.*\):/* \1 */:; \
64         s:^=>\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
65         s:^=>\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
66         s:=>::; p;}"
67 endef
68
69 quiet_cmd_defines = GEN     $@
70 define cmd_defines
71         (set -e; \
72          echo "#ifndef _GENERATED_ASM_DEFINES_H"; \
73          echo "#define _GENERATED_ASM_DEFINES_H"; \
74          echo "/*"; \
75          echo " * This file is autogenerated. If you need to change it,"; \
76          echo " * edit arch/$(SRCARCH)/asm-defines.c instead."; \
77          echo " *"; \
78          echo " * ALL MANUAL CHANGES TO THIS FILE WILL BE LOST!"; \
79          echo " */"; \
80          echo ""; \
81          sed -ne $(sed-y) $<; \
82          echo ""; \
83          echo "#endif" ) > $@
84 endef
85
86 defines-file := include/generated/asm-defines.h
87
88 targets := $(defines-file) arch/$(SRCARCH)/asm-defines.s
89
90 $(obj)/arch/$(SRCARCH)/asm-defines.s: $(src)/arch/$(SRCARCH)/asm-defines.c
91         $(call if_changed_dep,cc_s_c)
92
93 $(obj)/$(defines-file): $(obj)/arch/$(SRCARCH)/asm-defines.s
94         $(Q)mkdir -p $(dir $@)
95         $(call cmd,defines)
96
97 $(obj)/include/jailhouse/version.h: $(src)/Makefile FORCE
98         $(call filechk,version)
99
100 $(foreach co,$(CORE_OBJECTS),\
101         $(eval $(obj)/$(co): $(obj)/$(defines-file)))
102
103 $(obj)/setup.o: $(obj)/include/jailhouse/version.h
104
105 arch-builtin: $(obj)/$(defines-file) $(obj)/include/jailhouse/config.mk FORCE
106         $(Q)$(MAKE) $(build)=$(obj)/arch/$(SRCARCH) \
107                 CONFIG_MK=$(obj)/include/jailhouse/config.mk
108
109 always :=
110
111 define BUILD_JAILHOUSE_template
112 always += jailhouse$(1).bin
113
114 hypervisor$(1)-y := $$(CORE_OBJECTS) arch/$$(SRCARCH)/built-in$(1).o \
115         hypervisor.lds
116 targets += $$(hypervisor$(1)-y)
117
118 # Need fake recipe here so make will consider this a volatile target
119 $$(obj)/arch/$$(SRCARCH)/built-in$(1).o: arch-builtin
120         @
121
122 HYPERVISOR$(1)_OBJS = $$(addprefix $$(obj)/,$$(hypervisor$(1)-y))
123
124 LDFLAGS_hypervisor$(1).o := -T
125
126 targets += hypervisor$(1).o
127 $$(obj)/hypervisor$(1).o: $$(src)/hypervisor.lds $$(HYPERVISOR$(1)_OBJS)
128         $$(call if_changed,ld)
129
130 OBJCOPYFLAGS_jailhouse$(1).bin := -O binary -R .eh_frame
131
132 targets += jailhouse$(1).bin
133 $$(obj)/jailhouse$(1).bin: $$(obj)/hypervisor$(1).o
134         $$(call if_changed,objcopy)
135 endef
136
137 ifneq ($(BUILD_VARIANTS),)
138 $(foreach variant,$(BUILD_VARIANTS),\
139         $(eval $(call BUILD_JAILHOUSE_template,-$(variant))))
140 else
141 $(eval $(call BUILD_JAILHOUSE_template,))
142 endif
143
144 .PHONY: arch-builtin