]> rtime.felk.cvut.cz Git - jailhouse.git/blob - inmates/lib/x86/Makefile.lib
inmates: Refactor folder structure
[jailhouse.git] / inmates / lib / x86 / Makefile.lib
1 #
2 # Jailhouse, a Linux-based partitioning hypervisor
3 #
4 # Copyright (c) Siemens AG, 2013, 2014
5 #
6 # Authors:
7 #  Jan Kiszka <jan.kiszka@siemens.com>
8 #
9 # This work is licensed under the terms of the GNU GPL, version 2.  See
10 # the COPYING file in the top-level directory.
11 #
12
13 KBUILD_CFLAGS += -m64
14
15 define DECLARE_TARGETS =
16  _TARGETS = $(1)
17  always := $$(_TARGETS)
18  # $(NAME-y) NAME-linked.o NAME.bin
19  targets += $$(foreach t,$$(_TARGETS:.bin=-y),$$($$t)) \
20             $$(_TARGETS:.bin=-linked.o) $$(_TARGETS)
21 endef
22
23 # prevent deleting intermediate files which would cause rebuilds
24 .SECONDARY: $(addprefix $(obj)/,$(targets))
25
26 # obj/NAME-linked.o: ... obj/$(NAME-y)
27 .SECONDEXPANSION:
28 $(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix $$(obj)/,$$($$*-y))
29         $(call if_changed,ld)
30
31 $(obj)/%.bin: $(obj)/%-linked.o
32         $(call if_changed,objcopy)
33
34 # 32-bit (i386) support
35 define DECLARE_32_BIT =
36  CFLAGS_$(1).o := -m32
37  LDFLAGS_$(1)-linked.o := /dev/null -m elf_i386 -T
38 endef
39
40 AFLAGS_header-32.o := -m32
41
42 $(obj)/%-32.o: c_flags += -m32
43 $(obj)/%-32.o: $(obj)/%.c
44         $(call if_changed_rule,cc_o_c)