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