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