Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 9e27fc2e1b3dc8c36ef6a502edffc3a3d84d9dd9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Christopher Larson <chris_larson@mentor.com> |
| 3 | Date: Wed, 26 Aug 2015 17:23:48 -0700 |
| 4 | Subject: [PATCH] Support separation of SRCDIR and OBJDIR |
| 5 | |
| 6 | Typical use of VPATH to locate the sources. |
| 7 | |
| 8 | Upstream-Status: Pending |
| 9 | |
| 10 | Signed-off-by: Christopher Larson <chris_larson@mentor.com> |
| 11 | |
| 12 | --- |
| 13 | Makefile | 7 +++++-- |
| 14 | version.sh | 2 +- |
| 15 | 2 files changed, 6 insertions(+), 3 deletions(-) |
| 16 | |
| 17 | diff --git a/Makefile b/Makefile |
| 18 | index 548591a..da8d33a 100644 |
| 19 | --- a/Makefile |
| 20 | +++ b/Makefile |
| 21 | @@ -1,5 +1,8 @@ |
| 22 | MAKEFLAGS += --no-print-directory |
| 23 | |
| 24 | +SRCDIR ?= $(dir $(lastword $(MAKEFILE_LIST))) |
| 25 | +OBJDIR ?= $(PWD) |
| 26 | +VPATH = $(SRCDIR) |
| 27 | PREFIX ?= /usr |
| 28 | SBINDIR ?= $(PREFIX)/sbin |
| 29 | MANDIR ?= $(PREFIX)/share/man |
| 30 | @@ -95,11 +98,11 @@ VERSION_OBJS := $(filter-out version.o, $(OBJS)) |
| 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 | %.o: %.c iw.h nl80211.h |
| 38 | @$(NQ) ' CC ' $@ |
| 39 | - $(Q)$(CC) $(CFLAGS) -c -o $@ $< |
| 40 | + $(Q)$(CC) -I$(SRCDIR) $(CFLAGS) -c -o $@ $< |
| 41 | |
| 42 | ifeq ($(IW_ANDROID_BUILD),) |
| 43 | iw: $(OBJS) |
| 44 | diff --git a/version.sh b/version.sh |
| 45 | index 5354383..fa954cf 100755 |
| 46 | --- a/version.sh |
| 47 | +++ b/version.sh |
| 48 | @@ -5,5 +5,5 @@ OUT="$1" |
| 49 | |
| 50 | v="$VERSION" |
| 51 | |
| 52 | -echo '#include "iw.h"' > "$OUT" |
| 53 | +echo '#include <iw.h>' > "$OUT" |
| 54 | echo "const char iw_version[] = \"$v\";" >> "$OUT" |
| 55 | -- |
| 56 | 2.2.1 |
| 57 | |