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