xref: /kvm-unit-tests/arm/Makefile.common (revision 7430e2c554924e8ddb6156161708fa402c478b6f)
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: $(tests-all)
21
22##################################################################
23phys_base = $(LOADADDR)
24
25CFLAGS += -std=gnu99
26CFLAGS += -ffreestanding
27CFLAGS += -Wextra
28CFLAGS += -O2
29CFLAGS += -I lib -I lib/libfdt
30
31# We want to keep intermediate files
32.PRECIOUS: %.elf %.o
33
34asm-offsets = lib/$(ARCH)/asm-offsets.h
35include 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
55libeabi = lib/arm/libeabi.a
56eabiobjs = lib/arm/eabi_compat.o
57
58libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
59start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
60
61FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
62%.elf: LDFLAGS = $(CFLAGS) -nostdlib
63%.elf: %.o $(FLATLIBS) arm/flat.lds $(cstart.o)
64	$(CC) $(LDFLAGS) -o $@ \
65		-Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
66		$(filter %.o, $^) $(FLATLIBS) \
67		lib/auxinfo.c -DPROGNAME=\"$(@:.elf=.flat)\"
68
69%.flat: %.elf
70	$(OBJCOPY) -O binary $^ $@
71
72$(libeabi): $(eabiobjs)
73	$(AR) rcs $@ $^
74
75arm_clean: libfdt_clean asm_offsets_clean
76	$(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
77	      $(TEST_DIR)/.*.d lib/arm/.*.d
78
79generated-files = $(asm-offsets)
80$(tests-all:.flat=.o) $(cstart.o) $(cflatobjs): $(generated-files)
81