Skip to contentSkip to conversation

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

PATCH Superseded Maxime Chevallier (Netdev Foundation) 3 participants 6 messages Sep 9 – Sep 10

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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).

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

---
Targetting net-next, as the blamed commit lives there.

 tools/net/ynl/ynltool/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/net/ynl/ynltool/Makefile +1 -1
index b8c67cdb4fdf..1053e7606c86 100644
@@ -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
maintainer
#1 lore raw
Quoted 2 lines · On Wed, 9 Sep 2026 09:11:54 +0200 Maxime Chevallier (Netdev Foundation) wrote:

[email protected], [email protected]
Subject: [PATCH net-next] tools: ynl: Fix out-of-tree build for ynltool

Hi Maxime, thanks for the quick fix. Looks like this did not hit netdev, unfortunately. It reached lore but via a different ML, and our patchwork only trails netdev itself. Please repost.

#2 lore raw

Hi,

Quoted 8 lines · Jakub Kicinski
Quoted 2 lines · On Wed, 9 Sep 2026 09:11:54 +0200 Maxime Chevallier (Netdev Foundation) wrote:

[email protected], [email protected]
Subject: [PATCH net-next] tools: ynl: Fix out-of-tree build for ynltool

Hi Maxime, thanks for the quick fix. Looks like this did not hit netdev, unfortunately. It reached lore but via a different ML, and our patchwork only trails netdev itself. Please repost.

Dammit, seems like most of the patches I sent yesterday failed in a similar fashion :(

I'll resend right-away, sorry about that,

Maxime

Reviewed-by on v1 1/1
#3 lore raw
In reply to Maxime Chevallier (Netdev Foundation)
Quoted 44 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).

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

---
Targetting net-next, as the blamed commit lives there.

 tools/net/ynl/ynltool/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/net/ynl/ynltool/Makefile +1 -1
index b8c67cdb4fdf..1053e7606c86 100644
@@ -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
#4 lore raw

Hi Bobby,

Quoted 23 lines · Bobby Eshleman
Quoted 22 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).

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

[...]

Quoted 1 line

Thanks :)

Nicolai noted that there's another improvement to be made, as we don't account for modifications made to .h files. The diff would be :

-include $(wildcard *.d)
+include $(wildcard $(OUTPUT)*.d)

See [1].

May I keep your review tag if I add the above diff in v2 ?

Thanks,

Maxime

[1] : https://lore.kernel.org/all/[email protected]/

#5 lore raw
Quoted 39 lines · Maxime Chevallier

Hi Bobby,

Quoted 23 lines · Bobby Eshleman
Quoted 22 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).

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

[...]

Quoted 1 line

Thanks :)

Nicolai noted that there's another improvement to be made, as we don't account for modifications made to .h files. The diff would be :

(quoted diff) +1 -1
-include $(wildcard *.d)
+include $(wildcard $(OUTPUT)*.d)
Quoted 7 lines

See [1].

May I keep your review tag if I add the above diff in v2 ?

Thanks,

Maxime

Yes, np, feel free to carry it forward!

Best,
Bobby