<h1>Backport of <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="375556771" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/10302" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/10302/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/10302">#10302</a></h1>
<h3>Contribution description</h3>
<p>This fixes building an example that is outside of RIOT with docker and<br>
also fixes building from a release archive.</p>
<p>This currently prevents building from the release archive with our docker image.</p>
<p>It is the first commit split from <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="345335843" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/9646" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/9646/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/9646">#9646</a> so that it could go in the release.</p>
<h3>Testing procedure</h3>
<p>It does not compile in <code>master</code> as the build path is wrongly set:</p>
<p><code>-w '/data/riotbuild/riotproject//home/harter/work/git/riot_master_test/examples/hello-world/' \</code></p>
<pre><code># Simulate a release archive
git archive --format=tar --prefix=riot_master_test/ riot/master  | tar -C .. -x

# compiling fails with docker
DOCKER="sudo docker" BUILD_IN_DOCKER=1 make -C ../riot_master_test/examples/hello-world/
make: Entering directory '/home/harter/work/git/riot_master_test/examples/hello-world'
Launching build container using image "riot/riotbuild:latest".
sudo docker run --rm -t -u "$(id -u)" \
    -v '/home/harter/work/git/riot_master_test:/data/riotbuild/riotbase' \
    -v '/home/harter/work/git/riot_master_test/cpu:/data/riotbuild/riotcpu' \
    -v '/home/harter/work/git/riot_master_test/boards:/data/riotbuild/riotboard' \
    -v '/home/harter/work/git/riot_master_test/makefiles:/data/riotbuild/riotmake' \
    -v '/home/harter/work/git/riot_master_test/examples/hello-world:/data/riotbuild/riotproject' \
    -v /etc/localtime:/etc/localtime:ro \
    -e 'RIOTBASE=/data/riotbuild/riotbase' \
    -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' \
    -e 'RIOTCPU=/data/riotbuild/riotcpu' \
    -e 'RIOTBOARD=/data/riotbuild/riotboard' \
    -e 'RIOTMAKE=/data/riotbuild/riotmake' \
    -e 'RIOTPROJECT=/data/riotbuild/riotproject' \
    -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache \
     \
    -w '/data/riotbuild/riotproject//home/harter/work/git/riot_master_test/examples/hello-world/' \
    'riot/riotbuild:latest' make
make: *** No targets specified and no makefile found.  Stop.
/home/harter/work/git/riot_master_test/makefiles/docker.inc.mk:100: recipe for target '..in-docker-container' failed
make: *** [..in-docker-container] Error 2
make: Leaving directory '/home/harter/work/git/riot_master_test/examples/hello-world'
</code></pre>
<p>With this PR it is set correctly <code>-w '/data/riotbuild/riotproject/' \</code> and it compiles:</p>
<pre><code>git archive --format=tar --prefix=riot_buildrelpath_fix/ HEAD  | tar -C .. -x

DOCKER="sudo docker" BUILD_IN_DOCKER=1 make -C ../riot_buildrelpath_fix/examples/hello-world/
make: Entering directory '/home/harter/work/git/riot_buildrelpath_fix/examples/hello-world'
Launching build container using image "riot/riotbuild:latest".
sudo docker run --rm -t -u "$(id -u)" \
    -v '/home/harter/work/git/riot_buildrelpath_fix:/data/riotbuild/riotbase' \
    -v '/home/harter/work/git/riot_buildrelpath_fix/cpu:/data/riotbuild/riotcpu' \
    -v '/home/harter/work/git/riot_buildrelpath_fix/boards:/data/riotbuild/riotboard' \
    -v '/home/harter/work/git/riot_buildrelpath_fix/makefiles:/data/riotbuild/riotmake' \
    -v '/home/harter/work/git/riot_buildrelpath_fix/examples/hello-world:/data/riotbuild/riotproject' \
    -v /etc/localtime:/etc/localtime:ro \
    -e 'RIOTBASE=/data/riotbuild/riotbase' \
    -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' \
    -e 'RIOTCPU=/data/riotbuild/riotcpu' \
    -e 'RIOTBOARD=/data/riotbuild/riotboard' \
    -e 'RIOTMAKE=/data/riotbuild/riotmake' \
    -e 'RIOTPROJECT=/data/riotbuild/riotproject' \
    -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache \
     \
    -w '/data/riotbuild/riotproject/' \
    'riot/riotbuild:latest' make
