From e4ca9eb2bf7371fa9c1ac8951d298c989cb5aa28 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Mon, 23 Jan 2017 11:58:19 +0100
Subject: Let autogen.sh use either glibtoolize or libtoolize on macOS

This is necessary since conda's libtool installs libtoolize on macOS.
---
 build/linux/autogen.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/build/linux/autogen.sh b/build/linux/autogen.sh
index 544fdeb..bb3b5cc 100755
--- a/build/linux/autogen.sh
+++ b/build/linux/autogen.sh
@@ -12,8 +12,11 @@ if test $? -ne 0; then
   exit 1
 fi
 
-case `uname` in Darwin*) LIBTOOLIZEBIN=glibtoolize ;;
-  *) LIBTOOLIZEBIN=libtoolize ;; esac
+case `uname` in
+  Darwin*)
+    test -x "`which glibtoolize 2>/dev/null`" && LIBTOOLIZEBIN=glibtoolize || LIBTOOLIZEBIN=libtoolize ;;
+  *)
+    LIBTOOLIZEBIN=libtoolize ;; esac
 
 $LIBTOOLIZEBIN --install --force > /dev/null 2>&1
 if test $? -ne 0; then
-- 
cgit v1.2.3


From f0888d0cb90e3eef2cb31a4e1b183876a0bc3f42 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Mon, 23 Jan 2017 12:01:24 +0100
Subject: Use true instead of /bin/true

It's in /usr/bin/ on macOS.
---
 python/conda/libastra/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/conda/libastra/build.sh b/python/conda/libastra/build.sh
index 5807697..46736c4 100644
--- a/python/conda/libastra/build.sh
+++ b/python/conda/libastra/build.sh
@@ -7,7 +7,7 @@ $SRC_DIR/build/linux/autogen.sh
 # Add C++11 to compiler flags if nvcc supports it, mostly to work around a boost bug
 NVCC=$CUDA_ROOT/bin/nvcc
 echo "int main(){return 0;}" > $CONDA_PREFIX/test.cu
-$NVCC $CONDA_PREFIX/test.cu -ccbin $CC --std=c++11 -o $CONDA_PREFIX/test.out > /dev/null && EXTRA_NVCCFLAGS="--std=c++11" || /bin/true
+$NVCC $CONDA_PREFIX/test.cu -ccbin $CC --std=c++11 -o $CONDA_PREFIX/test.out > /dev/null && EXTRA_NVCCFLAGS="--std=c++11" || true
 rm -f $CONDA_PREFIX/test.out
 
 $SRC_DIR/build/linux/configure --with-install-type=prefix --with-cuda=$CUDA_ROOT --prefix=$CONDA_PREFIX NVCCFLAGS="-ccbin $CC $EXTRA_NVCCFLAGS" CC=$CC CXX=$CXX CFLAGS="-I$CONDA_PREFIX/include/boost" CXXFLAGS="-I$CONDA_PREFIX/include/boost"
-- 
cgit v1.2.3


From 4203c3132484cc669bd6f92d180c0623f85f569e Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Mon, 23 Jan 2017 12:10:38 +0100
Subject: Fix conda boost include flags

---
 python/conda/libastra/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/conda/libastra/build.sh b/python/conda/libastra/build.sh
index 46736c4..36c3eba 100644
--- a/python/conda/libastra/build.sh
+++ b/python/conda/libastra/build.sh
@@ -10,7 +10,7 @@ echo "int main(){return 0;}" > $CONDA_PREFIX/test.cu
 $NVCC $CONDA_PREFIX/test.cu -ccbin $CC --std=c++11 -o $CONDA_PREFIX/test.out > /dev/null && EXTRA_NVCCFLAGS="--std=c++11" || true
 rm -f $CONDA_PREFIX/test.out
 
-$SRC_DIR/build/linux/configure --with-install-type=prefix --with-cuda=$CUDA_ROOT --prefix=$CONDA_PREFIX NVCCFLAGS="-ccbin $CC $EXTRA_NVCCFLAGS" CC=$CC CXX=$CXX CFLAGS="-I$CONDA_PREFIX/include/boost" CXXFLAGS="-I$CONDA_PREFIX/include/boost"
+$SRC_DIR/build/linux/configure --with-install-type=prefix --with-cuda=$CUDA_ROOT --prefix=$CONDA_PREFIX NVCCFLAGS="-ccbin $CC -I$CONDA_PREFIX/include $EXTRA_NVCCFLAGS" CC=$CC CXX=$CXX CPPFLAGS="-I$CONDA_PREFIX/include"
 
 make install-libraries
 
