All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC kvm-unit-tests PATCH 0/8] Support for out-of-tree builds
@ 2017-04-06 19:07 ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini
  Cc: kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier,
	Alex Bennée

Hi,

While I was working on MTTCG I did find it a pain to maintain 2 source
trees (one for 64bit and one for 32bit). After speaking to someone
about the changes they made to their tests to support out-of-tree
builds I thought it might be worth porting to kvm-unit-tests.

As it turns out there where a few more warts involved but essentially
most of the difficulty is handled by VPATH. The remaining changes deal
creating target build directories and handling things like scripts
(which are just symlinked to the repo).

So far I've tested x86, arm and aarch64 builds but I'll complete the
set once people are happy with the general approach.

Enjoy,



Alex Bennée (8):
  configure: make it run-able from outside source tree
  Makefile: ensure build-head works out-of-src-tree
  Makefile: set VPATH based on SRCDIR
  Makefiles: use explicit path for including sub-Makefiles
  Makefile: add explicit mkdir for .o targets
  Makefiles: handle linking of scripts into build-tree
  Makefiles: fix up the x86 build include and link paths
  Makefiles: fix up the arm build include and link paths

 Makefile                | 33 +++++++++++++++++++++++++++------
 arm/Makefile            |  2 +-
 arm/Makefile.arm        |  2 +-
 arm/Makefile.arm64      |  2 +-
 arm/Makefile.common     | 15 +++++++++------
 configure               | 24 +++++++++++++++++-------
 powerpc/Makefile        |  2 +-
 powerpc/Makefile.ppc64  |  2 +-
 scripts/asm-offsets.mak |  4 +++-
 x86/Makefile            |  2 +-
 x86/Makefile.common     | 14 +++++++++-----
 x86/Makefile.i386       |  2 +-
 x86/Makefile.x86_64     |  2 +-
 13 files changed, 73 insertions(+), 33 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 0/8] Support for out-of-tree builds
@ 2017-04-06 19:07 ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

While I was working on MTTCG I did find it a pain to maintain 2 source
trees (one for 64bit and one for 32bit). After speaking to someone
about the changes they made to their tests to support out-of-tree
builds I thought it might be worth porting to kvm-unit-tests.

As it turns out there where a few more warts involved but essentially
most of the difficulty is handled by VPATH. The remaining changes deal
creating target build directories and handling things like scripts
(which are just symlinked to the repo).

So far I've tested x86, arm and aarch64 builds but I'll complete the
set once people are happy with the general approach.

Enjoy,



Alex Benn?e (8):
  configure: make it run-able from outside source tree
  Makefile: ensure build-head works out-of-src-tree
  Makefile: set VPATH based on SRCDIR
  Makefiles: use explicit path for including sub-Makefiles
  Makefile: add explicit mkdir for .o targets
  Makefiles: handle linking of scripts into build-tree
  Makefiles: fix up the x86 build include and link paths
  Makefiles: fix up the arm build include and link paths

 Makefile                | 33 +++++++++++++++++++++++++++------
 arm/Makefile            |  2 +-
 arm/Makefile.arm        |  2 +-
 arm/Makefile.arm64      |  2 +-
 arm/Makefile.common     | 15 +++++++++------
 configure               | 24 +++++++++++++++++-------
 powerpc/Makefile        |  2 +-
 powerpc/Makefile.ppc64  |  2 +-
 scripts/asm-offsets.mak |  4 +++-
 x86/Makefile            |  2 +-
 x86/Makefile.common     | 14 +++++++++-----
 x86/Makefile.i386       |  2 +-
 x86/Makefile.x86_64     |  2 +-
 13 files changed, 73 insertions(+), 33 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 1/8] configure: make it run-able from outside source tree
  2017-04-06 19:07 ` Alex Bennée
@ 2017-04-06 19:07   ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini
  Cc: kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier,
	Alex Bennée

This is a first step to enabling out-of-tree builds for
kvm-unit-tests. When you invoke configure like this:

  ../tree.git/configure [args]

It will detect we the case and:

  - link ../tree.git/Makefile to the build-dir
  - ensure lib is created with a correct lib/asm
  - set SRCDIR in the config.mk

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 configure | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 8821f37..223809c 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc
 ld=ld
@@ -102,12 +103,12 @@ elif [ "$arch" = "ppc64" ]; then
 else
     testdir=$arch
 fi
-if [ ! -d $testdir ]; then
+if [ ! -d $srcdir/$testdir ]; then
     echo "$testdir does not exist!"
     exit 1
 fi
-if [ -f $testdir/run ]; then
-    ln -fs $testdir/run $testdir-run
+if [ -f $srcdir/$testdir/run ]; then
+    ln -fs $srcdir/$testdir/run $testdir-run
 fi
 
 # check if uint32_t needs a long format modifier
@@ -135,18 +136,27 @@ fi
 rm -f lib_test.c
 fi
 
+# Are we in a separate build tree? If so, link the Makefile
+# so that 'make' works.
+if test ! -e Makefile; then
+    echo "linking Makefile..."
+    ln -s "${srcdir}/Makefile" .
+fi
+
 # link lib/asm for the architecture
 rm -f lib/asm
 asm=asm-generic
-if [ -d lib/$arch/asm ]; then
-	asm=$arch/asm
-elif [ -d lib/$testdir/asm ]; then
-	asm=$testdir/asm
+if [ -d $srcdir/lib/$arch/asm ]; then
+	asm=$srcdir/lib/$arch/asm
+elif [ -d $srcdir/lib/$testdir/asm ]; then
+	asm=$srcdir/lib/$testdir/asm
 fi
+mkdir -p lib
 ln -s $asm lib/asm
 
 # create the config
 cat <<EOF > config.mak
+SRCDIR=$srcdir
 PREFIX=$prefix
 HOST=$host
 ARCH=$arch
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 1/8] configure: make it run-able from outside source tree
@ 2017-04-06 19:07   ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

This is a first step to enabling out-of-tree builds for
kvm-unit-tests. When you invoke configure like this:

  ../tree.git/configure [args]

It will detect we the case and:

  - link ../tree.git/Makefile to the build-dir
  - ensure lib is created with a correct lib/asm
  - set SRCDIR in the config.mk

Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
---
 configure | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 8821f37..223809c 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc
 ld=ld
@@ -102,12 +103,12 @@ elif [ "$arch" = "ppc64" ]; then
 else
     testdir=$arch
 fi
-if [ ! -d $testdir ]; then
+if [ ! -d $srcdir/$testdir ]; then
     echo "$testdir does not exist!"
     exit 1
 fi
-if [ -f $testdir/run ]; then
-    ln -fs $testdir/run $testdir-run
+if [ -f $srcdir/$testdir/run ]; then
+    ln -fs $srcdir/$testdir/run $testdir-run
 fi
 
 # check if uint32_t needs a long format modifier
@@ -135,18 +136,27 @@ fi
 rm -f lib_test.c
 fi
 
+# Are we in a separate build tree? If so, link the Makefile
+# so that 'make' works.
+if test ! -e Makefile; then
+    echo "linking Makefile..."
+    ln -s "${srcdir}/Makefile" .
+fi
+
 # link lib/asm for the architecture
 rm -f lib/asm
 asm=asm-generic
-if [ -d lib/$arch/asm ]; then
-	asm=$arch/asm
-elif [ -d lib/$testdir/asm ]; then
-	asm=$testdir/asm
+if [ -d $srcdir/lib/$arch/asm ]; then
+	asm=$srcdir/lib/$arch/asm
+elif [ -d $srcdir/lib/$testdir/asm ]; then
+	asm=$srcdir/lib/$testdir/asm
 fi
+mkdir -p lib
 ln -s $asm lib/asm
 
 # create the config
 cat <<EOF > config.mak
+SRCDIR=$srcdir
 PREFIX=$prefix
 HOST=$host
 ARCH=$arch
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 2/8] Makefile: ensure build-head works out-of-src-tree
  2017-04-06 19:07 ` Alex Bennée
@ 2017-04-06 19:07   ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini; +Cc: kvm, marc.zyngier, linux-arm-kernel, kvmarm

