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