-- 
cgit v1.2.3


From 0f6c2fdc899b19000c3fcfa3f4e2129dd16a44ce Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Mon, 23 Jan 2017 12:32:10 +0100
Subject: Change lib/lib64 logic

macOS CUDA uses lib even on 64 bit
---
 build/linux/configure.ac       |  9 +--------
 python/conda/libastra/build.sh | 19 ++++++++++++-------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/build/linux/configure.ac b/build/linux/configure.ac
index 46c84a5..43cb1a8 100644
--- a/build/linux/configure.ac
+++ b/build/linux/configure.ac
@@ -102,14 +102,7 @@ if test x"$NVCC" != xno; then
   HAVECUDA=yes
   BACKUP_CUDA_LDFLAGS="$LDFLAGS"
   if test x"$with_cuda" != x -a x"$with_cuda" != xyes; then
-    case $host_cpu in
-    x86_64)
-      LDFLAGS_CUDA="-L$with_cuda/lib64"
-      ;;
-    *)
-      LDFLAGS_CUDA="-L$with_cuda/lib"
-      ;;
-    esac
+    test -d $with_cuda/lib64 && LDFLAGS_CUDA="-L$with_cuda/lib64" || LDFLAGS_CUDA="-L$with_cuda/lib"
     CPPFLAGS_CUDA="-I$with_cuda/include"
     LDFLAGS="$LDFLAGS $LDFLAGS_CUDA"
   fi
diff --git a/python/conda/libastra/build.sh b/python/conda/libastra/build.sh
index 36c3eba..50d2ae5 100644
--- a/python/conda/libastra/build.sh
+++ b/python/conda/libastra/build.sh
@@ -14,10 +14,15 @@ $SRC_DIR/build/linux/configure --with-install-type=prefix --with-cuda=$CUDA_ROOT
 
 make install-libraries
 
-LIBPATH=lib
-if [ $ARCH == 64 ]
-  then
-    LIBPATH+=64
-fi
-cp -P $CUDA_ROOT/$LIBPATH/libcudart.so.* $CONDA_PREFIX/lib
-cp -P $CUDA_ROOT/$LIBPATH/libcufft.so.* $CONDA_PREFIX/lib
+
+test -d $CUDA_ROOT/lib64 && LIBPATH="$CUDA_ROOT/lib64" || LIBPATH="$CUDA_ROOT/lib"
+
+case `uname` in
+  Darwin*)
+    cp -P $LIBPATH/libcudart.*.dylib $CONDA_PREFIX/lib
+    cp -P $LIBPATH/libcufft.*.dylib $CONDA_PREFIX/lib
+  *)
+    cp -P $LIBPATH/libcudart.so.* $CONDA_PREFIX/lib
+    cp -P $LIBPATH/libcufft.so.* $CONDA_PREFIX/lib
+    ;;
+esac
-- 
cgit v1.2.3


From 76bd01e47e4fc76b16d65d9cfc0216347951c518 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Mon, 23 Jan 2017 14:13:22 +0100
Subject: Silence errors from nvcc test run

---
 python/conda/libastra/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/conda/libastra/build.sh b/python/conda/libastra/build.sh
index 50d2ae5..98220f5 100644
--- a/python/conda/libastra/build.sh
+++ b/python/conda/libastra/build.sh
@@ -7,7 +7,7 @@ $SRC_DIR/build/linux/autogen.sh
 # Add C++11 to compiler flags if nvcc supports it, mostly to work around a boost bug
 NVCC=$CUDA_ROOT/bin/nvcc
 echo "int main(){return 0;}" > $CONDA_PREFIX/test.cu
