blob: fc2fe281523ee3f6b47658d37a3a5f7ac00db2f8 [file] [log] [blame]
#
# powerpc common makefile
#
# Authors: Andrew Jones <drjones@redhat.com>
#
tests-common = \
$(TEST_DIR)/selftest.elf \
$(TEST_DIR)/selftest-migration.elf \
$(TEST_DIR)/memory-verify.elf \
$(TEST_DIR)/spapr_hcall.elf \
$(TEST_DIR)/rtas.elf \
$(TEST_DIR)/emulator.elf \
$(TEST_DIR)/atomics.elf \
$(TEST_DIR)/tm.elf \
$(TEST_DIR)/smp.elf \
$(TEST_DIR)/sprs.elf \
$(TEST_DIR)/interrupts.elf
tests-all = $(tests-common) $(tests)
all: directories $(TEST_DIR)/boot_rom.bin $(tests-all)
##################################################################
mabi_no_altivec := $(call cc-option,-mabi=no-altivec,"")
CFLAGS += -std=gnu99
CFLAGS += -ffreestanding
CFLAGS += -O2 -msoft-float -mno-altivec $(mabi_no_altivec)
CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib
CFLAGS += -Wa,-mregnames
# We want to keep intermediate files
.PRECIOUS: %.o
asm-offsets = lib/$(ARCH)/asm-offsets.h
include $(SRCDIR)/scripts/asm-offsets.mak
cflatobjs += lib/util.o
cflatobjs += lib/getchar.o
cflatobjs += lib/alloc_phys.o
cflatobjs += lib/alloc.o
cflatobjs += lib/alloc_page.o
cflatobjs += lib/devicetree.o
cflatobjs += lib/migrate.o
cflatobjs += lib/powerpc/io.o
cflatobjs += lib/powerpc/hcall.o
cflatobjs += lib/powerpc/setup.o
cflatobjs += lib/powerpc/rtas.o
cflatobjs += lib/powerpc/processor.o
cflatobjs += lib/powerpc/handlers.o
cflatobjs += lib/powerpc/smp.o
OBJDIRS += lib/powerpc
%.aux.o: $(SRCDIR)/lib/auxinfo.c
$(CC) $(CFLAGS) -c -o $@ $< -DPROGNAME=\"$(@:.aux.o=.elf)\"
FLATLIBS = $(libcflat) $(LIBFDT_archive)
%.elf: CFLAGS += $(arch_CFLAGS)
%.elf: LDFLAGS += $(arch_LDFLAGS) -pie -n
%.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o) %.aux.o
$(LD) $(LDFLAGS) -o $@ \
-T $(SRCDIR)/powerpc/flat.lds --build-id=none \
$(filter %.o, $^) $(FLATLIBS)
@chmod a-x $@
@echo -n Checking $@ for unsupported reloc types...
@if $(OBJDUMP) -R $@ | grep R_ | grep -v R_PPC64_RELATIVE; then \
false; \
else \
echo " looks good."; \
fi
$(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf
dd if=/dev/zero of=$@ bs=256 count=1
$(OBJCOPY) -O binary $^ $@.tmp
cat $@.tmp >> $@
$(RM) $@.tmp
$(TEST_DIR)/boot_rom.elf: CFLAGS = -mbig-endian
$(TEST_DIR)/boot_rom.elf: $(TEST_DIR)/boot_rom.o
$(LD) -EB -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $<
@chmod a-x $@
powerpc_clean: asm_offsets_clean
$(RM) $(TEST_DIR)/*.{o,elf} $(TEST_DIR)/boot_rom.bin \
$(TEST_DIR)/.*.d lib/powerpc/.*.d
generated-files = $(asm-offsets)
$(tests-all:.elf=.o) $(cstart.o) $(cflatobjs): $(generated-files)