Building application "hello-world" for "native" with MCU "native".

"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotboard/native
"make" -C /data/riotbuild/riotboard/native/drivers
"make" -C /data/riotbuild/riotcpu/native
"make" -C /data/riotbuild/riotcpu/native/periph
"make" -C /data/riotbuild/riotcpu/native/vfs
   text    data     bss     dec     hex filename
  20641     372   47684   68697   10c59 /data/riotbuild/riotproject/bin/native/hello-world.elf
make: Leaving directory '/home/harter/work/git/riot_buildrelpath_fix/examples/hello-world'
</code></pre>
<p>Another testing procedure is to copy an application outside of a git repository.<br>
The behavior is the same as with the archive.</p>
<pre><code>cp -r examples/hello-world/ ..
RIOTBASE=${PWD}  DOCKER="sudo docker" BUILD_IN_DOCKER=1 make -C ../hello-world/ clean all
</code></pre>
<h3>Issues/PRs references</h3>
<p>The "external application" case was found in <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="345335843" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/9646" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/9646/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/9646">#9646</a> and the from an archive case was found during release tests <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="374053733" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/Release-Specs/issues/76" data-hovercard-type="issue" data-hovercard-url="/RIOT-OS/Release-Specs/issues/76/hovercard" href="https://github.com/RIOT-OS/Release-Specs/issues/76">RIOT-OS/Release-Specs#76</a></p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/RIOT-OS/RIOT/pull/10313'>https://github.com/RIOT-OS/RIOT/pull/10313</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Makefile.include: Fix BUILDRELPATH when RIOTPROJECT is CURDIR.</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/10313/files#diff-0">Makefile.include</a>
    (3)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/10313.patch'>https://github.com/RIOT-OS/RIOT/pull/10313.patch</a></li>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/10313.diff'>https://github.com/RIOT-OS/RIOT/pull/10313.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/10313">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AEn7YOXIIbuJZxugRPG-gvZk7kbnyqCnks5uqzQtgaJpZM4YHyeT">mute the thread</a>.<img src="https://github.com/notifications/beacon/AEn7YDXywSD6VX5iSgRGasg8BE3AgguJks5uqzQtgaJpZM4YHyeT.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/RIOT-OS/RIOT","title":"RIOT-OS/RIOT","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/RIOT-OS/RIOT"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Makefile.include: Fix BUILDRELPATH when RIOTPROJECT is CURDIR [backport 2018.10] (#10313)"}],"action":{"name":"View Pull Request","url":"https://github.com/RIOT-OS/RIOT/pull/10313"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/10313",
"url": "https://github.com/RIOT-OS/RIOT/pull/10313",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Makefile.include: Fix BUILDRELPATH when RIOTPROJECT is CURDIR [backport 2018.10] (#10313)",
"sections": [
{
"text": "",
"activityTitle": "**José Alamos**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@jia200x",
"facts": [

]
},
{
"title": "Commit Summary",
"facts": [
{
"name": "743e358",
"value": "Makefile.include: Fix BUILDRELPATH when RIOTPROJECT is CURDIR."
}
]
},
{
"title": "File Changes",
"facts": [
{
"name": "Modified",
"value": "[Makefile.include](https://github.com/RIOT-OS/RIOT/pull/10313/files#diff-0) (3 changes)"
}
]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"RIOT-OS/RIOT\",\n\"issueId\": 10313,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close pull request",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"PullRequestClose\",\n\"repositoryFullName\": \"RIOT-OS/RIOT\",\n\"pullRequestId\": 10313\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/RIOT-OS/RIOT/pull/10313"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/RIOT-OS/RIOT/pull/10313.patch"
}
],
"@type": "OpenUri",
"name": "View patch"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/RIOT-OS/RIOT/pull/10313.diff"
}
],
"@type": "OpenUri",
"name": "View diff"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 404694931\n}"
}
],
"themeColor": "26292E"
}
]</script>