From 8349ba180bb0a1acb6b5606163dac1998e173c43 Mon Sep 17 00:00:00 2001
From: Mark Charlebois <charlebm@gmail.com>
Date: Fri, 23 Oct 2015 17:37:46 -0700
Subject: [PATCH 1/3] DSPAL: removed simlinks that broke vagrant build

Vagrant did not like the simlinks in the dspal repo.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 src/lib/dspal | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lib/dspal b/src/lib/dspal
index 95e91546f4..caf445fe1e 160000
--- a/src/lib/dspal
+++ b/src/lib/dspal
@@ -1 +1 @@
-Subproject commit 95e91546f42e6d88d34a2bb29d0f428a8706c9e4
+Subproject commit caf445fe1e54a9631c6d4c6451f23452adb9897c

From 01ccbd8886ff549fff3239138f5cc6b55e353b91 Mon Sep 17 00:00:00 2001
From: Mark Charlebois <charlebm@gmail.com>
Date: Fri, 23 Oct 2015 20:42:15 -0700
Subject: [PATCH 2/3] qurt: added HEXAGON_TOOLS_ROOT variable

The environment variable HEXAGON_TOOLS_ROOT must be set to the location
of the installed HexagonTools. This could be a global install at
/opt/HEXAGON_Tools/7.2.10/Tools or it could be a personal install
${HOME}/Qualcomm/HEXAGON_Tools/7.2.10/Tools.

The default install path used by the installer is exported in the Vagrantfile.

There is still an issue that the hexagon linker fails on mmap of the shared folder.
If the shared folder was mounted via NFS for Linux and MacOS the problem would be
resolved.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 Vagrantfile                                     |  2 ++
 cmake/toolchains/Toolchain-hexagon-7.2.10.cmake | 17 +++++++++++++++--
 src/lib/dspal                                   |  2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/Vagrantfile b/Vagrantfile
index c24bfe6859..2fbf532b74 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -85,6 +85,8 @@ Vagrant.configure(2) do |config|
     tar -jxf gcc-arm-none-eabi-4_8-2014q3-20140805-linux.tar.bz2
     exportline="export PATH=$HOME/gcc-arm-none-eabi-4_8-2014q3/bin:\$PATH"
     if grep -Fxq "$exportline" ~/.profile; then echo nothing to do ; else echo $exportline >> ~/.profile; fi
+    exportline2="export HEXAGON_TOOLS_ROOT=$HOME/Qualcomm/HEXAGON_Tools/7.2.10/Tools"
+    if grep -Fxq "$exportline2" ~/.profile; then echo nothing to do ; else echo $exportline2 >> ~/.profile; fi
     . ~/.profile
     popd
     # setup ccache
diff --git a/cmake/toolchains/Toolchain-hexagon-7.2.10.cmake b/cmake/toolchains/Toolchain-hexagon-7.2.10.cmake
index 4e27436ec7..1ab6fd4060 100644
--- a/cmake/toolchains/Toolchain-hexagon-7.2.10.cmake
+++ b/cmake/toolchains/Toolchain-hexagon-7.2.10.cmake
@@ -34,8 +34,12 @@ include(CMakeForceCompiler)
 list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
 include(common/px4_base)
 
-if(NOT HEXAGON_TOOLS_ROOT)
-	set(HEXAGON_TOOLS_ROOT $ENV{HOME}/Qualcomm/HEXAGON_Tools/7.2.10/Tools)
+if ("$ENV{HEXAGON_TOOLS_ROOT}" STREQUAL "")
+	message(FATAL_ERROR
+		"The HexagonTools version 7.2.10 must be installed and the environment variable HEXAGON_TOOLS_ROOT must be set"
+		"(e.g. export HEXAGON_TOOLS_ROOT=/opt/HEXAGON_Tools/7.2.10/Tools)")
+else()
+	set(HEXAGON_TOOLS_ROOT $ENV{HEXAGON_TOOLS_ROOT})
 endif()
 
 macro (list2string out in)
@@ -239,3 +243,12 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 # for libraries and headers in the target directories
 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+# The Hexagon compiler doesn't support the -rdynamic flag and this is set
+# in the base cmake scripts. We have to redefine the __linux_compiler_gnu
+# macro for cmake 2.8 to work
+set(__LINUX_COMPILER_GNU 1)
+macro(__linux_compiler_gnu lang)
+  set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "")
+endmacro()
+
diff --git a/src/lib/dspal b/src/lib/dspal
index caf445fe1e..c8e885aac5 160000
--- a/src/lib/dspal
+++ b/src/lib/dspal
@@ -1 +1 @@
-Subproject commit caf445fe1e54a9631c6d4c6451f23452adb9897c
+Subproject commit c8e885aac51aa34855bb3880d3dc916b9e278083

From d030608def7c74147e895bf038747d315317dbc4 Mon Sep 17 00:00:00 2001
From: Mark Charlebois <charlebm@gmail.com>
Date: Fri, 23 Oct 2015 21:09:29 -0700
Subject: [PATCH 3/3] Modified Vagrantfile to use NFS folder sharing

Virtualbox has issues with certain operations on shared folders
using the default sharing mechanism. These are overcome using
NFS sharing.

On Ubuntu, sudo apt-get install nfs-kernel-server

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 Vagrantfile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Vagrantfile b/Vagrantfile
index 2fbf532b74..cea1289500 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -33,11 +33,14 @@ Vagrant.configure(2) do |config|
   # your network.
   # config.vm.network "public_network"
 
+  # Virtualbox requires a private network to use NFS
+  config.vm.network "private_network", type: "dhcp"
+
   # Share an additional folder to the guest VM. The first argument is
   # the path on the host to the actual folder. The second argument is
   # the path on the guest to mount the folder. And the optional third
   # argument is a set of non-required options.
-  config.vm.synced_folder ".", "/Firmware"
+  config.vm.synced_folder ".", "/Firmware", type: "nfs"
 
   # Provider-specific configuration so you can fine-tune various
   # backing providers for Vagrant. These expose provider-specific options.