xref: /kvm-unit-tests/arm/Makefile.common (revision 4a18bde1663489b27e679142e56809c1fd49b90d)
1#
2# arm common makefile
3#
4# Authors: Andrew Jones <drjones@redhat.com>
5#
6
7ifeq ($(LOADADDR),)
8	# qemu mach-virt default load address
9	LOADADDR = 0x40000000
10endif
11
12tests-common  = $(TEST_DIR)/selftest.flat
13tests-common += $(TEST_DIR)/spinlock-test.flat
14tests-common += $(TEST_DIR)/pci-test.flat
15tests-common += $(TEST_DIR)/pmu.flat
16tests-common += $(TEST_DIR)/gic.flat
17tests-common += $(TEST_DIR)/psci.flat
18
19tests-all = $(tests-common) $(tests)
20all: directories $(tests-all)
21
22##################################################################
23phys_base = $(LOADADDR)
24
25CFLAGS += -std=gnu99
26CFLAGS += -ffreestanding
27CFLAGS += -Wextra
28CFLAGS += -O2
29CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib
30
31# We want to keep intermediate files
32.PRECIOUS: %.elf %.o
33
34asm-offsets = lib/$(ARCH)/asm-offsets.h
35include $(SRCDIR)/scripts/asm-offsets.mak
36
37cflatobjs += lib/util.o
38cflatobjs += lib/alloc.o
39cflatobjs += lib/devicetree.o
40cflatobjs += lib/pci.o
41cflatobjs += lib/pci-host-generic.o
42cflatobjs += lib/pci-testdev.o
43cflatobjs += lib/virtio.o
44cflatobjs += lib/virtio-mmio.o
45cflatobjs += lib/chr-testdev.o
46cflatobjs += lib/arm/io.o
47cflatobjs += lib/arm/setup.o
48cflatobjs += lib/arm/mmu.o
49cflatobjs += lib/arm/bitops.o
50cflatobjs += lib/arm/psci.o
51cflatobjs += lib/arm/smp.o
52cflatobjs += lib/arm/delay.o
53cflatobjs += lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o
54
55OBJDIRS += lib/arm
56
57libeabi = lib/arm/libeabi.a
58eabiobjs = lib/arm/eabi_compat.o
59
60libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
61start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
62
63FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
64%.elf: LDFLAGS = $(CFLAGS) -nostdlib
65%.elf: %.o $(FLATLIBS) $(SRCDIR)/arm/flat.lds $(cstart.o)
66	$(CC) $(LDFLAGS) -o $@ \
67		-Wl,-T,$(SRCDIR)/arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
68		$(filter %.o, $^) $(FLATLIBS) \
69		$(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$(@:.elf=.flat)\"
70
71%.flat: %.elf
72	$(OBJCOPY) -O binary $^ $@
73
74$(libeabi): $(eabiobjs)
75	$(AR) rcs $@ $^
76
77arm_clean: libfdt_clean asm_offsets_clean
78	$(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
79	      $(TEST_DIR)/.*.d lib/arm/.*.d
80
81generated-files = $(asm-offsets)
82$(tests-all:.flat=.o) $(cstart.o) $(cflatobjs): $(generated-files)
83