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