[kvm-unit-tests PATCH v2 7/9] Makefiles: fix up the arm build dirs and include/link paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We still need to tell the compiler the correct search path for finding
headers and the like. This is slightly complicated by the "dynamic"
asm search path which is in our build tree but (may be) symlinked to
the right architectures headers.

Also we explicitly include SRCDIR for the linking scripts as VPATH
doesn't seem to find them well enough.

Also we set OBJDIRS for the lib/arm, lib/arm64 and generated
asm-offset files.

Signed-off-by: Alex Bennée <alex.bennee@xxxxxxxxxx>

---
v2
  - Setup OBJDIRS
---
 arm/Makefile.arm64      |  2 ++
 arm/Makefile.common     | 14 ++++++++------
 scripts/asm-offsets.mak |  4 +++-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
index b5fc1ec..24319d6 100644
--- a/arm/Makefile.arm64
+++ b/arm/Makefile.arm64
@@ -11,6 +11,8 @@ cstart.o = $(TEST_DIR)/cstart64.o
 cflatobjs += lib/arm64/processor.o
 cflatobjs += lib/arm64/spinlock.o
 
+OBJDIRS += lib/arm64
+
 # arm64 specific tests
 tests =
 
diff --git a/arm/Makefile.common b/arm/Makefile.common
index 74c7394..03b497b 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -17,7 +17,7 @@ tests-common += $(TEST_DIR)/gic.flat
 tests-common += $(TEST_DIR)/psci.flat
 
 tests-all = $(tests-common) $(tests)
-all: $(tests-all)
+all: directories $(tests-all)
 
 ##################################################################
 phys_base = $(LOADADDR)
@@ -26,13 +26,13 @@ CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
 CFLAGS += -Wextra
 CFLAGS += -O2
-CFLAGS += -I lib -I lib/libfdt
+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 scripts/asm-offsets.mak
+include $(SRCDIR)/scripts/asm-offsets.mak
 
 cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
@@ -52,6 +52,8 @@ 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
 
+OBJDIRS += lib/arm
+
 libeabi = lib/arm/libeabi.a
 eabiobjs = lib/arm/eabi_compat.o
 
@@ -60,11 +62,11 @@ start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
 
 FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
 %.elf: LDFLAGS = $(CFLAGS) -nostdlib
-%.elf: %.o $(FLATLIBS) arm/flat.lds $(cstart.o)
+%.elf: %.o $(FLATLIBS) $(SRCDIR)/arm/flat.lds $(cstart.o)
 	$(CC) $(LDFLAGS) -o $@ \
-		-Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
+		-Wl,-T,$(SRCDIR)/arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
 		$(filter %.o, $^) $(FLATLIBS) \
-		lib/auxinfo.c -DPROGNAME=\"$(@:.elf=.flat)\"
+		$(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$(@:.elf=.flat)\"
 
 %.flat: %.elf
 	$(OBJCOPY) -O binary $^ $@
diff --git a/scripts/asm-offsets.mak b/scripts/asm-offsets.mak
index b2578a6..b35da09 100644
--- a/scripts/asm-offsets.mak
+++ b/scripts/asm-offsets.mak
@@ -33,7 +33,9 @@ $(asm-offsets:.h=.s): $(asm-offsets:.h=.c)
 
 $(asm-offsets): $(asm-offsets:.h=.s)
 	$(call make_asm_offsets)
-	cp -f $(asm-offsets) lib/generated
+	cp -f $(asm-offsets) lib/generated/
+
+OBJDIRS += lib/generated
 
 asm_offsets_clean:
 	$(RM) $(asm-offsets) $(asm-offsets:.h=.s) \
-- 
2.11.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux