1# 2# arm common makefile 3# 4# Authors: Andrew Jones <drjones@redhat.com> 5# 6 7ifeq ($(LOADADDR),) 8 # qemu mach-virt default load address 9 LOADADDR = 0x40000000 10endif 11 12tests-common = \ 13 $(TEST_DIR)/selftest.flat \ 14 $(TEST_DIR)/spinlock-test.flat 15 16all: test_cases 17 18################################################################## 19phys_base = $(LOADADDR) 20 21CFLAGS += -std=gnu99 22CFLAGS += -ffreestanding 23CFLAGS += -Wextra 24CFLAGS += -O2 25CFLAGS += -I lib -I lib/libfdt 26 27asm-offsets = lib/$(ARCH)/asm-offsets.h 28include scripts/asm-offsets.mak 29 30cflatobjs += lib/util.o 31cflatobjs += lib/alloc.o 32cflatobjs += lib/devicetree.o 33cflatobjs += lib/virtio.o 34cflatobjs += lib/virtio-mmio.o 35cflatobjs += lib/chr-testdev.o 36cflatobjs += lib/arm/io.o 37cflatobjs += lib/arm/setup.o 38cflatobjs += lib/arm/mmu.o 39cflatobjs += lib/arm/bitops.o 40cflatobjs += lib/arm/psci.o 41cflatobjs += lib/arm/smp.o 42 43libeabi = lib/arm/libeabi.a 44eabiobjs = lib/arm/eabi_compat.o 45 46libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name) 47start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) ))) 48 49FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi) 50%.elf: LDFLAGS = $(CFLAGS) -nostdlib 51%.elf: %.o $(FLATLIBS) arm/flat.lds 52 $(CC) $(LDFLAGS) -o $@ \ 53 -Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \ 54 $(filter %.o, $^) $(FLATLIBS) 55 56%.flat: %.elf 57 $(OBJCOPY) -O binary $^ $@ 58 59$(libeabi): $(eabiobjs) 60 $(AR) rcs $@ $^ 61 62arm_clean: libfdt_clean asm_offsets_clean 63 $(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \ 64 $(TEST_DIR)/.*.d lib/arm/.*.d 65 66################################################################## 67 68generated_files = $(asm-offsets) 69 70test_cases: $(generated_files) $(tests-common) $(tests) 71 72$(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o 73$(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o 74