1From ff9f0a631c99fb6e2677c02bf572a5e69c70f5cf Mon Sep 17 00:00:00 2001
2From: Changhyeok Bae <changhyeok.bae@gmail.com>
3Date: Mon, 27 Jan 2020 22:48:03 +0100
4Subject: [PATCH] Support separation of SRCDIR and OBJDIR
5
6Typical use of VPATH to locate the sources.
7
8Upstream-Status: Pending
9
10Signed-off-by: Christopher Larson <chris_larson@mentor.com>
11Signed-off-by: Maxin B. John <maxin.john@intel.com>
12---
13 Makefile | 8 ++++++--
14 1 file changed, 6 insertions(+), 2 deletions(-)
15
16diff --git a/Makefile b/Makefile
17index 90f2251..714cdb9 100644
18--- a/Makefile
19+++ b/Makefile
20@@ -1,5 +1,9 @@
21 MAKEFLAGS += --no-print-directory
22
23+SRCDIR ?= $(dir $(lastword $(MAKEFILE_LIST)))
24+OBJDIR ?= $(PWD)
25+VPATH = $(SRCDIR)
26+
27 PREFIX ?= /usr
28 SBINDIR ?= $(PREFIX)/sbin
29 MANDIR ?= $(PREFIX)/share/man
30@@ -92,7 +96,7 @@ all: $(ALL)
31 version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) nl80211.h iw.h Makefile \
32 		$(wildcard .git/index .git/refs/tags)
33 	@$(NQ) ' GEN ' $@
34-	$(Q)./version.sh $@
35+	$(Q)cd $(SRCDIR) && ./version.sh $(OBJDIR)/$@
36
37 nl80211-commands.inc: nl80211.h
38 	@$(NQ) ' GEN ' $@
39@@ -100,7 +104,7 @@ nl80211-commands.inc: nl80211.h
40
41 %.o: %.c iw.h nl80211.h nl80211-commands.inc
42 	@$(NQ) ' CC  ' $@
43-	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
44+	$(Q)$(CC) -I$(SRCDIR) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
45
46 ifeq ($(IW_ANDROID_BUILD),)
47 iw:	$(OBJS)
48--
492.23.0
50
51