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