-$NVCC $CONDA_PREFIX/test.cu -ccbin $CC --std=c++11 -o $CONDA_PREFIX/test.out > /dev/null && EXTRA_NVCCFLAGS="--std=c++11" || true
+$NVCC $CONDA_PREFIX/test.cu -ccbin $CC --std=c++11 -o $CONDA_PREFIX/test.out > /dev/null 2>&1 && EXTRA_NVCCFLAGS="--std=c++11" || true
 rm -f $CONDA_PREFIX/test.out
 
 $SRC_DIR/build/linux/configure --with-install-type=prefix --with-cuda=$CUDA_ROOT --prefix=$CONDA_PREFIX NVCCFLAGS="-ccbin $CC -I$CONDA_PREFIX/include $EXTRA_NVCCFLAGS" CC=$CC CXX=$CXX CPPFLAGS="-I$CONDA_PREFIX/include"
-- 
cgit v1.2.3


From d70274581443afd30d8347dae737c419142c88da Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Mon, 23 Jan 2017 14:13:53 +0100
Subject: Add autotools and boost to macOS conda libastra dependencies

---
 python/conda/libastra/meta.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/python/conda/libastra/meta.yaml b/python/conda/libastra/meta.yaml
index c05a466..68cf47a 100644
--- a/python/conda/libastra/meta.yaml
+++ b/python/conda/libastra/meta.yaml
@@ -16,6 +16,10 @@ build:
 requirements:
   build:
     - vs2015_runtime # [win]
+    - boost # [osx]
+    - automake # [osx]
+    - autoconf # [osx]
+    - libtool # [osx]
 
   run:
     - vs2015_runtime # [win]
-- 
cgit v1.2.3


From 9f3f78472f7be84694baef8e67fec382febce639 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Tue, 24 Jan 2017 16:44:18 +0100
Subject: Move conda astra-toolbox package files to own subdirectory

Recent versions of conda-build (2.1.1 at least) seem to automatically build
packages in subdirectories (after the main directory).
---
 python/conda/astra-toolbox/bld.bat            | 33 ++++++++++++++++++
 python/conda/astra-toolbox/build.sh           |  4 +++
 python/conda/astra-toolbox/meta.yaml          | 48 +++++++++++++++++++++++++++
 python/conda/bld.bat                          | 33 ------------------
 python/conda/build.sh                         |  4 ---
 python/conda/linux_release/builder/Dockerfile | 24 +++++++-------
 python/conda/meta.yaml                        | 48 ---------------------------
 7 files changed, 97 insertions(+), 97 deletions(-)
 create mode 100644 python/conda/astra-toolbox/bld.bat
 create mode 100644 python/conda/astra-toolbox/build.sh
 create mode 100644 python/conda/astra-toolbox/meta.yaml
 delete mode 100644 python/conda/bld.bat
 delete mode 100644 python/conda/build.sh
 delete mode 100644 python/conda/meta.yaml

