| # |
| # arm common makefile |
| # |
| # Authors: Andrew Jones <drjones@redhat.com> |
| # |
| |
| tests-common = $(TEST_DIR)/selftest.$(exe) |
| tests-common += $(TEST_DIR)/spinlock-test.$(exe) |
| tests-common += $(TEST_DIR)/pci-test.$(exe) |
| tests-common += $(TEST_DIR)/pmu.$(exe) |
| tests-common += $(TEST_DIR)/gic.$(exe) |
| tests-common += $(TEST_DIR)/psci.$(exe) |
| tests-common += $(TEST_DIR)/sieve.$(exe) |
| tests-common += $(TEST_DIR)/pl031.$(exe) |
| tests-common += $(TEST_DIR)/dummy.$(exe) |
| |
| tests-all = $(tests-common) $(tests) |
| all: directories $(tests-all) |
| |
| $(TEST_DIR)/sieve.elf: AUXFLAGS = 0x1 |
| |
| ################################################################## |
| AUXFLAGS ?= 0x0 |
| |
| # stack.o relies on frame pointers. |
| KEEP_FRAME_POINTER := y |
| |
| CFLAGS += -std=gnu99 |
| CFLAGS += -ffreestanding |
| CFLAGS += -O2 |
| CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib |
| |
| # We want to keep intermediate files |
| .PRECIOUS: %.elf %.o |
| |
| asm-offsets = lib/$(ARCH)/asm-offsets.h |
| include $(SRCDIR)/scripts/asm-offsets.mak |
| |
| cflatobjs += lib/util.o lib/getchar.o |
| cflatobjs += lib/alloc_phys.o |
| cflatobjs += lib/alloc_page.o |
| cflatobjs += lib/vmalloc.o |
| cflatobjs += lib/alloc.o |
| cflatobjs += lib/devicetree.o |
| cflatobjs += lib/memregions.o |
| cflatobjs += lib/migrate.o |
| cflatobjs += lib/on-cpus.o |
| cflatobjs += lib/pci.o |
| cflatobjs += lib/pci-host-generic.o |
| cflatobjs += lib/pci-testdev.o |
| cflatobjs += lib/virtio.o |
| cflatobjs += lib/virtio-mmio.o |
| cflatobjs += lib/chr-testdev.o |
| cflatobjs += lib/arm/io.o |
| cflatobjs += lib/arm/setup.o |
| cflatobjs += lib/arm/mmu.o |
| cflatobjs += lib/arm/bitops.o |
| cflatobjs += lib/arm/psci.o |
| cflatobjs += lib/arm/smp.o |
| cflatobjs += lib/arm/delay.o |
| cflatobjs += lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o |
| cflatobjs += lib/arm/timer.o |
| ifeq ($(CONFIG_EFI),y) |
| cflatobjs += lib/efi.o |
| endif |
| |
| OBJDIRS += lib/arm |
| |
| libeabi = lib/arm/libeabi.a |
| eabiobjs = lib/arm/eabi_compat.o |
| |
| FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libeabi) |
| |
| ifeq ($(CONFIG_EFI),y) |
| %.aux.o: $(SRCDIR)/lib/auxinfo.c |
| $(CC) $(CFLAGS) -c -o $@ $< \ |
| -DPROGNAME=\"$(@:.aux.o=.efi)\" -DAUXFLAGS=$(AUXFLAGS) |
| |
| %.so: EFI_LDFLAGS += -defsym=EFI_SUBSYSTEM=0xa --no-undefined |
| %.so: %.o $(FLATLIBS) $(SRCDIR)/arm/efi/elf_aarch64_efi.lds $(cstart.o) %.aux.o |
| $(LD) $(EFI_LDFLAGS) -o $@ -T $(SRCDIR)/arm/efi/elf_aarch64_efi.lds \ |
| $(filter %.o, $^) $(FLATLIBS) $(EFI_LIBS) |
| |
| %.efi: %.so |
| $(call arch_elf_check, $^) |
| $(OBJCOPY) --only-keep-debug $^ $@.debug |
| $(OBJCOPY) --strip-debug $^ |
| $(OBJCOPY) --add-gnu-debuglink=$@.debug $^ |
| $(OBJCOPY) \ |
| -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ |
| -j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ |
| -j .reloc \ |
| -O binary $^ $@ |
| else |
| %.aux.o: $(SRCDIR)/lib/auxinfo.c |
| $(CC) $(CFLAGS) -c -o $@ $< \ |
| -DPROGNAME=\"$(@:.aux.o=.flat)\" -DAUXFLAGS=$(AUXFLAGS) |
| |
| %.elf: LDFLAGS += $(arch_LDFLAGS) |
| %.elf: %.o $(FLATLIBS) $(SRCDIR)/arm/flat.lds $(cstart.o) %.aux.o |
| $(LD) $(LDFLAGS) -o $@ -T $(SRCDIR)/arm/flat.lds \ |
| $(filter %.o, $^) $(FLATLIBS) |
| @chmod a-x $@ |
| |
| %.flat: %.elf |
| $(call arch_elf_check, $^) |
| $(OBJCOPY) -O binary $^ $@ |
| @chmod a-x $@ |
| endif |
| |
| $(libeabi): $(eabiobjs) |
| $(AR) rcs $@ $^ |
| |
| arm_clean: asm_offsets_clean |
| $(RM) $(TEST_DIR)/*.{o,flat,elf,so,efi,debug} $(libeabi) $(eabiobjs) \ |
| $(TEST_DIR)/.*.d $(TEST_DIR)/efi/.*.d lib/arm/.*.d |
| |
| generated-files = $(asm-offsets) |
| $(tests-all:.$(exe)=.o) $(cstart.o) $(cflatobjs): $(generated-files) |