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/memregions.o 46cflatobjs += lib/migrate.o 47cflatobjs += lib/on-cpus.o 48cflatobjs += lib/pci.o 49cflatobjs += lib/pci-host-generic.o 50cflatobjs += lib/pci-testdev.o 51cflatobjs += lib/virtio.o 52cflatobjs += lib/virtio-mmio.o 53cflatobjs += lib/chr-testdev.o 54cflatobjs += lib/arm/io.o 55cflatobjs += lib/arm/setup.o 56cflatobjs += lib/arm/mmu.o 57cflatobjs += lib/arm/bitops.o 58cflatobjs += lib/arm/psci.o 59cflatobjs += lib/arm/smp.o 60cflatobjs += lib/arm/delay.o 61cflatobjs += lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o 62cflatobjs += lib/arm/timer.o 63ifeq ($(CONFIG_EFI),y) 64cflatobjs += lib/efi.o 65endif 66 67OBJDIRS += lib/arm 68 69libeabi = lib/arm/libeabi.a 70eabiobjs = lib/arm/eabi_compat.o 71 72FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libeabi) 73 74ifeq ($(CONFIG_EFI),y) 75%.aux.o: $(SRCDIR)/lib/auxinfo.c 76 $(CC) $(CFLAGS) -c -o $@ $< \ 77 -DPROGNAME=\"$(@:.aux.o=.efi)\" -DAUXFLAGS=$(AUXFLAGS) 78 79%.so: EFI_LDFLAGS += -defsym=EFI_SUBSYSTEM=0xa --no-undefined 80%.so: %.o $(FLATLIBS) $(SRCDIR)/arm/efi/elf_aarch64_efi.lds $(cstart.o) %.aux.o 81 $(LD) $(EFI_LDFLAGS) -o $@ -T $(SRCDIR)/arm/efi/elf_aarch64_efi.lds \ 82 $(filter %.o, $^) $(FLATLIBS) $(EFI_LIBS) 83 84%.efi: %.so 85 $(call arch_elf_check, $^) 86 $(OBJCOPY) --only-keep-debug $^ $@.debug 87 $(OBJCOPY) --strip-debug $^ 88 $(OBJCOPY) --add-gnu-debuglink=$@.debug $^ 89 $(OBJCOPY) \ 90 -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ 91 -j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ 92 -j .reloc \ 93 -O binary $^ $@ 94else 95%.aux.o: $(SRCDIR)/lib/auxinfo.c 96 $(CC) $(CFLAGS) -c -o $@ $< \ 97 -DPROGNAME=\"$(@:.aux.o=.flat)\" -DAUXFLAGS=$(AUXFLAGS) 98 99%.elf: LDFLAGS += $(arch_LDFLAGS) 100%.elf: %.o $(FLATLIBS) $(SRCDIR)/arm/flat.lds $(cstart.o) %.aux.o 101 $(LD) $(LDFLAGS) -o $@ -T $(SRCDIR)/arm/flat.lds \ 102 $(filter %.o, $^) $(FLATLIBS) 103 @chmod a-x $@ 104 105%.flat: %.elf 106 $(call arch_elf_check, $^) 107 $(OBJCOPY) -O binary $^ $@ 108 @chmod a-x $@ 109endif 110 111$(libeabi): $(eabiobjs) 112 $(AR) rcs $@ $^ 113 114arm_clean: asm_offsets_clean 115 $(RM) $(TEST_DIR)/*.{o,flat,elf,so,efi,debug} $(libeabi) $(eabiobjs) \ 116 $(TEST_DIR)/.*.d $(TEST_DIR)/efi/.*.d lib/arm/.*.d 117 118generated-files = $(asm-offsets) 119$(tests-all:.$(exe)=.o) $(cstart.o) $(cflatobjs): $(generated-files) 120