diff --git a/python/conda/astra-toolbox/bld.bat b/python/conda/astra-toolbox/bld.bat
new file mode 100644
index 0000000..15777ce
--- /dev/null
+++ b/python/conda/astra-toolbox/bld.bat
@@ -0,0 +1,33 @@
+@echo off
+
+set R=%SRC_DIR%
+
+set B_VC=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64
+call "%B_VC%\vcvars64.bat"
+
+set B_BV=1_62
+set B_BOOST=D:\wjp\boost_%B_BV%_0
+
+cd /D "%B_BOOST%\lib64-msvc-14.0"
+
+mkdir "%R%\lib\x64"
+mkdir "%R%\bin\x64\Release_CUDA"
+
+copy boost_unit_test_framework-vc140-mt-%B_BV%.lib %R%\lib\x64
+copy libboost_chrono-vc140-mt-%B_BV%.lib %R%\lib\x64
+copy libboost_date_time-vc140-mt-%B_BV%.lib %R%\lib\x64
+copy libboost_system-vc140-mt-%B_BV%.lib %R%\lib\x64
+copy libboost_thread-vc140-mt-%B_BV%.lib %R%\lib\x64
+
+cd %B_BOOST%
+
+xcopy /i /e /q boost "%R%\lib\include\boost"
+
+cd /D %R%
+
+cd python
+
+set VS90COMNTOOLS=%VS140COMNTOOLS%
+set CL=/DASTRA_CUDA /DASTRA_PYTHON "/I%R%\include" "/I%R%\lib\include" "/I%CUDA_PATH%\include"
+copy "%CONDA_PREFIX%\Library\lib\AstraCuda64.lib" astra.lib
+python builder.py build_ext --compiler=msvc install
diff --git a/python/conda/astra-toolbox/build.sh b/python/conda/astra-toolbox/build.sh
new file mode 100644
index 0000000..951fd88
--- /dev/null
+++ b/python/conda/astra-toolbox/build.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd $SRC_DIR/python/
+CPPFLAGS="-DASTRA_CUDA -DASTRA_PYTHON $CPPFLAGS -I$SRC_DIR/ -I$SRC_DIR/include -I$CUDA_ROOT/include" CC=$CC python ./builder.py build install
diff --git a/python/conda/astra-toolbox/meta.yaml b/python/conda/astra-toolbox/meta.yaml
new file mode 100644
index 0000000..942397e
--- /dev/null
+++ b/python/conda/astra-toolbox/meta.yaml
@@ -0,0 +1,48 @@
+package:
+  name: astra-toolbox
+  version: '1.8'
+
+source:
+  git_url: https://github.com/astra-toolbox/astra-toolbox.git
+  git_tag: v1.8
+
+build:
+  number: 0
+  script_env:
+    - CC # [not win]
+    - CUDA_ROOT # [not win]
+
+test:
+  imports:
+    - astra
+
+  requires:
+    # To avoid large downloads just for testing after build phase
+    - nomkl # [not win]
+
+requirements:
+  build:
+    - python
+    - cython >=0.13
+    - nomkl # [not win]
+    - numpy
+    - scipy
+    - six
+    - libastra ==1.8
+
+  run:
+    - python
+    - numpy x.x
+    - scipy
+    - six
+    - libastra ==1.8
+
+
+about:
+  home: http://www.astra-toolbox.com
+  license: GPLv3
+  summary: 'The ASTRA Toolbox is a Python toolbox of high-performance GPU primitives for 2D and 3D tomography.'
+
+# See
+# http://docs.continuum.io/conda/build.html for
+# more information about meta.yaml
diff --git a/python/conda/bld.bat b/python/conda/bld.bat
deleted file mode 100644
index 15777ce..0000000
--- a/python/conda/bld.bat
+++ /dev/null
@@ -1,33 +0,0 @@
-@echo off
-
-set R=%SRC_DIR%
-
-set B_VC=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64
-call "%B_VC%\vcvars64.bat"
-
-set B_BV=1_62
-set B_BOOST=D:\wjp\boost_%B_BV%_0
-
-cd /D "%B_BOOST%\lib64-msvc-14.0"
-
-mkdir "%R%\lib\x64"
-mkdir "%R%\bin\x64\Release_CUDA"
-
-copy boost_unit_test_framework-vc140-mt-%B_BV%.lib %R%\lib\x64
-copy libboost_chrono-vc140-mt-%B_BV%.lib %R%\lib\x64
-copy libboost_date_time-vc140-mt-%B_BV%.lib %R%\lib\x64
-copy libboost_system-vc140-mt-%B_BV%.lib %R%\lib\x64
-copy libboost_thread-vc140-mt-%B_BV%.lib %R%\lib\x64
-
-cd %B_BOOST%
-
-xcopy /i /e /q boost "%R%\lib\include\boost"
-
-cd /D %R%
-
-cd python
-
-set VS90COMNTOOLS=%VS140COMNTOOLS%
-set CL=/DASTRA_CUDA /DASTRA_PYTHON "/I%R%\include" "/I%R%\lib\include" "/I%CUDA_PATH%\include"
-copy "%CONDA_PREFIX%\Library\lib\AstraCuda64.lib" astra.lib
-python builder.py build_ext --compiler=msvc install
diff --git a/python/conda/build.sh b/python/conda/build.sh
deleted file mode 100644
index 951fd88..0000000
--- a/python/conda/build.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cd $SRC_DIR/python/
-CPPFLAGS="-DASTRA_CUDA -DASTRA_PYTHON $CPPFLAGS -I$SRC_DIR/ -I$SRC_DIR/include -I$CUDA_ROOT/include" CC=$CC python ./builder.py build install
diff --git a/python/conda/linux_release/builder/Dockerfile b/python/conda/linux_release/builder/Dockerfile
index 8be05b8..2404609 100644
--- a/python/conda/linux_release/builder/Dockerfile
+++ b/python/conda/linux_release/builder/Dockerfile
@@ -2,16 +2,16 @@ FROM astra-build-env
 ARG BUILD_NUMBER=
 WORKDIR /root
 RUN git clone --depth 1 https://github.com/astra-toolbox/astra-toolbox
