All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH boot-wrapper] Fix out-of-tree build
@ 2018-04-23 16:32 Jean-Philippe Brucker
  2018-04-26 12:57 ` Mark Rutland
  0 siblings, 1 reply; 2+ messages in thread
From: Jean-Philippe Brucker @ 2018-04-23 16:32 UTC (permalink / raw)
  To: linux-arm-kernel

Adding AArch32 support to the boot-wrapper changed the source layout and
broke out-of-tree build. This patch allows to put all generated files
into a separate directory again, and build multiple images in parallel:

    mkdir build/ && cd build/
    ~/src/boot-wrapper-aarch64/configure ...
    make

Make attempts to output object files into build/arch/aarchXX/, but fails
because that folder doesn't exist in the build directory. Add mkdir as
prerequisite for any *.o target in the arch folder.

So that Make doesn't confuse the destination folder with the source,
override VPATH to only affect .S and .c sources.

And set $(ARCH_SRC) as order-only-prerequisite (after a '|'). Otherwise
Make would rebuild all objects whenever the timestamp of $(ARCH_SRC)
changes, which is every time an object is rebuilt...

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 Makefile.am | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 49cfa84..d3b5188 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -118,7 +118,7 @@ CHOSEN_NODE	:= chosen {						\
 		   };
 
 CPPFLAGS	+= $(INITRD_FLAGS)
-CFLAGS		+= -Iinclude/ -I$(ARCH_SRC)/include/
+CFLAGS		+= -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/
 CFLAGS		+= -Wall -fomit-frame-pointer
 CFLAGS		+= -ffunction-sections -fdata-sections
 LDFLAGS		+= --gc-sections
@@ -126,6 +126,12 @@ LDFLAGS		+= --gc-sections
 OFILES		+= boot_common.o bakery_lock.o platform.o $(GIC) cache.o lib.o
 OFILES		+= $(addprefix $(ARCH_SRC),boot.o stack.o $(BOOTMETHOD) utils.o)
 
+# Don't lookup all prerequisites in $(top_srcdir), only the source files. When
+# building outside the source tree $(ARCH_SRC) needs to be created.
+VPATH		=
+vpath %.c $(top_srcdir)
+vpath %.S $(top_srcdir)
+
 all: $(IMAGE)
 
 CLEANFILES = $(IMAGE) linux-system.axf xen-system.axf $(OFILES) model.lds fdt.dtb
@@ -133,7 +139,10 @@ CLEANFILES = $(IMAGE) linux-system.axf xen-system.axf $(OFILES) model.lds fdt.dt
 $(IMAGE): $(OFILES) model.lds fdt.dtb $(KERNEL_IMAGE) $(FILESYSTEM) $(XEN_IMAGE)
 	$(LD) $(LDFLAGS) $(OFILES) -o $@ --script=model.lds
 
-%.o: %.S Makefile
+$(ARCH_SRC):
+	$(MKDIR_P) $@
+
+%.o: %.S Makefile | $(ARCH_SRC)
 	$(CC) $(CPPFLAGS) -D__ASSEMBLY__ $(CFLAGS) $(DEFINES) -c -o $@ $<
 
 %.o: %.c Makefile
-- 
2.17.0

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

* [PATCH boot-wrapper] Fix out-of-tree build
  2018-04-23 16:32 [PATCH boot-wrapper] Fix out-of-tree build Jean-Philippe Brucker
@ 2018-04-26 12:57 ` Mark Rutland
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Rutland @ 2018-04-26 12:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 23, 2018 at 05:32:06PM +0100, Jean-Philippe Brucker wrote:
> Adding AArch32 support to the boot-wrapper changed the source layout and
> broke out-of-tree build. This patch allows to put all generated files
> into a separate directory again, and build multiple images in parallel:
> 
>     mkdir build/ && cd build/
>     ~/src/boot-wrapper-aarch64/configure ...
>     make
> 
> Make attempts to output object files into build/arch/aarchXX/, but fails
> because that folder doesn't exist in the build directory. Add mkdir as
> prerequisite for any *.o target in the arch folder.
> 
> So that Make doesn't confuse the destination folder with the source,
> override VPATH to only affect .S and .c sources.
> 
> And set $(ARCH_SRC) as order-only-prerequisite (after a '|'). Otherwise
> Make would rebuild all objects whenever the timestamp of $(ARCH_SRC)
> changes, which is every time an object is rebuilt...
> 
> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

Applied, thanks!

Mark.

> ---
>  Makefile.am | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 49cfa84..d3b5188 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -118,7 +118,7 @@ CHOSEN_NODE	:= chosen {						\
>  		   };
>  
>  CPPFLAGS	+= $(INITRD_FLAGS)
> -CFLAGS		+= -Iinclude/ -I$(ARCH_SRC)/include/
> +CFLAGS		+= -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/
>  CFLAGS		+= -Wall -fomit-frame-pointer
>  CFLAGS		+= -ffunction-sections -fdata-sections
>  LDFLAGS		+= --gc-sections
> @@ -126,6 +126,12 @@ LDFLAGS		+= --gc-sections
>  OFILES		+= boot_common.o bakery_lock.o platform.o $(GIC) cache.o lib.o
>  OFILES		+= $(addprefix $(ARCH_SRC),boot.o stack.o $(BOOTMETHOD) utils.o)
>  
> +# Don't lookup all prerequisites in $(top_srcdir), only the source files. When
> +# building outside the source tree $(ARCH_SRC) needs to be created.
> +VPATH		=
> +vpath %.c $(top_srcdir)
> +vpath %.S $(top_srcdir)
> +
>  all: $(IMAGE)
>  
>  CLEANFILES = $(IMAGE) linux-system.axf xen-system.axf $(OFILES) model.lds fdt.dtb
> @@ -133,7 +139,10 @@ CLEANFILES = $(IMAGE) linux-system.axf xen-system.axf $(OFILES) model.lds fdt.dt
>  $(IMAGE): $(OFILES) model.lds fdt.dtb $(KERNEL_IMAGE) $(FILESYSTEM) $(XEN_IMAGE)
>  	$(LD) $(LDFLAGS) $(OFILES) -o $@ --script=model.lds
>  
> -%.o: %.S Makefile
> +$(ARCH_SRC):
> +	$(MKDIR_P) $@
> +
> +%.o: %.S Makefile | $(ARCH_SRC)
>  	$(CC) $(CPPFLAGS) -D__ASSEMBLY__ $(CFLAGS) $(DEFINES) -c -o $@ $<
>  
>  %.o: %.c Makefile
> -- 
> 2.17.0
> 

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

end of thread, other threads:[~2018-04-26 12:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23 16:32 [PATCH boot-wrapper] Fix out-of-tree build Jean-Philippe Brucker
2018-04-26 12:57 ` Mark Rutland

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.