Pass -C $(SRCDIR) to the git command that generates the build-head
stamp.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 16ce297..eba7b28 100644
--- a/Makefile
+++ b/Makefile
@@ -80,7 +80,7 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 
 -include */.*.d */*/.*.d
 
-all: $(shell git rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
+all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
 
 standalone: all
 	@scripts/mkstandalone.sh
-- 
2.11.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 2/8] Makefile: ensure build-head works out-of-src-tree
@ 2017-04-06 19:07   ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

Pass -C $(SRCDIR) to the git command that generates the build-head
stamp.

Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 16ce297..eba7b28 100644
--- a/Makefile
+++ b/Makefile
@@ -80,7 +80,7 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 
 -include */.*.d */*/.*.d
 
-all: $(shell git rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
+all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
 
 standalone: all
 	@scripts/mkstandalone.sh
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 3/8] Makefile: set VPATH based on SRCDIR
  2017-04-06 19:07 ` Alex Bennée
@ 2017-04-06 19:07   ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini; +Cc: kvm, marc.zyngier, linux-arm-kernel, kvmarm

Setting the VPATH prompts make to search VPATH for source files. There
are still some fix-ups needed for linking and including other Makefile
fragments for each architecture.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index eba7b28..80bc57e 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@ endif
 
 include config.mak
 
+# Set search path for all sources
+VPATH=$(SRCDIR)
+
 libdirs-get = $(shell [ -d "lib/$(1)" ] && echo "lib/$(1) lib/$(1)/asm")
 ARCH_LIBDIRS := $(call libdirs-get,$(ARCH)) $(call libdirs-get,$(TEST_DIR))
 
-- 
2.11.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 3/8] Makefile: set VPATH based on SRCDIR
@ 2017-04-06 19:07   ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

Setting the VPATH prompts make to search VPATH for source files. There
are still some fix-ups needed for linking and including other Makefile
fragments for each architecture.

Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index eba7b28..80bc57e 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@ endif
 
 include config.mak
 
+# Set search path for all sources
+VPATH=$(SRCDIR)
+
 libdirs-get = $(shell [ -d "lib/$(1)" ] && echo "lib/$(1) lib/$(1)/asm")
 ARCH_LIBDIRS := $(call libdirs-get,$(ARCH)) $(call libdirs-get,$(TEST_DIR))
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
  2017-04-06 19:07 ` Alex Bennée
@ 2017-04-06 19:07   ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini; +Cc: kvm, marc.zyngier, linux-arm-kernel, kvmarm

I would of thought VPATH took care of this but apparently not.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 Makefile               | 8 ++++----
 arm/Makefile           | 2 +-
 arm/Makefile.arm       | 2 +-
 arm/Makefile.arm64     | 2 +-
 powerpc/Makefile       | 2 +-
 powerpc/Makefile.ppc64 | 2 +-
 x86/Makefile           | 2 +-
 x86/Makefile.i386      | 2 +-
 x86/Makefile.x86_64    | 2 +-
 9 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 80bc57e..781186e 100644
--- a/Makefile
+++ b/Makefile
@@ -32,14 +32,14 @@ cflatobjs := \
 	lib/stack.o
 
 # libfdt paths
-LIBFDT_objdir = lib/libfdt
-LIBFDT_srcdir = lib/libfdt
+LIBFDT_objdir = $(SRCDIR)/lib/libfdt
+LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
 LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
 LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
 LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
 
-#include architecure specific make rules
-include $(TEST_DIR)/Makefile
+#include architecture specific make rules
+include $(SRCDIR)/$(TEST_DIR)/Makefile
 
 # cc-option
 # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
diff --git a/arm/Makefile b/arm/Makefile
index 369a38b..8a007ab 100644
--- a/arm/Makefile
+++ b/arm/Makefile
@@ -1 +1 @@
-include $(TEST_DIR)/Makefile.$(ARCH)
+include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
diff --git a/arm/Makefile.arm b/arm/Makefile.arm
index 92f3757..6b57284 100644
--- a/arm/Makefile.arm
+++ b/arm/Makefile.arm
@@ -22,6 +22,6 @@ cflatobjs += lib/arm/stack.o
 # arm specific tests
 tests =
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
 
 arch_clean: arm_clean
diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
index 0b0761c..b5fc1ec 100644
--- a/arm/Makefile.arm64
+++ b/arm/Makefile.arm64
@@ -14,7 +14,7 @@ cflatobjs += lib/arm64/spinlock.o
 # arm64 specific tests
 tests =
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
 
 arch_clean: arm_clean
 	$(RM) lib/arm64/.*.d
diff --git a/powerpc/Makefile b/powerpc/Makefile
index 369a38b..8a007ab 100644
--- a/powerpc/Makefile
+++ b/powerpc/Makefile
@@ -1 +1 @@
-include $(TEST_DIR)/Makefile.$(ARCH)
+include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index 3da3a83..3c0294a 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -20,7 +20,7 @@ cflatobjs += lib/ppc64/spinlock.o
 # ppc64 specific tests
 tests =
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
 
 arch_clean: powerpc_clean
 	$(RM) lib/ppc64/.*.d
diff --git a/x86/Makefile b/x86/Makefile
index 369a38b..8a007ab 100644
--- a/x86/Makefile
+++ b/x86/Makefile
@@ -1 +1 @@
-include $(TEST_DIR)/Makefile.$(ARCH)
+include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
diff --git a/x86/Makefile.i386 b/x86/Makefile.i386
index 284b9e5..d801b80 100644
--- a/x86/Makefile.i386
+++ b/x86/Makefile.i386
@@ -7,4 +7,4 @@ cflatobjs += lib/x86/setjmp32.o
 tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \
 	$(TEST_DIR)/cmpxchg8b.flat
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64
index 3e2821e..30f82a6 100644
--- a/x86/Makefile.x86_64
+++ b/x86/Makefile.x86_64
@@ -17,7 +17,7 @@ tests += $(TEST_DIR)/vmx.flat
 tests += $(TEST_DIR)/tscdeadline_latency.flat
 tests += $(TEST_DIR)/intel-iommu.flat
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
 
 $(TEST_DIR)/hyperv_clock.elf: $(TEST_DIR)/hyperv_clock.o
 
-- 
2.11.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
@ 2017-04-06 19:07   ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

I would of thought VPATH took care of this but apparently not.

Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
---
 Makefile               | 8 ++++----
 arm/Makefile           | 2 +-
 arm/Makefile.arm       | 2 +-
 arm/Makefile.arm64     | 2 +-
 powerpc/Makefile       | 2 +-
 powerpc/Makefile.ppc64 | 2 +-
 x86/Makefile           | 2 +-
 x86/Makefile.i386      | 2 +-
 x86/Makefile.x86_64    | 2 +-
 9 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 80bc57e..781186e 100644
--- a/Makefile
+++ b/Makefile
@@ -32,14 +32,14 @@ cflatobjs := \
 	lib/stack.o
 
 # libfdt paths
-LIBFDT_objdir = lib/libfdt
-LIBFDT_srcdir = lib/libfdt
+LIBFDT_objdir = $(SRCDIR)/lib/libfdt
+LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
 LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
 LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
 LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
 
-#include architecure specific make rules
-include $(TEST_DIR)/Makefile
+#include architecture specific make rules
+include $(SRCDIR)/$(TEST_DIR)/Makefile
 
 # cc-option
 # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
diff --git a/arm/Makefile b/arm/Makefile
index 369a38b..8a007ab 100644
--- a/arm/Makefile
+++ b/arm/Makefile
@@ -1 +1 @@
-include $(TEST_DIR)/Makefile.$(ARCH)
+include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
diff --git a/arm/Makefile.arm b/arm/Makefile.arm
index 92f3757..6b57284 100644
--- a/arm/Makefile.arm
+++ b/arm/Makefile.arm
@@ -22,6 +22,6 @@ cflatobjs += lib/arm/stack.o
 # arm specific tests
 tests =
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
 
 arch_clean: arm_clean
diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
index 0b0761c..b5fc1ec 100644
--- a/arm/Makefile.arm64
+++ b/arm/Makefile.arm64
@@ -14,7 +14,7 @@ cflatobjs += lib/arm64/spinlock.o
 # arm64 specific tests
 tests =
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
 
 arch_clean: arm_clean
 	$(RM) lib/arm64/.*.d
diff --git a/powerpc/Makefile b/powerpc/Makefile
index 369a38b..8a007ab 100644
--- a/powerpc/Makefile
+++ b/powerpc/Makefile
@@ -1 +1 @@
-include $(TEST_DIR)/Makefile.$(ARCH)
+include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index 3da3a83..3c0294a 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -20,7 +20,7 @@ cflatobjs += lib/ppc64/spinlock.o
 # ppc64 specific tests
 tests =
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
 
 arch_clean: powerpc_clean
 	$(RM) lib/ppc64/.*.d
diff --git a/x86/Makefile b/x86/Makefile
index 369a38b..8a007ab 100644
--- a/x86/Makefile
+++ b/x86/Makefile
@@ -1 +1 @@
-include $(TEST_DIR)/Makefile.$(ARCH)
+include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
diff --git a/x86/Makefile.i386 b/x86/Makefile.i386
index 284b9e5..d801b80 100644
--- a/x86/Makefile.i386
+++ b/x86/Makefile.i386
@@ -7,4 +7,4 @@ cflatobjs += lib/x86/setjmp32.o
 tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \
 	$(TEST_DIR)/cmpxchg8b.flat
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64
index 3e2821e..30f82a6 100644
--- a/x86/Makefile.x86_64
+++ b/x86/Makefile.x86_64
@@ -17,7 +17,7 @@ tests += $(TEST_DIR)/vmx.flat
 tests += $(TEST_DIR)/tscdeadline_latency.flat
 tests += $(TEST_DIR)/intel-iommu.flat
 
-include $(TEST_DIR)/Makefile.common
+include $(SRCDIR)/$(TEST_DIR)/Makefile.common
 
 $(TEST_DIR)/hyperv_clock.elf: $(TEST_DIR)/hyperv_clock.o
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
  2017-04-06 19:07 ` Alex Bennée
@ 2017-04-06 19:07   ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini; +Cc: kvm, marc.zyngier, linux-arm-kernel, kvmarm

This is fairly direct way of ensuring the target build directories are
created before we build a binary blob. mkdir -p fails gracefully if
the directory is already there.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Makefile b/Makefile
index 781186e..56598df 100644
--- a/Makefile
+++ b/Makefile
@@ -79,8 +79,13 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 	$(AR) rcs $@ $^
 
 %.o: %.S
+	mkdir -p $(dir $@)
 	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
 
+%.o: %.c
+	mkdir -p $(dir $@)
+	$(CC) $(CFLAGS) -c -o $@ $<
+
 -include */.*.d */*/.*.d
 
 all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
-- 
2.11.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
@ 2017-04-06 19:07   ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

This is fairly direct way of ensuring the target build directories are
created before we build a binary blob. mkdir -p fails gracefully if
the directory is already there.

Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
---
 Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Makefile b/Makefile
index 781186e..56598df 100644
--- a/Makefile
+++ b/Makefile
@@ -79,8 +79,13 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 	$(AR) rcs $@ $^
 
 %.o: %.S
+	mkdir -p $(dir $@)
 	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
 
+%.o: %.c
+	mkdir -p $(dir $@)
+	$(CC) $(CFLAGS) -c -o $@ $<
+
 -include */.*.d */*/.*.d
 
 all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree
  2017-04-06 19:07 ` Alex Bennée
@ 2017-04-06 19:07   ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini; +Cc: kvm, marc.zyngier, linux-arm-kernel, kvmarm

When doing an out-of-src-tree build we still want access to the
various bits of common script machinery to run. This is handled by the
scripts-common list which sub-builds can add explicit extra stuff to.

The final rule is conditional so we don't attempt to link files when
we are doing an in-src-tree build.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 Makefile            | 13 +++++++++++++
 x86/Makefile.common |  4 ++++
 2 files changed, 17 insertions(+)

diff --git a/Makefile b/Makefile
index 56598df..c9fea88 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,10 @@ cflatobjs := \
 	lib/report.o \
 	lib/stack.o
 
+# These are scripts we want linked from the source tree
+scripts-common := run_tests.sh \
+	scripts
+
 # libfdt paths
 LIBFDT_objdir = $(SRCDIR)/lib/libfdt
 LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
@@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 	mkdir -p $(dir $@)
 	$(CC) $(CFLAGS) -c -o $@ $<
 
+$(scripts-common): $(SRCDIR)/$@
+	ln -sf $<$@ $@
+
 -include */.*.d */*/.*.d
 
+
+# We only need to link common scripts for out-of-src-tree builds
+ifneq ($(CURDIR), $(SRCDIR))
+all: $(scripts-common)
+endif
+
 all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
 
 standalone: all
diff --git a/x86/Makefile.common b/x86/Makefile.common
index fbab82c..ef6e543 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -54,8 +54,12 @@ tests-common += api/dirty-log
 tests-common += api/dirty-log-perf
 endif
 
+scripts-common += $(TEST_DIR)/run
+scripts-common += $(TEST_DIR)/unittests.cfg
+
 test_cases: $(tests-common) $(tests)
 
+
 $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
 
 $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
-- 
2.11.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree
@ 2017-04-06 19:07   ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

When doing an out-of-src-tree build we still want access to the
various bits of common script machinery to run. This is handled by the
scripts-common list which sub-builds can add explicit extra stuff to.

The final rule is conditional so we don't attempt to link files when
we are doing an in-src-tree build.

Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
---
 Makefile            | 13 +++++++++++++
 x86/Makefile.common |  4 ++++
 2 files changed, 17 insertions(+)

diff --git a/Makefile b/Makefile
index 56598df..c9fea88 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,10 @@ cflatobjs := \
 	lib/report.o \
 	lib/stack.o
 
+# These are scripts we want linked from the source tree
+scripts-common := run_tests.sh \
+	scripts
+
 # libfdt paths
 LIBFDT_objdir = $(SRCDIR)/lib/libfdt
 LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
@@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 	mkdir -p $(dir $@)
 	$(CC) $(CFLAGS) -c -o $@ $<
 
+$(scripts-common): $(SRCDIR)/$@
+	ln -sf $<$@ $@
+
 -include */.*.d */*/.*.d
 
+
+# We only need to link common scripts for out-of-src-tree builds
+ifneq ($(CURDIR), $(SRCDIR))
+all: $(scripts-common)
+endif
+
 all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
 
 standalone: all
diff --git a/x86/Makefile.common b/x86/Makefile.common
index fbab82c..ef6e543 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -54,8 +54,12 @@ tests-common += api/dirty-log
 tests-common += api/dirty-log-perf
 endif
 
+scripts-common += $(TEST_DIR)/run
+scripts-common += $(TEST_DIR)/unittests.cfg
+
 test_cases: $(tests-common) $(tests)
 
+
 $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
 
 $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 7/8] Makefiles: fix up the x86 build include and link paths
  2017-04-06 19:07 ` Alex Bennée
@ 2017-04-06 19:07   ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini
  Cc: kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier,
	Alex Bennée

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.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 Makefile            |  2 +-
 x86/Makefile.common | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index c9fea88..22da887 100644
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,7 @@ $(libcflat): $(cflatobjs)
 	$(AR) rcs $@ $^
 
 include $(LIBFDT_srcdir)/Makefile.libfdt
-$(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt -Wno-sign-compare
+$(LIBFDT_archive): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -Wno-sign-compare
 $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 	$(AR) rcs $@ $^
 
diff --git a/x86/Makefile.common b/x86/Makefile.common
index ef6e543..032ed19 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -17,7 +17,7 @@ cflatobjs += lib/x86/acpi.o
 cflatobjs += lib/x86/stack.o
 
 $(libcflat): LDFLAGS += -nostdlib
-$(libcflat): CFLAGS += -ffreestanding -I lib
+$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
 
 CFLAGS += -m$(bits)
 CFLAGS += -O1
@@ -31,8 +31,8 @@ libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
 .PRECIOUS: %.elf %.o
 
 FLATLIBS = lib/libcflat.a $(libgcc)
-%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o)
-	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
+%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
+	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
 		$(filter %.o, $^) $(FLATLIBS)
 
 %.flat: %.elf
@@ -60,10 +60,10 @@ scripts-common += $(TEST_DIR)/unittests.cfg
 test_cases: $(tests-common) $(tests)
 
 
-$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
+$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
 
 $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
-	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^
+	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^
 
 $(TEST_DIR)/realmode.o: bits = 32
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 7/8] Makefiles: fix up the x86 build include and link paths
@ 2017-04-06 19:07   ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
---
 Makefile            |  2 +-
 x86/Makefile.common | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index c9fea88..22da887 100644
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,7 @@ $(libcflat): $(cflatobjs)
 	$(AR) rcs $@ $^
 
 include $(LIBFDT_srcdir)/Makefile.libfdt
-$(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt -Wno-sign-compare
+$(LIBFDT_archive): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -Wno-sign-compare
 $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 	$(AR) rcs $@ $^
 
diff --git a/x86/Makefile.common b/x86/Makefile.common
index ef6e543..032ed19 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -17,7 +17,7 @@ cflatobjs += lib/x86/acpi.o
 cflatobjs += lib/x86/stack.o
 
 $(libcflat): LDFLAGS += -nostdlib
-$(libcflat): CFLAGS += -ffreestanding -I lib
+$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
 
 CFLAGS += -m$(bits)
 CFLAGS += -O1
@@ -31,8 +31,8 @@ libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
 .PRECIOUS: %.elf %.o
 
 FLATLIBS = lib/libcflat.a $(libgcc)
-%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o)
-	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
+%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
+	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
 		$(filter %.o, $^) $(FLATLIBS)
 
 %.flat: %.elf
@@ -60,10 +60,10 @@ scripts-common += $(TEST_DIR)/unittests.cfg
 test_cases: $(tests-common) $(tests)
 
 
-$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
+$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
 
 $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
-	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^
+	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^
 
 $(TEST_DIR)/realmode.o: bits = 32
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 8/8] Makefiles: fix up the arm build include and link paths
  2017-04-06 19:07 ` Alex Bennée
@ 2017-04-06 19:07   ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: drjones, pbonzini; +Cc: kvm, marc.zyngier, linux-arm-kernel, kvmarm

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.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 arm/Makefile.common     | 15 +++++++++------
 scripts/asm-offsets.mak |  4 +++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/arm/Makefile.common b/arm/Makefile.common
index 74c7394..b1fead1 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -16,7 +16,10 @@ tests-common += $(TEST_DIR)/pmu.flat
 tests-common += $(TEST_DIR)/gic.flat
 tests-common += $(TEST_DIR)/psci.flat
 
-tests-all = $(tests-common) $(tests)
+scripts-common += $(TEST_DIR)/run
+scripts-common += $(TEST_DIR)/unittests.cfg
+
+tests-all = $(tests-common) $(tests) $(scripts_common)
 all: $(tests-all)
 
 ##################################################################
@@ -26,13 +29,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
@@ -60,11 +63,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..ecf583f 100644
--- a/scripts/asm-offsets.mak
+++ b/scripts/asm-offsets.mak
@@ -29,11 +29,13 @@ define make_asm_offsets
 endef
 
 $(asm-offsets:.h=.s): $(asm-offsets:.h=.c)
+	mkdir -p $(dir $@)
 	$(CC) $(CFLAGS) -fverbose-asm -S -o $@ $<
 
 $(asm-offsets): $(asm-offsets:.h=.s)
 	$(call make_asm_offsets)
-	cp -f $(asm-offsets) lib/generated
+	mkdir -p lib/generated
+	cp -f $(asm-offsets) lib/generated/
 
 asm_offsets_clean:
 	$(RM) $(asm-offsets) $(asm-offsets:.h=.s) \
-- 
2.11.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 8/8] Makefiles: fix up the arm build include and link paths
@ 2017-04-06 19:07   ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-06 19:07 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
---
 arm/Makefile.common     | 15 +++++++++------
 scripts/asm-offsets.mak |  4 +++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/arm/Makefile.common b/arm/Makefile.common
index 74c7394..b1fead1 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -16,7 +16,10 @@ tests-common += $(TEST_DIR)/pmu.flat
 tests-common += $(TEST_DIR)/gic.flat
 tests-common += $(TEST_DIR)/psci.flat
 
-tests-all = $(tests-common) $(tests)
+scripts-common += $(TEST_DIR)/run
+scripts-common += $(TEST_DIR)/unittests.cfg
+
+tests-all = $(tests-common) $(tests) $(scripts_common)
 all: $(tests-all)
 
 ##################################################################
@@ -26,13 +29,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
@@ -60,11 +63,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..ecf583f 100644
--- a/scripts/asm-offsets.mak
+++ b/scripts/asm-offsets.mak
@@ -29,11 +29,13 @@ define make_asm_offsets
 endef
 
 $(asm-offsets:.h=.s): $(asm-offsets:.h=.c)
+	mkdir -p $(dir $@)
 	$(CC) $(CFLAGS) -fverbose-asm -S -o $@ $<
 
 $(asm-offsets): $(asm-offsets:.h=.s)
 	$(call make_asm_offsets)
-	cp -f $(asm-offsets) lib/generated
+	mkdir -p lib/generated
+	cp -f $(asm-offsets) lib/generated/
 
 asm_offsets_clean:
 	$(RM) $(asm-offsets) $(asm-offsets:.h=.s) \
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 9/8] Makefiles: Fix up the powerpc build include and link paths
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07  6:58     ` Thomas Huth
  -1 siblings, 0 replies; 62+ messages in thread
From: Thomas Huth @ 2017-04-07  6:58 UTC (permalink / raw)
  To: alex.bennee, pbonzini, rkrcmar
  Cc: drjones, kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier

The changes for out-of-tree builds are here pretty much the same
as for the ARM Makefile.common.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 powerpc/Makefile.common | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index e536ffe..1fbcafb 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -12,7 +12,10 @@ tests-common = \
 	$(TEST_DIR)/tm.elf \
 	$(TEST_DIR)/sprs.elf
 
-tests-all = $(tests-common) $(tests)
+scripts-common += $(TEST_DIR)/run
+scripts-common += $(TEST_DIR)/unittests.cfg
+
+tests-all = $(tests-common) $(tests) $(scripts_common)
 all: $(TEST_DIR)/boot_rom.bin $(tests-all)
 
 ##################################################################
@@ -21,14 +24,14 @@ 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
 CFLAGS += -Wa,-mregnames
 
 # We want to keep intermediate files
 .PRECIOUS: %.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
@@ -44,10 +47,11 @@ cflatobjs += lib/powerpc/smp.o
 FLATLIBS = $(libcflat) $(LIBFDT_archive)
 %.elf: CFLAGS += $(arch_CFLAGS)
 %.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie -n
-%.elf: %.o $(FLATLIBS) powerpc/flat.lds $(cstart.o) $(reloc.o)
-	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) lib/auxinfo.c -DPROGNAME=\"$@\"
+%.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o)
+	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c \
+		-DPROGNAME=\"$@\"
 	$(LD) $(LDFLAGS) -o $@ \
-		-T powerpc/flat.lds --build-id=none \
+		-T $(SRCDIR)/powerpc/flat.lds --build-id=none \
 		$(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
 	$(RM) $(@:.elf=.aux.o)
 	@echo -n Checking $@ for unsupported reloc types...
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 9/8] Makefiles: Fix up the powerpc build include and link paths
@ 2017-04-07  6:58     ` Thomas Huth
  0 siblings, 0 replies; 62+ messages in thread
From: Thomas Huth @ 2017-04-07  6:58 UTC (permalink / raw)
  To: linux-arm-kernel

The changes for out-of-tree builds are here pretty much the same
as for the ARM Makefile.common.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 powerpc/Makefile.common | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index e536ffe..1fbcafb 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -12,7 +12,10 @@ tests-common = \
 	$(TEST_DIR)/tm.elf \
 	$(TEST_DIR)/sprs.elf
 
-tests-all = $(tests-common) $(tests)
+scripts-common += $(TEST_DIR)/run
+scripts-common += $(TEST_DIR)/unittests.cfg
+
+tests-all = $(tests-common) $(tests) $(scripts_common)
 all: $(TEST_DIR)/boot_rom.bin $(tests-all)
 
 ##################################################################
@@ -21,14 +24,14 @@ 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
 CFLAGS += -Wa,-mregnames
 
 # We want to keep intermediate files
 .PRECIOUS: %.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
@@ -44,10 +47,11 @@ cflatobjs += lib/powerpc/smp.o
 FLATLIBS = $(libcflat) $(LIBFDT_archive)
 %.elf: CFLAGS += $(arch_CFLAGS)
 %.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie -n
-%.elf: %.o $(FLATLIBS) powerpc/flat.lds $(cstart.o) $(reloc.o)
-	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) lib/auxinfo.c -DPROGNAME=\"$@\"
+%.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o)
+	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c \
+		-DPROGNAME=\"$@\"
 	$(LD) $(LDFLAGS) -o $@ \
-		-T powerpc/flat.lds --build-id=none \
+		-T $(SRCDIR)/powerpc/flat.lds --build-id=none \
 		$(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
 	$(RM) $(@:.elf=.aux.o)
 	@echo -n Checking $@ for unsupported reloc types...
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 9/8] Makefiles: Fix up the powerpc build include and link paths
  2017-04-07  6:58     ` Thomas Huth
@ 2017-04-07  8:02       ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07  8:02 UTC (permalink / raw)
  To: Thomas Huth; +Cc: kvm, marc.zyngier, pbonzini, kvmarm, linux-arm-kernel


Thomas Huth <thuth@redhat.com> writes:

> The changes for out-of-tree builds are here pretty much the same
> as for the ARM Makefile.common.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>

It was only when I posted I realised that there was only one
architecture left (too used to QEMUs multitude). I didn't intend for
PowerPC to be the last puppy in the shop!

Thanks for you patch. Applied ;-)

> ---
>  powerpc/Makefile.common | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
> index e536ffe..1fbcafb 100644
> --- a/powerpc/Makefile.common
> +++ b/powerpc/Makefile.common
> @@ -12,7 +12,10 @@ tests-common = \
>  	$(TEST_DIR)/tm.elf \
>  	$(TEST_DIR)/sprs.elf
>
> -tests-all = $(tests-common) $(tests)
> +scripts-common += $(TEST_DIR)/run
> +scripts-common += $(TEST_DIR)/unittests.cfg
> +
> +tests-all = $(tests-common) $(tests) $(scripts_common)
>  all: $(TEST_DIR)/boot_rom.bin $(tests-all)
>
>  ##################################################################
> @@ -21,14 +24,14 @@ 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
>  CFLAGS += -Wa,-mregnames
>
>  # We want to keep intermediate files
>  .PRECIOUS: %.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
> @@ -44,10 +47,11 @@ cflatobjs += lib/powerpc/smp.o
>  FLATLIBS = $(libcflat) $(LIBFDT_archive)
>  %.elf: CFLAGS += $(arch_CFLAGS)
>  %.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie -n
> -%.elf: %.o $(FLATLIBS) powerpc/flat.lds $(cstart.o) $(reloc.o)
> -	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) lib/auxinfo.c -DPROGNAME=\"$@\"
> +%.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o)
> +	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c \
> +		-DPROGNAME=\"$@\"
>  	$(LD) $(LDFLAGS) -o $@ \
> -		-T powerpc/flat.lds --build-id=none \
> +		-T $(SRCDIR)/powerpc/flat.lds --build-id=none \
>  		$(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
>  	$(RM) $(@:.elf=.aux.o)
>  	@echo -n Checking $@ for unsupported reloc types...


--
Alex Bennée
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 9/8] Makefiles: Fix up the powerpc build include and link paths
@ 2017-04-07  8:02       ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07  8:02 UTC (permalink / raw)
  To: linux-arm-kernel


Thomas Huth <thuth@redhat.com> writes:

> The changes for out-of-tree builds are here pretty much the same
> as for the ARM Makefile.common.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>

It was only when I posted I realised that there was only one
architecture left (too used to QEMUs multitude). I didn't intend for
PowerPC to be the last puppy in the shop!

Thanks for you patch. Applied ;-)

> ---
>  powerpc/Makefile.common | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
> index e536ffe..1fbcafb 100644
> --- a/powerpc/Makefile.common
> +++ b/powerpc/Makefile.common
> @@ -12,7 +12,10 @@ tests-common = \
>  	$(TEST_DIR)/tm.elf \
>  	$(TEST_DIR)/sprs.elf
>
> -tests-all = $(tests-common) $(tests)
> +scripts-common += $(TEST_DIR)/run
> +scripts-common += $(TEST_DIR)/unittests.cfg
> +
> +tests-all = $(tests-common) $(tests) $(scripts_common)
>  all: $(TEST_DIR)/boot_rom.bin $(tests-all)
>
>  ##################################################################
> @@ -21,14 +24,14 @@ 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
>  CFLAGS += -Wa,-mregnames
>
>  # We want to keep intermediate files
>  .PRECIOUS: %.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
> @@ -44,10 +47,11 @@ cflatobjs += lib/powerpc/smp.o
>  FLATLIBS = $(libcflat) $(LIBFDT_archive)
>  %.elf: CFLAGS += $(arch_CFLAGS)
>  %.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie -n
> -%.elf: %.o $(FLATLIBS) powerpc/flat.lds $(cstart.o) $(reloc.o)
> -	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) lib/auxinfo.c -DPROGNAME=\"$@\"
> +%.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o)
> +	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c \
> +		-DPROGNAME=\"$@\"
>  	$(LD) $(LDFLAGS) -o $@ \
> -		-T powerpc/flat.lds --build-id=none \
> +		-T $(SRCDIR)/powerpc/flat.lds --build-id=none \
>  		$(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
>  	$(RM) $(@:.elf=.aux.o)
>  	@echo -n Checking $@ for unsupported reloc types...


--
Alex Benn?e

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07  8:53     ` Thomas Huth
  -1 siblings, 0 replies; 62+ messages in thread
From: Thomas Huth @ 2017-04-07  8:53 UTC (permalink / raw)
  To: Alex Bennée, drjones, pbonzini
  Cc: marc.zyngier, linux-arm-kernel, kvm, kvmarm

On 06.04.2017 21:07, Alex Bennée wrote:
> I would of thought VPATH took care of this but apparently not.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile               | 8 ++++----
>  arm/Makefile           | 2 +-
>  arm/Makefile.arm       | 2 +-
>  arm/Makefile.arm64     | 2 +-
>  powerpc/Makefile       | 2 +-
>  powerpc/Makefile.ppc64 | 2 +-
>  x86/Makefile           | 2 +-
>  x86/Makefile.i386      | 2 +-
>  x86/Makefile.x86_64    | 2 +-
>  9 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 80bc57e..781186e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -32,14 +32,14 @@ cflatobjs := \
>  	lib/stack.o
>  
>  # libfdt paths
> -LIBFDT_objdir = lib/libfdt
> -LIBFDT_srcdir = lib/libfdt
> +LIBFDT_objdir = $(SRCDIR)/lib/libfdt

I think this is wrong - objdir should not get a SRCDIR prefix.

 Thomas

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
@ 2017-04-07  8:53     ` Thomas Huth
  0 siblings, 0 replies; 62+ messages in thread
From: Thomas Huth @ 2017-04-07  8:53 UTC (permalink / raw)
  To: linux-arm-kernel

On 06.04.2017 21:07, Alex Benn?e wrote:
> I would of thought VPATH took care of this but apparently not.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  Makefile               | 8 ++++----
>  arm/Makefile           | 2 +-
>  arm/Makefile.arm       | 2 +-
>  arm/Makefile.arm64     | 2 +-
>  powerpc/Makefile       | 2 +-
>  powerpc/Makefile.ppc64 | 2 +-
>  x86/Makefile           | 2 +-
>  x86/Makefile.i386      | 2 +-
>  x86/Makefile.x86_64    | 2 +-
>  9 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 80bc57e..781186e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -32,14 +32,14 @@ cflatobjs := \
>  	lib/stack.o
>  
>  # libfdt paths
> -LIBFDT_objdir = lib/libfdt
> -LIBFDT_srcdir = lib/libfdt
> +LIBFDT_objdir = $(SRCDIR)/lib/libfdt

I think this is wrong - objdir should not get a SRCDIR prefix.

 Thomas

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
  2017-04-07  8:53     ` Thomas Huth
@ 2017-04-07  9:21       ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07  9:21 UTC (permalink / raw)
  To: Thomas Huth; +Cc: kvm, marc.zyngier, linux-arm-kernel, pbonzini, kvmarm


Thomas Huth <thuth@redhat.com> writes:

> On 06.04.2017 21:07, Alex Bennée wrote:
>> I would of thought VPATH took care of this but apparently not.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  Makefile               | 8 ++++----
>>  arm/Makefile           | 2 +-
>>  arm/Makefile.arm       | 2 +-
>>  arm/Makefile.arm64     | 2 +-
>>  powerpc/Makefile       | 2 +-
>>  powerpc/Makefile.ppc64 | 2 +-
>>  x86/Makefile           | 2 +-
>>  x86/Makefile.i386      | 2 +-
>>  x86/Makefile.x86_64    | 2 +-
>>  9 files changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 80bc57e..781186e 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -32,14 +32,14 @@ cflatobjs := \
>>  	lib/stack.o
>>
>>  # libfdt paths
>> -LIBFDT_objdir = lib/libfdt
>> -LIBFDT_srcdir = lib/libfdt
>> +LIBFDT_objdir = $(SRCDIR)/lib/libfdt
>
> I think this is wrong - objdir should not get a SRCDIR prefix.

Good catch - which explains why I was seeing libfdt.a in the source tree.

--
Alex Bennée
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
@ 2017-04-07  9:21       ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07  9:21 UTC (permalink / raw)
  To: linux-arm-kernel


Thomas Huth <thuth@redhat.com> writes:

> On 06.04.2017 21:07, Alex Benn?e wrote:
>> I would of thought VPATH took care of this but apparently not.
>>
>> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
>> ---
>>  Makefile               | 8 ++++----
>>  arm/Makefile           | 2 +-
>>  arm/Makefile.arm       | 2 +-
>>  arm/Makefile.arm64     | 2 +-
>>  powerpc/Makefile       | 2 +-
>>  powerpc/Makefile.ppc64 | 2 +-
>>  x86/Makefile           | 2 +-
>>  x86/Makefile.i386      | 2 +-
>>  x86/Makefile.x86_64    | 2 +-
>>  9 files changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 80bc57e..781186e 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -32,14 +32,14 @@ cflatobjs := \
>>  	lib/stack.o
>>
>>  # libfdt paths
>> -LIBFDT_objdir = lib/libfdt
>> -LIBFDT_srcdir = lib/libfdt
>> +LIBFDT_objdir = $(SRCDIR)/lib/libfdt
>
> I think this is wrong - objdir should not get a SRCDIR prefix.

Good catch - which explains why I was seeing libfdt.a in the source tree.

--
Alex Benn?e

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07  9:22     ` Thomas Huth
  -1 siblings, 0 replies; 62+ messages in thread
From: Thomas Huth @ 2017-04-07  9:22 UTC (permalink / raw)
  To: Alex Bennée, drjones, pbonzini
  Cc: kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier

On 06.04.2017 21:07, Alex Bennée wrote:
> When doing an out-of-src-tree build we still want access to the
> various bits of common script machinery to run. This is handled by the
> scripts-common list which sub-builds can add explicit extra stuff to.
> 
> The final rule is conditional so we don't attempt to link files when
> we are doing an in-src-tree build.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile            | 13 +++++++++++++
>  x86/Makefile.common |  4 ++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 56598df..c9fea88 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -31,6 +31,10 @@ cflatobjs := \
>  	lib/report.o \
>  	lib/stack.o
>  
> +# These are scripts we want linked from the source tree
> +scripts-common := run_tests.sh \
> +	scripts
> +
>  # libfdt paths
>  LIBFDT_objdir = $(SRCDIR)/lib/libfdt
>  LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
> @@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  	mkdir -p $(dir $@)
>  	$(CC) $(CFLAGS) -c -o $@ $<
>  
> +$(scripts-common): $(SRCDIR)/$@
> +	ln -sf $<$@ $@

The prerequisite does not seem to work correctly here. I can see that
the symlinks are regenerated each time I run make. Even worse, during
the second run, there is a

ln -sf /home/thuth/devel/kvm-unit-tests/scripts scripts

which generates a symlink in the source directory, since the "scripts"
symlink already exists!

I think you can not use automatic variables like $@ in the prerequisite
list, can you?

Maybe it would be better to create these symlinks in the configure
script already?

>  -include */.*.d */*/.*.d
>  
> +
> +# We only need to link common scripts for out-of-src-tree builds
> +ifneq ($(CURDIR), $(SRCDIR))
> +all: $(scripts-common)
> +endif
> +
>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
>  
>  standalone: all
> diff --git a/x86/Makefile.common b/x86/Makefile.common
> index fbab82c..ef6e543 100644
> --- a/x86/Makefile.common
> +++ b/x86/Makefile.common
> @@ -54,8 +54,12 @@ tests-common += api/dirty-log
>  tests-common += api/dirty-log-perf
>  endif
>  
> +scripts-common += $(TEST_DIR)/run
> +scripts-common += $(TEST_DIR)/unittests.cfg
> +
>  test_cases: $(tests-common) $(tests)
>  
> +

Cosmetic nit: Superfluous white space change.

>  $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
>  
>  $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
> 

 Thomas

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree
@ 2017-04-07  9:22     ` Thomas Huth
  0 siblings, 0 replies; 62+ messages in thread
From: Thomas Huth @ 2017-04-07  9:22 UTC (permalink / raw)
  To: linux-arm-kernel

On 06.04.2017 21:07, Alex Benn?e wrote:
> When doing an out-of-src-tree build we still want access to the
> various bits of common script machinery to run. This is handled by the
> scripts-common list which sub-builds can add explicit extra stuff to.
> 
> The final rule is conditional so we don't attempt to link files when
> we are doing an in-src-tree build.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  Makefile            | 13 +++++++++++++
>  x86/Makefile.common |  4 ++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 56598df..c9fea88 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -31,6 +31,10 @@ cflatobjs := \
>  	lib/report.o \
>  	lib/stack.o
>  
> +# These are scripts we want linked from the source tree
> +scripts-common := run_tests.sh \
> +	scripts
> +
>  # libfdt paths
>  LIBFDT_objdir = $(SRCDIR)/lib/libfdt
>  LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
> @@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  	mkdir -p $(dir $@)
>  	$(CC) $(CFLAGS) -c -o $@ $<
>  
> +$(scripts-common): $(SRCDIR)/$@
> +	ln -sf $<$@ $@

The prerequisite does not seem to work correctly here. I can see that
the symlinks are regenerated each time I run make. Even worse, during
the second run, there is a

ln -sf /home/thuth/devel/kvm-unit-tests/scripts scripts

which generates a symlink in the source directory, since the "scripts"
symlink already exists!

I think you can not use automatic variables like $@ in the prerequisite
list, can you?

Maybe it would be better to create these symlinks in the configure
script already?

>  -include */.*.d */*/.*.d
>  
> +
> +# We only need to link common scripts for out-of-src-tree builds
> +ifneq ($(CURDIR), $(SRCDIR))
> +all: $(scripts-common)
> +endif
> +
>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
>  
>  standalone: all
> diff --git a/x86/Makefile.common b/x86/Makefile.common
> index fbab82c..ef6e543 100644
> --- a/x86/Makefile.common
> +++ b/x86/Makefile.common
> @@ -54,8 +54,12 @@ tests-common += api/dirty-log
>  tests-common += api/dirty-log-perf
>  endif
>  
> +scripts-common += $(TEST_DIR)/run
> +scripts-common += $(TEST_DIR)/unittests.cfg
> +
>  test_cases: $(tests-common) $(tests)
>  
> +

Cosmetic nit: Superfluous white space change.

>  $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
>  
>  $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
> 

 Thomas

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree
  2017-04-07  9:22     ` Thomas Huth
@ 2017-04-07 10:38       ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07 10:38 UTC (permalink / raw)
  To: Thomas Huth
  Cc: drjones, pbonzini, kvm, linux-arm-kernel, kvmarm,
	christoffer.dall, marc.zyngier


Thomas Huth <thuth@redhat.com> writes:

> On 06.04.2017 21:07, Alex Bennée wrote:
>> When doing an out-of-src-tree build we still want access to the
>> various bits of common script machinery to run. This is handled by the
>> scripts-common list which sub-builds can add explicit extra stuff to.
>>
>> The final rule is conditional so we don't attempt to link files when
>> we are doing an in-src-tree build.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  Makefile            | 13 +++++++++++++
>>  x86/Makefile.common |  4 ++++
>>  2 files changed, 17 insertions(+)
>>
>> diff --git a/Makefile b/Makefile
>> index 56598df..c9fea88 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -31,6 +31,10 @@ cflatobjs := \
>>  	lib/report.o \
>>  	lib/stack.o
>>
>> +# These are scripts we want linked from the source tree
>> +scripts-common := run_tests.sh \
>> +	scripts
>> +
>>  # libfdt paths
>>  LIBFDT_objdir = $(SRCDIR)/lib/libfdt
>>  LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
>> @@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>>  	mkdir -p $(dir $@)
>>  	$(CC) $(CFLAGS) -c -o $@ $<
>>
>> +$(scripts-common): $(SRCDIR)/$@
>> +	ln -sf $<$@ $@
>
> The prerequisite does not seem to work correctly here. I can see that
> the symlinks are regenerated each time I run make. Even worse, during
> the second run, there is a
>
> ln -sf /home/thuth/devel/kvm-unit-tests/scripts scripts
>
> which generates a symlink in the source directory, since the "scripts"
> symlink already exists!
>
> I think you can not use automatic variables like $@ in the prerequisite
> list, can you?
>
> Maybe it would be better to create these symlinks in the configure
> script already?

Hmm maybe. The trouble is catching them all. That's why I wanted to have
something like scripts-common that sub Makefiles could add to.

We could certainly make the rule a bit more robust against re-linking
though.

>
>>  -include */.*.d */*/.*.d
>>
>> +
>> +# We only need to link common scripts for out-of-src-tree builds
>> +ifneq ($(CURDIR), $(SRCDIR))
>> +all: $(scripts-common)
>> +endif
>> +
>>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
>>
>>  standalone: all
>> diff --git a/x86/Makefile.common b/x86/Makefile.common
>> index fbab82c..ef6e543 100644
>> --- a/x86/Makefile.common
>> +++ b/x86/Makefile.common
>> @@ -54,8 +54,12 @@ tests-common += api/dirty-log
>>  tests-common += api/dirty-log-perf
>>  endif
>>
>> +scripts-common += $(TEST_DIR)/run
>> +scripts-common += $(TEST_DIR)/unittests.cfg
>> +
>>  test_cases: $(tests-common) $(tests)
>>
>> +
>
> Cosmetic nit: Superfluous white space change.
>
>>  $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
>>
>>  $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
>>
>
>  Thomas


--
Alex Bennée

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree
@ 2017-04-07 10:38       ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07 10:38 UTC (permalink / raw)
  To: linux-arm-kernel


Thomas Huth <thuth@redhat.com> writes:

> On 06.04.2017 21:07, Alex Benn?e wrote:
>> When doing an out-of-src-tree build we still want access to the
>> various bits of common script machinery to run. This is handled by the
>> scripts-common list which sub-builds can add explicit extra stuff to.
>>
>> The final rule is conditional so we don't attempt to link files when
>> we are doing an in-src-tree build.
>>
>> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
>> ---
>>  Makefile            | 13 +++++++++++++
>>  x86/Makefile.common |  4 ++++
>>  2 files changed, 17 insertions(+)
>>
>> diff --git a/Makefile b/Makefile
>> index 56598df..c9fea88 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -31,6 +31,10 @@ cflatobjs := \
>>  	lib/report.o \
>>  	lib/stack.o
>>
>> +# These are scripts we want linked from the source tree
>> +scripts-common := run_tests.sh \
>> +	scripts
>> +
>>  # libfdt paths
>>  LIBFDT_objdir = $(SRCDIR)/lib/libfdt
>>  LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
>> @@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>>  	mkdir -p $(dir $@)
>>  	$(CC) $(CFLAGS) -c -o $@ $<
>>
>> +$(scripts-common): $(SRCDIR)/$@
>> +	ln -sf $<$@ $@
>
> The prerequisite does not seem to work correctly here. I can see that
> the symlinks are regenerated each time I run make. Even worse, during
> the second run, there is a
>
> ln -sf /home/thuth/devel/kvm-unit-tests/scripts scripts
>
> which generates a symlink in the source directory, since the "scripts"
> symlink already exists!
>
> I think you can not use automatic variables like $@ in the prerequisite
> list, can you?
>
> Maybe it would be better to create these symlinks in the configure
> script already?

Hmm maybe. The trouble is catching them all. That's why I wanted to have
something like scripts-common that sub Makefiles could add to.

We could certainly make the rule a bit more robust against re-linking
though.

>
>>  -include */.*.d */*/.*.d
>>
>> +
>> +# We only need to link common scripts for out-of-src-tree builds
>> +ifneq ($(CURDIR), $(SRCDIR))
>> +all: $(scripts-common)
>> +endif
>> +
>>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
>>
>>  standalone: all
>> diff --git a/x86/Makefile.common b/x86/Makefile.common
>> index fbab82c..ef6e543 100644
>> --- a/x86/Makefile.common
>> +++ b/x86/Makefile.common
>> @@ -54,8 +54,12 @@ tests-common += api/dirty-log
>>  tests-common += api/dirty-log-perf
>>  endif
>>
>> +scripts-common += $(TEST_DIR)/run
>> +scripts-common += $(TEST_DIR)/unittests.cfg
>> +
>>  test_cases: $(tests-common) $(tests)
>>
>> +
>
> Cosmetic nit: Superfluous white space change.
>
>>  $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
>>
>>  $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
>>
>
>  Thomas


--
Alex Benn?e

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 1/8] configure: make it run-able from outside source tree
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07 11:40     ` Andrew Jones
  -1 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 11:40 UTC (permalink / raw)
  To: Alex Bennée; +Cc: kvm, marc.zyngier, linux-arm-kernel, pbonzini, kvmarm

On Thu, Apr 06, 2017 at 08:07:20PM +0100, Alex Bennée wrote:
> This is a first step to enabling out-of-tree builds for
> kvm-unit-tests. When you invoke configure like this:
> 
>   ../tree.git/configure [args]
> 
> It will detect we the case and:
> 
>   - link ../tree.git/Makefile to the build-dir
>   - ensure lib is created with a correct lib/asm
>   - set SRCDIR in the config.mk
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  configure | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/configure b/configure
> index 8821f37..223809c 100755
> --- a/configure
> +++ b/configure
> @@ -1,5 +1,6 @@
>  #!/bin/bash
>  
> +srcdir=$(cd "$(dirname "$0")"; pwd)

Why not just $(dirname "$0")? Any reason the path can't
be relative?  Also, could use realpath vs. the cd/pwd.

>  prefix=/usr/local
>  cc=gcc
>  ld=ld
> @@ -102,12 +103,12 @@ elif [ "$arch" = "ppc64" ]; then
>  else
>      testdir=$arch
>  fi
> -if [ ! -d $testdir ]; then
> +if [ ! -d $srcdir/$testdir ]; then
>      echo "$testdir does not exist!"
>      exit 1
>  fi
> -if [ -f $testdir/run ]; then
> -    ln -fs $testdir/run $testdir-run
> +if [ -f $srcdir/$testdir/run ]; then
> +    ln -fs $srcdir/$testdir/run $testdir-run
>  fi

$srcdir could have spaces in it, so now we need "" on all these
references, e.g. [ -f "$srcdir/$testdir/run" ]

>  
>  # check if uint32_t needs a long format modifier
> @@ -135,18 +136,27 @@ fi
>  rm -f lib_test.c
>  fi
>  
> +# Are we in a separate build tree? If so, link the Makefile
> +# so that 'make' works.
> +if test ! -e Makefile; then

[ ! -e Makefile ]

> +    echo "linking Makefile..."
> +    ln -s "${srcdir}/Makefile" .

No need for the {}

> +fi
> +
>  # link lib/asm for the architecture
>  rm -f lib/asm
>  asm=asm-generic
> -if [ -d lib/$arch/asm ]; then
> -	asm=$arch/asm
> -elif [ -d lib/$testdir/asm ]; then
> -	asm=$testdir/asm
> +if [ -d $srcdir/lib/$arch/asm ]; then
> +	asm=$srcdir/lib/$arch/asm
> +elif [ -d $srcdir/lib/$testdir/asm ]; then
> +	asm=$srcdir/lib/$testdir/asm

""'s

>  fi
> +mkdir -p lib
>  ln -s $asm lib/asm
>  
>  # create the config
>  cat <<EOF > config.mak
> +SRCDIR=$srcdir
>  PREFIX=$prefix
>  HOST=$host
>  ARCH=$arch
> -- 
> 2.11.0
>

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 1/8] configure: make it run-able from outside source tree
@ 2017-04-07 11:40     ` Andrew Jones
  0 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 11:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 06, 2017 at 08:07:20PM +0100, Alex Benn?e wrote:
> This is a first step to enabling out-of-tree builds for
> kvm-unit-tests. When you invoke configure like this:
> 
>   ../tree.git/configure [args]
> 
> It will detect we the case and:
> 
>   - link ../tree.git/Makefile to the build-dir
>   - ensure lib is created with a correct lib/asm
>   - set SRCDIR in the config.mk
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  configure | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/configure b/configure
> index 8821f37..223809c 100755
> --- a/configure
> +++ b/configure
> @@ -1,5 +1,6 @@
>  #!/bin/bash
>  
> +srcdir=$(cd "$(dirname "$0")"; pwd)

Why not just $(dirname "$0")? Any reason the path can't
be relative?  Also, could use realpath vs. the cd/pwd.

>  prefix=/usr/local
>  cc=gcc
>  ld=ld
> @@ -102,12 +103,12 @@ elif [ "$arch" = "ppc64" ]; then
>  else
>      testdir=$arch
>  fi
> -if [ ! -d $testdir ]; then
> +if [ ! -d $srcdir/$testdir ]; then
>      echo "$testdir does not exist!"
>      exit 1
>  fi
> -if [ -f $testdir/run ]; then
> -    ln -fs $testdir/run $testdir-run
> +if [ -f $srcdir/$testdir/run ]; then
> +    ln -fs $srcdir/$testdir/run $testdir-run
>  fi

$srcdir could have spaces in it, so now we need "" on all these
references, e.g. [ -f "$srcdir/$testdir/run" ]

>  
>  # check if uint32_t needs a long format modifier
> @@ -135,18 +136,27 @@ fi
>  rm -f lib_test.c
>  fi
>  
> +# Are we in a separate build tree? If so, link the Makefile
> +# so that 'make' works.
> +if test ! -e Makefile; then

[ ! -e Makefile ]

> +    echo "linking Makefile..."
> +    ln -s "${srcdir}/Makefile" .

No need for the {}

> +fi
> +
>  # link lib/asm for the architecture
>  rm -f lib/asm
>  asm=asm-generic
> -if [ -d lib/$arch/asm ]; then
> -	asm=$arch/asm
> -elif [ -d lib/$testdir/asm ]; then
> -	asm=$testdir/asm
> +if [ -d $srcdir/lib/$arch/asm ]; then
> +	asm=$srcdir/lib/$arch/asm
> +elif [ -d $srcdir/lib/$testdir/asm ]; then
> +	asm=$srcdir/lib/$testdir/asm

""'s

>  fi
> +mkdir -p lib
>  ln -s $asm lib/asm
>  
>  # create the config
>  cat <<EOF > config.mak
> +SRCDIR=$srcdir
>  PREFIX=$prefix
>  HOST=$host
>  ARCH=$arch
> -- 
> 2.11.0
>

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 2/8] Makefile: ensure build-head works out-of-src-tree
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07 11:44     ` Andrew Jones
  -1 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 11:44 UTC (permalink / raw)
  To: Alex Bennée
  Cc: pbonzini, kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier

On Thu, Apr 06, 2017 at 08:07:21PM +0100, Alex Bennée wrote:
> Pass -C $(SRCDIR) to the git command that generates the build-head
> stamp.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 16ce297..eba7b28 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -80,7 +80,7 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  
>  -include */.*.d */*/.*.d
>  
> -all: $(shell git rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
> +all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
>  
>  standalone: all
>  	@scripts/mkstandalone.sh
> -- 
> 2.11.0
>

Reviewed-by: Andrew Jones <drjones@redhat.com> 

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 2/8] Makefile: ensure build-head works out-of-src-tree
@ 2017-04-07 11:44     ` Andrew Jones
  0 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 11:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 06, 2017 at 08:07:21PM +0100, Alex Benn?e wrote:
> Pass -C $(SRCDIR) to the git command that generates the build-head
> stamp.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 16ce297..eba7b28 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -80,7 +80,7 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  
>  -include */.*.d */*/.*.d
>  
> -all: $(shell git rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
> +all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
>  
>  standalone: all
>  	@scripts/mkstandalone.sh
> -- 
> 2.11.0
>

Reviewed-by: Andrew Jones <drjones@redhat.com> 

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 1/8] configure: make it run-able from outside source tree
  2017-04-07 11:40     ` Andrew Jones
@ 2017-04-07 11:46       ` Peter Maydell
  -1 siblings, 0 replies; 62+ messages in thread
From: Peter Maydell @ 2017-04-07 11:46 UTC (permalink / raw)
  To: Andrew Jones
  Cc: Alex Bennée, kvm-devel, Marc Zyngier, arm-mail-list,
	Paolo Bonzini, kvmarm

On 7 April 2017 at 12:40, Andrew Jones <drjones@redhat.com> wrote:
> On Thu, Apr 06, 2017 at 08:07:20PM +0100, Alex Bennée wrote:
>> diff --git a/configure b/configure
>> index 8821f37..223809c 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1,5 +1,6 @@
>>  #!/bin/bash
>>
>> +srcdir=$(cd "$(dirname "$0")"; pwd)
>
> Why not just $(dirname "$0")? Any reason the path can't
> be relative?  Also, could use realpath vs. the cd/pwd.

Having srcdir be maybe relative and maybe absolute seems
like a recipe for confusion later on to me -- much better
for it to always be an absolute path, I think.
(Compare how QEMU's configure is careful to absolutize
the source_path variable.)

realpath isn't portable (not on OSX, for instance).

thanks
-- PMM

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 1/8] configure: make it run-able from outside source tree
@ 2017-04-07 11:46       ` Peter Maydell
  0 siblings, 0 replies; 62+ messages in thread
From: Peter Maydell @ 2017-04-07 11:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 7 April 2017 at 12:40, Andrew Jones <drjones@redhat.com> wrote:
> On Thu, Apr 06, 2017 at 08:07:20PM +0100, Alex Benn?e wrote:
>> diff --git a/configure b/configure
>> index 8821f37..223809c 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1,5 +1,6 @@
>>  #!/bin/bash
>>
>> +srcdir=$(cd "$(dirname "$0")"; pwd)
>
> Why not just $(dirname "$0")? Any reason the path can't
> be relative?  Also, could use realpath vs. the cd/pwd.

Having srcdir be maybe relative and maybe absolute seems
like a recipe for confusion later on to me -- much better
for it to always be an absolute path, I think.
(Compare how QEMU's configure is careful to absolutize
the source_path variable.)

realpath isn't portable (not on OSX, for instance).

thanks
-- PMM

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 3/8] Makefile: set VPATH based on SRCDIR
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07 11:56     ` Andrew Jones
  -1 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 11:56 UTC (permalink / raw)
  To: Alex Bennée
  Cc: pbonzini, kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier

On Thu, Apr 06, 2017 at 08:07:22PM +0100, Alex Bennée wrote:
> Setting the VPATH prompts make to search VPATH for source files. There
> are still some fix-ups needed for linking and including other Makefile
> fragments for each architecture.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index eba7b28..80bc57e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -7,6 +7,9 @@ endif
>  
>  include config.mak
>  
> +# Set search path for all sources
> +VPATH=$(SRCDIR)

nit: prefer spaces around the =

> +
>  libdirs-get = $(shell [ -d "lib/$(1)" ] && echo "lib/$(1) lib/$(1)/asm")
>  ARCH_LIBDIRS := $(call libdirs-get,$(ARCH)) $(call libdirs-get,$(TEST_DIR))
>  
> -- 
> 2.11.0
> 

Reviewed-by: Andrew Jones <drjones@redhat.com>

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 3/8] Makefile: set VPATH based on SRCDIR
@ 2017-04-07 11:56     ` Andrew Jones
  0 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 11:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 06, 2017 at 08:07:22PM +0100, Alex Benn?e wrote:
> Setting the VPATH prompts make to search VPATH for source files. There
> are still some fix-ups needed for linking and including other Makefile
> fragments for each architecture.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index eba7b28..80bc57e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -7,6 +7,9 @@ endif
>  
>  include config.mak
>  
> +# Set search path for all sources
> +VPATH=$(SRCDIR)

nit: prefer spaces around the =

> +
>  libdirs-get = $(shell [ -d "lib/$(1)" ] && echo "lib/$(1) lib/$(1)/asm")
>  ARCH_LIBDIRS := $(call libdirs-get,$(ARCH)) $(call libdirs-get,$(TEST_DIR))
>  
> -- 
> 2.11.0
> 

Reviewed-by: Andrew Jones <drjones@redhat.com>

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07 12:20     ` Andrew Jones
  -1 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 12:20 UTC (permalink / raw)
  To: Alex Bennée; +Cc: kvm, marc.zyngier, linux-arm-kernel, pbonzini, kvmarm

On Thu, Apr 06, 2017 at 08:07:23PM +0100, Alex Bennée wrote:
> I would of thought VPATH took care of this but apparently not.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile               | 8 ++++----
>  arm/Makefile           | 2 +-
>  arm/Makefile.arm       | 2 +-
>  arm/Makefile.arm64     | 2 +-
>  powerpc/Makefile       | 2 +-
>  powerpc/Makefile.ppc64 | 2 +-
>  x86/Makefile           | 2 +-
>  x86/Makefile.i386      | 2 +-
>  x86/Makefile.x86_64    | 2 +-
>  9 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 80bc57e..781186e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -32,14 +32,14 @@ cflatobjs := \
>  	lib/stack.o
>  
>  # libfdt paths
> -LIBFDT_objdir = lib/libfdt
> -LIBFDT_srcdir = lib/libfdt
> +LIBFDT_objdir = $(SRCDIR)/lib/libfdt
> +LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
>  LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
>  LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
>  LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))

Can't we just do VPATH += $LIBFDT_srcdir instead?

>  
> -#include architecure specific make rules
> -include $(TEST_DIR)/Makefile
> +#include architecture specific make rules
> +include $(SRCDIR)/$(TEST_DIR)/Makefile

Yeah, it appears VPATH doesn't apply to 'include', and I don't see any
variable that does...  The only way to get make to look elsewhere is
by adding '-I dir' to the make invocation, which we don't want to require.
I guess adding SRCDIR to all include lines, like this patch does, is the
only way to go.

>  
>  # cc-option
>  # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
> diff --git a/arm/Makefile b/arm/Makefile
> index 369a38b..8a007ab 100644
> --- a/arm/Makefile
> +++ b/arm/Makefile
> @@ -1 +1 @@
> -include $(TEST_DIR)/Makefile.$(ARCH)
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
> diff --git a/arm/Makefile.arm b/arm/Makefile.arm
> index 92f3757..6b57284 100644
> --- a/arm/Makefile.arm
> +++ b/arm/Makefile.arm
> @@ -22,6 +22,6 @@ cflatobjs += lib/arm/stack.o
>  # arm specific tests
>  tests =
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
>  
>  arch_clean: arm_clean
> diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
> index 0b0761c..b5fc1ec 100644
> --- a/arm/Makefile.arm64
> +++ b/arm/Makefile.arm64
> @@ -14,7 +14,7 @@ cflatobjs += lib/arm64/spinlock.o
>  # arm64 specific tests
>  tests =
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
>  
>  arch_clean: arm_clean
>  	$(RM) lib/arm64/.*.d
> diff --git a/powerpc/Makefile b/powerpc/Makefile
> index 369a38b..8a007ab 100644
> --- a/powerpc/Makefile
> +++ b/powerpc/Makefile
> @@ -1 +1 @@
> -include $(TEST_DIR)/Makefile.$(ARCH)
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
> diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
> index 3da3a83..3c0294a 100644
> --- a/powerpc/Makefile.ppc64
> +++ b/powerpc/Makefile.ppc64
> @@ -20,7 +20,7 @@ cflatobjs += lib/ppc64/spinlock.o
>  # ppc64 specific tests
>  tests =
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
>  
>  arch_clean: powerpc_clean
>  	$(RM) lib/ppc64/.*.d
> diff --git a/x86/Makefile b/x86/Makefile
> index 369a38b..8a007ab 100644
> --- a/x86/Makefile
> +++ b/x86/Makefile
> @@ -1 +1 @@
> -include $(TEST_DIR)/Makefile.$(ARCH)
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
> diff --git a/x86/Makefile.i386 b/x86/Makefile.i386
> index 284b9e5..d801b80 100644
> --- a/x86/Makefile.i386
> +++ b/x86/Makefile.i386
> @@ -7,4 +7,4 @@ cflatobjs += lib/x86/setjmp32.o
>  tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \
>  	$(TEST_DIR)/cmpxchg8b.flat
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
> diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64
> index 3e2821e..30f82a6 100644
> --- a/x86/Makefile.x86_64
> +++ b/x86/Makefile.x86_64
> @@ -17,7 +17,7 @@ tests += $(TEST_DIR)/vmx.flat
>  tests += $(TEST_DIR)/tscdeadline_latency.flat
>  tests += $(TEST_DIR)/intel-iommu.flat
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
>  
>  $(TEST_DIR)/hyperv_clock.elf: $(TEST_DIR)/hyperv_clock.o
>  
> -- 
> 2.11.0
>

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
@ 2017-04-07 12:20     ` Andrew Jones
  0 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 12:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 06, 2017 at 08:07:23PM +0100, Alex Benn?e wrote:
> I would of thought VPATH took care of this but apparently not.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  Makefile               | 8 ++++----
>  arm/Makefile           | 2 +-
>  arm/Makefile.arm       | 2 +-
>  arm/Makefile.arm64     | 2 +-
>  powerpc/Makefile       | 2 +-
>  powerpc/Makefile.ppc64 | 2 +-
>  x86/Makefile           | 2 +-
>  x86/Makefile.i386      | 2 +-
>  x86/Makefile.x86_64    | 2 +-
>  9 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 80bc57e..781186e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -32,14 +32,14 @@ cflatobjs := \
>  	lib/stack.o
>  
>  # libfdt paths
> -LIBFDT_objdir = lib/libfdt
> -LIBFDT_srcdir = lib/libfdt
> +LIBFDT_objdir = $(SRCDIR)/lib/libfdt
> +LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
>  LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
>  LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
>  LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))

Can't we just do VPATH += $LIBFDT_srcdir instead?

>  
> -#include architecure specific make rules
> -include $(TEST_DIR)/Makefile
> +#include architecture specific make rules
> +include $(SRCDIR)/$(TEST_DIR)/Makefile

Yeah, it appears VPATH doesn't apply to 'include', and I don't see any
variable that does...  The only way to get make to look elsewhere is
by adding '-I dir' to the make invocation, which we don't want to require.
I guess adding SRCDIR to all include lines, like this patch does, is the
only way to go.

>  
>  # cc-option
>  # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
> diff --git a/arm/Makefile b/arm/Makefile
> index 369a38b..8a007ab 100644
> --- a/arm/Makefile
> +++ b/arm/Makefile
> @@ -1 +1 @@
> -include $(TEST_DIR)/Makefile.$(ARCH)
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
> diff --git a/arm/Makefile.arm b/arm/Makefile.arm
> index 92f3757..6b57284 100644
> --- a/arm/Makefile.arm
> +++ b/arm/Makefile.arm
> @@ -22,6 +22,6 @@ cflatobjs += lib/arm/stack.o
>  # arm specific tests
>  tests =
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
>  
>  arch_clean: arm_clean
> diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64
> index 0b0761c..b5fc1ec 100644
> --- a/arm/Makefile.arm64
> +++ b/arm/Makefile.arm64
> @@ -14,7 +14,7 @@ cflatobjs += lib/arm64/spinlock.o
>  # arm64 specific tests
>  tests =
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
>  
>  arch_clean: arm_clean
>  	$(RM) lib/arm64/.*.d
> diff --git a/powerpc/Makefile b/powerpc/Makefile
> index 369a38b..8a007ab 100644
> --- a/powerpc/Makefile
> +++ b/powerpc/Makefile
> @@ -1 +1 @@
> -include $(TEST_DIR)/Makefile.$(ARCH)
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
> diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
> index 3da3a83..3c0294a 100644
> --- a/powerpc/Makefile.ppc64
> +++ b/powerpc/Makefile.ppc64
> @@ -20,7 +20,7 @@ cflatobjs += lib/ppc64/spinlock.o
>  # ppc64 specific tests
>  tests =
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
>  
>  arch_clean: powerpc_clean
>  	$(RM) lib/ppc64/.*.d
> diff --git a/x86/Makefile b/x86/Makefile
> index 369a38b..8a007ab 100644
> --- a/x86/Makefile
> +++ b/x86/Makefile
> @@ -1 +1 @@
> -include $(TEST_DIR)/Makefile.$(ARCH)
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH)
> diff --git a/x86/Makefile.i386 b/x86/Makefile.i386
> index 284b9e5..d801b80 100644
> --- a/x86/Makefile.i386
> +++ b/x86/Makefile.i386
> @@ -7,4 +7,4 @@ cflatobjs += lib/x86/setjmp32.o
>  tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \
>  	$(TEST_DIR)/cmpxchg8b.flat
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
> diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64
> index 3e2821e..30f82a6 100644
> --- a/x86/Makefile.x86_64
> +++ b/x86/Makefile.x86_64
> @@ -17,7 +17,7 @@ tests += $(TEST_DIR)/vmx.flat
>  tests += $(TEST_DIR)/tscdeadline_latency.flat
>  tests += $(TEST_DIR)/intel-iommu.flat
>  
> -include $(TEST_DIR)/Makefile.common
> +include $(SRCDIR)/$(TEST_DIR)/Makefile.common
>  
>  $(TEST_DIR)/hyperv_clock.elf: $(TEST_DIR)/hyperv_clock.o
>  
> -- 
> 2.11.0
>

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 7/8] Makefiles: fix up the x86 build include and link paths
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07 13:31     ` Andrew Jones
  -1 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 13:31 UTC (permalink / raw)
  To: Alex Bennée
  Cc: pbonzini, kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier

On Thu, Apr 06, 2017 at 08:07:26PM +0100, Alex Bennée wrote:
> 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.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile            |  2 +-
>  x86/Makefile.common | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index c9fea88..22da887 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -78,7 +78,7 @@ $(libcflat): $(cflatobjs)
>  	$(AR) rcs $@ $^
>  
>  include $(LIBFDT_srcdir)/Makefile.libfdt
> -$(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt -Wno-sign-compare
> +$(LIBFDT_archive): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -Wno-sign-compare
>  $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  	$(AR) rcs $@ $^
>  
> diff --git a/x86/Makefile.common b/x86/Makefile.common
> index ef6e543..032ed19 100644
> --- a/x86/Makefile.common
> +++ b/x86/Makefile.common
> @@ -17,7 +17,7 @@ cflatobjs += lib/x86/acpi.o
>  cflatobjs += lib/x86/stack.o
>  
>  $(libcflat): LDFLAGS += -nostdlib
> -$(libcflat): CFLAGS += -ffreestanding -I lib
> +$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
>  
>  CFLAGS += -m$(bits)
>  CFLAGS += -O1
> @@ -31,8 +31,8 @@ libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
>  .PRECIOUS: %.elf %.o
>  
>  FLATLIBS = lib/libcflat.a $(libgcc)
> -%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o)
> -	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
> +%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
> +	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
>  		$(filter %.o, $^) $(FLATLIBS)
>  
>  %.flat: %.elf
> @@ -60,10 +60,10 @@ scripts-common += $(TEST_DIR)/unittests.cfg
>  test_cases: $(tests-common) $(tests)
>  
>  
> -$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
> +$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
>  
>  $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
> -	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^
> +	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^
>  
>  $(TEST_DIR)/realmode.o: bits = 32
>  
> -- 
> 2.11.0
>

I'm curious if we can drop this patch by telling VPATH about all the
directories: VPATH += $(SRCDIR)/$(TEST_DIR) $(SRCDIR)/lib ...

If so, then I think the earlier patch that sets VPATH to SRCDIR should
set it to the list of all common dirs, and the arch makefiles will += in
whatever else they need.

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 7/8] Makefiles: fix up the x86 build include and link paths
@ 2017-04-07 13:31     ` Andrew Jones
  0 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 13:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 06, 2017 at 08:07:26PM +0100, Alex Benn?e wrote:
> 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.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  Makefile            |  2 +-
>  x86/Makefile.common | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index c9fea88..22da887 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -78,7 +78,7 @@ $(libcflat): $(cflatobjs)
>  	$(AR) rcs $@ $^
>  
>  include $(LIBFDT_srcdir)/Makefile.libfdt
> -$(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt -Wno-sign-compare
> +$(LIBFDT_archive): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -Wno-sign-compare
>  $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  	$(AR) rcs $@ $^
>  
> diff --git a/x86/Makefile.common b/x86/Makefile.common
> index ef6e543..032ed19 100644
> --- a/x86/Makefile.common
> +++ b/x86/Makefile.common
> @@ -17,7 +17,7 @@ cflatobjs += lib/x86/acpi.o
>  cflatobjs += lib/x86/stack.o
>  
>  $(libcflat): LDFLAGS += -nostdlib
> -$(libcflat): CFLAGS += -ffreestanding -I lib
> +$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
>  
>  CFLAGS += -m$(bits)
>  CFLAGS += -O1
> @@ -31,8 +31,8 @@ libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
>  .PRECIOUS: %.elf %.o
>  
>  FLATLIBS = lib/libcflat.a $(libgcc)
> -%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o)
> -	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
> +%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
> +	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
>  		$(filter %.o, $^) $(FLATLIBS)
>  
>  %.flat: %.elf
> @@ -60,10 +60,10 @@ scripts-common += $(TEST_DIR)/unittests.cfg
>  test_cases: $(tests-common) $(tests)
>  
>  
> -$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
> +$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
>  
>  $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
> -	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^
> +	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^
>  
>  $(TEST_DIR)/realmode.o: bits = 32
>  
> -- 
> 2.11.0
>

I'm curious if we can drop this patch by telling VPATH about all the
directories: VPATH += $(SRCDIR)/$(TEST_DIR) $(SRCDIR)/lib ...

If so, then I think the earlier patch that sets VPATH to SRCDIR should
set it to the list of all common dirs, and the arch makefiles will += in
whatever else they need.

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree
  2017-04-07 10:38       ` Alex Bennée
@ 2017-04-07 13:37         ` Andrew Jones
  -1 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 13:37 UTC (permalink / raw)
  To: Alex Bennée
  Cc: Thomas Huth, pbonzini, kvm, linux-arm-kernel, kvmarm,
	christoffer.dall, marc.zyngier

On Fri, Apr 07, 2017 at 11:38:07AM +0100, Alex Bennée wrote:
> 
> Thomas Huth <thuth@redhat.com> writes:
> 
> > On 06.04.2017 21:07, Alex Bennée wrote:
> >> When doing an out-of-src-tree build we still want access to the
> >> various bits of common script machinery to run. This is handled by the
> >> scripts-common list which sub-builds can add explicit extra stuff to.
> >>
> >> The final rule is conditional so we don't attempt to link files when
> >> we are doing an in-src-tree build.
> >>
> >> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> >> ---
> >>  Makefile            | 13 +++++++++++++
> >>  x86/Makefile.common |  4 ++++
> >>  2 files changed, 17 insertions(+)
> >>
> >> diff --git a/Makefile b/Makefile
> >> index 56598df..c9fea88 100644
> >> --- a/Makefile
> >> +++ b/Makefile
> >> @@ -31,6 +31,10 @@ cflatobjs := \
> >>  	lib/report.o \
> >>  	lib/stack.o
> >>
> >> +# These are scripts we want linked from the source tree
> >> +scripts-common := run_tests.sh \
> >> +	scripts
> >> +
> >>  # libfdt paths
> >>  LIBFDT_objdir = $(SRCDIR)/lib/libfdt
> >>  LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
> >> @@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
> >>  	mkdir -p $(dir $@)
> >>  	$(CC) $(CFLAGS) -c -o $@ $<
> >>
> >> +$(scripts-common): $(SRCDIR)/$@
> >> +	ln -sf $<$@ $@
> >
> > The prerequisite does not seem to work correctly here. I can see that
> > the symlinks are regenerated each time I run make. Even worse, during
> > the second run, there is a
> >
> > ln -sf /home/thuth/devel/kvm-unit-tests/scripts scripts
> >
> > which generates a symlink in the source directory, since the "scripts"
> > symlink already exists!
> >
> > I think you can not use automatic variables like $@ in the prerequisite
> > list, can you?
> >
> > Maybe it would be better to create these symlinks in the configure
> > script already?
> 
> Hmm maybe. The trouble is catching them all. That's why I wanted to have
> something like scripts-common that sub Makefiles could add to.
> 
> We could certainly make the rule a bit more robust against re-linking
> though.

I think I'd prefer configure doing this linking. I don't think we'll
ever have more than

 ln -sf "$srcdir/$testdir/run" $testdir/
 ln -sf "$srcdir/$testdir/unittests.cfg" $testdir/
 ln -sf "$srcdir/run_tests.sh"
 ln -sf "$srcdir/scripts"

(And now I see what we want an absolute path for $srcdir.)

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree
@ 2017-04-07 13:37         ` Andrew Jones
  0 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 13:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 07, 2017 at 11:38:07AM +0100, Alex Benn?e wrote:
> 
> Thomas Huth <thuth@redhat.com> writes:
> 
> > On 06.04.2017 21:07, Alex Benn?e wrote:
> >> When doing an out-of-src-tree build we still want access to the
> >> various bits of common script machinery to run. This is handled by the
> >> scripts-common list which sub-builds can add explicit extra stuff to.
> >>
> >> The final rule is conditional so we don't attempt to link files when
> >> we are doing an in-src-tree build.
> >>
> >> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> >> ---
> >>  Makefile            | 13 +++++++++++++
> >>  x86/Makefile.common |  4 ++++
> >>  2 files changed, 17 insertions(+)
> >>
> >> diff --git a/Makefile b/Makefile
> >> index 56598df..c9fea88 100644
> >> --- a/Makefile
> >> +++ b/Makefile
> >> @@ -31,6 +31,10 @@ cflatobjs := \
> >>  	lib/report.o \
> >>  	lib/stack.o
> >>
> >> +# These are scripts we want linked from the source tree
> >> +scripts-common := run_tests.sh \
> >> +	scripts
> >> +
> >>  # libfdt paths
> >>  LIBFDT_objdir = $(SRCDIR)/lib/libfdt
> >>  LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
> >> @@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
> >>  	mkdir -p $(dir $@)
> >>  	$(CC) $(CFLAGS) -c -o $@ $<
> >>
> >> +$(scripts-common): $(SRCDIR)/$@
> >> +	ln -sf $<$@ $@
> >
> > The prerequisite does not seem to work correctly here. I can see that
> > the symlinks are regenerated each time I run make. Even worse, during
> > the second run, there is a
> >
> > ln -sf /home/thuth/devel/kvm-unit-tests/scripts scripts
> >
> > which generates a symlink in the source directory, since the "scripts"
> > symlink already exists!
> >
> > I think you can not use automatic variables like $@ in the prerequisite
> > list, can you?
> >
> > Maybe it would be better to create these symlinks in the configure
> > script already?
> 
> Hmm maybe. The trouble is catching them all. That's why I wanted to have
> something like scripts-common that sub Makefiles could add to.
> 
> We could certainly make the rule a bit more robust against re-linking
> though.

I think I'd prefer configure doing this linking. I don't think we'll
ever have more than

 ln -sf "$srcdir/$testdir/run" $testdir/
 ln -sf "$srcdir/$testdir/unittests.cfg" $testdir/
 ln -sf "$srcdir/run_tests.sh"
 ln -sf "$srcdir/scripts"

(And now I see what we want an absolute path for $srcdir.)

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 8/8] Makefiles: fix up the arm build include and link paths
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07 13:56     ` Andrew Jones
  -1 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 13:56 UTC (permalink / raw)
  To: Alex Bennée
  Cc: pbonzini, kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier

On Thu, Apr 06, 2017 at 08:07:27PM +0100, Alex Bennée wrote:
> 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.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  arm/Makefile.common     | 15 +++++++++------
>  scripts/asm-offsets.mak |  4 +++-
>  2 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/arm/Makefile.common b/arm/Makefile.common
> index 74c7394..b1fead1 100644
> --- a/arm/Makefile.common
> +++ b/arm/Makefile.common
> @@ -16,7 +16,10 @@ tests-common += $(TEST_DIR)/pmu.flat
>  tests-common += $(TEST_DIR)/gic.flat
>  tests-common += $(TEST_DIR)/psci.flat
>  
> -tests-all = $(tests-common) $(tests)
> +scripts-common += $(TEST_DIR)/run
> +scripts-common += $(TEST_DIR)/unittests.cfg
> +
> +tests-all = $(tests-common) $(tests) $(scripts_common)
>  all: $(tests-all)
>  
>  ##################################################################
> @@ -26,13 +29,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
> @@ -60,11 +63,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..ecf583f 100644
> --- a/scripts/asm-offsets.mak
> +++ b/scripts/asm-offsets.mak
> @@ -29,11 +29,13 @@ define make_asm_offsets
>  endef
>  
>  $(asm-offsets:.h=.s): $(asm-offsets:.h=.c)
> +	mkdir -p $(dir $@)
>  	$(CC) $(CFLAGS) -fverbose-asm -S -o $@ $<

For some reason I'm not a big fan of all these mkdirs getting sprinkled
around.  Maybe we can just have the arch makefiles be sure to create
lib/$(ARCH) first?

>  
>  $(asm-offsets): $(asm-offsets:.h=.s)
>  	$(call make_asm_offsets)
> -	cp -f $(asm-offsets) lib/generated
> +	mkdir -p lib/generated

Could make this directory from configure

> +	cp -f $(asm-offsets) lib/generated/
>  
>  asm_offsets_clean:
>  	$(RM) $(asm-offsets) $(asm-offsets:.h=.s) \
> -- 
> 2.11.0
>

Thanks,
drew 

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 8/8] Makefiles: fix up the arm build include and link paths
@ 2017-04-07 13:56     ` Andrew Jones
  0 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 13:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 06, 2017 at 08:07:27PM +0100, Alex Benn?e wrote:
> 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.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  arm/Makefile.common     | 15 +++++++++------
>  scripts/asm-offsets.mak |  4 +++-
>  2 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/arm/Makefile.common b/arm/Makefile.common
> index 74c7394..b1fead1 100644
> --- a/arm/Makefile.common
> +++ b/arm/Makefile.common
> @@ -16,7 +16,10 @@ tests-common += $(TEST_DIR)/pmu.flat
>  tests-common += $(TEST_DIR)/gic.flat
>  tests-common += $(TEST_DIR)/psci.flat
>  
> -tests-all = $(tests-common) $(tests)
> +scripts-common += $(TEST_DIR)/run
> +scripts-common += $(TEST_DIR)/unittests.cfg
> +
> +tests-all = $(tests-common) $(tests) $(scripts_common)
>  all: $(tests-all)
>  
>  ##################################################################
> @@ -26,13 +29,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
> @@ -60,11 +63,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..ecf583f 100644
> --- a/scripts/asm-offsets.mak
> +++ b/scripts/asm-offsets.mak
> @@ -29,11 +29,13 @@ define make_asm_offsets
>  endef
>  
>  $(asm-offsets:.h=.s): $(asm-offsets:.h=.c)
> +	mkdir -p $(dir $@)
>  	$(CC) $(CFLAGS) -fverbose-asm -S -o $@ $<

For some reason I'm not a big fan of all these mkdirs getting sprinkled
around.  Maybe we can just have the arch makefiles be sure to create
lib/$(ARCH) first?

>  
>  $(asm-offsets): $(asm-offsets:.h=.s)
>  	$(call make_asm_offsets)
> -	cp -f $(asm-offsets) lib/generated
> +	mkdir -p lib/generated

Could make this directory from configure

> +	cp -f $(asm-offsets) lib/generated/
>  
>  asm_offsets_clean:
>  	$(RM) $(asm-offsets) $(asm-offsets:.h=.s) \
> -- 
> 2.11.0
>

Thanks,
drew 

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 8/8] Makefiles: fix up the arm build include and link paths
  2017-04-07 13:56     ` Andrew Jones
@ 2017-04-07 14:29       ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07 14:29 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, marc.zyngier, linux-arm-kernel, pbonzini, kvmarm


Andrew Jones <drjones@redhat.com> writes:

> On Thu, Apr 06, 2017 at 08:07:27PM +0100, Alex Bennée wrote:
>> 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.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  arm/Makefile.common     | 15 +++++++++------
>>  scripts/asm-offsets.mak |  4 +++-
>>  2 files changed, 12 insertions(+), 7 deletions(-)
>>
>> diff --git a/arm/Makefile.common b/arm/Makefile.common
>> index 74c7394..b1fead1 100644
>> --- a/arm/Makefile.common
>> +++ b/arm/Makefile.common
>> @@ -16,7 +16,10 @@ tests-common += $(TEST_DIR)/pmu.flat
>>  tests-common += $(TEST_DIR)/gic.flat
>>  tests-common += $(TEST_DIR)/psci.flat
>>
>> -tests-all = $(tests-common) $(tests)
>> +scripts-common += $(TEST_DIR)/run
>> +scripts-common += $(TEST_DIR)/unittests.cfg
>> +
>> +tests-all = $(tests-common) $(tests) $(scripts_common)
>>  all: $(tests-all)
>>
>>  ##################################################################
>> @@ -26,13 +29,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
>> @@ -60,11 +63,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..ecf583f 100644
>> --- a/scripts/asm-offsets.mak
>> +++ b/scripts/asm-offsets.mak
>> @@ -29,11 +29,13 @@ define make_asm_offsets
>>  endef
>>
>>  $(asm-offsets:.h=.s): $(asm-offsets:.h=.c)
>> +	mkdir -p $(dir $@)
>>  	$(CC) $(CFLAGS) -fverbose-asm -S -o $@ $<
>
> For some reason I'm not a big fan of all these mkdirs getting sprinkled
> around.  Maybe we can just have the arch makefiles be sure to create
> lib/$(ARCH) first?

Yeah I guess its a bit of a hammer to crack a nut. I guess the correct
way to deal with it is to have a proper dependency for build
directories.

I spent some time looking at QEMU's build-systems approach to it but
there was some deep magic involved so I went simple instead.

>>  $(asm-offsets): $(asm-offsets:.h=.s)
>>  	$(call make_asm_offsets)
>> -	cp -f $(asm-offsets) lib/generated
>> +	mkdir -p lib/generated
>
> Could make this directory from configure

Sure. I guess it depends on if we are likely to see other such
directories need creating.

>
>> +	cp -f $(asm-offsets) lib/generated/
>>
>>  asm_offsets_clean:
>>  	$(RM) $(asm-offsets) $(asm-offsets:.h=.s) \
>> --
>> 2.11.0
>>
>
> Thanks,
> drew


--
Alex Bennée
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 8/8] Makefiles: fix up the arm build include and link paths
@ 2017-04-07 14:29       ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07 14:29 UTC (permalink / raw)
  To: linux-arm-kernel


Andrew Jones <drjones@redhat.com> writes:

> On Thu, Apr 06, 2017 at 08:07:27PM +0100, Alex Benn?e wrote:
>> 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.
>>
>> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
>> ---
>>  arm/Makefile.common     | 15 +++++++++------
>>  scripts/asm-offsets.mak |  4 +++-
>>  2 files changed, 12 insertions(+), 7 deletions(-)
>>
>> diff --git a/arm/Makefile.common b/arm/Makefile.common
>> index 74c7394..b1fead1 100644
>> --- a/arm/Makefile.common
>> +++ b/arm/Makefile.common
>> @@ -16,7 +16,10 @@ tests-common += $(TEST_DIR)/pmu.flat
>>  tests-common += $(TEST_DIR)/gic.flat
>>  tests-common += $(TEST_DIR)/psci.flat
>>
>> -tests-all = $(tests-common) $(tests)
>> +scripts-common += $(TEST_DIR)/run
>> +scripts-common += $(TEST_DIR)/unittests.cfg
>> +
>> +tests-all = $(tests-common) $(tests) $(scripts_common)
>>  all: $(tests-all)
>>
>>  ##################################################################
>> @@ -26,13 +29,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
>> @@ -60,11 +63,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..ecf583f 100644
>> --- a/scripts/asm-offsets.mak
>> +++ b/scripts/asm-offsets.mak
>> @@ -29,11 +29,13 @@ define make_asm_offsets
>>  endef
>>
>>  $(asm-offsets:.h=.s): $(asm-offsets:.h=.c)
>> +	mkdir -p $(dir $@)
>>  	$(CC) $(CFLAGS) -fverbose-asm -S -o $@ $<
>
> For some reason I'm not a big fan of all these mkdirs getting sprinkled
> around.  Maybe we can just have the arch makefiles be sure to create
> lib/$(ARCH) first?

Yeah I guess its a bit of a hammer to crack a nut. I guess the correct
way to deal with it is to have a proper dependency for build
directories.

I spent some time looking at QEMU's build-systems approach to it but
there was some deep magic involved so I went simple instead.

>>  $(asm-offsets): $(asm-offsets:.h=.s)
>>  	$(call make_asm_offsets)
>> -	cp -f $(asm-offsets) lib/generated
>> +	mkdir -p lib/generated
>
> Could make this directory from configure

Sure. I guess it depends on if we are likely to see other such
directories need creating.

>
>> +	cp -f $(asm-offsets) lib/generated/
>>
>>  asm_offsets_clean:
>>  	$(RM) $(asm-offsets) $(asm-offsets:.h=.s) \
>> --
>> 2.11.0
>>
>
> Thanks,
> drew


--
Alex Benn?e

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 7/8] Makefiles: fix up the x86 build include and link paths
  2017-04-07 13:31     ` Andrew Jones
@ 2017-04-07 14:30       ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07 14:30 UTC (permalink / raw)
  To: Andrew Jones
  Cc: pbonzini, kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier


Andrew Jones <drjones@redhat.com> writes:

> On Thu, Apr 06, 2017 at 08:07:26PM +0100, Alex Bennée wrote:
>> 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.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  Makefile            |  2 +-
>>  x86/Makefile.common | 10 +++++-----
>>  2 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index c9fea88..22da887 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -78,7 +78,7 @@ $(libcflat): $(cflatobjs)
>>  	$(AR) rcs $@ $^
>>
>>  include $(LIBFDT_srcdir)/Makefile.libfdt
>> -$(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt -Wno-sign-compare
>> +$(LIBFDT_archive): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -Wno-sign-compare
>>  $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>>  	$(AR) rcs $@ $^
>>
>> diff --git a/x86/Makefile.common b/x86/Makefile.common
>> index ef6e543..032ed19 100644
>> --- a/x86/Makefile.common
>> +++ b/x86/Makefile.common
>> @@ -17,7 +17,7 @@ cflatobjs += lib/x86/acpi.o
>>  cflatobjs += lib/x86/stack.o
>>
>>  $(libcflat): LDFLAGS += -nostdlib
>> -$(libcflat): CFLAGS += -ffreestanding -I lib
>> +$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
>>
>>  CFLAGS += -m$(bits)
>>  CFLAGS += -O1
>> @@ -31,8 +31,8 @@ libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
>>  .PRECIOUS: %.elf %.o
>>
>>  FLATLIBS = lib/libcflat.a $(libgcc)
>> -%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o)
>> -	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
>> +%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
>> +	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
>>  		$(filter %.o, $^) $(FLATLIBS)
>>
>>  %.flat: %.elf
>> @@ -60,10 +60,10 @@ scripts-common += $(TEST_DIR)/unittests.cfg
>>  test_cases: $(tests-common) $(tests)
>>
>>
>> -$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
>> +$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
>>
>>  $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
>> -	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^
>> +	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^
>>
>>  $(TEST_DIR)/realmode.o: bits = 32
>>
>> --
>> 2.11.0
>>
>
> I'm curious if we can drop this patch by telling VPATH about all the
> directories: VPATH += $(SRCDIR)/$(TEST_DIR) $(SRCDIR)/lib ...
>
> If so, then I think the earlier patch that sets VPATH to SRCDIR should
> set it to the list of all common dirs, and the arch makefiles will += in
> whatever else they need.

I'll look into it.

--
Alex Bennée

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 7/8] Makefiles: fix up the x86 build include and link paths
@ 2017-04-07 14:30       ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-04-07 14:30 UTC (permalink / raw)
  To: linux-arm-kernel


Andrew Jones <drjones@redhat.com> writes:

> On Thu, Apr 06, 2017 at 08:07:26PM +0100, Alex Benn?e wrote:
>> 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.
>>
>> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
>> ---
>>  Makefile            |  2 +-
>>  x86/Makefile.common | 10 +++++-----
>>  2 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index c9fea88..22da887 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -78,7 +78,7 @@ $(libcflat): $(cflatobjs)
>>  	$(AR) rcs $@ $^
>>
>>  include $(LIBFDT_srcdir)/Makefile.libfdt
>> -$(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt -Wno-sign-compare
>> +$(LIBFDT_archive): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -Wno-sign-compare
>>  $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>>  	$(AR) rcs $@ $^
>>
>> diff --git a/x86/Makefile.common b/x86/Makefile.common
>> index ef6e543..032ed19 100644
>> --- a/x86/Makefile.common
>> +++ b/x86/Makefile.common
>> @@ -17,7 +17,7 @@ cflatobjs += lib/x86/acpi.o
>>  cflatobjs += lib/x86/stack.o
>>
>>  $(libcflat): LDFLAGS += -nostdlib
>> -$(libcflat): CFLAGS += -ffreestanding -I lib
>> +$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
>>
>>  CFLAGS += -m$(bits)
>>  CFLAGS += -O1
>> @@ -31,8 +31,8 @@ libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
>>  .PRECIOUS: %.elf %.o
>>
>>  FLATLIBS = lib/libcflat.a $(libgcc)
>> -%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o)
>> -	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
>> +%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
>> +	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
>>  		$(filter %.o, $^) $(FLATLIBS)
>>
>>  %.flat: %.elf
>> @@ -60,10 +60,10 @@ scripts-common += $(TEST_DIR)/unittests.cfg
>>  test_cases: $(tests-common) $(tests)
>>
>>
>> -$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
>> +$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
>>
>>  $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
>> -	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^
>> +	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^
>>
>>  $(TEST_DIR)/realmode.o: bits = 32
>>
>> --
>> 2.11.0
>>
>
> I'm curious if we can drop this patch by telling VPATH about all the
> directories: VPATH += $(SRCDIR)/$(TEST_DIR) $(SRCDIR)/lib ...
>
> If so, then I think the earlier patch that sets VPATH to SRCDIR should
> set it to the list of all common dirs, and the arch makefiles will += in
> whatever else they need.

I'll look into it.

--
Alex Benn?e

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-07 14:42     ` Andrew Jones
  -1 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 14:42 UTC (permalink / raw)
  To: Alex Bennée; +Cc: kvm, marc.zyngier, linux-arm-kernel, pbonzini, kvmarm

On Thu, Apr 06, 2017 at 08:07:24PM +0100, Alex Bennée wrote:
> This is fairly direct way of ensuring the target build directories are
> created before we build a binary blob. mkdir -p fails gracefully if
> the directory is already there.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 781186e..56598df 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -79,8 +79,13 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  	$(AR) rcs $@ $^
>  
>  %.o: %.S
> +	mkdir -p $(dir $@)
>  	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
>  
> +%.o: %.c
> +	mkdir -p $(dir $@)
> +	$(CC) $(CFLAGS) -c -o $@ $<

This rule will override any arch makefile %.o rule.  I don't think we want
to do that.  And I guess that means we should move the '%.o: %.S' rule up
above the include $(TEST_DIR)/Makefile so we don't override those either.

> +
>  -include */.*.d */*/.*.d
>  
>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
> -- 
> 2.11.0
>

I'd prefer we just have a couple places where we do mkdir:  one in the
common Makefile for common dirs (BUILD_DIRS) and one in the arch makefile
for arch dirs (ARCH_BUILD_DIRS).

The example linked below looks like something we might be able to apply.

https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html#Prerequisite-Types

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
@ 2017-04-07 14:42     ` Andrew Jones
  0 siblings, 0 replies; 62+ messages in thread
From: Andrew Jones @ 2017-04-07 14:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 06, 2017 at 08:07:24PM +0100, Alex Benn?e wrote:
> This is fairly direct way of ensuring the target build directories are
> created before we build a binary blob. mkdir -p fails gracefully if
> the directory is already there.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  Makefile | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 781186e..56598df 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -79,8 +79,13 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  	$(AR) rcs $@ $^
>  
>  %.o: %.S
> +	mkdir -p $(dir $@)
>  	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
>  
> +%.o: %.c
> +	mkdir -p $(dir $@)
> +	$(CC) $(CFLAGS) -c -o $@ $<

This rule will override any arch makefile %.o rule.  I don't think we want
to do that.  And I guess that means we should move the '%.o: %.S' rule up
above the include $(TEST_DIR)/Makefile so we don't override those either.

> +
>  -include */.*.d */*/.*.d
>  
>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
> -- 
> 2.11.0
>

I'd prefer we just have a couple places where we do mkdir:  one in the
common Makefile for common dirs (BUILD_DIRS) and one in the arch makefile
for arch dirs (ARCH_BUILD_DIRS).

The example linked below looks like something we might be able to apply.

https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html#Prerequisite-Types

Thanks,
drew

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
  2017-04-07 12:20     ` Andrew Jones
@ 2017-04-27 15:54       ` Paolo Bonzini
  -1 siblings, 0 replies; 62+ messages in thread
From: Paolo Bonzini @ 2017-04-27 15:54 UTC (permalink / raw)
  To: Andrew Jones, Alex Bennée
  Cc: marc.zyngier, linux-arm-kernel, kvm, kvmarm



On 07/04/2017 14:20, Andrew Jones wrote:
>> -LIBFDT_objdir = lib/libfdt
>> -LIBFDT_srcdir = lib/libfdt
>> +LIBFDT_objdir = $(SRCDIR)/lib/libfdt
>> +LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
>>  LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
>>  LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
>>  LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
> Can't we just do VPATH += $LIBFDT_srcdir instead?

That would search for every file in the lib/libfdt subdirectory of the
source directory, while here the desired prefix is just $(SRCDIR).

Paolo

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles
@ 2017-04-27 15:54       ` Paolo Bonzini
  0 siblings, 0 replies; 62+ messages in thread
From: Paolo Bonzini @ 2017-04-27 15:54 UTC (permalink / raw)
  To: linux-arm-kernel



On 07/04/2017 14:20, Andrew Jones wrote:
>> -LIBFDT_objdir = lib/libfdt
>> -LIBFDT_srcdir = lib/libfdt
>> +LIBFDT_objdir = $(SRCDIR)/lib/libfdt
>> +LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
>>  LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
>>  LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
>>  LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
> Can't we just do VPATH += $LIBFDT_srcdir instead?

That would search for every file in the lib/libfdt subdirectory of the
source directory, while here the desired prefix is just $(SRCDIR).

Paolo

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
  2017-04-06 19:07   ` Alex Bennée
@ 2017-04-27 15:57     ` Paolo Bonzini
  -1 siblings, 0 replies; 62+ messages in thread
From: Paolo Bonzini @ 2017-04-27 15:57 UTC (permalink / raw)
  To: Alex Bennée, drjones; +Cc: marc.zyngier, linux-arm-kernel, kvm, kvmarm



On 06/04/2017 21:07, Alex Bennée wrote:
> This is fairly direct way of ensuring the target build directories are
> created before we build a binary blob. mkdir -p fails gracefully if
> the directory is already there.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 781186e..56598df 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -79,8 +79,13 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  	$(AR) rcs $@ $^
>  
>  %.o: %.S
> +	mkdir -p $(dir $@)

Should this use @ for cleanliness?

Paolo

>  	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
>  
> +%.o: %.c
> +	mkdir -p $(dir $@)
> +	$(CC) $(CFLAGS) -c -o $@ $<
> +
>  -include */.*.d */*/.*.d
>  
>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
> 
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
@ 2017-04-27 15:57     ` Paolo Bonzini
  0 siblings, 0 replies; 62+ messages in thread
From: Paolo Bonzini @ 2017-04-27 15:57 UTC (permalink / raw)
  To: linux-arm-kernel



On 06/04/2017 21:07, Alex Benn?e wrote:
> This is fairly direct way of ensuring the target build directories are
> created before we build a binary blob. mkdir -p fails gracefully if
> the directory is already there.
> 
> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
> ---
>  Makefile | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 781186e..56598df 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -79,8 +79,13 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>  	$(AR) rcs $@ $^
>  
>  %.o: %.S
> +	mkdir -p $(dir $@)

Should this use @ for cleanliness?

Paolo

>  	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
>  
> +%.o: %.c
> +	mkdir -p $(dir $@)
> +	$(CC) $(CFLAGS) -c -o $@ $<
> +
>  -include */.*.d */*/.*.d
>  
>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
> 

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
  2017-04-27 15:57     ` Paolo Bonzini
@ 2017-05-11 15:30       ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-05-11 15:30 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: drjones, kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier


Paolo Bonzini <pbonzini@redhat.com> writes:

> On 06/04/2017 21:07, Alex Bennée wrote:
>> This is fairly direct way of ensuring the target build directories are
>> created before we build a binary blob. mkdir -p fails gracefully if
>> the directory is already there.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  Makefile | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/Makefile b/Makefile
>> index 781186e..56598df 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -79,8 +79,13 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>>  	$(AR) rcs $@ $^
>>
>>  %.o: %.S
>> +	mkdir -p $(dir $@)
>
> Should this use @ for cleanliness?

I'm not sure I follow. Did you mean use $(@D) directly?

>
> Paolo
>
>>  	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
>>
>> +%.o: %.c
>> +	mkdir -p $(dir $@)
>> +	$(CC) $(CFLAGS) -c -o $@ $<
>> +
>>  -include */.*.d */*/.*.d
>>
>>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
>>


--
Alex Bennée

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
@ 2017-05-11 15:30       ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-05-11 15:30 UTC (permalink / raw)
  To: linux-arm-kernel


Paolo Bonzini <pbonzini@redhat.com> writes:

> On 06/04/2017 21:07, Alex Benn?e wrote:
>> This is fairly direct way of ensuring the target build directories are
>> created before we build a binary blob. mkdir -p fails gracefully if
>> the directory is already there.
>>
>> Signed-off-by: Alex Benn?e <alex.bennee@linaro.org>
>> ---
>>  Makefile | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/Makefile b/Makefile
>> index 781186e..56598df 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -79,8 +79,13 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
>>  	$(AR) rcs $@ $^
>>
>>  %.o: %.S
>> +	mkdir -p $(dir $@)
>
> Should this use @ for cleanliness?

I'm not sure I follow. Did you mean use $(@D) directly?

>
> Paolo
>
>>  	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
>>
>> +%.o: %.c
>> +	mkdir -p $(dir $@)
>> +	$(CC) $(CFLAGS) -c -o $@ $<
>> +
>>  -include */.*.d */*/.*.d
>>
>>  all: $(shell git -C $(SRCDIR) rev-parse --verify --short=8 HEAD >build-head 2>/dev/null)
>>


--
Alex Benn?e

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
  2017-05-11 15:30       ` Alex Bennée
@ 2017-05-12 10:36         ` Paolo Bonzini
  -1 siblings, 0 replies; 62+ messages in thread
From: Paolo Bonzini @ 2017-05-12 10:36 UTC (permalink / raw)
  To: Alex Bennée; +Cc: kvm, marc.zyngier, linux-arm-kernel, kvmarm



On 11/05/2017 17:30, Alex Bennée wrote:
>>>
>>>  %.o: %.S
>>> +	mkdir -p $(dir $@)
>> Should this use @ for cleanliness?
> > I'm not sure I follow. Did you mean use $(@D) directly?

That too, but I was thinking of using "@mkdir" to avoid spamming the
output with mkdir commands.

Paolo
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
@ 2017-05-12 10:36         ` Paolo Bonzini
  0 siblings, 0 replies; 62+ messages in thread
From: Paolo Bonzini @ 2017-05-12 10:36 UTC (permalink / raw)
  To: linux-arm-kernel



On 11/05/2017 17:30, Alex Benn?e wrote:
>>>
>>>  %.o: %.S
>>> +	mkdir -p $(dir $@)
>> Should this use @ for cleanliness?
> > I'm not sure I follow. Did you mean use $(@D) directly?

That too, but I was thinking of using "@mkdir" to avoid spamming the
output with mkdir commands.

Paolo

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
  2017-05-12 10:36         ` Paolo Bonzini
@ 2017-05-12 11:14           ` Alex Bennée
  -1 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-05-12 11:14 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: drjones, kvm, linux-arm-kernel, kvmarm, christoffer.dall, marc.zyngier


Paolo Bonzini <pbonzini@redhat.com> writes:

> On 11/05/2017 17:30, Alex Bennée wrote:
>>>>
>>>>  %.o: %.S
>>>> +	mkdir -p $(dir $@)
>>> Should this use @ for cleanliness?
>> > I'm not sure I follow. Did you mean use $(@D) directly?
>
> That too, but I was thinking of using "@mkdir" to avoid spamming the
> output with mkdir commands.

Gotcha.

>
> Paolo


--
Alex Bennée

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets
@ 2017-05-12 11:14           ` Alex Bennée
  0 siblings, 0 replies; 62+ messages in thread
From: Alex Bennée @ 2017-05-12 11:14 UTC (permalink / raw)
  To: linux-arm-kernel


Paolo Bonzini <pbonzini@redhat.com> writes:

> On 11/05/2017 17:30, Alex Benn?e wrote:
>>>>
>>>>  %.o: %.S
>>>> +	mkdir -p $(dir $@)
>>> Should this use @ for cleanliness?
>> > I'm not sure I follow. Did you mean use $(@D) directly?
>
> That too, but I was thinking of using "@mkdir" to avoid spamming the
> output with mkdir commands.

Gotcha.

>
> Paolo


--
Alex Benn?e

^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2017-05-12 11:14 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06 19:07 [RFC kvm-unit-tests PATCH 0/8] Support for out-of-tree builds Alex Bennée
2017-04-06 19:07 ` Alex Bennée
2017-04-06 19:07 ` [RFC kvm-unit-tests PATCH 1/8] configure: make it run-able from outside source tree Alex Bennée
2017-04-06 19:07   ` Alex Bennée
2017-04-07 11:40   ` Andrew Jones
2017-04-07 11:40     ` Andrew Jones
2017-04-07 11:46     ` Peter Maydell
2017-04-07 11:46       ` Peter Maydell
2017-04-06 19:07 ` [RFC kvm-unit-tests PATCH 2/8] Makefile: ensure build-head works out-of-src-tree Alex Bennée
2017-04-06 19:07   ` Alex Bennée
2017-04-07 11:44   ` Andrew Jones
2017-04-07 11:44     ` Andrew Jones
2017-04-06 19:07 ` [RFC kvm-unit-tests PATCH 3/8] Makefile: set VPATH based on SRCDIR Alex Bennée
2017-04-06 19:07   ` Alex Bennée
2017-04-07 11:56   ` Andrew Jones
2017-04-07 11:56     ` Andrew Jones
2017-04-06 19:07 ` [RFC kvm-unit-tests PATCH 4/8] Makefiles: use explicit path for including sub-Makefiles Alex Bennée
2017-04-06 19:07   ` Alex Bennée
2017-04-07  8:53   ` Thomas Huth
2017-04-07  8:53     ` Thomas Huth
2017-04-07  9:21     ` Alex Bennée
2017-04-07  9:21       ` Alex Bennée
2017-04-07 12:20   ` Andrew Jones
2017-04-07 12:20     ` Andrew Jones
2017-04-27 15:54     ` Paolo Bonzini
2017-04-27 15:54       ` Paolo Bonzini
2017-04-06 19:07 ` [RFC kvm-unit-tests PATCH 5/8] Makefile: add explicit mkdir for .o targets Alex Bennée
2017-04-06 19:07   ` Alex Bennée
2017-04-07 14:42   ` Andrew Jones
2017-04-07 14:42     ` Andrew Jones
2017-04-27 15:57   ` Paolo Bonzini
2017-04-27 15:57     ` Paolo Bonzini
2017-05-11 15:30     ` Alex Bennée
2017-05-11 15:30       ` Alex Bennée
2017-05-12 10:36       ` Paolo Bonzini
2017-05-12 10:36         ` Paolo Bonzini
2017-05-12 11:14         ` Alex Bennée
2017-05-12 11:14           ` Alex Bennée
2017-04-06 19:07 ` [RFC kvm-unit-tests PATCH 6/8] Makefiles: handle linking of scripts into build-tree Alex Bennée
2017-04-06 19:07   ` Alex Bennée
2017-04-07  9:22   ` Thomas Huth
2017-04-07  9:22     ` Thomas Huth
2017-04-07 10:38     ` Alex Bennée
2017-04-07 10:38       ` Alex Bennée
2017-04-07 13:37       ` Andrew Jones
2017-04-07 13:37         ` Andrew Jones
2017-04-06 19:07 ` [RFC kvm-unit-tests PATCH 7/8] Makefiles: fix up the x86 build include and link paths Alex Bennée
2017-04-06 19:07   ` Alex Bennée
2017-04-07 13:31   ` Andrew Jones
2017-04-07 13:31     ` Andrew Jones
2017-04-07 14:30     ` Alex Bennée
2017-04-07 14:30       ` Alex Bennée
2017-04-06 19:07 ` [RFC kvm-unit-tests PATCH 8/8] Makefiles: fix up the arm " Alex Bennée
2017-04-06 19:07   ` Alex Bennée
2017-04-07  6:58   ` [RFC kvm-unit-tests PATCH 9/8] Makefiles: Fix up the powerpc " Thomas Huth
2017-04-07  6:58     ` Thomas Huth
2017-04-07  8:02     ` Alex Bennée
2017-04-07  8:02       ` Alex Bennée
2017-04-07 13:56   ` [RFC kvm-unit-tests PATCH 8/8] Makefiles: fix up the arm " Andrew Jones
2017-04-07 13:56     ` Andrew Jones
2017-04-07 14:29     ` Alex Bennée
2017-04-07 14:29       ` Alex Bennée

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.