public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Maxin John <maxin.john@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net
Subject: [PATCH] iw: Makefile: support out-of-tree builds
Date: Thu, 23 Apr 2026 14:31:54 +0300	[thread overview]
Message-ID: <20260423113154.1070521-1-maxin.john@gmail.com> (raw)

Enable out-of-tree builds without modifying the source tree.
Out-of-tree builds are required by build frameworks such as OpenEmbedded.

Signed-off-by: Maxin John <maxin.john@gmail.com>
---
 Makefile | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 2652fac4e6ee..fbbc3042cd37 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,8 @@
 MAKEFLAGS += --no-print-directory
 
+SRCDIR := $(dir $(lastword $(MAKEFILE_LIST)))
+VPATH := $(SRCDIR)
+
 PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR ?= $(PREFIX)/share/man
@@ -21,7 +24,11 @@ CFLAGS += -D__SANE_USERSPACE_TYPES__
 CFLAGS += $(CFLAGS_EVAL)
 CFLAGS += $(EXTRA_CFLAGS)
 
-_OBJS := $(sort $(patsubst %.c,%.o,$(wildcard *.c)))
+CPPFLAGS += -I$(SRCDIR)
+CPPFLAGS += -I.
+
+_SRCS := $(wildcard $(SRCDIR)/*.c)
+_OBJS := $(sort $(patsubst $(SRCDIR)/%.c,%.o,$(_SRCS)))
 VERSION_OBJS := $(filter-out version.o, $(_OBJS))
 OBJS := $(VERSION_OBJS) version.o
 
@@ -92,16 +99,18 @@ endif
 
 all: $(ALL)
 
-version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \
-		$(wildcard .git/index .git/refs/tags)
+version.c: $(SRCDIR)/version.sh \
+	$(patsubst %.o,$(SRCDIR)/%.c,$(VERSION_OBJS)) \
+	$(SRCDIR)/nl80211.h $(SRCDIR)/iw.h $(SRCDIR)/Makefile \
+	$(wildcard $(SRCDIR)/.git/index $(SRCDIR)/.git/refs/tags)
 	@$(NQ) ' GEN ' $@
-	$(Q)./version.sh $@
+	$(Q)$(SRCDIR)/version.sh $@
 
-nl80211-commands.inc: nl80211.h
+nl80211-commands.inc: $(SRCDIR)/nl80211.h
 	@$(NQ) ' GEN ' $@
-	$(Q)sed 's%^\tNL80211_CMD_%%;t n;d;:n s%^\([^=]*\),.*%\t[NL80211_CMD_\1] = \"\L\1\",%;t;d' nl80211.h | grep -v "reserved" > $@
+	$(Q)sed 's%^\tNL80211_CMD_%%;t n;d;:n s%^\([^=]*\),.*%\t[NL80211_CMD_\1] = \"\L\1\",%;t;d' $(SRCDIR)/nl80211.h | grep -v "reserved" > $@
 
-%.o: %.c iw.h nl80211.h nl80211-commands.inc
+%.o: %.c $(SRCDIR)/iw.h $(SRCDIR)/nl80211.h nl80211-commands.inc
 	@$(NQ) ' CC  ' $@
 	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
 
-- 
2.47.3


                 reply	other threads:[~2026-04-23 11:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260423113154.1070521-1-maxin.john@gmail.com \
    --to=maxin.john@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox