From fc49cc9bad7c88e828d8638eb5b51bc9456ef290 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Thu, 14 Jan 2021 14:10:14 +0000
Subject: [PATCH] RF: In official FSL installs, fsl-devel.sh activates the
 $FSLDIR conda environment. Also sets default values for FSLDEVDIR and
 FSLCONFDIR if not set by the user.

---
 etc/fslconf/fsl-devel.sh | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/etc/fslconf/fsl-devel.sh b/etc/fslconf/fsl-devel.sh
index 586895d..a17d2c1 100644
--- a/etc/fslconf/fsl-devel.sh
+++ b/etc/fslconf/fsl-devel.sh
@@ -1,13 +1,39 @@
 # FSL configuration file for developers
-#  - to be sourced by the user, typically in .bashrc or equivalent
 #
-# Written by Mark Jenkinson
-#  FMRIB Analysis Group, University of Oxford
+# This file must be sourced in order to compile
+# Makefile-based FSL projects.
+#
+# $FSLDIR must be set before this script is called.
+#
+# Standard environment configuration for developing FSL is:
+#   export FSLDIR=/usr/local/fsl
+#   source $FSLDIR/etc/fslconf/fsl-devel.sh
+#
 
 # SHBASECOPYRIGHT
 
-FSLCONFDIR=$FSLDIR/config
 
-export FSLCONFDIR
+# If this is an official (fslinstaller-installed)
+# FSL installation, we activate the $FSLDIR conda
+# environment so that we have access to its compiler
+# toolchain (if one is installed).
+if [ -e $FSLDIR/share/fsl/base_environment ]; then
+  baseenv=$(cat $FSLDIR/share/fsl/base_environment)
+  source $baseenv/bin/activate $FSLDIR
+fi
+
+# FSLCONFDIR contains the FSL Makefile machinery
+# for compiling and installing FSL Makefile-based
+# projects.
+if [ ! -d "$FSLCONFDIR" ]; then
+  export FSLCONFDIR=$FSLDIR/config
+fi
+
+# FSLDEVDIR is an optional installation destination
+# for development, so that locally built projects
+# can be installed separately from FSLDIR.
+if [ ! -d "$FSLDEVDIR" ]; then
+  export FSLDEVDIR=$FSLDIR
+fi
 
 source $FSLDIR/etc/fslconf/fsl.sh
-- 
GitLab