1# 2# arm common makefile 3# 4# Authors: Andrew Jones <drjones@redhat.com> 5# 6 7tests-common = $(TEST_DIR)/selftest.$(exe) 8tests-common += $(TEST_DIR)/spinlock-test.$(exe) 9tests-common += $(TEST_DIR)/pci-test.$(exe) 10tests-common += $(TEST_DIR)/pmu.$(exe) 11tests-common += $(TEST_DIR)/gic.$(exe) 12tests-common += $(TEST_DIR)/psci.$(exe) 13tests-common += $(TEST_DIR)/sieve.$(exe) 14tests-common += $(TEST_DIR)/pl031.$(exe) 15tests-common += $(TEST_DIR)/dummy.$(exe) 16 17tests-all = $(tests-common) $(tests) 18all: directories $(tests-all) 19 20$(TEST_DIR)/sieve.elf: AUXFLAGS = 0x1 21 22################################################################## 23AUXFLAGS ?= 0x0 24 25# stack.o relies on frame pointers. 26KEEP_FRAME_POINTER := y 27 28CFLAGS += -std=gnu99 29CFLAGS += -ffreestanding 30CFLAGS += -O2 31CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib 32 33# We want to keep intermediate files 34.PRECIOUS: %.elf %.o 35 36asm-offsets = lib/$(ARCH)/asm-offsets.h 37include $(SRCDIR)/scripts/asm-offsets.mak 38 39cflatobjs += lib/util.o lib/getchar.o 40cflatobjs += lib/alloc_phys.o 41cflatobjs += lib/alloc_page.o 42cflatobjs += lib/vmalloc.o 43cflatobjs += lib/alloc.o 44cflatobjs += lib/devicetree.o 45cflatobjs += lib/migrate.o 46cflatobjs += lib/pci.o 47cflatobjs += lib/pci-host-generic.o 48cflatobjs += lib/pci-testdev.o 49cflatobjs += lib/virtio.o 50cflatobjs += lib/virtio-mmio.o 51cflatobjs += lib/chr-testdev.o 52cflatobjs += lib/arm/io.o 53cflatobjs += lib/arm/setup.o 54cflatobjs += lib/arm/mmu.o 55cflatobjs += lib/arm/bitops.o 56cflatobjs += lib/arm/psci.o 57cflatobjs += lib/arm/smp.o 58cflatobjs += lib/arm/delay.o 59cflatobjs += lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o 60cflatobjs += lib/arm/timer.o 61ifeq ($(CONFIG_EFI),y) 62cflatobjs += lib/efi.o 63endif 64 65OBJDIRS += lib/arm 66 67libeabi = lib/arm/libeabi.a 68eabiobjs = lib/arm/eabi_compat.o 69 70FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libeabi) 71 72ifeq ($(CONFIG_EFI),y) 73%.so: EFI_LDFLAGS += -defsym=EFI_SUBSYSTEM=0xa --no-undefined 74%.so: %.o $(FLATLIBS) $(SRCDIR)/arm/efi/elf_aarch64_efi.lds $(cstart.o) 75 $(CC) $(CFLAGS) -c -o $(@:.so=.aux.o) $(SRCDIR)/lib/auxinfo.c \ 76 -DPROGNAME=\"$(@:.so=.efi)\" -DAUXFLAGS=$(AUXFLAGS) 77 $(LD) $(EFI_LDFLAGS) -o $@ -T $(SRCDIR)/arm/efi/elf_aarch64_efi.lds \ 78 $(filter %.o, $^) $(FLATLIBS) $(@:.so=.aux.o) \ 79 $(EFI_LIBS) 80 $(RM) $(@:.so=.aux.o) 81 82%.efi: %.so 83 $(call arch_elf_check, $^) 84 $(OBJCOPY) --only-keep-debug $^ $@.debug 85 $(OBJCOPY) --strip-debug $^ 86 $(OBJCOPY) --add-gnu-debuglink=$@.debug $^ 87 $(OBJCOPY) \ 88 -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ 89 -j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ 90 -j .reloc \ 91 -O binary $^ $@ 92else 93%.elf: LDFLAGS += $(arch_LDFLAGS) 94%.elf: %.o $(FLATLIBS) $(SRCDIR)/arm/flat.lds $(cstart.o) 95 $(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c \ 96 -DPROGNAME=\"$(@:.elf=.flat)\" -DAUXFLAGS=$(AUXFLAGS) 97 $(LD) $(LDFLAGS) -o $@ -T $(SRCDIR)/arm/flat.lds \ 98 $(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o) 99 $(RM) $(@:.elf=.aux.o) 100 @chmod a-x $@ 101 102%.flat: %.elf 103 $(call arch_elf_check, $^) 104 $(OBJCOPY) -O binary $^ $@ 105 @chmod a-x $@ 106endif 107 108$(libeabi): $(eabiobjs) 109 $(AR) rcs $@ $^ 110 111arm_clean: asm_offsets_clean 112 $(RM) $(TEST_DIR)/*.{o,flat,elf,so,efi,debug} $(libeabi) $(eabiobjs) \ 113 $(TEST_DIR)/.*.d $(TEST_DIR)/efi/.*.d lib/arm/.*.d 114 115generated-files = $(asm-offsets) 116$(tests-all:.$(exe)=.o) $(cstart.o) $(cflatobjs): $(generated-files) 117