From f82ace910f020f61eed9bbaf47bb419c40fea923 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= <gaetan.harter@fu-berlin.de>
Date: Mon, 29 Oct 2018 11:47:16 +0100
Subject: [PATCH] Makefile.include: Fix default RIOTBASE when there is
 Makefile.local

When an application only includes Makefile.include without specifying
RIOTBASE and uses a `Makefile.local` file, RIOTBASE would use a wrong
default value and get the value of the directory where `Makefile.local` is.
---
 Makefile.include | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Makefile.include b/Makefile.include
index 351406751d..5c815483de 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -1,3 +1,6 @@
+# 'Makefile.include' directory, must be evaluated before other 'include'
+_riotbase := $(dir $(lastword $(MAKEFILE_LIST)))
+
 # Globally set default goal to `all`
 .DEFAULT_GOAL := all
 
@@ -5,7 +8,7 @@
 -include Makefile.local
 
 # set undefined variables
-RIOTBASE       ?= $(dir $(lastword $(MAKEFILE_LIST)))
+RIOTBASE       ?= $(_riotbase)
 CCACHE_BASEDIR ?= $(RIOTBASE)
 RIOTCPU        ?= $(RIOTBASE)/cpu
 RIOTBOARD      ?= $(RIOTBASE)/boards
-- 
GitLab