-RUN [ -z $BUILD_NUMBER ] || perl -pi -e "s/^(\s*number:\s*)[0-9]+$/\${1}$BUILD_NUMBER/" astra-toolbox/python/conda/libastra/meta.yaml astra-toolbox/python/conda/meta.yaml
+RUN [ -z $BUILD_NUMBER ] || perl -pi -e "s/^(\s*number:\s*)[0-9]+$/\${1}$BUILD_NUMBER/" astra-toolbox/python/conda/libastra/meta.yaml astra-toolbox/python/conda/astra-toolbox/meta.yaml
 RUN conda-build --python=3.5 astra-toolbox/python/conda/libastra
-RUN conda-build --python 2.7 --numpy 1.8 astra-toolbox/python/conda
-RUN conda-build --python 2.7 --numpy 1.9 astra-toolbox/python/conda
-RUN conda-build --python 2.7 --numpy 1.10 astra-toolbox/python/conda
-RUN conda-build --python 2.7 --numpy 1.11 astra-toolbox/python/conda
-RUN conda-build --python 2.7 --numpy 1.12 astra-toolbox/python/conda
-RUN conda-build --python 3.5 --numpy 1.9 astra-toolbox/python/conda
-RUN conda-build --python 3.5 --numpy 1.10 astra-toolbox/python/conda
-RUN conda-build --python 3.5 --numpy 1.11 astra-toolbox/python/conda
-RUN conda-build --python 3.5 --numpy 1.12 astra-toolbox/python/conda
-RUN conda-build --python 3.6 --numpy 1.11 astra-toolbox/python/conda
-RUN conda-build --python 3.6 --numpy 1.12 astra-toolbox/python/conda
+RUN conda-build --python 2.7 --numpy 1.8 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 2.7 --numpy 1.9 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 2.7 --numpy 1.10 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 2.7 --numpy 1.11 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 2.7 --numpy 1.12 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 3.5 --numpy 1.9 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 3.5 --numpy 1.10 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 3.5 --numpy 1.11 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 3.5 --numpy 1.12 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 3.6 --numpy 1.11 astra-toolbox/python/conda/astra-toolbox
+RUN conda-build --python 3.6 --numpy 1.12 astra-toolbox/python/conda/astra-toolbox
diff --git a/python/conda/meta.yaml b/python/conda/meta.yaml
deleted file mode 100644
index 942397e..0000000
--- a/python/conda/meta.yaml
+++ /dev/null
@@ -1,48 +0,0 @@
-package:
-  name: astra-toolbox
-  version: '1.8'
-
-source:
-  git_url: https://github.com/astra-toolbox/astra-toolbox.git
-  git_tag: v1.8
-
-build:
-  number: 0
-  script_env:
-    - CC # [not win]
-    - CUDA_ROOT # [not win]
-
-test:
-  imports:
-    - astra
-
-  requires:
-    # To avoid large downloads just for testing after build phase
-    - nomkl # [not win]
-
-requirements:
-  build:
-    - python
-    - cython >=0.13
-    - nomkl # [not win]
-    - numpy
-    - scipy
-    - six
-    - libastra ==1.8
-
-  run:
-    - python
-    - numpy x.x
-    - scipy
-    - six
-    - libastra ==1.8
-
-
-about:
-  home: http://www.astra-toolbox.com
-  license: GPLv3
-  summary: 'The ASTRA Toolbox is a Python toolbox of high-performance GPU primitives for 2D and 3D tomography.'
-
-# See
-# http://docs.continuum.io/conda/build.html for
-# more information about meta.yaml
-- 
cgit v1.2.3


