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