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