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