]> rtime.felk.cvut.cz Git - arc.git/blobdiff - examples/build_example.mk
More application changes
[arc.git] / examples / build_example.mk
index a260cacc2fdf81bfd72ea581bfa38aa2f5ca6f01..89e523e064608b09369dca2b859ae9e9e24f9ebd 100644 (file)
@@ -1,33 +1,30 @@
-\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