-\r
-\r
-ifeq ($(EXAMPLENAME),)\r
-$(error whyyyyyy)\r
+#\r
+# This makefile helps to build the examples. It tries to figure out if \r
+# it is an in-tree-build or if it is a seperate project (it's then invoked \r
+# from the top makefile) \r
+#\r
+\r
+ifndef EXAMPLENAME\r
+$(error EXAMPLENAME is not set. . This makefile is invoked the wrong way))\r
endif\r
\r
ifndef ROOTDIR\r
$(error ROOTDIR is not set. This makefile is invoked the wrong way)\r
endif\r
\r
-#export EXAMPLENAME\r
-\r
-ifndef BOARDDIR\r
-# Assume in-tree-build \r
-boardpath=$(realpath $(CURDIR)/../..)\r
-boarddir=$(subst $(realpath $(ROOTDIR)/boards)/,,$(boardpath))\r
-ugh=1\r
-else\r
- # BOARDIR is defined\r
- ifndef BDIR\r
- # Assume that we want to build current directory\r
- BDIR=$(CURDIR)\r
- ugh=1\r
- else\r
- # BOARDIR and BDIR are defined \r
- # out-of-tree build\r
- endif\r
+ifeq (${MAKELEVEL},0)\r
+ BUILD_IN_TREE=y\r
+\r
+ ifneq ($(BOARDDIR),)\r
+ $(warning BOARDDIR defined in an in-tree-build)\r
+ endif\r
+ \r
+ boardpath=$(realpath $(CURDIR)/../..)\r
+ boarddir=$(subst $(realpath $(ROOTDIR)/boards)/,,$(boardpath))\r
+ \r
endif\r
\r
-ifeq ($(ugh),1) \r
+ifeq (${BUILD_IN_TREE},y) \r
\r
export example:=$(subst $(abspath $(CURDIR)/..)/,,$(CURDIR))\r
\r