From b51e404d3be18b9b1e39e6e3548eed9ddb586ea7 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Fri, 3 Feb 2017 16:55:32 +0100
Subject: Use standard _OPENMP directive for checking openmp

---
 matlab/mex/mexCopyDataHelpFunctions.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/matlab/mex/mexCopyDataHelpFunctions.cpp b/matlab/mex/mexCopyDataHelpFunctions.cpp
index a172a03..74f0538 100644
--- a/matlab/mex/mexCopyDataHelpFunctions.cpp
+++ b/matlab/mex/mexCopyDataHelpFunctions.cpp
@@ -29,12 +29,10 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
 
 #include "mexHelpFunctions.h"
 
-#define HAVE_OMP
-
 #define ROUND_DOWN(x, s) ((x) & ~((s)-1))
 
-#ifdef HAVE_OMP
-#	include <omp.h>
+#ifdef _OPENMP
+#include <omp.h>
 #endif
 
 #if defined(__SSE2__)
-- 
cgit v1.2.3


From 99718ef1734c0db06034127da703f70a1c30f1a3 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Fri, 3 Feb 2017 16:57:54 +0100
Subject: Disable openmp on macOS

---
 build/linux/Makefile.in  | 3 +++
 build/linux/configure.ac | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in
index 9066f0a..ae3dec8 100644
--- a/build/linux/Makefile.in
+++ b/build/linux/Makefile.in
@@ -4,6 +4,7 @@ cuda=@HAVECUDA@
 matlab=@HAVEMATLAB@
 python=@HAVEPYTHON@
 boostutf=@HAVEBOOSTUTF@
+macos=@IS_MACOS@
 
 MATLAB_ROOT=@MATLAB_ROOT@
 octave=@HAVEOCTAVE@
@@ -64,9 +65,11 @@ endif
 ifeq ($(matlab),yes)
 # TODO: Do we also want -fopenmp for octave?
 CPPFLAGS+=-I$(MATLAB_ROOT)/extern/include -DMATLAB_MEX_FILE
+ifeq ($(macos),no)
 CXXFLAGS+=-fopenmp
 LDFLAGS+=-fopenmp
 endif
+endif
 
 # MODLDFLAGS are the base LDFLAGS for matlab, octave, python modules
 MODLDFLAGS=$(LDFLAGS) -L$(abs_top_builddir)/.libs
diff --git a/build/linux/configure.ac b/build/linux/configure.ac
index 43cb1a8..813b462 100644
--- a/build/linux/configure.ac
+++ b/build/linux/configure.ac
@@ -251,13 +251,16 @@ AC_CANONICAL_HOST
 case $host_os in
   darwin* )
         CPPFLAGS_OS="-stdlib=libstdc++ -mmacosx-version-min=10.6"
+        IS_MACOS=yes
         ;;
     *)
         CPPFLAGS_OS=""
+        IS_MACOS=no
         ;;
 esac
 
 AC_SUBST(CPPFLAGS_OS)
+AC_SUBST(IS_MACOS)
 
 # For some reason, some older versions of autoconf produce a config.status
 # that disables all lines looking like VPATH=@srcdir@
-- 
cgit v1.2.3


From a3336fc3445fca283be97528d60f2f55501491b0 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Fri, 3 Feb 2017 16:58:36 +0100
Subject: Use @loader_path to make mex files find libastra.0.dylib in cwd

---
 build/linux/Makefile.in | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in
index ae3dec8..0120d60 100644
--- a/build/linux/Makefile.in
+++ b/build/linux/Makefile.in
@@ -304,6 +304,12 @@ mex: $(MATLAB_MEX)
 
 %.$(MEXSUFFIX): %.o $(MATLAB_CXX_OBJECTS) libastra.la
 	$(MEX) LDFLAGS="$(MEXLDFLAGS)" $(MEXFLAGS) $(LIBS) $(MEXLIBS) -lastra -output $* $*.o $(MATLAB_CXX_OBJECTS)
