diff --git a/buildroot-2024.02/Makefile b/buildroot-2024.02/Makefile
index e5053e422..09658b498 100644
--- a/buildroot-2024.02/Makefile
+++ b/buildroot-2024.02/Makefile
@@ -34,8 +34,12 @@ SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
# or avoid confusing packages that can use the O=
syntax for out-of-tree
# build by preventing it from being forwarded to sub-make calls.
ifneq ("$(origin O)", "command line")
+ifneq ($(TARGET_OUTPUT_DIR),)
+O := $(TARGET_OUTPUT_DIR)
+else
O := $(CURDIR)/output
endif
+endif
# Check if the current Buildroot execution meets all the pre-requisites.
# If they are not met, Buildroot will actually do its job in a sub-make meeting