xref: /kvm-unit-tests/powerpc/Makefile.common (revision c76b0d0a3842ba312a2d8512f7a3728f4598bf94)
1#
2# powerpc common makefile
3#
4# Authors: Andrew Jones <drjones@redhat.com>
5#
6
7tests-common = \
8	$(TEST_DIR)/selftest.elf \
9	$(TEST_DIR)/selftest-migration.elf \
10	$(TEST_DIR)/memory-verify.elf \
11	$(TEST_DIR)/spapr_hcall.elf \
12	$(TEST_DIR)/rtas.elf \
13	$(TEST_DIR)/emulator.elf \
14	$(TEST_DIR)/tm.elf \
15	$(TEST_DIR)/smp.elf \
16	$(TEST_DIR)/sprs.elf \
17	$(TEST_DIR)/interrupts.elf
18
19tests-all = $(tests-common) $(tests)
20all: directories $(TEST_DIR)/boot_rom.bin $(tests-all)
21
22##################################################################
23
24mabi_no_altivec := $(call cc-option,-mabi=no-altivec,"")
25
26CFLAGS += -std=gnu99
27CFLAGS += -ffreestanding
28CFLAGS += -O2 -msoft-float -mno-altivec $(mabi_no_altivec)
29CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib
30CFLAGS += -Wa,-mregnames
31
32# We want to keep intermediate files
33.PRECIOUS: %.o
34
35asm-offsets = lib/$(ARCH)/asm-offsets.h
36include $(SRCDIR)/scripts/asm-offsets.mak
37
38cflatobjs += lib/util.o
39cflatobjs += lib/getchar.o
40cflatobjs += lib/alloc_phys.o
41cflatobjs += lib/alloc.o
42cflatobjs += lib/alloc_page.o
43cflatobjs += lib/devicetree.o
44cflatobjs += lib/migrate.o
45cflatobjs += lib/powerpc/io.o
46cflatobjs += lib/powerpc/hcall.o
47cflatobjs += lib/powerpc/setup.o
48cflatobjs += lib/powerpc/rtas.o
49cflatobjs += lib/powerpc/processor.o
50cflatobjs += lib/powerpc/handlers.o
51cflatobjs += lib/powerpc/smp.o
52
53OBJDIRS += lib/powerpc
54
55%.aux.o: $(SRCDIR)/lib/auxinfo.c
56	$(CC) $(CFLAGS) -c -o $@ $< -DPROGNAME=\"$(@:.aux.o=.elf)\"
57
58FLATLIBS = $(libcflat) $(LIBFDT_archive)
59%.elf: CFLAGS += $(arch_CFLAGS)
60%.elf: LDFLAGS += $(arch_LDFLAGS) -pie -n
61%.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o) %.aux.o
62	$(LD) $(LDFLAGS) -o $@ \
63		-T $(SRCDIR)/powerpc/flat.lds --build-id=none \
64		$(filter %.o, $^) $(FLATLIBS)
65	@chmod a-x $@
66	@echo -n Checking $@ for unsupported reloc types...
67	@if $(OBJDUMP) -R $@ | grep R_ | grep -v R_PPC64_RELATIVE; then	\
68		false;							\
69	else								\
70		echo " looks good.";					\
71	fi
72
73$(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf
74	dd if=/dev/zero of=$@ bs=256 count=1
75	$(OBJCOPY) -O binary $^ $@.tmp
76	cat $@.tmp >> $@
77	$(RM) $@.tmp
78
79$(TEST_DIR)/boot_rom.elf: CFLAGS = -mbig-endian
80$(TEST_DIR)/boot_rom.elf: $(TEST_DIR)/boot_rom.o
81	$(LD) -EB -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $<
82	@chmod a-x $@
83
84powerpc_clean: asm_offsets_clean
85	$(RM) $(TEST_DIR)/*.{o,elf} $(TEST_DIR)/boot_rom.bin \
86	      $(TEST_DIR)/.*.d lib/powerpc/.*.d
87
88generated-files = $(asm-offsets)
89$(tests-all:.elf=.o) $(cstart.o) $(cflatobjs): $(generated-files)
90