+ifeq ($(install_type),module)
+ifeq ($(macos),yes)
+	@# tell macOS dynamic loader to look in mex directory for libastra.0.dylib
+	install_name_tool -change `otool -DX .libs/$(SONAME)` @loader_path/$(SONAME) $@
+endif
+endif
 
 ifeq ($(python),yes)
 matlab/mex/astra_mex_plugin_c.$(MEXSUFFIX): matlab/mex/astra_mex_plugin_c.o $(MATLAB_CXX_OBJECTS) libastra.la
-- 
cgit v1.2.3


From f5c25084f09a8f35c4e3d01eb84de984778ae8a9 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Fri, 3 Feb 2017 16:58:56 +0100
Subject: Set stdlib to libstdc++ on macOS consistently

---
 build/linux/Makefile.in  | 3 ++-
 build/linux/configure.ac | 9 ++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in
index 0120d60..1c0c56a 100644
--- a/build/linux/Makefile.in
+++ b/build/linux/Makefile.in
@@ -50,7 +50,8 @@ CXXFLAGS+=-g -O3 -Wall -Wshadow
 LIBS+=-lpthread
 LDFLAGS+=-g
 
-CPPFLAGS+=@CPPFLAGS_OS@
+CXXFLAGS+=@CXXFLAGS_OS@
+LDFLAGS+=@LDFLAGS_OS@
 
 BOOSTUTF_LIBS=@LIBS_BOOSTUTF@
 
diff --git a/build/linux/configure.ac b/build/linux/configure.ac
index 813b462..b95d94f 100644
--- a/build/linux/configure.ac
+++ b/build/linux/configure.ac
@@ -250,16 +250,19 @@ AC_SUBST(HAVEPYTHON)
 AC_CANONICAL_HOST
 case $host_os in
   darwin* )
-        CPPFLAGS_OS="-stdlib=libstdc++ -mmacosx-version-min=10.6"
+        CXXFLAGS_OS="-stdlib=libstdc++ -mmacosx-version-min=10.6"
+        LDFLAGS_OS="-stdlib=libstdc++"
         IS_MACOS=yes
         ;;
     *)
-        CPPFLAGS_OS=""
+        CXXFLAGS_OS=""
+        LDFLAGS_OS=""
         IS_MACOS=no
         ;;
 esac
 
-AC_SUBST(CPPFLAGS_OS)
+AC_SUBST(CXXFLAGS_OS)
+AC_SUBST(LDFLAGS_OS)
 AC_SUBST(IS_MACOS)
 
 # For some reason, some older versions of autoconf produce a config.status
-- 
cgit v1.2.3


From cd32957185094680b84014e1ea8411ce6b142f74 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Mon, 6 Feb 2017 15:38:07 +0100
Subject: Add basic macOS/homebrew build instructions

---
 README.md  | 15 +++++++++++++++
 README.txt | 13 +++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/README.md b/README.md
index dc523a2..8af69a7 100644
--- a/README.md
+++ b/README.md
@@ -83,6 +83,21 @@ make install
 
 This will install Astra into your current Python environment.
 
+### macOS, from source
+
+Use the Homebrew package manager to install boost, libtool, autoconf, automake.
+
+```
+cd build/linux
+./autogen.sh
+CPPFLAGS="-I/usr/local/include" NVCCFLAGS="-I/usr/local/include" ./configure \
+  --with-cuda=/usr/local/cuda \
+  --with-matlab=/Applications/MATLAB_R2016b.app \
+  --prefix=$HOME/astra \
+  --with-install-type=module
+make
+make install
+```
 
 ### Windows, from source using Visual Studio 2015
 
diff --git a/README.txt b/README.txt
index 8de13b2..6d84ea0 100644
--- a/README.txt
+++ b/README.txt
@@ -109,7 +109,20 @@ make install
 This will install Astra into your current Python environment.
 
 
+macOS, from source:
+--------------------
+
+Use the Homebrew package manager to install boost, libtool, autoconf, automake.
 
+cd build/linux
+./autogen.sh
+CPPFLAGS="-I/usr/local/include" NVCCFLAGS="-I/usr/local/include" ./configure \
+  --with-cuda=/usr/local/cuda \
+  --with-matlab=/Applications/MATLAB_R2016b.app \
+  --prefix=$HOME/astra \
+  --with-install-type=module
+make
+make install
 
 
 Windows, from source using Visual Studio 2015:
-- 
cgit v1.2.3