]> rtime.felk.cvut.cz Git - jailhouse.git/blob - inmates/lib/x86/Makefile.lib
inmates: Build library archive and link it implicitly
[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) lib/lib[32].a
27 .SECONDEXPANSION:
28 $(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix $$(obj)/,$$($$*-y)) \
29                    $(INMATES_LIB)/$$(if $$($$*_32),lib32.a,lib.a)
30         $(call if_changed,ld)
31
32 $(obj)/%.bin: $(obj)/%-linked.o
33         $(call if_changed,objcopy)
34
35 # 32-bit (i386) support
36 define DECLARE_32_BIT =
37  CFLAGS_$(1).o := -m32
38  LDFLAGS_$(1)-linked.o := /dev/null -m elf_i386 -T
39  $(1)_32 := y
40 endef