Skip to contentSkip to conversation

tools: ynl: Fix out-of-tree build for ynltool

PATCH Applied Maxime Chevallier (Netdev Foundation) 3 participants 3 messages Sep 11 – Sep 15

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tools: ynl: Fix out-of-tree build for ynltool

After the blamed commit, running a out-of-tree build for ynltool fails :

  # make -C tools/net/ynl/ynltool O=/tmp/o1
  make: Entering directory 'tools/net/ynl/ynltool'
  make: *** No rule to make target '/tmp/o1/json_writer.o', needed by '/tmp/o1/ynltool'.  Stop.

ynltool's Makefile correctly accounts for $(OUTPUT) to get the list of object files to generate :

OBJS := $(patsubst %.c,$(OUTPUT)%.o,$(SRCS))

but it never actually set $(OUTPUT) before the blamed commit, meaning that out-of-tree buils of ynltool were always actually in-tree.

Now, the O= parameter is correctly accounted for, and the %o: %c rule fails.

Let's update the %o: %c rule to also use $(OUTPUT), as well as the .d file expansion so that any header change is taken into account.

Fixes 917f713b4ec4 ("tools: ynl: Allow cross-compiling ynl and associated tools")

---
V2: Add include $(wildcard $(OUTPUT)*.d), from Nicolai

V1: https://lore.kernel.org/netdev/[email protected]/

 tools/net/ynl/ynltool/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/net/ynl/ynltool/Makefile +2 -2
index b8c67cdb4fdf..e79b8af353c3 100644
@@ -23,7 +23,7 @@ OBJS := $(patsubst %.c,$(OUTPUT)%.o,$(SRCS))
 
 YNLTOOL := $(OUTPUT)ynltool
 
-include $(wildcard *.d)
+include $(wildcard $(OUTPUT)*.d)
 
 all: $(YNLTOOL)
 
@@ -31,7 +31,7 @@ $(YNLTOOL): ../libynl.a $(OBJS)
 	$(Q)echo -e "\tLINK $@"
 	$(Q)$(CC) $(CFLAGS) -o $@ $(OBJS) ../libynl.a -lm
 
-%.o: %.c ../libynl.a
+$(OUTPUT)%.o: %.c ../libynl.a
 	$(Q)echo -e "\tCC $@"
 	$(Q)$(COMPILE.c) -MMD -c -o $@ $<
 
Signature · 1 line
2.55.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 45 lines · Maxime Chevallier (Netdev Foundation)

After the blamed commit, running a out-of-tree build for ynltool fails :

 # make -C tools/net/ynl/ynltool O=/tmp/o1
 make: Entering directory 'tools/net/ynl/ynltool'
 make: *** No rule to make target '/tmp/o1/json_writer.o', needed by '/tmp/o1/ynltool'.  Stop.

ynltool's Makefile correctly accounts for $(OUTPUT) to get the list of object files to generate :

OBJS := $(patsubst %.c,$(OUTPUT)%.o,$(SRCS))

but it never actually set $(OUTPUT) before the blamed commit, meaning that out-of-tree buils of ynltool were always actually in-tree.

Now, the O= parameter is correctly accounted for, and the %o: %c rule fails.

Let's update the %o: %c rule to also use $(OUTPUT), as well as the .d file expansion so that any header change is taken into account.

Fixes 917f713b4ec4 ("tools: ynl: Allow cross-compiling ynl and associated tools")

---
V2: Add include $(wildcard $(OUTPUT)*.d), from Nicolai

V1: https://lore.kernel.org/netdev/[email protected]/

tools/net/ynl/ynltool/Makefile | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
tools/net/ynl/ynltool/Makefile +0 -0
index b8c67cdb4fdf..e79b8af353c3 100644
@@ -23,7 +23,7 @@ OBJS := $(patsubst %.c,$(OUTPUT)%.o,$(SRCS))
 

YNLTOOL := $(OUTPUT)ynltool

tools/net/ynl/ynltool/Makefile +1 -1
-include $(wildcard *.d)
+include $(wildcard $(OUTPUT)*.d)

all: $(YNLTOOL)

tools/net/ynl/ynltool/Makefile $(YNLTOOL): ../libynl.a $(OBJS) · line 37

Quoted 8 lines
tools/net/ynl/ynltool/Makefile +1 -1
@@ -31,7 +31,7 @@ $(YNLTOOL): ../libynl.a $(OBJS)
 	$(Q)echo -e "\tLINK $@"
 	$(Q)$(CC) $(CFLAGS) -o $@ $(OBJS) ../libynl.a -lm
 
-%.o: %.c ../libynl.a
+$(OUTPUT)%.o: %.c ../libynl.a
 	$(Q)echo -e "\tCC $@"
 	$(Q)$(COMPILE.c) -MMD -c -o $@ $<
 

Thanks,
Nicolai

#2 lore raw
In reply to Maxime Chevallier (Netdev Foundation)
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 11 Sep 2026 18:41:33 +0200 you wrote:

After the blamed commit, running a out-of-tree build for ynltool fails :

  # make -C tools/net/ynl/ynltool O=/tmp/o1
  make: Entering directory 'tools/net/ynl/ynltool'
  make: *** No rule to make target '/tmp/o1/json_writer.o', needed by '/tmp/o1/ynltool'.  Stop.

ynltool's Makefile correctly accounts for $(OUTPUT) to get the list of object files to generate :

[...]

Here is the summary with links:
- [net-next,v2] tools: ynl: Fix out-of-tree build for ynltool

    https://git.kernel.org/netdev/net-next/c/c0bb05f2d19e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html